From d8e722d6193ef17d1420bbeb934219dcde31c6bf Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 16 Jul 2013 03:12:27 -0400 Subject: Improve list section. --- racket.html.markdown | 13 +++++++++---- 1 file 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 ; => # ;;; 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 -- cgit v1.2.3