tailwindcss
References:
(ns hiccdown.html | |
(:require [clojure.edn :as edn] | |
[instaparse.core :as insta :refer [defparser]])) | |
;; A cross-platform (CLJC) html->hiccup converter for Hiccdown's own needs. | |
;; For now, only used in the tests. | |
(defparser html-parser " | |
nodes = node* | |
<node> = text | open-close-tags | self-closing-tag | |
open-close-tags = opening-tag nodes closing-tag |
[{:title ":clojureD 2020", | |
:id "PLaSn8eiZ631lrDFmUTBH9LFGzAxc3tvU4", | |
:items | |
({:title | |
"clojureD 2020: Lightning Talks by Mikkel Gravgaard, Daniel Slutsky, Daniel Janus and Arne Brasseur", | |
:id "fVtawjGbvOQ", | |
:duration "1363"} | |
{:title | |
"clojureD 2020: \"From Lazy Lisper to Confident Clojurist\" by Alexander Oloo", | |
:id "j57UbYFbI-U", |
tailwindcss
References:
#GNU Screen Cheat Sheet
##Basics
(def my-cat | |
(fn [rf] | |
(fn ([] (rf)) | |
([result] (rf result)) | |
([result input] | |
(reduce (fn [acc val] | |
(cond | |
(or (= val :fish) | |
(= val :heat)) | |
acc |
(def my-cat | |
(fn [rf] | |
(fn ([] (rf)) | |
([result] (rf result)) | |
([result input] | |
(reduce (fn [acc val] | |
(if (or (= val :fish) | |
(= val :heat)) | |
acc | |
(rf acc val))) |
(defn debug | |
; Default parameters stuffs. | |
([] (debug 0)) | |
([indent] (debug indent ">" "<")) | |
([indent in out] | |
(let [spaces (apply str (repeat indent \space))] | |
(debug (str spaces in) | |
(str spaces out)))) | |
; The transducer code starts here. | |
([in out] |
(def identity | |
(fn [rf] | |
(fn ([] (rf)) | |
([result] (rf result)) | |
([result input] (rf result input))))) | |
(into [] identity (list 1 2 3)) |
(defn nth' [coll n] | |
(transduce (drop n) (completing #(reduced %2)) nil coll)) | |
(defn tree-seq' | |
[branch? children root] | |
(eduction (take-while some?) (map first) | |
(iterate (fn [[node pair]] | |
(when-some [[[node' & r] cont] (if (branch? node) | |
(if-some [cs (not-empty (children node))] | |
[cs pair] |
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.