From: daniel watson Date: Wed, 17 Aug 2016 03:24:26 +0000 (-0700) Subject: complete chapter 3 notes X-Git-Url: http://challenge-bot.com/repos/?p=ozzloy%40gmail.com%2Frealm-of-racket-journey;a=commitdiff_plain;h=ecaeb60c4cda7c6b75541fc828241446bab9cbdd complete chapter 3 notes --- diff --git a/notes.org b/notes.org index 10afb31..1c78100 100644 --- a/notes.org +++ b/notes.org @@ -63,3 +63,25 @@ this creates a structure * fields: name, id#, dorm * (equal? (student-name freshman1) 'Joe) +*** nesting structures + * (struct student-body (freshmen sophomores juniors seniors)) + * (define all-student (list a b) (list) (list c d) (list e)) + * a b c d e can all be student struct instances + * nested selectors: + * (student-name (first (student-body-freshmen all-students))) +*** structure transparency + * default is opaque + * opaque means comparison is by identity not value + * (equal? false (equal? (student 'joe 1 'dorm) (student 'joe 1 'dorm))) + * (equal? true (equal? freshman1 freshman1)) + * transparent structs are compared on value + * create transparent struct type: (struct a (b) #:transparent) + * (equal? true (equal? (a 'b) (a 'b))) + * (define b (a b)) + * (equal? true (equal? b b)) + * all structures in book are transparent +**** checkpoint + * basic data: booleans, symbols, numbers, strings + * lists + * structs + * nesting of lists and structs