Last active
May 26, 2017 03:23
-
-
Save aphyr/d3928b01efa00f5389e62fe4a6444458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def conf {:people [{:lang :clojure}, {:lang :ruby}, {:lang :m4}]}) | |
(defn clojurists | |
"Returns all clojurists at a conference." | |
[conf] | |
(filter #(= :clojure (:lang %)) (:people conf))) | |
(defn final-person | |
"Returns the last attendee to the conference." | |
[conf] | |
(peek (:people conf))) | |
; Often in my code, most functions work on any collection type, and users are expected | |
; to pass in any collection. I may convert back and forth between lazy seqs and vecs | |
; internally, as I massage the collection into the right shape to answer some question. | |
; This means that some functions performance (e.g. with nth), and in other cases | |
; correctness (e.g. with peek/push/pop) depends on whether the collection is a vector | |
; or not. I'd like my types to enforce this, but only where it matters, rather than | |
; require :people *always* be a vector. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment