Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; =================
- ;; Data definitions:
- ;; ListOfString is one of:
- ;; - empty
- ;; - (cons String ListOfString)
- ;; interp. a list of strings
- (define LS0 empty)
- (define LS1 (cons "a" empty))
- (define LS2 (cons "a" (cons "b" empty)))
- (define LS3 (cons "c" (cons "b" (cons "a" empty))))
- #;
- (define (fn-for-los los)
- (cond [(empty? los) (...)]
- [else
- (... (first los)
- (fn-for-los (rest los)))]))
- ;; Template rules used:
- ;; - one of: 2 cases
- ;; - atomic distinct: empty
- ;; - compound: (cons String ListOfString)
- ;; - atomic non-distinct: (first los) is String
- ;; - self-reference: (rest los) is ListOfString
- ;; =================
- ;; Functions:
- ;; ListOfString -> ListOfString
- ;; adds "!" to every string in a ListOfString
- (check-expect (yell empty) empty)
- (check-expect (yell (cons "cat" empty)) (cons "cat!" empty))
- (check-expect (yell (cons "cat"(cons "Nas" empty))) (cons "cat!"(cons "Nas!" empty)))
- (define (yell los)
- (cond [(empty? los) empty]
- [else
- (...) ]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement