@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.@mfikes very cool and super interesting how simple the implementation is
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/
posted to Hacker News
I would be very interested in the spacemacs/CIDER demo video. I like spacemacs, but i am not yet into REPL-driven development.
@orestis Thanks for the writeup. What did you mean with apropos-like functionality? I suppose you didnโt mean clojure.core/apropos?
me too, i'm using the repl but i have a feeling i'm missing out on a lot of the experience
I mean similar to the apropos Linux command where you search a command by your intention, and you get a list of suggestions.