clojure-koans/19_datatypes.clj

26 lines
790 B
Clojure
Raw Normal View History

; "Holding records is meaningful only when the record is worthy of you"
2011-02-11 01:13:52 +00:00
(= __ (.prize (Nobel. "peace")))
; "Types are quite similar"
2011-02-11 01:13:52 +00:00
(= __ (.prize (Pulitzer. "literature")))
; "Records may be treated like maps"
2011-02-11 01:13:52 +00:00
(= __ (:prize (Nobel. "physics")))
; "While types may not"
2011-02-11 01:13:52 +00:00
(= __ (:prize (Pulitzer. "poetry")))
; "Further study reveals why"
2011-02-11 01:13:52 +00:00
(= __
(map map? [(Nobel. "chemistry")
(Pulitzer. "music")]))
; "Either sort of datatype can define methods in a protocol"
2011-02-11 01:13:52 +00:00
(= __
(with-out-str (present (Oscar. "Best Picture") "Evil Alien Conquerors")))
; "Surely we can implement our own by now"
2011-02-11 01:13:52 +00:00
(= "You're really the Worst Picture, Final Destination 5... sorry."
(with-out-str (present (Razzie. "Worst Picture") "Final Destination 5")))