Scheme 在Racket中创建附加函数

Scheme 在Racket中创建附加函数,scheme,racket,Scheme,Racket,在ISL中,如何创建一个递归追加函数,该函数接受两个列表,并返回第一个列表中所有最高位置元素的列表以及第二个列表中的最高位置元素,而不使用lambda或append 基本上,用于这些检查的函数期望: (check-expect (append-test '(a b c) '(d e f g h)) (list 'a 'b 'c 'd 'e 'f 'g 'h)) (check-expect (append-test '() '(7 2 0 1 8 3 4)) (list 7 2 0 1 8 3

在ISL中,如何创建一个递归追加函数,该函数接受两个列表,并返回第一个列表中所有最高位置元素的列表以及第二个列表中的最高位置元素,而不使用lambda或append

基本上,用于这些检查的函数期望:

(check-expect (append-test '(a b c) '(d e f g h))  (list 'a 'b 'c 'd 'e 'f 'g 'h))
(check-expect (append-test '() '(7 2 0 1 8 3 4)) (list 7 2 0 1 8 3 4))
我觉得它肯定会使用地图,因为这是我们最近一直关注的。这是我所拥有的,确实有用,但我想知道是否有一种方法可以用map、foldr、foldl、filter或类似的东西来简化它

以下是我目前掌握的情况:

(define (append-test lst1 lst2)
  (cond
    [(and (empty? lst1)(empty? lst2)) '()]
    [(empty? lst1) lst2]
    [(empty? lst2) lst1]
    [else (cons (first (first (list lst1 lst2)))
                (append-test (rest lst1) lst2))]))

这比那简单得多

(define (append-test lhs rhs)
  (if (empty? lhs)
      rhs
      (cons (first lhs) (append-test (rest lhs) rhs))))

这比那简单得多

(define (append-test lhs rhs)
  (if (empty? lhs)
      rhs
      (cons (first lhs) (append-test (rest lhs) rhs))))