Last active
June 20, 2017 10:08
-
-
Save pjullah/cf6a5bda5220a3541a37c10648c6699f to your computer and use it in GitHub Desktop.
Notes of Clojure function usage
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
; construct a map, using the keys from one vector, and the values from another | |
(zipmap keys vals) |
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
(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