diff options
author | Eli Barzilay <eli@barzilay.org> | 2013-07-16 03:12:27 -0400 |
---|---|---|
committer | Eli Barzilay <eli@barzilay.org> | 2013-07-16 03:12:27 -0400 |
commit | d8e722d6193ef17d1420bbeb934219dcde31c6bf (patch) | |
tree | ec732e572dfb27df4a0e1f0e1d2f17e31b36ade7 /racket.html.markdown | |
parent | 547a8a6db1fb74a843bb0fbf1f81dd3d67eb92c4 (diff) |
Improve list section.
Diffstat (limited to 'racket.html.markdown')
-rw-r--r-- | racket.html.markdown | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/racket.html.markdown b/racket.html.markdown index 90b29d21..dfd30438 100644 --- a/racket.html.markdown +++ b/racket.html.markdown @@ -128,14 +128,19 @@ my-pet ; => #<dog> ;;; Lists -;; Lists are linked-list data structures +;; Lists are linked-list data structures, made of `cons' pairs and end +;; with a `null' (or '()) to mark the end of the list +(cons 1 (cons 2 (cons 3 null))) ; => '(1 2 3) +;; `list' is a convenience variadic constructor for lists (list 1 2 3) ; => '(1 2 3) +;; and a quote can also be used for a literal list value +'(1 2 3) ; => '(1 2 3) -;; Use `cons' to add an item to the beginning of a list -(cons 4 '(1 2 3)) ; => (4 1 2 3) +;; Can still use `cons' to add an item to the beginning of a list +(cons 4 '(1 2 3)) ; => '(4 1 2 3) ;; Use `append' to add lists together -(append '(1 2) '(3 4)) ; => (1 2 3 4) +(append '(1 2) '(3 4)) ; => '(1 2 3 4) ;;; Vectors |