CPSC 110 Lecture : CPSC lecture 2.docx

23
CPSC 110 Full Course Notes
Verified Note
23 documents
Document Summary
Use ;; for permanent comments, use ; for temporary comments. Signature must look like ;; number -> number , i. e. upper-cased word, space, arrow, space, upper-cased word. To comment out an entire section, use #; If function produces a boolean, function name ends in question mark ( ? ) Q: design a function called yell that consumes strings like hello and adds ! to produce strings like hello! . (see lecture2. rkt) Htdf: (how to design functions recipe: signature, purpose, stub, run the program and see if there are errors, define examples, wrap each in check-expect, template and inventory, code function body, test and debug. ;; purpose: add ! to the end of the string consumed s. ;; define examples and check errors (check-expect (yell hello) hello!) (check-expect (yell ) !) (check-expect (yell bye) (string-append bye !)) ;; ( s)) (define (yell s) (string-append s !))