Fork me on GitHub
#beginners
<
2016-07-21
>
meowy11:07:47

@andrepnh I can't elaborate on it right now because I gotta go, but Go has a lot of flaws.

meowy11:07:22

Broken type system with no generics, awful dependency management (which, for a newish language, is inexcusable given that Java's done it right for at least over a decade)...

andrepnh12:07:05

@meowy: dependency management too? that one is new to me

andrepnh12:07:53

most criticism I had or heard of golang can be summarized in this post: http://yager.io/programming/go.html

meowy14:07:29

@andrepnh Things might have changed, but last time I checked, Go's built in dependency management essentially only lets you get the master branch of a GitHub repo. No version management, nothing.

meowy14:07:03

I do remember that some people came up with things like third party dependency managers that are meant to solve this issue, but...

dominicm15:07:32

My favourite part of Go is that I can write stuff in comments, that changes my code!

akiva15:07:40

You guys might want to move this discussion over to #C03RZGPG3 since it’s no longer really about Clojure.

byron-woodfork16:07:00

Hey everyone, I've got a question. How would I pair up two data structures? Example.. I have.. [["a" "b"], ["1", "2"]] And I want them to be.. [["a", "1"], ["b", "2"]]

Alex Miller (Clojure team)16:07:29

think of it as the firsts and the seconds - does that help?

byron-woodfork16:07:05

Sorry, I probably should've elaborated a bit. Pairing up two of them is easy. The collections I have actually contain around 15 values each.

byron-woodfork16:07:38

I've paired two of them, using the first and last options. But that won't be possible when there's more than 2.

d-side16:07:41

Assuming all the collections have equal numbers of elements, you can map first them, then recur this operation to map rest of these collections, until the first collection is empty.

Alex Miller (Clojure team)16:07:48

you could use interleave

Alex Miller (Clojure team)16:07:13

interleave takes the first of each, the second of each, the third of each, ...

d-side16:07:09

Yeah, nice one

byron-woodfork16:07:14

@d-side: thanks, I've been trying to figure out a way that doesn't involve a loop though. @alexmiller good stuff

d-side16:07:45

Well, there has to be a loop somewhere, if not in your code, then inside 🙂

byron-woodfork16:07:02

I've been experimenting with interleave to figure out how to use that to my benefit. I suppose I was missing the partition function. Thx!

byron-woodfork16:07:26

@d-side: yup. I just don't want to be the one to write it if/when there's something that does it for me 😃

d-side16:07:31

Less code, less the chance to fail, I get it 🙂

st17:07:09

user=> (map (fn[x i] [x i]) ["a" "b" "c"] ["1", "2" "3"])
(["a" "1"] ["b" "2"] ["c" "3”])

st17:07:01

@byron-woodfork: taking advantage of the fact that map can also deal with multiple collections as parameters...

Chris O’Donnell17:07:56

And if you want that to scale to arbitrary size, you could do (apply (partial map vector) colls)

jswart17:07:11

@byron-woodfork: there is also partition-all which is the same as partition but it won’t chop off any remaining items that can’t be merged. see: http://gigasquidsoftware.com/blog/2015/01/26/partition-with-game-of-thrones-pugs/

byron-woodfork18:07:31

You all are awesome! Thx everyone 😃

akiva18:07:00

@codonnell, I wonder what the scale/perf difference is (if any) between using (partial map vector) and mapv.

Chris O’Donnell18:07:05

@akiva: I don't quite follow. Where are you suggesting using mapv?

akiva18:07:37

Nevermind; I misread.

cezar22:07:19

wonder if I could get some help here. I'm trying to do something really simple. I need to find matching ranges in an interval tree. I found this library

(require '[org.dthume.data.interval-treeset :as it])
which looks like it may be able to do what I need but the documentation for it is... let's just say not the greatest. So here is the issue. Given this interval tree:
(def cts (into (it/interval-treeset :as-interval :span)
               [{:span [6 9] :id 4} {:span [6 8] :id 3} {:span [3 5] :id 2} {:span [0 2] :id 1}]))
all I want is to be able to get something like:
(it/gimme-thevalues cts 7)
=> {:span [6 9], :id 4} {:span [6 8], :id 3}
but for the life of me I can't figure out how to get that from this scant documentation: http://dthume.github.io/data.interval-tree/codox/org.dthume.data.interval-treeset.html

cezar22:07:44

the closest call I found that worked for just one the first interval was this:

(it/first-overlapping cts [7 7])
=> {:span [6 9], :id 4}

cezar22:07:04

which is not quite what I want as I may have overlapping intervals and need all of them

cezar23:07:28

still no answer that I can glean from there

madstap23:07:32

I haven't tested it, but maybe use select-overlapping, then selection.overlapping-subset ?

cezar23:07:36

not sure what the select-overlapping does 😕

cezar23:07:57

is there a simple interval tree for clojure that isn't so hard to use?

cezar23:07:49

I found another here: https://github.com/mobiusinversion/interval-tree but it looks like abandonware and blows up even with the example on the front page