043-prelude.scm (613B)
1 ; Verify the full embedded prelude: list, length, reverse, append, 2 ; list-ref, map, for-each are all in scope before user code. 3 (define xs (list 7 8 9)) 4 (define ys (append xs (list 10))) ; (7 8 9 10) 5 (define rev (reverse ys)) ; (10 9 8 7) 6 (define mapped (map (lambda (n) (- n 5)) ys)) ; (2 3 4 5) 7 ; for-each is side-effecting; just verify it runs without error by 8 ; consuming a list with a no-op lambda. 9 (for-each (lambda (x) x) ys) 10 (sys-exit (+ (length ys) 11 (+ (list-ref rev 0) 12 (list-ref mapped 3)))) 13 ; length=4, list-ref rev 0 = 10, list-ref mapped 3 = 5. 4+10+5 = 19