Skip to content

Instantly share code, notes, and snippets.

View Reefersleep's full-sized avatar

Søren Knudsen Reefersleep

View GitHub Profile
@Reefersleep
Reefersleep / destructuring.clj
Created June 9, 2020 20:12
Nested destructuring in Clojure
(let [person {:first-name "Fred"                            ;;Binding this map literal, with stuff nested in it, to the symbol 'person'.
              :age        42
              :pets       {:dogs ["Rusty" "Fido"]
                           :cats ["Snowy" "Tom" "Garfield" "Queenie"]}
              :family     [{:name     "Sarah"
                            :relation :wife}
                           {:name     "Dennis"
                            :relation :son}]}
      ;;Here comes a bunch of destructuring!
      {:keys                                           [first-name age] ;;Just picking key values directly from the root level of the map
(defproject derpanet "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-3211"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[reagent "0.5.0"]]
(ns ^:figwheel-always derpanet.core
(:require [reagent.core :as r]
[figwheel.client :as fw :include-macros true]
[cljs.core.async :refer [chan close!]])
(:require-macros
[cljs.core.async.macros :as m :refer [go]]))
(defn number-box [number text-color]
[:p {:style {:border-color "black"
@Reefersleep
Reefersleep / gist:d0ed08a3f2915db25138
Created May 27, 2015 18:02
broke indentation a different way
(ns derpa.core
(:gen-class))
(defn initialize-cells [number] (vec (repeat number 0)))
(defn interpret [src]
(loop [src src
reader-position 0
cells (initialize-cells 200)
cell-pointer 50
@Reefersleep
Reefersleep / gist:b1b2b35eacec6e7a33c6
Created May 27, 2015 17:39
Trying to figure out why the = indentation does not work properly in my vim
(ns derpa.core
(:gen-class))
(defn initialize-cells [number] (vec (repeat number 0)))
(defn interpret [src]
(loop [src src
reader-position 0
cells (initialize-cells 200)
cell-pointer 50