This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Ahh, finally figured out what was eating all the newlines in my
<pre> tags in the XML blog files that I'm importing. Turns out that
clojure.data.zip.xml/text doesn't just return the content of the node, it does whitespace removal as well.
I'm puzzled: does anybody really want the current behavior where it replaces the regexp of
(str "[\\s" (char 160) "]+") with a single space?
is it possible to create a
defmethod that will match on any value for a given argument?
anyone have a strong understanding of Perlin noise and want to help me with my clojure implementation of it? happy to pay for your time if that shot in the dark came anywhere near you
Say I have two collections, and I want to compare the first to the first, second to the second, etc. Like so:
Is there a nicer way? Bear in mind that I want to be able to run any function on the pairs, so the many ways of testing deep equality are out of bounds.
(let [f = ; but it could be anything! exemplars [1 2 3 4] candidates [1 2 3 4]] (for [[e c] (map vector exemplars candidates)] (f e c)))
@jeremyraines: Do you need a Clojure implementation of Perlin noise, or are you specifically trying to get your version working? If it's important enough that you're willing to pay, then the former might be true...
And in either case, there are a few existing implementations in Clojure that might steer you the right way.
it's the latter, for understanding. I'm willing to pay just because I'm frustrated
The closest I ever came to Perlin noise was watching Ken Perlin give a talk on it, which was fascinating, but light on technical details. Sorry I can't help personally.
on your question: is f a comparator so what you want back is a collection of trues and falses?
Yeah, I could do the same thing with
(every? (fn [[e c]] (f e c)) (map vector exemplars candidates)), and it might be a bit more intention-revealing.
In my specific case,
exemplars is a collection of maps, where I expect the candidates to have the values from the exemplar maps, but possibly additional ones. To be exact, I'm just testing database stuff, where I don't care about the timestamps and whatnot. It's not exactly rocket science, but anything I learn while doing basic stuff can only help me when doing more complicated stuff.
In particular, doing the
(map vector coll1 coll2) thing to get a pairwise collection feels like a roundabout way of doing something simple.
(partition 2 (interleave coll1 coll2)) is very similar, and more self-documenting, I guess.
map vector, I have no idea how that even works.
I mean, I vaguely remember that
(map f coll1) runs
(f element) on each element, and
(map f coll1 coll2) runs
(f element1 element2), so that's how it works, but it's tricky.
(map vector c1 c2) works because map takes a variable number of collections, yeah
that version with
every? seems good. I could be wrong but I think it has the benefit of being lazy, too, where the
for version isn't
If you wanted to get to the first
false comparison you could do
(first (filter false? (map = exemplars candidates)))
Is there something that looks vaguely like the opposite of
interleave? Something that takes
n, and returns an
n-element collection of collections? E.g.,
(foo 3 [1 2 3 4 5 6]) ;; => ((1 4) (2 5) (3 6))
Though, that partitions by number of elements, not number of resulting collections
@jeremyraines: apparently my question was asked an answered in 2009 (https://groups.google.com/forum/#!topic/clojure/f31RdxAbwZI)
(defn unravel [n coll] (map #(take-nth n (drop % coll)) (range n)))