My circuit is a little rusty. And I only have a dr schema translator on hand ...
You need to use your list and return only the first element of each sublist.
, cons, , ( ).
, .
, - , ( ) ( )
(cons 1) => error: cons need two parameters
(cons 1 null) => (list 1)
(cons 1 2) => error: need a value (first parameter) and a list (the second one)
(cons 1 (cons 2 null) => (list 1 2)
. , , ,
(define (car-list alist)
(cond
((null? alist) null)
(else (cons (car(car alist)) (car-list (cdr alist))))
)
)
; tail recursion version usage: (car-acc-list alist null)
(define (car-acc-list alist acc)
(cond
((null? alist) acc)
(else (car-acc-list (cdr alist) (cons (car(car alist)) acc)))
)
)
cond, if, , .
: ( ) , cdr.
((null? Alist) null), . , .
, / .
, drscheme , (lgpl). , , .