I want to append to lists without using append
V3nom
tobias at v3nom.de
Mon Apr 4 12:57:28 UTC 2022
define the lists:
(define liste (cons 10(cons 20(cons 30(cons 40 ' ())))))
(define liste2 (cons 20(cons 30(cons 10(cons 40 ' ())))))
define the "function":
(define (listapp list1 list2)(
if (null? (cdr list1))
(cons (car list1) (listapp list2 (cdr list1)))
(if (null? (cdr list2))
(cons (car list2) (cdr list2))
(cons (car list1) (listapp (cdr list1) list2))
)))
append them:
(listapp liste liste2)
What do i do wrong? i think this should work but it is giving me
an error message like:mcdr: contract violation expected: mpair?
given: ()
Thanks for helping me :)
Greetings
More information about the Digitalmars-d-learn
mailing list