Fork me on GitHub
#clojure
<
2016-03-17
>
amacdougall01:03:12

I'm reading up on Specter, and it seems really powerful and useful. Anyone have an opinion? Pitfalls or limitations I should look out for as I experiment?

zcaudate03:03:58

hey guys, has anyone got a Method code too large exception when using hiccup?

zcaudate03:03:12

and if so, is there a good way around it?

seancorfield04:03:02

@zcaudate: I assume you have a large data structure in a single function?

seancorfield04:03:08

We use Hiccup to generate some pretty complex web pages and don't hit that error, but all our functions containing Hiccup fragments are pretty small and they are composed (and mapped over data structures) to build the full page.

zcaudate06:03:48

@seancorfield: yeah… it just snuck up on me… having said that… I don’t think the datastructure I need parsed is THAT big… and it’s really a shame that there is no unmacroed version of hiccup

lmergen10:03:51

is there any way to keep track of the amount of bytes read from an inputstream? or do i have to start using Java magic for that?

urbanslug10:03:01

Are clojure transducers not just currying?

urbanslug10:03:37

*carried functions

dialelo10:03:54

not exactly, multiple transformations (`map`, filter et al) get fused into one stack of function calls

dialelo10:03:11

there are no intermediate results

urbanslug12:03:13

hey there’s this function that takes a function that returns a bool and makes it return the opposite boolean value.

lmergen12:03:12

is there some kind of meta input-stream that combines a sequence of input streams into a single input stream?

lmergen13:03:33

hmmm... this seems like something people do not have to do a lot

lmergen13:03:09

the problem i'm solving: i have remote locations (s3) of chunks of a big file (video) .. i want to "combine" all those chunks into a single big file

lmergen13:03:52

so, what i'm planning to do: transform remote location into an input-stream, then run (reduce) on the sequence to reduce it into one big stream

lmergen13:03:03

so i need a function that combines two inputstreams into one

donaldball13:03:58

Perhaps you want to write a fn that returns a proxy that implements InputStream, implementing the read methods by reading from its seq of input streams until exhausted

lmergen13:03:23

yeah, i was afraid it was going to be something like that, which is exactly what i want to avoid simple_smile

lmergen13:03:31

yes, i think that's my best bet

martinklepsch13:03:45

Is there a built-in like this? (x even? [1 2 3 4 5]) => [[2 4] [1 3 5]] ?

niwinz13:03:11

user=> (vals (group-by even? [1 2 3 4 5]))
([1 3 5] [2 4])

martinklepsch13:03:28

user=> (vals (group-by even? [2 3 4 5])) 
([2 4] [3 5])

martinklepsch13:03:59

using vals requires extra checking of the first item to be sure

martinklepsch13:03:07

but yeah, I guess group-by is the way to go simple_smile

niwinz13:03:51

(mapv second (sort-by first (group-by even? [1 2 3 4 5])))
;; => [[1 3 5] [2 4]]

martinklepsch13:03:38

@niwinz: figured using group-by is fine and has the advantage about being explicit about where are what values: {:even [...] :not-even [...]} vs. [[2 4] [1 3 5]]

micahasmith14:03:22

quick question

micahasmith15:03:13

let’s say i wanted to take a function like (defn add [a] (+ a a)), and later in my code, get the actual code for the function, like '(defn add [a] (+ a a)), so that i could walk it

eraserhd15:03:03

@micahasmith: There’s no general way to do this. You could get source filename and line number and read it in, or you could create a macro that attaches the source to the function.

micahasmith15:03:01

you know, i think the macro-way could work for me. thanks @eraserhd !

urbanslug15:03:36

Why can’t I (:require [cljs.core.async :refer [<!!]]) ?

urbanslug15:03:45

or even do it in macros?

urbanslug15:03:08

(:require-macros [cljs.core.async.macros :refer [<!!]])

urbanslug15:03:16

Oh is it not in cljs.core.async?

hans15:03:41

@urbanslug: maybe #C03S1L9DN gives you better feedback.

jr15:03:39

@urbanslug: cljs.core.async does not have a thread blocking version of take <!!

urbanslug15:03:31

jr: I don’t know why I don’t think of these as thread blocking versions but rather...

urbanslug15:03:10

I think of them as not accessible in main process of execution

tomjack16:03:06

user> (read-string "{:keys #foo//[bar baz]}")
{:keys [foo/bar foo/baz]}
simple_smile

george.w.singer16:03:57

Consider (def a "apple"). Is there a way to replace a with an expression? Something like (def (symbol a) "apple")?

george.w.singer16:03:07

I tried in a REPL and it spits out an error

richiardiandrea16:03:18

@george.w.singer I would probably use macros for that

richiardiandrea16:03:55

If the task is more complicated than what you've written of course :)

noisesmith17:03:09

george.w.singer: if you don't need the metadata def adds, it's simple to do with intern

noisesmith17:03:49

But yeah, if you need to call def because you like def's metadata additions, you need a macro. But I think, as in the real world, intern is under-appreciated.

george.w.singer19:03:00

@noisesmith thanks for pointing me in that direction