summaryrefslogtreecommitdiffhomepage
path: root/racket.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'racket.html.markdown')
-rw-r--r--racket.html.markdown11
1 files changed, 9 insertions, 2 deletions
diff --git a/racket.html.markdown b/racket.html.markdown
index 96dcaf25..38335bc1 100644
--- a/racket.html.markdown
+++ b/racket.html.markdown
@@ -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