Skip to content

Instantly share code, notes, and snippets.

@pjullah
Last active June 20, 2017 10:08
Show Gist options
  • Save pjullah/cf6a5bda5220a3541a37c10648c6699f to your computer and use it in GitHub Desktop.
Save pjullah/cf6a5bda5220a3541a37c10648c6699f to your computer and use it in GitHub Desktop.
Notes of Clojure function usage
; construct a map, using the keys from one vector, and the values from another
(zipmap keys vals)
(repeatedly n f) ; call f, n times. n is optional. If n not provided returns lazy seq
(doseq [x '(1 2 3 4)] ; perform a side effect once for each member of a sequence
(prn x))
; can also use run!
(run! prn '(1 2 3 4))
; conditional - can use 'when' or 'if', depending on the number of clauses. 'if' requires an else clause, while 'when' does not.
(it (test) true false)
(when (test) ...)
; REGEX
; split a string on regex
(clojure.string/split string-to-split #",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment