[SOLVED] CS (define x (list 1 2))

$25

File Name: CS_(define_x_(list_1_2)).zip
File Size: 226.08 KB

5/5 - (1 vote)

(define x (list 1 2))
(define y (list 3 4 5))
(define a (append x y))
(define b (list x y))
(define c (cons x y))

(define t (list (list 1 2 3) 4 (list 5 6 (list 7))))

(define (traverse t)
(cond ((null? t)) ;do nothing
((list? (car t)) (begin (traverse (car t))
(traverse (cdr t))))
(else (begin (display (car t)) (traverse (cdr t))))))

(define (scale-tree t factor)
(cond ((null? t) ())
((list? (car t)) (cons(scale-tree (car t) factor)
(scale-tree (cdr t) factor)))
(else (cons (* (car t) factor)
(scale-tree (cdr t) factor)))))

(define (tree-map t f)
(cond ((null? t) ())
((list? (car t)) (cons (tree-map (car t) f)
(tree-map (cdr t) f)))
(else (cons (f (car t))
(tree-map (cdr t) f)))))

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS (define x (list 1 2))
$25