我有一个remove_duplicates函数,用于删除列表中的重复项并返回新列表。
(define (remove_duplicate list)
(cond
((null? list) '() )
;member? returns #t if the element is in the list and #f otherwise
((member? (car list) (cdr list)) (remove_duplicate(cdr list)))
(else (cons (car list) (remove_duplicate (cdr list))))
))
我想将此函数调用的返回值赋给另一个函数f中的变量。
(define (f list)
;I have tried this syntax and various other things without getting the results I would like
(let* (list) (remove_duplicates list))
)
感谢任何帮助,谢谢!
答案 0 :(得分:2)
这是使用let
的正确语法:
(define (f lst)
(let ((list-without-dups (remove_duplicates lst)))
; here you can use the variable called list-without-dups
))
另请注意,将list
命名为参数和/或变量是一个坏主意,它与具有相同名称的内置过程发生冲突。