From 51ce7fda40f3c951b807971587374c56fa9d7916 Mon Sep 17 00:00:00 2001 From: Derek Date: Wed, 30 Nov 2016 15:36:56 -0500 Subject: [racket/en] Expand list section (#2588) * Expand list section * Update backtick --- racket.html.markdown | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'racket.html.markdown') 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 ; => # (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 -- cgit v1.2.3 From 51e14b0e341d5df2fb1bf9174e2c9b7016a4c07c Mon Sep 17 00:00:00 2001 From: Steve Chae Date: Thu, 27 Apr 2017 12:21:10 -0400 Subject: [racket/en] Fix Incorrect Names in Mutable Struct Examples (per Issue #2714) (#2715) * Fix wrong mutable struct namee * Re-added space after ; --- racket.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'racket.html.markdown') diff --git a/racket.html.markdown b/racket.html.markdown index 38335bc1..c6b1deba 100644 --- a/racket.html.markdown +++ b/racket.html.markdown @@ -147,8 +147,8 @@ my-pet ; => # (struct rgba-color (red green blue alpha) #:mutable) (define burgundy (rgba-color 144 0 32 1.0)) -(set-color-green! burgundy 10) -(color-green burgundy) ; => 10 +(set-rgba-color-green! burgundy 10) +(rgba-color-green burgundy) ; => 10 ;;; Pairs (immutable) ;; `cons' constructs pairs, `car' and `cdr' extract the first -- cgit v1.2.3 From 090876533bf0bab4b089210e73b4ee3f9c86ecb8 Mon Sep 17 00:00:00 2001 From: Nenad Mijatovic Date: Mon, 3 Dec 2018 22:30:37 +0100 Subject: Fix section numbering Index number for the `Functions` sections is numbered `3.` -- just like the `Structs and Collections` section before it. This fixes section numbering for `Functions` and all subsequent sections. --- racket.html.markdown | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'racket.html.markdown') diff --git a/racket.html.markdown b/racket.html.markdown index c6b1deba..60a895e0 100644 --- a/racket.html.markdown +++ b/racket.html.markdown @@ -249,7 +249,7 @@ m ; => '#hash((b . 2) (a . 1) (c . 3)) <-- no `d' (hash-remove m 'a) ; => '#hash((b . 2) (c . 3)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 3. Functions +;; 4. Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Use `lambda' to create functions. @@ -319,7 +319,7 @@ m ; => '#hash((b . 2) (a . 1) (c . 3)) <-- no `d' ; => "Hi Finn, 6 extra args" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 4. Equality +;; 5. Equality ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; for numbers use `=' @@ -369,7 +369,7 @@ m ; => '#hash((b . 2) (a . 1) (c . 3)) <-- no `d' (equal? (list 3) (list 3)) ; => #t ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 5. Control Flow +;; 6. Control Flow ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Conditionals @@ -505,7 +505,7 @@ m ; => '#hash((b . 2) (a . 1) (c . 3)) <-- no `d' (+ 1 (raise 2))) ; => 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 6. Mutation +;; 7. Mutation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Use `set!' to assign a new value to an existing variable @@ -541,7 +541,7 @@ vec ; => #(1 2 3 4) (hash-remove! m3 'a) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 7. Modules +;; 8. Modules ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Modules let you organize code into multiple files and reusable @@ -568,7 +568,7 @@ vec ; => #(1 2 3 4) ; (show "~a" 1 #\A) ; => error, `show' was not exported ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 8. Classes and Objects +;; 9. Classes and Objects ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Create a class fish% (-% is idiomatic for class bindings) @@ -609,7 +609,7 @@ vec ; => #(1 2 3 4) (send (new (add-color fish%) [size 10] [color 'red]) get-color) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 9. Macros +;; 10. Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Macros let you extend the syntax of the language @@ -651,7 +651,7 @@ vec ; => #(1 2 3 4) ;; it, the compiler will get in an infinite loop ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 10. Contracts +;; 11. Contracts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Contracts impose constraints on values exported from modules @@ -678,7 +678,7 @@ vec ; => #(1 2 3 4) ;; more details.... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; 11. Input & output +;; 12. Input & output ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Racket has this concept of "port", which is very similar to file -- cgit v1.2.3