This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-28
Channels
- # admin-announcements (1)
- # beginners (33)
- # boot (35)
- # braveandtrue (1)
- # cider (6)
- # cljs-dev (59)
- # cljsrn (24)
- # clojure (44)
- # clojure-austin (3)
- # clojure-china (1)
- # clojure-russia (13)
- # clojure-spec (63)
- # clojurescript (71)
- # community-development (1)
- # core-async (2)
- # cursive (6)
- # datomic (1)
- # editors-rus (2)
- # emacs (3)
- # hoplon (47)
- # jobs-discuss (3)
- # keechma (1)
- # lein-figwheel (2)
- # om (38)
- # om-next (4)
- # onyx (2)
- # other-languages (63)
- # parinfer (3)
- # planck (4)
- # re-frame (3)
- # reagent (2)
- # slack-help (4)
- # specter (26)
- # tmp-json-parsing (7)
- # uncomplicate (66)
- # yada (7)
@dragosboca: I am 99.9% sure Rhino will give you JSON.stringify
method which converts a JS object to a string, which then you can get into Clojure-land and parse using Cheshire
is there an idiomatic way to handle the scenario where you have to alternate between -> and ->> in the same thread ?
i know there is a <-
in plumatic/plumbing.core that converts ->>
to ->
, what is the opposite of that function, and would you consider that a sane approach ?
@lmergen, solutions exist (like as->
) but in my experience you're mostly better off refactoring, e.g. by breaking out logic into a fn
another trick is to use (#(foo % more))
(not the enclosing parens)
but that's also not super readable
@maxp, what kind of collection?
@maxp, maybe a sorted-set would work
there's also ordered sets in a library: https://github.com/amalloy/ordered
otherwise you can of course implement it yourself, by searching a vector manually and adding if the element is not found, but searching in a vector is O(n), not O(1)
or keep a vector and a set, always update both
I discovered that nth
works on an eduction
in Clojure but not ClojureScript. Without yet understanding the machinery, does this sound right? Specific example: (nth (eduction (filter even?) (range)) 5)
yields 10
in Clojure but an error that nth
is not supported on cljs.core/Eduction
in ClojureScript.
(def xform (comp (map inc) (filter even?))) CompilerException clojure.lang.ArityException: Wrong number of args (1) passed to: core/map, compiling:(form-init6257104107699274545.clj:1:18)
old clojure version? π
:dependencies [[org.clojure/clojure "1.6.0"] [co.paralleluniverse/pulsar "0.6.2"] [org.clojure/core.async "0.2.374"]
transducers were introduced in 1.7
I think there is #C053AK3F9
@fasiha @adambros the upcoming version of Specter has what you need:
(transform (continuous-subseqs string?)
(fn [s] [(apply str s)])
[:p "h" "i" :c :d "t" "h" "e" "r" "e"]
)
->
[:p "hi" :c :d "there"]
if you copy the definition of continuous-subseqs
you can use it with the currently released version
@nathanmarz: how would you use that with a nested structure?
eg: [:p "h" "i" :c [:d "t" "h" "e" "r" βeβ]]
@adambros: Here's one way to do it:
(declarepath ALL-VECTORS)
(providepath ALL-VECTORS
(continue-then-stay
ALL
vector?
ALL-VECTORS))
(transform [ALL-VECTORS (continuous-subseqs string?)]
(fn [s] [(apply str s)])
[:p "h" "i" :c [:d "t" "h" "e" "r" "e"]]
)
->
[:p "hi" :c [:d "there"]]
awesome, looks like thatβs recursive so it would handle infinite nesting
yes, that's right
did you write this after the conversation i had with fasiha?
yea, seemed like a pretty good use case
i must say im impressed, quick turnaround there
most of my coworkers love specter
and now i have a reason to like it even more
i can just talk to the creator!
yup π
there's a #C0FVDQLQ5 channel as well