Fork me on GitHub
#ldnclj
<
2015-11-12
>
agile_geek08:11:00

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.

martinklepsch13:11:59

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

martinklepsch13:11:40

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?

mccraigmccraig13:11:45

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

martinklepsch13:11:56

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

martinklepsch13:11:16

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

mccraigmccraig13:11:46

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

martinklepsch13:11:53

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

mccraigmccraig15:11:18

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

gjnoonan15:11:47

mccraigmccraig: clj-clr ?

mccraigmccraig15:11:08

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

minimal15:11:04

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

agile_geek15:11:37

@minimal: Scala should know better….or is that ‘is no better’?

mccraigmccraig15:11:39

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

mccraigmccraig15:11:21

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

mccraigmccraig15:11:59

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

minimal15:11:56

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

minimal15:11:08

@mccraigmccraig: chars in cljs are just strings right?

agile_geek15:11:20

@minimal: oh how I love the ‘magic’ of implicits!

mccraigmccraig15:11:30

yeah, js doesn't have chars @minimal

mccraigmccraig15:11:19

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

minimal15:11:55

another cljs difference I found today

(count (range))
1.7976931348623157e+308

minimal15:11:23

range uses maxint for the default instead of iterating forever

mccraigmccraig16:11:44

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

mccraigmccraig16:11:26

how does it short-circuit tho ?

minimal16:11:29

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

minimal16:11:13

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