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.
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>my-project</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<dependencies> | |
<!-- none yet --> |
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
(require '[cljs.analyzer :as a]) | |
(defn methods-by-protocol [ns] | |
(->> (a/get-namespace ns) | |
:defs | |
(map val) | |
(filter :protocol) | |
(reduce | |
(fn [map d] | |
(update-in map [(:protocol d)] #(conj (or % #{}) d))) |
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
(ns base-conversion.core) | |
(def characters | |
(concat (map char (range 48 58)) (map char (range 65 91)))) | |
(def conversion-table | |
(zipmap | |
characters | |
(range))) |
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
(time | |
(def data-thread | |
(let [c (chan) | |
res (atom [])] | |
;; fetch em all | |
(doseq [i (range 10 100)] | |
(thread (>!! c (blocking-get (format "http://fssnip.net/%d" i))))) | |
;; gather results | |
(doseq [_ (range 10 100)] | |
(swap! res conj (<!! c))) |
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
## Using Emacs CIDER as the Figwheel REPL tool | |
project.clj should have this line: | |
``` | |
:figwheel { :nrepl-port 7888 } | |
``` | |
At the defproject-level. | |
It enables external tools to connect to the Figwheel REPL. To connect |
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
;; SEE: https://github.com/cgrand/macrovich | |
;; macros and code in a single cljc working across clj, cljs and self-hosted cljs | |
;; require clojurescript from master | |
(ns foo.core | |
#?(:cljs (:require-macros | |
[net.cgrand.meta-macros :refer [macros no-macros]] | |
[foo.core :refer [add]]) | |
:clj (:require |
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
(ns switch | |
(:require [clojure.pprint :as pprint])) | |
(defn project-clj-map [filename] | |
(->> (slurp filename) | |
(read-string) | |
(drop 1) | |
(partition 2) | |
(map vec) | |
(into {}))) |
Fortunatly we could use pre-built gccemacs right now.
Those two repos did the greate job for us.
https://github.com/twlz0ne/nix-gccemacs-darwin
https://github.com/twlz0ne/nix-gccemacs-sierra
Here is the tutorial:
OlderNewer