Fork me on GitHub
#beginners
<
2015-10-22
>
roberto02:10:29

is there a way to use a var inside a regex? For example (re-matches #”my-var.*” a-string) ??

agile_geek06:10:10

@roberto: Interested to know your use case and the solution, would you like to share?

roberto13:10:39

yeah, of course. I used re-pattern:

(let [title “Meet.*”
         phrase “Meet & Greet"]
   (-> title re-pattern (re-matches phrase)))

agile_geek14:10:50

@roberto: have done similar myself.

boz19:10:26

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))

alexmiller20:10:29

(def sin #(Math/sin %)) (def cos #(Math/cos %)) (defn square [x] (* x x))

alexmiller20:10:36

you could also (apply + ((juxt (comp square sin) (comp square cos)) 2.5))

chadhs21:10:56

do you guys like hiccup or selmer more for templating in web development?

chadhs21:10:25

hicciup looks/feels clojuric ← a real word

chadhs21:10:41

selmer is nice for us coming from django or jinja2 backgrounds lol

jfntn21:10:16

chadhs: I’ve personally had nothing but trouble with those string templating things, I’d definitely recommend hiccup

chadhs21:10:57

@jfntn: what do you mean by string templating?

chadhs21:10:14

string replacement in selmer that happens?

jfntn21:10:28

yeah and all the logic that you can use in the templates

jfntn21:10:23

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

chadhs21:10:23

interesting

chadhs21:10:38

hiccup is more idiomatic to clojure would you say?

jfntn21:10:26

If you don’t have to sell it to web-designers it’s definitely a more fluent option

gjnoonan21:10:01

I sold Hiccup to designers, and they were quite taken with it. Especially when they learnt how to abstract things out into components etc

boz23:10:45

Thanks @alexmiller ! juxt was my missing piece. … and I should have included the sin, cos and square defs in my question simple_smile