Fill in the missing expressions to complete the following definitions of some basic list-manipulation operations as accumulations:
(define (map p sequence) (accumulate (lambda (x y) <??>) nil sequence)) (define (append seq1 seq2) (accumulate cons <??> <??>)) (define (length sequence) (accumulate <??> 0 sequence))
There are no comments yet.
You must log in to post a comment.Login
(define (square x) (* x x)) (define x '(1 2 3)) (check-equal? (map square x) '(1 4 9)) (check-equal? (append x (list 4 5)) (list 1 2 3 4 5)) (check-equal? (length '()) 0) (check-equal? (length x) 3)