This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-29
Channels
- # adventofcode (11)
- # beginners (98)
- # boot (2)
- # cider (3)
- # clara (3)
- # cljs-dev (15)
- # cljsrn (2)
- # clojure (122)
- # clojure-austin (4)
- # clojure-russia (1)
- # clojure-spec (2)
- # clojurescript (30)
- # css (6)
- # cursive (5)
- # docs (1)
- # fulcro (4)
- # hoplon (118)
- # keechma (3)
- # leiningen (5)
- # lumo (1)
- # off-topic (28)
- # onyx (6)
- # re-frame (4)
- # reagent (1)
- # reitit (1)
- # shadow-cljs (53)
- # sql (1)
- # unrepl (1)
@bhauman I needed a reducible tree-seq for Planck (to avoid head-holding in its file-seq
implementation), and came up with this
(defn reducible-tree-seq
[branch? children root]
(eduction
(take-while seq)
(map first)
(iterate (fn [[node & queue]]
(cond-> queue
(branch? node) (into (reverse (children node)))))
[root])))
Dropping it into your day 24 solution (replacing tree-seq
with reducible-tree-seq
) appears to drop the runtime in half (probably simply because it is not lazy).
I also tried a variant
(transduce (map #(nth % 2)) max 0
(reducible-tree-seq branch? children [index 0 0 0]))
with similar results.
Strictly speaking, since it returns an eduction
, it doesn’t directly implement the reducing protocols, but if you feed it to transduce
you effectively get what you want.Has anyone though of doing adventofcode directly in emacs using elisp + a text buffer? 😉
Someone published an elisp solution in reddit: https://www.reddit.com/r/adventofcode/comments/7h5n38/2017_day_2_part_1_2_emacs_lisp_still_resist_to/
I got Shenzhen I/O and am playing it with my son. It's a pretty good game (teaching him assembly without him really realizing it.) 🙂
I blogged about my experience with Clojure and Advent of Code: https://orestis.gr/25-days-of-clojure/
I would be very interested in the spacemacs/CIDER demo video. I like spacemacs, but i am not yet into REPL-driven development.
me too, i'm using the repl but i have a feeling i'm missing out on a lot of the experience