This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-25
Channels
- # aleph (1)
- # beginners (72)
- # boot (3)
- # cider (28)
- # cljs-dev (193)
- # cljsrn (11)
- # clojure (73)
- # clojure-brasil (3)
- # clojure-gamedev (2)
- # clojure-russia (6)
- # clojure-spec (30)
- # clojure-uk (26)
- # clojured (1)
- # clojurescript (32)
- # code-reviews (9)
- # core-async (4)
- # datascript (5)
- # datomic (9)
- # dirac (38)
- # fulcro (23)
- # garden (11)
- # leiningen (1)
- # luminus (11)
- # lumo (6)
- # off-topic (17)
- # quil (2)
- # re-frame (2)
- # reagent (3)
- # ring (3)
- # shadow-cljs (12)
- # spacemacs (4)
- # sql (2)
- # unrepl (85)
- # vim (3)
Hey guys. I have a problem with one of my Clojurescript functions. I have two functions that use the ^:export
metatag. One of them works just fine when called, but the other one doesn't. I keep getting the message Uncaught TypeError: cljs.tracker.bluetoggle is not a function
. I've restarted my server multiple times, but it still doesn't work. I have no idea what's going on and why one function works but the other doesn't.
the most straightforward way to debug this would be to evaluate cljs.tracker
at the JS console
why do your namespaces begin with cljs
though?
any recommendation on a general approach to finding the ‘difference’ of two trees? something like
(let [[nu old _] (clojure.data/diff t1 t2)]
;; old with all 'updates' from nu removed
;; (something/difference old nu)
)
@sundarj I only chose the word difference to be evocative. this needs to word on arbitrary clojure data (edn)
edn is a string format
@uwo Are you looking for clojure.data/diff
perhaps?
boot.user=> (doc clojure.data/diff)
-------------------------
clojure.data/diff
([a b])
Recursively compares a and b, returning a tuple of
[things-only-in-a things-only-in-b things-in-both].
Comparison rules:
* For equal a and b, return [nil nil a].
* Maps are subdiffed where keys match and values differ.
* Sets are never subdiffed.
* All sequential things are treated as associative collections
by their indexes, with results returned as vectors.
* Everything else (including strings!) is treated as
an atom and compared for equality.
nil
nearly. I’m working with the results of clojure.data/diff, so if
let [[new' old' both] (clojure.diff new old)]
, I’d like to find something like the “difference” keypath-wise of old’ and new’.
old’ is going to contain both the key paths that were updated and ones that never existed in new. I’m looking for only this latter category of obsolete datoms
Could somebody recommend a syntactic term rewriting library for Clojure? I have tried using core.match
and termito
, but they don't seem to be featureful enough. The typical conversion rule I'd need is something of (select ?a ["foo"])
⇒ (:foo ?a)
, (select ?a ["foo" "bar"])
⇒ (get-in ?a [:foo :bar])
, (select ?a ["foo"] :or ?b)
⇒ (:a ?a ?b)
, (select ?a ["foo" "bar"] :or ?b)
⇒ (get-in ?a [:foo :bar] ?b)
.
Or maybe not a syntactic rewriting, if there is another, simpler, way to achieve the same result.
When I run clj -Sdeps '{:deps {org.clojurescript {:git/url "
where will clojurescript be cloned?
How can I download just this Jar. https://clojars.org/kitchen-async
Hi, I have found it in clojar's repo: https://clojars.org/repo/kitchen-async/kitchen-async/0.1.0-SNAPSHOT/
@matan that is a very vague question, do you have a more specific example of what you’re trying to do?
Sorry about that. I guess Spekter should have something, but I just rolled my own
(defn update-all-vals [input-map f]
(apply merge
(map
(fn [[k v]] {k (f v)})
input-map)))
Sounds like this isn't very cpu efficient isn't it (like most of the functional abstractions)
@matan if i was to roll my own I'd do something like: (defn update-all-vals [input-map f] (into {} (map (fn [[k v]] [k (f v)])) input-map))
if you want to optimize it there's fairly non-invasive stuff you can do to make it go faster, but i wouldn't bother unless it proves to be a bottleneck
Is Clojure needed ? You could find solutions via shell (awk, sed, ...).
Examples : nl -w2 -s',' a.txt > b.txt
or awk '{print NR "," $0}' a.txt > b.txt
Are there any maintained wrapper for JavaFX? I have seen fn-fx and clojurefx but they all seem abandoned
Does anyone know of an efficient way to work over a matrix from a random point within the matrix, not using row or column major order, but more of an adjacent style ordering?
@yogidevbear what does the data structure look like? Seems like row and column addressing are standard. Would you make a zipper or something similar? Don't know of another common way to do it
For example, if I have this vector of vectors:
[[0 0 0]
[1 0 0]
[0 0 0]
And I want to walk it from a particular coordinate (e.g. [1 2]
= second column, third row), going up, right , down and left from that point, and then doing the same from each successive point, based on a logical checkSorry, I know this is rather abstract
So I'd want to walk the matrix, ignoring the cell with the 1
value
[[0 2 3 0 1]
[0 0 1 0 4]
[1 0 0 0 6]
[0 2 0 4 5]]
Or taking the example above, if I started with a zero on the second last row, walk all adjacent cells, and if they have a zero, update that zero with a value and repeat for it's adjacent cells
In that example, all zeros except for the bottom left one would be updated
I'm not sure that you can escape the row/col index approach -- but for any given x/y pair, you can generate the set of neighbors as x/y coords tho'...
So if I was changing them to 9's, the result would look like:
[[9 2 3 9 1]
[9 9 1 9 4]
[1 9 9 9 6]
[0 2 9 4 5]]
My thinking at present is to have a hashmap to keep coordinates that have already been tested as I move forward
I'm very unclear what problem you're describing I'm afraid...
And a function to call that will have a for
to get calculate the adjacent cells which can recur
I forget what day it was but it had to compute neighbors in an infinite grid and not double count them
It was day 14th (https://adventofcode.com/2017/day/14)
Sounds very similar
I've tried some google, but my fu is a bit off on this one
Thanks for the tip Dan, I'll have a look for his repo in a moment
Sounds like graph traversal to me, check out the breadth first search algorithm for example
You can keep a set of coords that have been checked #{[0 0] [0 1] [1 2]}
for example (you said hash map but I think you want a set?)
You can think of your matrix as a graph where the neighbour nodes are the cells above, to the left, to the right, or below the current cell
Yes @seancorfield, sorry
Thanks @curlyfry, breadth first search may be what I'm trying to search for
Why would the following function give me a CompilerException java.lang.IllegalStateException: Can't pop empty vector
error?
(defn test
[X Y MX]
(for [:up [X (dec Y)]
:right [(inc X) Y]
:down [X (inc Y)]
:left [(dec X) Y]]
(conj MX :up :right :down :left)))
for
doesn't use keywords, it uses symbols (certain keywords introduce conditions and additional bindings so I expect the compiler is parsing your for
according to keyword?
).
Ah, silly me 🙂
(defn test
[X Y MX]
(for [up [X (dec Y)]
right [(inc X) Y]
down [X (inc Y)]
left [(dec X) Y]]
(conj MX up right down left)))
I was using :up
instead of up
, etc
UPPER CASE symbols... shudder 😆
those for bindings still look very weird
are you expecting each of the right hand vectors to act like a range?
no that doesn't work either