Last active
March 1, 2018 06:34
-
-
Save zelark/9fe4f14139a4d4eb80a3f69a3c0584e2 to your computer and use it in GitHub Desktop.
teaching
This file contains hidden or 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
;; function execution | |
;; (func arg1 arg2 arg3 ... argN) | |
;; function defenition | |
;; (defn <name> <args> <body>) | |
'(1 2 3) | |
[1 2 3] | |
(defn hello [name] (println "Hello," name)) | |
(hello "Alex") | |
(true? true) | |
(true? false) | |
(true? nil) | |
(not= true false) | |
(and false true false) | |
(or [] true) | |
; (if <cond> <if-true> <if-false>) | |
(if (< 1 2) | |
"yes") | |
; factor(4) => 1 * 2 * 3 * 4 = 24 | |
; factor(0) => 1 | |
; factor(1) => 1 | |
(defn factor [n] | |
(if (> n 1) | |
(* n (factor (- n 1))) | |
1)) | |
(factor 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment