Advertisement
urbanslug

Untitled

Jul 7th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. ;; =================
  2. ;; Data definitions:
  3.  
  4. ;; ListOfString is one of:
  5. ;; - empty
  6. ;; - (cons String ListOfString)
  7. ;; interp. a list of strings
  8.  
  9. (define LS0 empty)
  10. (define LS1 (cons "a" empty))
  11. (define LS2 (cons "a" (cons "b" empty)))
  12. (define LS3 (cons "c" (cons "b" (cons "a" empty))))
  13.  
  14. #;
  15. (define (fn-for-los los)
  16. (cond [(empty? los) (...)]
  17. [else
  18. (... (first los)
  19. (fn-for-los (rest los)))]))
  20.  
  21. ;; Template rules used:
  22. ;; - one of: 2 cases
  23. ;; - atomic distinct: empty
  24. ;; - compound: (cons String ListOfString)
  25. ;; - atomic non-distinct: (first los) is String
  26. ;; - self-reference: (rest los) is ListOfString
  27.  
  28. ;; =================
  29. ;; Functions:
  30.  
  31. ;; ListOfString -> ListOfString
  32. ;; adds "!" to every string in a ListOfString
  33.  
  34. (check-expect (yell empty) empty)
  35. (check-expect (yell (cons "cat" empty)) (cons "cat!" empty))
  36. (check-expect (yell (cons "cat"(cons "Nas" empty))) (cons "cat!"(cons "Nas!" empty)))
  37.  
  38.  
  39. (define (yell los)
  40. (cond [(empty? los) empty]
  41. [else
  42. (...) ]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement