Clojure Koans 1 Equality Notebook
Welcome to my first notebook highlighting the Clojure Koans :)
In this notebook, I'll break down, solve, and investigate the Clojure Koans to better understand Clojure. I hope the "micro-skills" that I find will be useful for Clojure learners.
Please follow along with me in my journey, attempt to answer the questions I pose, ask new questions I haven't thought of, or propose new "skills".
Your feedback is crucial to making these notebooks awesome!
Original Koans repo is here: https://github.com/functional-koans/clojure-koans/
Spoilers Alert!
I share my answers for each Koan exercise ("meditation") below. If you are new to Clojure and want to attempt these for yourself, I urge you to come back after you have spent a little time on them.
Format
For each exercise I include:
my answer to the Koan exercise
one or more relevant skills (numbered in the order I find them)
one or more questions (numbered in the order I think of them)
Note: For each notebook, I will prefix skills and questions w/ the notebook number times 1000, so that way there will be room for 999 skills and questions per section... Yep, that should be enough.
;; configurations (don't edit this block){:deps {org.clojure/clojure {:mvn/version "1.10.1"} ;; complient is used for autocompletion ;; add your libs here (and restart the runtime to pick up changes) compliment/compliment {:mvn/version "0.3.9"}}};; configurations test{:hello (clojure-version)};; "We shall contemplate truth by testing reality, via equality"(= true true);; skill 1001: compare two things using the `=` equality function;; question 1001: What are smallest individual pieces/parts/items in Clojure syntax called? (entities, things, symbols, tokens, etc..) For two examples, above there are `=` and `true`. [glossary vocabulary terminology];; skill 1011: evaluate Clojure code;; "To understand reality, we must compare our expectations against reality"(= 2 (+ 1 1));; skill 1002: add/sum two numbers together using the `+` addition function;; skill 1012: nest a form/expression inside of another;; "You can test equality of many things"(= (+ 3 4) 7 (+ 2 5));; skill 1003: compare more than two items at once using the `=` equality function(swap! koan-tree assoc 1003 {:type "skill" :text "add/sum two numbers together using the `+` addition function"});;"Some things may appear different, but be the same"(= true (= 2 2/1));;"You cannot generally float to heavens of integers"(= false (= 2 2.0));; description: Compare for strict equality an integer and decimal precision number of equal value in Clojure to get a result of `false`;; question 1002: Are equal value float/decimal precision numbers and integers equivalent in ClojureScipt?;; answer 1002a: Yes, float/decimal precision numbers and integers are equivalent in ClojureScript.;; question 1003: What the "double equal sign" (==) function called in Clojure? [glossary vocabulary terminology];; skill 1004: Compare numerical equality irregardless of type using the `==` function(swap! koan-tree assoc 1004 {:type "skill" :text "Compare numerical equality irregardless of type using the `==` function"});; "But a looser equality is also possible"(= true (== 2.0 2));; question 1004: What are typical use-cases for loose equality?;;"Something is not equal to nothing"(= true (not (= 1 nil)));; skill 1005: Convert something is true to false and vice-versa using the `not` function(swap! koan-tree assoc 1005 {:type "skill" :text "Convert something is true to false and vice-versa using the `not` function"});;"Strings, and keywords, and symbols: oh my!"(= false (= "hello" :hello hello));; question 1005: What are the typical use cases for keywords?;; question 1006: What are the typical use cases for symbols?;; question 1007: What are the most generalized pieces of syntax in Clojure? Which of these are valid/accepted vocab; forms, tokens, expressions, symbols, entities, statements? What is their relationship hierarchy? [glossary vocabulary terminology] !!!;;"Make a keyword with your keyboard"(= :hello (keyword "hello"));; skill 1006: Write/Create a keyword literal using the `:` colon prefix;; question 1008: What is the `:` colon prefix called in Clojure? [glossary vocabulary terminology];; skill 1007: Create a keyword from a string using the `keyword` function(swap! koan-tree assoc 1006 {:type "skill" :text "Write/Create a keyword literal using the `:` colon prefix"} 1007 {:type "skill" :text "Create a keyword from a string using the `keyword` function"});;"Symbolism is all around us"(= hello (symbol "hello"));; skill 1008: Write/Create a symbol literal using the `'` single quote prefix;; question 1009: What is the (') single quote prefix called in Clojure? [glossary vocabulary terminology];; skill 1009: Create a symbol from a string using the `symbol` function(swap! koan-tree assoc 1008 {:type "skill" :text "Write/Create a symbol literal using the `'` single quote prefix (?)"} 1009 {:type "skill" :text "Create a symbol from a string using the `symbol` function"});;"What could be equivalent to nothing?"(= nil nil);; question 1010: What exactly is `nil` in Clojure? (is it a type?, is it a symbol?, what category of "things" does it belong to?, etc.) [glossary vocabulary terminology];;"When things cannot be equal, they must be different"(not= :fill-in-the-blank :blah);; skill 1010: Compare for inequality using the `not=` function Update (2021_05_02):
I'm experimenting with creating a hybrid tree of skills, questions, and facts.
To-Do:
[ ] Create a hierarchy of nodes where each node can have one or more prerequisite nodes, and there are three types of nodes: skills, questions, and facts, where facts can be answers to questions or simply just statements (all facts come with examples & sources to back them up)