Clojure learning log
'(1 2 3)
syntax to construct lists. a '
basically means “don’t interpret this as an expression”.
You can use :a <map>
and <map> :a
syntax to get a value out of a map. They have a slight difference, though I don’t remember what exactly.
Seems like you can get nth element of a vector with this weird syntax:
|
|
# New cool functions
iterate
peek
, pop
lazy-seq
walk
, tree-seq
- mind blown.
Transpose:apply mapv vector [[1 2 3] [41 42 43]] => [[1 41] [2 42] [3 43]]
Can be used for Python vibes:
|
|
Clojure Destructuring Tutorial and Cheat Sheet
Recursively transform a nested map into transients, and then back to persistents
Destructuring can shoot you in the foot. For example, this function works fine with a sequence of any length:
This should be in the standard library:
|
|
Find index of an element matching a predicate in Clojure? - Stack Overflow
How to drop the nth item in a collection in Clojure? - Stack Overflow
clojure - Returning duplicates in a sequence - Stack Overflow
defpure
macro by Fred Overflow.
Advent of Clerk repo has some cool code in the GitHub forks. Check out the Network.
# Articles
- https://www.abhinavomprakash.com/posts/clojure-walk/
- Clojure - Transient Data Structures
- Clojure reducers and transducers
# 4Clojure
Custom flatten:
|
|
# Random syntax things
Not equal operator is not=
, not !=
. !=
has some different meaning.