Last active
December 30, 2015 06:39
-
-
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
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
; 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