Skip to content

Instantly share code, notes, and snippets.

@aphyr
Last active May 26, 2017 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aphyr/d3928b01efa00f5389e62fe4a6444458 to your computer and use it in GitHub Desktop.
Save aphyr/d3928b01efa00f5389e62fe4a6444458 to your computer and use it in GitHub Desktop.
(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