我正在尝试使用SCHEME编写代码,该代码使用两个参数,例如'(2 1 3)&'(a b c)并给出列表'(b a c)。我的代码无法递归或迭代。任何帮助!使用Scheme重新排列列表中的元素
(define project
(lambda (list1 list2 list3 n b index)
(define n (length(list1)))
(let ((i n))
(for-each (i)
(cond
((null? list1) (display "empty"))
(else
(define n (car list1))
(define index (- n 1))
(define b (list-ref list2 index))
(define list3 (cons list3 b))
(define list1 (cdr list1))
list3))))))
这会提高您发布的代码的可读性,如果它正确缩进。所有主要的Scheme开发环境都有一个自动完成的功能。 –
我已经复制了几次缩进代码,但情况越来越糟糕。 PS无法上传快照。 :/ – farey
Gah在这里也有空格标签D:D: – jozefg