Approximate overview
name->sortable
(define name->sortable
(let ([space-before (lambda (str) (if str (string-append " " str) ""))]
[space-after (lambda (str) (if str (string-append str " ") ""))])
(lambda (name)
(let ([prefix (name-prefix name)]
[given (name-given name)]
[middle (name-middle name)]
[family (name-family name)]
[suffix (name-suffix name)])
(cond
; Normal case: They have a family name. It comes first.
[family
(string-append family
", "
given
(space-before middle)
(space-before suffix)
(space-before prefix))]
; Special case: Royalty and Religious, generalized
[(not middle)
(string-append (space-after prefix)
given
(space-before suffix))]
; Special case: No family but middle
[else
(string-append given
(space-before middle)
(space-before suffix)
(space-before prefix))])))))
Why are there two let
expressions?
Things that don’t depend on the input go outside the lambda.
Things that do depend on the input go inside the lambda.
;; Acknowledgements:
;; List of space related words that helped me create my syllex
;; https://relatedwords.io/space
;;
;; Racket documentation for `member,` which was really useful for the maddish libs
;; https://docs.racket-lang.org/reference/pairs.html
;; Project Gutenburg record of Alice's Adventures in Wonderland by Lewis Caroll
;; https://www.gutenberg.org/ebooks/11
;;
;; PDF covering diphthongs and vowel combos that was helpful in counting syllables
;; https://www.waikato.ac.nz/__data/assets/pdf_file/0005/314456/Word-lists-for-Vowels-Diphthongs.pdf
;; PDF describing one particularly programatic syllable-counting method
;; https://www.howmanysyllables.com/syllable_rules/howtocountsyllables
;; Presentation showing how to identify silent E's
;; https://ckla.amplify.com/skillsboost/wp-content/uploads/2020/08/G3_TeacherExtension_W1_D4.pdf
;; Help figuring out recursion over lists
;; Hallie, Nameera,
Could you explain member
(or member?
)?
(member? val lst)
takes a value and a list and determines whether or not the value appears in the list.
(define member? (lambda (val lst) (cond [(null? lst) #f] [(equal? val (car lst)) #t] [else (member? val (cdr lst))])))
(member val lst)
takes a value and a list and returns either (a) the portion of the list starting with val, if val appears in the list, or (b) false, if val does not appear in the list.
When using struct do we ever have to use define
or does struct
serve as the definition?
struct
implicitly defines all the procedures (the constructor, the basic predicate, the extractors, mutators if we permit them, etc.)
Can you summarize the main idea in the precondition testing reading?
Sometimes programmers provide incorrect parameters to the procedures we create. We may want to issue an error when that happens. We can use the
error
procedure to do that.
Why didn’t you have us do preconditions earlier?
Um … I’m not sure.
Why would I create a new data type when I could just put data in a pre-existing structure like lists, vectors or hash-tables?
Data abstraction! This takes us further along the path that “the implementation doesn’t/shouldn’t matter”.
It’s less work to write
(struct foo (a b c))
than to write the five procedures that command generates.
Data protection / program safety. Client programmers can’t do things with our structures other than what we permit. (More or less.) If you use a hash table or a vector, clients might be able to mutate them when we don’t want them to.
Do you plan to distribute grade reports soon?
Yes; sometime this weekend.
I like CS. What should I take next year.
CSC-161, Imperative Problem Solving, is the next course in our introductory sequence. Cute robots!
CSC-207, Objects, Data Structures, and Algorithms, follows 161.
If you are considering a CS major, you might also look toward MAT/CSC-208 or MAT-218, which provide the mathematical foundations of CS. (Taking one of the two is required for the major.)
Does SamR do summer MAPs?
Sometimes, but not this summer.
Add (define chirp-contents chirp-kernel-contents)
(and similar).
; SAM SAID I CAN STOP HERE
Another token activity.