Created
June 1, 2021 12:55
-
-
Save jackrusher/959b35e031fb9b2d30c0211337a310ed to your computer and use it in GitHub Desktop.
Condensed visual tutorial in #Bauhaus style for a subset of the #Clojure seq API (inspired by similar JS tweets)
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
(def ■ '■) | |
(def ▲ '▲) | |
(def ● '●) | |
(first [● ■ ▲]) ; ● | |
(second [● ■ ▲]) ; ■ | |
(nth [● ■ ▲] 2) ; ▲ | |
(rest [● ■ ▲]) ; (■ ▲) | |
(last [● ■ ▲]) ; ▲ | |
(butlast [● ■ ▲]) ; (● ■) | |
(map (partial = ■) [■ ● ■ ▲]) ; (true false true false) | |
(filter (partial = ■) [■ ● ■ ▲]) ; (■ ■) | |
(remove (partial = ■) [■ ● ■ ▲]) ; (● ▲) | |
(distinct [■ ● ■ ▲ ● ▲]) ; (■ ● ▲) | |
(interpose '▲ [● ● ●]) ; (● ▲ ● ▲ ●) | |
(interleave [■ ■ ■] [▲ ▲ ▲] [● ● ●]) ; (■ ▲ ● ■ ▲ ● ■ ▲ ●) | |
(take 3 [■ ■ ● ● ▲ ▲]) ; (■ ■ ●) | |
(take-nth 2 [■ ■ ● ● ▲ ▲ ■ ■]) ; (■ ● ▲ ■) | |
(take-while (partial = ■) [■ ■ ● ● ▲ ▲ ■ ■]) ; (■ ■) | |
(drop-while (partial = ■) [■ ■ ● ● ▲ ▲ ■ ■]) ; (● ● ▲ ▲ ■ ■) | |
(partition 2 [■ ■ ● ● ▲ ▲ ■ ■]) ; ((■ ■) (● ●) (▲ ▲) (■ ■)) | |
(partition 2 1 [■ ■ ● ● ▲ ▲ ■ ■]) ; ((■ ■) (■ ●) (● ●) (● ▲) (▲ ▲) (▲ ■) (■ ■)) | |
(split-at 3 [■ ■ ● ● ▲ ▲ ■ ■]) ; [(■ ■ ●) (● ▲ ▲ ■ ■)] | |
(frequencies [■ ■ ● ● ▲ ▲ ■ ■]) ; {■ 4, ● 2, ▲ 2} | |
(some (partial = ●) [■ ● ■ ▲]) ; true | |
(every? (partial = ●) [■ ● ■ ▲]) ; false | |
(every? (partial = ●) [● ● ●]) ; true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment