Fork me on GitHub

Had to share this: building an index of words as a series of nested maps (if you've ever written a hangman solver you've done this), and I have three components I want to concat into a vector of letters: • a vector of letters • a letter • a string I want to do it in order, so the end result is [\e \a \c \h \l \e \t \t \e \r \a \n \e \n \t \r \y] How to do this? Obv. this isn't a hard algorithmic problem, but how to do it cleanly? I mess around with big transformations (apply vector) and (apply str) everywhere), hate it, and come up with: (into (conj vector-of-letters letter) string) This is a lot better than the earlier mutant that used type conversions and apply everywhere, but still.... Knowing that strings are technically collections, I wonder if I can cut a fn call by doing something like: (reduce conj vector-of-letters letter string), but this throws an error because reduce only takes three args---f, initial-value, and a collection (I was trying to reduce over "letter + string" in my head) But then I remember that into is basically (reduce conj), and, the clever part: clojurescript doesn't have chars, just one-letter strings, so letter is not a char, but a string---or, in other words, a collection. Behold! (reduce into vector-of-letters '(letter string)) if you try this: (reduce into ["a" "b" "c"] '("d" "efg")) => returns ["a" "b" "c" "d" "e" "f" "g"] (pitfall is this only works in cljs; (reduce into ["a" "b" "c"] '(\d "efg")) will work in cljs as \d evaluates as \`"d"`, but will throw an error in clojure-land where there is a dedicated char type) Still a muted "Eureka" was heard.

🍪 4

quite clever 🙂


What are the differences between Figwheel, Figwheel Main, and Shadow?


From what I understand, Figwheel Main is supposed to be an updated version of Figwheel, but people still use the old version.


Figwheel Main is modeled after cljs.main - so it's designed to be deps (as in deps.edn) friendly


the original figwheel was more oriented around lein (which a lot of people still use)


shadow is really a complete build tool that covers a pretty large variety of use cases


Is there an analogous framework for Boot?


hrm I don't know I don't follow boot that closely


but that really shouldn't be necessary


deps.edn stuff are not plugins - they're mostly reusable with any tool


So is Shadow more of in the class of lein or boot, but for cljs?


no - I just mean it covers a lot of use cases under one tool - web, node, react-native, provide own repl / hotloader