Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zelark
Last active March 1, 2018 06:34
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 zelark/9fe4f14139a4d4eb80a3f69a3c0584e2 to your computer and use it in GitHub Desktop.
Save zelark/9fe4f14139a4d4eb80a3f69a3c0584e2 to your computer and use it in GitHub Desktop.
teaching
;; 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