This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-04
Channels
- # arachne (2)
- # bangalore-clj (3)
- # beginners (34)
- # boot (22)
- # cider (1)
- # cljs-dev (86)
- # cljsjs (3)
- # clojure (42)
- # clojure-argentina (6)
- # clojure-austin (10)
- # clojure-chicago (1)
- # clojure-france (3)
- # clojure-russia (135)
- # clojure-spain (1)
- # clojure-uk (4)
- # clojurescript (69)
- # core-async (13)
- # cursive (11)
- # datascript (6)
- # datomic (8)
- # dirac (2)
- # emacs (10)
- # euroclojure (1)
- # events (1)
- # gsoc (13)
- # jobs-rus (9)
- # lumo (7)
- # off-topic (18)
- # om (16)
- # perun (3)
- # planck (1)
- # portland-or (1)
- # re-frame (25)
- # ring (22)
- # spacemacs (1)
- # untangled (14)
I'm going to bet one of you has a clever, much shorter way of turning the string GUILD_CREATE
into the keyword :guilds
(also MESSAGE_CREATE
into :messages
, etc) rather than this unwieldly thing: (keyword (str (clojure.string/lower-case (first (clojure.string/split "GUILD_CREATE" #"_"))) "s"))
Or maybe (defn pluralize [s] (-> s (str/replace #"(.*)_.*" "$1s") str/lower-case keyword))
if you like regex.
Pity that Java regex doesn't support Perl conversions otherwise (str/replace s #"(.*)_.*" "\L$1s")
would be sufficient...
Hmm, "\\L$1s"
I guess, given Java's escape sequence rules 🙂
Ended up going with (-> (str/split "GUILD_CREATE" #"_") first str/lower-case)
Turns out there was already an automatic pluralize in the function I was calling this data with 😄
Hi, I'm writing a nested loop of sorts to traverse a matrix. I'm using something like (loop [r 0] (loop [c 0] ...))
to represent the row and col numbers, but when (= c 7)
I need to go to the next row, while calling recur
will only let me rebind c. How can I increment r?
I try to solve this one of the clojure koans :
"You can quote symbols as well as lists... without evaluation!"
(= `age (let [age 9] (quote age)))
how would I chain str/replace-first
?
(-> (str/split (message :content) #" ") first (str/replace-first "what here? %1?" #"!" ""))
(in other words how do I chain a function with a multiple arity)
@eslachance: when you use ->
you leave out the first argument
I... googled and with some help figured it out too
here, actually, (-> (str/split (message :content) #" ") first (str/replace-first (config :prefix) ""))
(my final code)
it's beautiful. I love threading macros
eslachance have at it! 😄 https://github.com/rplevy/swiss-arrows
Honestly my biggest issue is, I just don't know all the terminology. I thought "chaining function" but if I'd googled "threading macro" I would have found it right away
also check out as->
: https://clojuredocs.org/clojure.core/as-%3E
oh right! yes I sort of remembered that, somehow.
so (as-> 0 n (inc n) (inc n))
is the same as (-> 0 inc inc)
in this particular case
I am going to have so much fun doing clojure tutorial videos.