[racket/en] Expand list section (#2588)

* Expand list section
* Update backtick
This commit is contained in:
Derek 2016-11-30 15:36:56 -05:00 committed by Samantha McVey
parent d0918b2576
commit 51ce7fda40

View File

@ -164,10 +164,17 @@ my-pet ; => #<dog>
(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
;; a quote can also be used for a literal list value
'(1 2 3) ; => '(1 2 3)
;; a quasiquote (represented by the backtick character) with commas
;; can be used to evaluate functions
`(1 ,(+ 1 1) 3) ; => '(1 2 3)
;; Racket has predefined functions on top of car and cdr, to extract parts of a list
;; With lists, car/cdr work slightly differently
(car '(1 2 3)) ; => 1
(cdr '(1 2 3)) ; => '(2 3)
;; Racket also has predefined functions on top of car and cdr, to extract parts of a list
(cadr (list 1 2 3)) ; => 2
(car (cdr (list 1 2 3))) ; => 2