With cnData
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
Dim SrchRange As Range
Set SrchRange = .Range(.Cells(1, 1), .Cells(LastRow, 7))
End With
我必须在Scheme中的列表上编写函数。 我该如何解决重复问题?
答案 0 :(得分:1)
不是将>=
作为一个条件,而是可以单独测试相等性,每当(car lst1)
等于(car lst2)
时,您将保留其中一个,但在递归时删除它们通过这样做来打电话:
(cons (car lst1)
(merge-sorted (cdr lst1) (cdr lst2)))
例如:
(define (merge-sorted lst1 lst2)
(cond
((null? lst1) lst2)
((null? lst2) lst1)
((> (car lst1)
(car lst2))
(cons (car lst2)
(merge-sorted lst1 (cdr lst2))))
((< (car lst1)
(car lst2))
(cons (car lst1)
(merge-sorted (cdr lst1) lst2)))
(else
(cons (car lst1)
(merge-sorted (cdr lst1) (cdr lst2))))))
然后你会:
(merge-sorted '(1 3 4) '(2 4 5))
=> '(1 2 3 4 5)