Created
September 21, 2011 09:25
-
-
Save djhworld/1231651 to your computer and use it in GitHub Desktop.
clojure one liners
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
; double everything in a list | |
(map #(* 2 %) (range 1 10)) | |
; sum a list of numbers | |
(reduce + (range 1 1000)) | |
; read a file | |
(clojure.string/split (slurp "cl.clj") #"\n") | |
;partition a list | |
(partition-by #(> % 60) [49, 58, 76, 82, 88, 90]) | |
;find the maximum | |
((fn [xs] (last (sort xs))) [14 35 -7 98 46]) | |
;find the minimum | |
((fn [xs] (first (sort xs))) [14 35 -7 98 46]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment