This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-22
Channels
- # admin-announcements (29)
- # aws (2)
- # beginners (25)
- # boot (110)
- # business (15)
- # cider (39)
- # cljs-dev (3)
- # clojure (90)
- # clojure-czech (28)
- # clojure-hamburg (1)
- # clojure-japan (24)
- # clojure-poland (149)
- # clojure-russia (46)
- # clojure-sg (9)
- # clojure-uk (6)
- # clojure-ukraine (1)
- # clojurescript (105)
- # core-async (37)
- # cursive (9)
- # dato (7)
- # datomic (6)
- # emacs (10)
- # events (1)
- # hoplon (22)
- # jobs (4)
- # ldnclj (38)
- # leiningen (4)
- # off-topic (17)
- # om (173)
- # onyx (134)
- # re-frame (46)
- # reagent (35)
is there a way to use a var inside a regex? For example (re-matches #”my-var.*” a-string) ??
@roberto: Interested to know your use case and the solution, would you like to share?
yeah, of course. I used re-pattern:
(let [title “Meet.*”
phrase “Meet & Greet"]
(-> title re-pattern (re-matches phrase)))
@roberto: have done similar myself.
About 13:30 into http://www.infoq.com/presentations/We-Really-Dont-Know-How-To-Compute , Mr. Sussman shows
((+ (square sin) (square cos)) 2.5)
#| 1. |#
How is that done in Clojure?
It’s equivalent to this in Clojure, assuming square
, sin
and cos
are defined
(+ ((comp square sin) 2.5) ((comp square cos) 2.5))
(def sin #(Math/sin %)) (def cos #(Math/cos %)) (defn square [x] (* x x))
you could also (apply + ((juxt (comp square sin) (comp square cos)) 2.5))
chadhs: I’ve personally had nothing but trouble with those string templating things, I’d definitely recommend hiccup
that’s a weird level of indirection that can be very confusing, in hiccup it’s just code sptitting out data there is basically no learning curve
I sold Hiccup to designers, and they were quite taken with it. Especially when they learnt how to abstract things out into components etc
Thanks @alexmiller ! juxt
was my missing piece. … and I should have included the sin, cos and square defs in my question