Skip to content

Instantly share code, notes, and snippets.

@fricze
Last active December 30, 2015 06:39
Show Gist options
  • Save fricze/7790908 to your computer and use it in GitHub Desktop.
Save fricze/7790908 to your computer and use it in GitHub Desktop.
Clojure: wykonujemy operacje na jamniczku, jamniczek poznaje Jadzię. Tworzymy pierwszą funkcję, poprawiamy konstrukcję funkcji, poznajemy destructuring
; and now, we gonna write first function
(defn is-dragon? ; name ?
"Function which takes a creature,
and check if this creature is dragon" ; doc
[creature] ; args
(if (= "dragon" (:species creature)) ; body
true
false))
(is-dragon? zenek)
(def jadzia
{:names ["Jadwiga" "Cukiereczek" "Panienka z okienka"]
:species "dragon"
:age 4.5
:health :even-better})
(is-dragon? jadzia)
(defn is-dragon?
"Function which takes a creature,
and check if this creature is dragon"
[creature]
(= "dragon" (:species creature)))
(defn is-dragon?
"Function which takes a creature,
and check if this creature is dragon"
[{species :species}]
(= "dragon" species))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment