This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-22
Channels
- # admin-announcements (1)
- # aws-lambda (1)
- # beginners (38)
- # boot (48)
- # cider (11)
- # clara (4)
- # cljs-dev (61)
- # cljsrn (9)
- # clojure (68)
- # clojure-austin (3)
- # clojure-greece (9)
- # clojure-mexico (6)
- # clojure-russia (40)
- # clojure-spec (165)
- # clojure-uk (134)
- # clojurescript (37)
- # cursive (5)
- # datomic (25)
- # defnpodcast (2)
- # hoplon (1)
- # jobs (1)
- # juxt (1)
- # lein-figwheel (3)
- # leiningen (4)
- # mount (14)
- # off-topic (8)
- # om (29)
- # onyx (9)
- # protorepl (4)
- # quil (1)
- # re-frame (56)
- # reagent (3)
- # rethinkdb (1)
- # spacemacs (4)
- # specter (12)
- # test-check (2)
- # testing (1)
- # vim (12)
- # yada (4)
cezar00:07:46
oh well, for the size of my trees (less than 100 nodes) it looks like a linear search will be fast enough:
(def data
[
{:span [21 22] :id 13}
{:span [10 20] :id 12}
{:span [17 19] :id 11}
{:span [16 17] :id 10}
{:span [15 17] :id 9}
{:span [13 14] :id 8}
{:span [11 12] :id 7}
{:span [8 11] :id 6}
{:span [7 9] :id 5}
{:span [6 9] :id 4}
{:span [6 8] :id 3}
{:span [3 5] :id 2}
{:span [0 2] :id 1}])
(defn find-intervals [data, n]
(filter
(fn [{span :span}]
(and
(>= n (first span))
(< n (second span))))
data))
cezar00:07:21
(time
(dotimes [n 20000000]
find-intervals data (mod n 22)))
"Elapsed time: 480.723187 msecs"
codonnell05:07:58
And the transducer solution works with arbitrarily many vectors, though it doesn't use transients. Nice!
cezar20:07:06
can one use transients with a sorted-map? I get errors but nowhere in the documentation does it say that transients can't be used with a sorted-map
cezar20:07:35
(def tmap (transient sorted-map))
CompilerException java.lang.ClassCastException: clojure.core$sorted_map cannot be cast to clojure.lang.IEditableCollection, compiling:(form-init206135609334303987.clj:1:11)
dg20:07:59
It looks like the core sorted maps don't implement the right protocol, but there's https://github.com/clojure/data.avl which demonstrates using them with transient.
polymeris21:07:35
Hi. Have a cljs question regarding foreign-libs. I have this in my dev cljs build:
:foreign-libs [{:file "resources/browserified/foo.js"
:provides ["js.foo"]}
And in my cljs file I have (:require [js.foo])
. This works, I get access to the stuff in foo.js from the browser console.