summaryrefslogtreecommitdiffhomepage
path: root/racket.html.markdown
diff options
context:
space:
mode:
authorEli Barzilay <eli@barzilay.org>2013-07-16 04:13:06 -0400
committerEli Barzilay <eli@barzilay.org>2013-07-16 04:13:06 -0400
commit0063574a4d574e4c5fe85c65159f760be7009da2 (patch)
treee49396d941f4e0b6a95b0c46fa006572bbcc01d5 /racket.html.markdown
parentb55ce4f045d62aa9224827aed6133827cc698788 (diff)
Some list function examples.
Diffstat (limited to 'racket.html.markdown')
-rw-r--r--racket.html.markdown9
1 files changed, 9 insertions, 0 deletions
diff --git a/racket.html.markdown b/racket.html.markdown
index 4b5465d9..eb2bf4c0 100644
--- a/racket.html.markdown
+++ b/racket.html.markdown
@@ -142,6 +142,15 @@ my-pet ; => #<dog>
;; Use `append' to add lists together
(append '(1 2) '(3 4)) ; => '(1 2 3 4)
+;; Lists are a very basic type, so there is a *lot* of functionality for
+;; them, a few examples:
+(map add1 '(1 2 3)) ; => '(2 3 4)
+(map + '(1 2 3) '(10 20 30)) ; => '(11 22 33)
+(filter even? '(1 2 3 4)) ; => '(2 4)
+(count even? '(1 2 3 4)) ; => 2
+(take '(1 2 3 4) 2) ; => '(1 2)
+(drop '(1 2 3 4) 2) ; => '(3 4)
+
;;; Vectors
;; Vectors are fixed-length arrays