ldnclj

Find us on #clojure-uk
agile_geek 2015-11-12T07:56:47.000007Z

Morning

agile_geek 2015-11-12T08:01:00.000008Z

ProCloDo is on next Tuesday, if anyone fancies coming along and helping build the slowest developed Event Management system in History! šŸ˜‰ Sign up here: https://docs.google.com/forms/d/1SgT6dQksU3eDDJp37cX2dzcDRODEPF1-wDWEJJA2uL0/viewform Doors open 6pm, Review progress so far 6:30pm, coding 7pm.

thomas 2015-11-12T09:26:34.000010Z

morning

martinklepsch 2015-11-12T13:32:59.000011Z

Ok if I ask some bidi questions here? Previously tried in #C03S1KBA2 but I feel like the ratio of bidi users is higher here :simple_smile:

martinklepsch 2015-11-12T13:36:40.000012Z

Basically have a routing scheme like this

;; /DE/de/batterie
;; /DE/en/battery
;; /DE/de/batterie/gespeichert
;; /DE/en/battery/saved
i.e. it has i18n routes. Now the used segments depend on en or de in the second segment. Is there any bidi feature that comes to mind suited for this?

mccraigmccraig 2015-11-12T13:51:45.000013Z

martinklepsch: dyu mean pulling out the second segment as a parameter ?

martinklepsch 2015-11-12T13:52:56.000014Z

@mccraigmccraig: Iā€™m doing that, the problem is more: when using path-for how do I make the third segment depend on the second

martinklepsch 2015-11-12T13:53:16.000015Z

currently I have something like this:

(defn path-for [route opts]
  "Small wrapper around Bidi's path-for to set
   i18n route parameters depeding on language"
  (->> (get i18n-routes (:lang opts))
       (assoc opts :i18n-route)
       (mapcat identity)
       (apply bidi/path-for routes route)))

mccraigmccraig 2015-11-12T13:53:46.000016Z

ah, gotcha... that's more advanced bidi usage than mine :simple_smile:

martinklepsch 2015-11-12T13:53:53.000017Z

which is reasonably ok but I think it wont work well anymore as soon as I add additional segments (like the ā€œsavedā€) thing above..

mccraigmccraig 2015-11-12T15:04:18.000018Z

lol - guess which clj* platform this is running on : (map inc "foo") ;=> ("f1" "o1" "o1")

gjnoonan 2015-11-12T15:30:47.000019Z

mccraigmccraig: clj-clr ?

mccraigmccraig 2015-11-12T15:32:08.000020Z

@gjnoonan: cljs - only in js does "f" + 1 => "f1"

minimal 2015-11-12T15:42:04.000021Z

scala> "f" + 1
res1: String = f1

agile_geek 2015-11-12T15:48:11.000022Z

@mccraigmccraig: the joys of JS!

agile_geek 2015-11-12T15:48:37.000023Z

@minimal: Scala should know betterā€¦.or is that ā€˜is no betterā€™?

mccraigmccraig 2015-11-12T15:49:39.000024Z

ha, that doesn't look entirely unreasonably now @minimal

mccraigmccraig 2015-11-12T15:50:21.000025Z

i guess what surprised me was the combination of map working with single-character strings rather than chars and the arithmetic op

mccraigmccraig 2015-11-12T15:50:59.000026Z

but if you are going to convert the args to + automatically then converting to a string makes more sense

minimal 2015-11-12T15:54:56.000027Z

@agile_geek: scala has implicits so you can recreate some js gotchas

minimal 2015-11-12T15:56:08.000028Z

@mccraigmccraig: chars in cljs are just strings right?

agile_geek 2015-11-12T15:56:20.000029Z

@minimal: oh how I love the ā€˜magicā€™ of implicits!

mccraigmccraig 2015-11-12T15:56:30.000030Z

yeah, js doesn't have chars @minimal

mccraigmccraig 2015-11-12T15:57:19.000031Z

and (+ "f" 1) ;-> "f1" seems reasonable... (inc "f") ;-> "f1" less so

minimal 2015-11-12T15:58:55.000034Z

another cljs difference I found today

(count (range))
1.7976931348623157e+308

mccraigmccraig 2015-11-12T15:59:16.000035Z

haha wtf ?

minimal 2015-11-12T15:59:23.000036Z

range uses maxint for the default instead of iterating forever

mccraigmccraig 2015-11-12T16:01:44.000037Z

lol - evaluating (range) in my cljs repl made chrome a bit unhappy

mccraigmccraig 2015-11-12T16:02:26.000038Z

how does it short-circuit tho ?

minimal 2015-11-12T16:02:29.000039Z

cljs.user=> (source range)
(defn range
  "Returns a lazy seq of nums from start (inclusive) to end
   (exclusive), by step, where start defaults to 0, step to 1,
   and end to infinity."
  ([] (range 0 (.-MAX-VALUE js/Number) 1))
  ([end] (range 0 end 1))
  ([start end] (range start end 1))
  ([start end step] (Range. nil start end step nil)))

minimal 2015-11-12T16:04:13.000041Z

clojure no args version is ([] (iterate inc' 0))