docs: add example scheme programs
This commit is contained in:
1 parent
5e1aec0f78
commit
5649b7bad8
6 files changed
+151
No files matched your search
@@ -0,0 +1,24 @@
|
||||
; Higher-order list operations.
|
||||
(display "squares: ")
|
||||
(display (map (lambda (x) (* x x)) '(1 2 3 4 5)))
|
||||
(newline)
|
||||
|
||||
(display "odds: ")
|
||||
(display (filter odd? '(1 2 3 4 5 6 7 8)))
|
||||
(newline)
|
||||
|
||||
(display "sum via fold: ")
|
||||
(display (fold-left + 0 '(1 2 3 4 5 6 7 8 9 10)))
|
||||
(newline)
|
||||
|
||||
(display "zip-add: ")
|
||||
(display (map + '(1 2 3) '(10 20 30)))
|
||||
(newline)
|
||||
|
||||
(display "for-each: ")
|
||||
(for-each display '(a b c d))
|
||||
(newline)
|
||||
|
||||
(display "append+reverse: ")
|
||||
(display (reverse (append '(1 2) '(3 4) '(5 6))))
|
||||
(newline)
|
||||
Reference in new issue
Block a user