This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-01
Channels
- # announcements (21)
- # architecture (6)
- # aws (18)
- # babashka (14)
- # beginners (231)
- # boot (1)
- # calva (2)
- # chlorine-clover (22)
- # cider (34)
- # clara (16)
- # clj-kondo (53)
- # cljdoc (5)
- # cljs-dev (22)
- # cljsrn (3)
- # clojure (283)
- # clojure-europe (24)
- # clojure-italy (9)
- # clojure-nl (5)
- # clojure-spec (5)
- # clojure-uk (57)
- # clojurescript (14)
- # core-typed (8)
- # cursive (4)
- # data-science (11)
- # datomic (41)
- # docker (24)
- # duct (2)
- # emacs (2)
- # exercism (29)
- # fulcro (96)
- # graalvm (4)
- # jobs-discuss (1)
- # kaocha (53)
- # lambdaisland (20)
- # malli (5)
- # nrepl (4)
- # observability (7)
- # off-topic (40)
- # pathom (44)
- # pedestal (8)
- # re-frame (19)
- # shadow-cljs (58)
- # spacemacs (2)
- # sql (9)
- # tools-deps (15)
- # vim (3)
- # yada (10)
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.
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
shadow is really a complete build tool that covers a pretty large variety of use cases
Is there an analogous framework for Boot?
OK, thanks @dnolen.
So is Shadow more of in the class of lein or boot, but for cljs?