#clojure log - Sep 13 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:12 srid: is it possible to trace javascript errors (in browser) down to cljs source line no?

0:13 amalloy: seems unlikely, srid, but i guess i'm not the expert

0:23 dnolen: srid: not yet no, you need source mapping for that.

2:08 antares_: hi. I have a type hint inside a syntax-quoted form, like this: (String. ^bytes message-payload#) and compilation fails with "Unable to resolve classname: clojure.core/bytes". What do I do? without this type hint, String ctor cannot be determined.

2:15 amalloy: ^"[B" should work

2:17 ^bytes is a convenience that i guess the syntax-quoting system might not know about

2:25 antares_: amalloy: thanks. I ended up with ~(with-meta v { :tag bytes }) where v is generated with gemsym.

2:29 tsdh: Is there a way to programmatically generate strings containing nested #=() forms? I want to generate something like "#=(+ 1 #=(+ 2 3))", but don't get it...

2:36 Ah, got it using format instead of str.

2:36 ambroff: anyone have any idea how to use into-array to create a byte[][]? I can't figure out how to name the byte[] type.

2:37 amalloy: &(class (into-array [(make-array Byte/TYPE 1)]))

2:37 lazybot: ⇒ [[B

2:37 ambroff: I have a sequence of byte[] objects and I want to turn it into a two dimensional array so I can invoke a variadic method that takes byte[]… as a parameter

2:37 oh thank you amalloy!

2:38 amalloy: really though if you have a sequence of byte[]s, just a plain old into-array should work?

2:39 tsdh: i think chouser is right; trying to do a bunch of code evaluation in the reader is madness

2:40 tsdh: amalloy: Most probably he is right, but as long as I don't have a better solution...

2:52 amalloy: This works flawlessly (http://pastebin.com/4QAhwJWp) and allows me to read and write arbitrary clojure data structures containing instances of those custom 2 java classes. Although not very clean, I don't see how to do it otherwise. But I'm still open for suggestions.

3:00 thorwil: hmm, if i start appengine-magic from a lein repl, i can use datastore ops fine. but via swank, after clojure-jack-in, i get: No API environment is registered for this thread.

3:24 ok, so i learned slime-eval-buffer and pasting to the repl makes a difference, there :)

4:03 Jeffrey04: good evening~

4:04 i just threw 10mil of lines into my script and it throws OutOfMemoryError (-Xmx2G), is there anyway I can rewrite the code so that it doesn't use up all the memory?

4:04 http://stackoverflow.com/questions/7186663/clustering-fkmeans-with-mahout-using-clojure < the first clojure script

4:05 10mil lines of input from stdin*

4:05 clojure 1.3-snapshot if this is relevant

4:12 Fossi: Jeffrey04: seems like something isn't lazy (prolly the java part)

4:13 so it realizes the whole seq when trying to pass that on

4:13 you can try to force evaluation (doall) earlier to see what consumes too much memory on the way

4:14 Jeffrey04: Fossi: not sure, I don't even know where to begin debugging ;/

4:15 Fossi: Jeffrey04: i don't get the domain at all, but i assume you want to read some lines, crunch them and spit them out again then continue?

4:16 kzar: I wanted to fix a typo in a 4clojure problem but the source in Github seems to only go up to problem 87. Where's the latest version?

4:19 Jeffrey04: Fossi: it first turn the first block in the stackoverflow.com post into something like this: { tag_sit [image_a 0 image_b 1] tag_lorem [image_a 1 image_b 0] ...}

4:19 then it will continue processing them

4:20 suspecting the inner reduce call is killing the script

4:21 Fossi: Jeffrey04: so you want all the data in memory at once?

4:22 what i meant above was: turn the inner reduce into a method, and test-call that with doall

4:22 and see if that already fails

4:23 Jeffrey04: probably not, thinking of caching them into temp file

4:23 Fossi: so you know whether that "first" step already fails

4:24 because with "normal" evaluation all the seqs will be sazy

4:24 *lazy

4:24 and it will fail just at passing it down to java on realizing the whole map/reduce construct

4:27 Jeffrey04: ok

4:27 let me try

5:46 fliebel: Does ClojureScript have its own channel and mailing list?

5:51 Ah https://groups.google.com/forum/#!topic/clojure/3b77dCMuvQs

5:54 michaelr525: hey

5:54 fliebel: michaelr525: Hi

5:54 michaelr525: what's up? :)

6:03 tsdh: Do I see it correctly that in clojure 1.3 ^:dynamic vars rebound with `binding' will have the rebound value in all threads spawned in the dynamic scope of the `binding'?

6:06 raek: only with clojure's own constructs, like 'future'

6:07 tsdh: raek: Of course, that's what I've used to test my assumption. :-)

7:16 thorwil: where does output from println end up, with a swank session started via clojure-jack-in?

7:18 raek: thorwil: for expression evaluated from the repl thread, they should end up in the repl. in other threads they end up at the top of the buffer called something with "swank" in it

7:19 you might want to do a (intern 'clojure.core '*out* *out*) in your repl

7:22 thorwil: raek: that did the trick, thanks!

7:23 before, there was no output in the repl and wild mix of looging in *swank* (without print output)

7:26 now if server messages keep out of the swank repl, this might actually be worth the move away from running a lein repl for appenegine-magic/jetty plus swank

7:48 bendlas: I'm having an issue with connecting Eclipse + CCW to an external nRepl

7:48 It works, basically, but autocompletion throws an error

7:48 anybody seeing the same, or knows how to fix?

8:11 pphant: afternoon - can anyone explain why :arglists metadata only appears after I call defn twice?

9:41 tsdh: Wow, the canonical lazy fibonacci sequence example performs fife times faster than a straight-forward iterative java solution. http://pastebin.com/DwFqADLs

9:42 Why is that? Because clojure starts the calculation with longs and promotes to slower BigInt ops only later on?

9:43 opqdonut: I guess yeah

9:43 try using BigInteger.ZERO and ONE instead of 0 and 1 in the clojure version and see what happens

9:47 tsdh: opqdonut: Hm, it's still as fast as before using 0N 1N...

9:49 michaelr525: compiler optimization maybe

9:49 i mean maybe it still compiles to integer

9:51 tsdh: Or clojure.lang.BigInt simply performs better than java.math.BigInteger.

10:05 TimMc: clojure.lang.BigInt... new in 1.3?

10:05 yes, it is

10:06 "unlike BigInteger, BigInt has consistent hashcodes with Long, through range of long"

10:11 michaelr525: cool

10:31 leeda: doesn't clojure core have a recursive merge for maps?

10:34 michaelr525: i found this: http://clojuredocs.org/clojure_contrib/clojure.contrib.map-utils/deep-merge-with

10:35 leeda: ^^

10:35 leeda: basically i want to do this: (merge {:a {:z 1}} {:a {:a 1 :b 1}}) -> {:a {:a 1 :b 1 :z 1}}

10:36 ,(merge {:a {:z 1}} {:a {:a 1 :b 1}})

10:36 clojurebot: {:a {:a 1, :b 1}}

10:36 leeda: michaelr525: hm looks like it might work, wonder what function i should use

10:37 michaelr525: ,(require 'clojure.contrib.map-utils)

10:37 clojurebot: #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/contrib/map_utils__init.class or clojure/contrib/map_utils.clj on classpath: >

10:37 jli: is there a way to turn off pull requests in github? hopefully people don't just think clojure is ignoring them

10:37 michaelr525: leeda: maybe identity

10:37 leeda: surprised there's nothing in clojure.core though

10:37 jkkramer: ,(merge-with merge {:a {:z 1}} {:a {:a 1 :b 1}}) ;for one-level deep

10:37 clojurebot: {:a {:b 1, :a 1, :z 1}}

10:37 leeda: michaelr525: yeah i'll try that

10:37 jkkramer: oh haha that works

10:38 jli: wait why would you want to do that?

10:38 jli: leeda: because contributors have to sign a CA, and the channels for contributing are via JIRA

10:39 leeda: jli: ah ok

10:39 raek: Clojure has it's own issue tracking system and does not accept patches outside the system

10:39 redinger: jli: As far as I know we cannot turn off pull requests

10:39 Or at least, I don't see such an option

10:39 jkkramer: it lets you turn off issues, which may in turn disable pull requests

10:40 redinger: We've turned off issues

10:41 jkkramer: too bad github itself doesn't accept pull requests

10:44 jli: I guess someone would could just close them manually

10:45 with a link to the contributing page

10:47 TimMc: jkkramer: Isn't github on github?

10:47 Maybe it is in a private repo.

10:47 jli: I don't think it is

10:48 TimMc: I guess they don't want people forking them.

10:48 jli: yeah, not publically at all

10:48 jkkramer: github-the-company is, github-the-site is not

10:48 jli: publicly at least*

10:48 TimMc: I think some of their components are public.

10:51 hugod: the github wiki (gollum) is on github

10:55 oh, and I see they now have a github maven plugin, with goals for uploading artifacts to a project's download area on gihub, and to publish to gh-pages

11:49 michaelr525: anyone here uses ERC for IRCing?

11:50 how to get the number of people in the channel?

11:50 Scriptor: there's some elisp script you have to install, it's not bundles afaik

12:01 technomancy: michaelr525: (hash-table-size erc-channel-users)

12:02 what I wouldn't give for a reasonable associative data structure in elisp =(

12:04 hugod: what rhickey hoped he'd never see? https://github.com/pallet/zi-cljs

12:09 ambrosebs: hugod: he knew someone would do it ;)

12:10 michaelr525: technomancy: hey thanks!

12:10 err

12:11 mdeboard: Why didn't he want to see that?

12:11 Does it compile to JVM bytecode ?

12:11 michaelr525: technomancy: can i just eval it while in the irc buffer?

12:11 mdeboard: or?

12:11 technomancy: michaelr525: M-:, yeah. it's buffer-local.

12:11 mdeboard: @ hugod ambrosebs

12:11 oh, uh

12:11 I remember from the "introducing cljs" talk

12:12 michaelr525: technomancy: ok, i need you to hold my hand :) how do it do it?

12:13 technomancy: michaelr525: just hit M-: from the ERC buffer you want to count and enter the expression above.

12:13 mdeboard: what was it? no in-browser execution?

12:13 hugod: mdeboard: no, it just runs the clojurescript compiler - but it uses clojurescript, closure-compiler and the closure library from jars

12:13 mdeboard: hugod: Why is that negative? I don't get it, I guess, but want to :P

12:14 technomancy: hugod: anything would be an improvement over "be sure to set CLOJURESCRIPT_HOME before you do anything"

12:14 gives me flashbacks to hadoop =\

12:15 hugod: technomancy: I don't think you have to do that anymore - my patch to infer clojurescript_home from the script path was applied across the board, I believe

12:15 michaelr525: 201 Origin Ocean Additional Currency 1 (null) ORIGIN_OCEAN_ADDON_CURRENCY 0 1 1 1 1 1 4

12:15 technomancy: hugod: oh good

12:16 michaelr525: technomancy: thanks

12:17 hugod: mdeboard: I don't think it is negative - just some people dislike maven…

12:17 mdeboard: hugod: Oh ok, thought you were referring to the distaste (iirc) for in-browser evaluation

13:15 dbushenko: you guys!

13:16 #lisp has only 345 users, while #clojure -- 347!

13:16 mdeboard: yeah that's how trends work :P

13:17 dbushenko: this winter #clojure had just about 200-220 on the average

13:17 clojure gains popularity!

13:18 SergeyD: hi, where is defmacro in 1.3? I got a strange error that about clojure.contrib.def/defmacro after I removed the clojure contrib jar. Though I do not use or require clojure contrib anymore

13:20 Sorry, I was probably wrong

13:20 Just "defmacro" in REPL works

13:50 mattmitchell: Is there a nice alternative to this: (apply concat (map :id (map :records data))) => yields a list of ids from {:records [{:id 1}]} ??

13:50 lazybot: mattmitchell: Uh, no. Why would you even ask?

13:50 mattmitchell: well hrm

13:51 mdeboard: lol @ smart-aleck lazybot

13:51 amalloy: heehee

13:51 mattmitchell: lazybot: How was I to know?

13:51 :)

13:51 TimMc: haha!

13:51 It got me that time.

13:52 mattmitchell: data is [{:records ...}] presumably

13:52 amalloy: mattmitchell: do you mean [{:records [{:id 1}]}]? your (map :records) doesn't make sense otherwise

13:53 mattmitchell: amalloy: oh yes sorry

13:53 hmm, bad example

13:53 Let me think of another

13:54 TimMc: Perhaps you are looking for some kind of tree-walk thingum.

13:55 Hrm... maybe that's too general

13:55 amalloy: &(let [data [{:records [{:id 1}, {:id 2}]}] (for [{records :records} data, {id :id} records] id))

13:55 lazybot: java.lang.IllegalArgumentException: let requires an even number of forms in binding vector

13:55 amalloy: &(let [data [{:records [{:id 1}, {:id 2}]}]] (for [{records :records} data, {id :id} records] id))

13:55 lazybot: ⇒ (1 2)

13:56 TimMc: Oh, there's that flatten aspect of for again.

13:56 mattmitchell: TimMc: yes something like that, extract a flat list of values for a certain attribute, where the attribute is in a nested structure

13:56 TimMc: mattmitchell: Looks like amalloy nailed it.

13:57 mattmitchell: Oh I see. Yeah that's nice.

13:58 amalloy TimMc thanks!

13:58 TimMc: ,(inc amalloy) for reminding me that for can descend more than one layer

13:58 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0)>

13:58 TimMc: &(inc amalloy) then

13:58 lazybot: java.lang.Exception: Unable to resolve symbol: amalloy in this context

13:59 amalloy: TimMc: for is fantastic. i use it in like every other function

13:59 TimMc: amalloy: Sorry, you don't exist.

14:01 mattmitchell: wow, how does that "for" example even work? Need to dig into "for" now.

14:01 TimMc: mattmitchell: A for with n bindings is like n nested for loops.

14:02 mattmitchell: TimMc: So your list of bindings can reflect the nesting?

14:02 TimMc: Yup.

14:03 mattmitchell: Very awesome

14:03 TimMc: Each binding can use the bindings before it. You can use it for recursive descent, like amalloy did, or cartesian products if the second binding doesn't use the first.

14:03 mattmitchell: Nice, thanks

14:03 TimMc: ,(for [a [1 2 3], b '[x y]] [a b])

14:03 clojurebot: ([1 x] [1 y] [2 x] [2 y] [3 x] ...)

14:04 mattmitchell: Ahh OK. Good example.

14:05 amalloy: &(let [items '[a b c]] (for [x items y items :when (not= x y)] [x y]))

14:05 is another example of useful stuff you can do with `for`

14:05 lazybot: ⇒ ([a b] [a c] [b a] [b c] [c a] [c b])

14:06 TimMc: haha, nice!

14:06 mattmitchell: Cool

14:06 TimMc: Very readable.

14:06 amalloy: &(let [items '[a b c]] (for [x items y items :while (not= x y)] #{x y})) ; no duplicates

14:06 lazybot: ⇒ (#{a b} #{a c} #{c b})

14:07 amalloy: that might be the first time i've ever wanted to use :while, though - i find :when and :let a lot more useful

14:21 mattmitchell: is there a nice way to know if a number falls within a given range?

14:22 amalloy: &(< 5 8 10)

14:22 lazybot: ⇒ true

14:22 amalloy: &(< 5 22 10)

14:22 lazybot: ⇒ false

14:22 hiredman: ,(.contains (range 10) 8) ;; don't do this

14:22 clojurebot: true

14:23 mattmitchell: hiredman: nice one :)

14:23 amalloy: heh

14:23 mattmitchell: amalloy: man, why does it always look so simple?

14:23 amalloy: ,(contains? (range 10) 8) ;; much more efficient!

14:23 clojurebot: false

14:23 amalloy: (also wrong of course)

14:24 pdk: (doc contains?)

14:24 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."

14:24 pdk: :|

14:49 kjeldahl`: Anybody ready for a Congomongo question? git://gist.github.com/1214676.git

14:49 In essence enforcing a unique index and detecting when an insert fails.

14:50 mattmitchell: Curious about a more idiomatic way to do this, anyone have any suggestions? https://gist.github.com/1214682

14:51 It removes :rates items if the :total_rate falls outside the min-rate and max-rate

14:52 amalloy: mattmitchell: i smell a for/when pattern...

14:52 mattmitchell: that's what I was wondering

14:57 amalloy: i guess there are a number of ways you could do this

14:57 https://gist.github.com/1214703 is a rewrite with for/when

14:58 you could also do something like...map over the collection with an update-in that fixes the :rates key, and then filter for non-empty :rates keys

15:00 mattmitchell: amalloy: Really nice, thanks! :)

15:05 amalloy: clojurebot: ping

15:05 clojurebot: PONG!

15:12 zippy314_: Hi. Looking for help interpreting the syntax of the cyclic load deps warning under 1.2.1: Cyclic load dependency: [ /anansi/streamscapes/streamscapes ]->/anansi/streamscapes/ident->[ /anansi/streamscapes/streamscapes ]->/anansi/streamscapes/channel->/anansi/test/streamscapes/channel

15:12 Am I supposed to read that backwards?

15:13 wondering what the [ ] mean.

15:33 seancorfield: pastebin the use/require clauses from each of those namespaces for us to look at?

15:34 scgilardi: [ ] highlights the path that the loader attempted to load twice

15:35 it reads forward

15:36 arohner: I have a clj file that takes 5-10s to compile in swank, when normally things take 0.01s. The file is not unusually long (50 LoC), but imports several java classes.

15:36 is there anything I can do about that? is it a known issue?

15:36 amalloy: arohner: it probably compiles in no time at all, then wastes a bunch of time printing status messages

15:36 try (setq font-lock-verbose nil)

15:37 arohner: amalloy: no change. It takes 5s before the …….. shows up

15:40 amalloy: dunno, then. maybe technomancy has seen it before

15:41 grim_radical: how would i test if a variable is a java array? i can't seem to find an array analog to things like coll?, string?, etc

15:41 amalloy: &(.isArray (class []))

15:41 lazybot: ⇒ false

15:41 hugod: arohner: how are you compiling it in swank?

15:41 grim_radical: amalloy: ah, of course...thanks!

15:41 arohner: hugod: C-c C-k

15:42 amalloy: &(.isArray (class (into-array ["test"])))

15:42 lazybot: ⇒ true

15:44 mccraig: i have a lazy-seq of vectors… is there a stdlib function that will give me a lazy-seq of the concatenation of those vectors ?

15:45 chouser: ,(apply concat '([1 2 3] [4 5 6] [7 8 9]))

15:45 clojurebot: (1 2 3 4 5 ...)

15:45 mccraig: chouser: but that does not seem to be lazy…

15:45 hugod: arohner: have you tried calling load-file from the slime repl? is that what the 0.01s is?

15:45 Chousuke: it is

15:46 chouser: mccraig: it should be "mostly" lazy -- not quite as lazy as it could be with a more specific function iirc.

15:46 arohner: hugod: load-file takes 1s

15:46 clojurebot: I don't understand.

15:46 Chousuke: ,(take 1 (apply concat (repeat [1 2 3])))

15:46 clojurebot: (1)

15:46 mccraig: chouser: it seems to evaluate the entire contents of my lazy-seq of vectors

15:47 Chousuke: as you can see, it doesn't :)

15:47 are you sure you're not forcing evaluation somewhere else?

15:47 arohner: hugod: actually, it varies, 1s to 10s

15:47 chouser: mccraig: it probably forces the first 2 or 3 steps of the lazy seq initially

15:48 hugod: arohner: lots of gc?

15:48 Chousuke: hmm

15:48 ,(take 1 (apply concat (repeat [(do (print "hey") 1) 2 3])))

15:48 clojurebot: hey

15:48 (1)

15:49 pcavs: ,doc repeat

15:49 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>

15:49 Chousuke: hm, duh

15:49 just realised my experiment doesn't quite work .P

15:49 oh well

16:01 mccraig: chouser Chousuke : you are right… it is evaluating the first 3 steps of the lazy seq, and since the test seq only has 3 steps, i took that to mean it was evaluating all steps : thanks

16:13 rata_: hi

16:14 how can I specify the groupid of a package from maven central in project.clj?

16:15 arohner: rata_: in dependencies [group-id/artifact-id "version"]

16:15 rata_: arohner: ok, thanks =)

16:24 TimMc: amalloy: ##(contains? (set (range 10)) 8) much better :-P

16:24 lazybot: ⇒ true

16:24 amalloy: not nearly as efficient though

16:25 TimMc: Yours efficiently returned the wrong answer.

16:25 clojurebot: llahna: anyway the answer is no. you can use #(some-fn %1 default-arg %2), for example

16:25 amalloy: TimMc: yeah, that was the whole fun of it

16:26 clojurebot: llahna: anyway the answer?

16:26 clojurebot: llahna: anyway the answer is no. you can use #(some-fn %1 default-arg %2), for example

16:27 amalloy: brilliant

16:54 TimMc: clojurebot: yeah?

16:54 clojurebot: excusez-moi

16:54 TimMc: wait, nvm

17:40 arohner: is it possible to ask for the list of all loaded classes? Does that make sense on the JVM?

17:41 companion_cube: it may load the "list" class, hence modifying the observed state :)

17:42 brehaut: arohner: looking at the ClassLoader (http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html) methods, it doesnt appear to be obvious if it is possible

17:42 technomancy: arohner: I don't think you can distinguish between classes that have been loaded vs classes that are just on the classpath

17:42 because it's supposed to be transparent

17:42 amalloy: chouser: looks like data.xml is set up to be built by hudson, but the builds have been failing; is that accurate? i don't understand hudson

17:42 joegallo: if this isn't out of date: http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725-classsrc2.html

17:43 then you might could wallhack that field and read it off the some of the usual suspect classloaders

17:43 but that's not appropriate for, like, real code

17:43 ieure: Is there a way to create a thing like a Python generator with Clojure?

17:44 arohner: my goal is to make a find-class that works similar to find-doc. I could deal with loading all classes, but I'd prefer not to

17:44 thanks all

17:44 brehaut: ieure: do you mean a function that yields items one by one, or do you mean the iterable object that is returned by that function?

17:44 joegallo: http://download.oracle.com/javase/6/docs/api/java/lang/instrument/Instrumentation.html

17:44 has a getAllLoadedClasses() :)

17:44 ieure: brehaut, Well, both, but I am more interested in the former.

17:45 amalloy: ieure: lazy-seqs are isomorphic to generators, really, i think

17:45 brehaut: ieure: theres no direct analogy, but the lazy-seq macro is what you are looking for

17:45 amalloy: nah, seqs are superior in about every way to generators

17:46 ieure: brehaut, It’s not clear from the docs that it is, but they are often difficult to grasp in their terseness.

17:46 The docs make it seem more like it is memoizing.

17:47 So basically I want to stitch together paginated results into a single seq.

17:47 But I don’t know the offset of page N' until I have consumed page N.

17:47 brehaut: ieure: the big difference is that generators are iteratively defined, and lazy-seqs are recursively defined. inside a lazy-seq cons is roughly equivalent to yield in python

17:48 technomancy: ieure: you may be able to even just (apply concat (for [...]))

17:48 ieure: technomancy, Maybe.

17:48 brehaut, Interesting perspective.

17:48 I need to meditate on this.

17:48 brehaut: ieure: oh, there is one thing that generators can do that i dont think seqs support: generators can have a value 'sent' back into the generator function

17:49 ieure: brehaut, Yeah. Though that is not something I need.

17:50 So, if I create a lazy-seq that produces the results I want, does it: a) perform all the requests for pages the first time I begin to consume it, or b) perform the requests for page N as I consume across page boundaries?

17:50 amalloy: brehaut: explain

17:50 ?

17:50 brehaut: amalloy: which part?

17:51 amalloy: generators can have a value 'sent' back into the generator function

17:51 hiredman: ieure: it depends how you construct it

17:51 ieure: From the docs, it appears that A is the case, whereas I want B.

17:51 hiredman: lazy seqs don't know anything about "pages" whatever those are, but if you construct it in a way that knows about pages then yes

17:53 ieure: hiredman, It’s unclear to me how I would do it. Can you point me to an example?

17:53 joegallo: it would be pretty misleading to call it a "lazy" seq if the answer were a, i think :)

17:53 ieure: joegallo, Okay, but this is the only interpretation I can get from the docs.

17:53 "Takes a body of expressions that returns an ISeq or nil, and yields

17:53 a Seqable object that will invoke the body only the first time seq

17:53 is called, and will cache the result and return it on all subsequent

17:53 seq calls."

17:53 Sounds like memoization, not lazy/infinite seq creation.

17:54 hiredman: ieure: what if the body is a cons?

17:54 ieure: hiredman, I don’t know, what if it is?

17:54 brehaut: amalloy: heres a trivial example: def foo():\n a = True\n while a:\n i = yield 1\n\n

17:54 ieure: hiredman, Is a cons an ISeq or nil?

17:54 hiredman: ieure: well read that again with s/body/cons/

17:55 brehaut: amalloy: i = foo()\ni.next() # => 1\ni.send(False) # => StopIteration exception thrown

17:55 #python must be an extremely frustrating place

17:55 ieure: brehaut, It’s not, really.

17:56 I just have not internalized the Clojure way as fully as I have Python.

17:56 brehaut: ieure: there must be a better way to post example code then.

17:58 amalloy: brehaut: btw, ; is equivalent to \n and makes the code a little more readable :P

17:59 brehaut: amalloy: sure :P

17:59 amalloy: the indentation isnt very fun though

18:00 amalloy: i don't think i understand the send() yet. does that mean that the generator continues as if "yield 1" returned False?

18:00 brehaut: yeah, the return value for yield is the result of send

18:00 it turns a generator into an annoying coroutine

18:31 gfredericks: hrm. I'm trying to run the clojurescript tests (script/test) and it wants a V8_HOME.

18:32 so I download and build v8 and set V8_HOME to that directory, and it says:

18:32 script/test: line 9: /home/user/v8-read-only/d8: No such file or directory

18:33 oh I see v8 has a "d8" build target....

18:40 srid: my web app works flawlessly with clojure-1.3.0-RC1, but what's with the "not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise" warnings?

18:40 brehaut: srid: you have *earmuffs* on a var name

18:41 srid: "Warning: *append* not declared dynamic [...]" <- that's a core function, no?

18:41 brehaut: srid: but havent added the :dynamic meta; *earmuff* var names indicate that they are ok to rebind

18:41 srid: ah, i am yet to read upon on 'bindings'.

18:42 brehaut: maybe the "append" is coming from some other library, but the warning doesn't tell source location at all.

18:42 brehaut: it like is

18:42 s/like/likely/

18:42 lazybot: <brehaut> it likely is

18:42 brehaut: i dont know how to find out sorry

18:51 patchwork: hey #clojure, I just ran a lein deps and it is missing the [org.clojure/java.jdbc "0.0.3-SNAPSHOT"] artifact? I ran it yesterday and it was there. Any reason why it would go missing?

18:51 seancorfield: you need to specify the sonatype repo to pick up snapshots

18:52 java.jdbc is at 0.0.6 right now on maven central

18:52 technomancy: from what I understand snapshots aren't even guaranteed to stick around anyway

18:53 seancorfield: 0.0.3-SNAPSHOT would be very old, so you may be right technomancy

18:54 the only snapshot i'm relying on right now is congomongo because we're a bit lax about making non-snapshot releases :(

18:55 patchwork: Aha, gotcha. Thanks!

18:56 I will update it

18:56 I was going off the instructions for the heroku clojure install

19:03 seancorfield: i'm surprised that refers to a snapshot (given that i had to do fixes to support postgresql for that)

19:03 patchwork: http://devcenter.heroku.com/articles/clojure-web-application

19:04 possibly the page just needs to be updated?

19:04 seancorfield: yeah, i'll ping aaron about that

19:42 srid: why are the key/value pairs reversed in map destructuring? eg: (let [{x 2, y 5} {2 "hello", 5 "foo"}] [x y])

20:01 amalloy: technomancy: i'm trying to upgrade to 1.3 but can't get either cake or lein to run swank properly. i assume someone's managed to do this already; what do i need to do? i've tried $ lein plugin install swank-clojure 1.4.0-SNAPSHOT, but still $ lein swank seems to have issues: https://gist.github.com/1215517

20:02 hiredman: check for old versions of swank in lib

20:02 but that is actually a problem with contrib

20:02 technomancy: amalloy: I haven't tried 1.3 since ~alpha2, but I also haven't heard anyone else mention that

20:03 swank does have some "let's use this contrib functionality if it's on the classpath" features

20:03 hiredman: some dependency is transitively compiling clojure.contrib using 1.2

20:03 then packaging up the classfiles which are not abi compatible with 1.3

20:03 * hiredman has seen this before

20:04 amalloy: hiredman: yes, i haven't yet hunted down which of my deps depend on contrib; i was hoping to use swank to help me find them

20:04 hiredman: well, this is something that is aot compiled

20:04 amalloy: maybe mvn will tell me?

20:04 * technomancy would be a lot more tempted to port dependency:tree to lein if lein pom && mvn dependency:tree were not so easy to type

20:28 seancorfield: Q about reflection warnings... Given this code: (let [c (.charAt "Hello" 2)] (println (type c)) (= c \l))

20:28 (= c \l) gives a reflection warning that equiv can't be resolved

20:29 it prints Character (but String.charAt(int) returns char)

20:29 bhenry: ,(let [c (.charAt "Hello" 2)] (println (type c)) (= c \l))

20:29 clojurebot: java.lang.Character

20:29 true

20:30 seancorfield: ,(set! *warn-on-reflection* true)

20:30 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set>

20:30 seancorfield: bah

20:30 bhenry: ah

20:31 hiredman: = is being inlined as (. clojure.lang.Util equiv c \l)

20:32 I doubt there is a Character, char overload for equiv

20:32 that is rather unfortunate

20:32 seancorfield: fwiw i tried (= c (Character. \l)) but that also complained it couldn't resolve equiv

20:33 hiredman: oh whoops

20:33 char, char

20:33 charAt returns a primitive char

20:35 seancorfield: ah my bad - \l is Character, c is char

20:35 if i wrap c as (Character. c) it work

20:35 s

20:36 hiredman: yeah

20:36 equiv really needs overloads for every combination of all primitives and Object

20:39 seancorfield: maybe i'd do better working with code points instead...

20:43 acuozzo: Hi, I've done some googling, but nothing's turned up. Is there a standalone clojure beautifier/formatter?

20:45 technomancy: acuozzo: not really

20:45 dnolen: acuozzo: Clojure has a pretty printer though I think someone really needs to do some work to make it print really well formatted Clojure source.

20:45 acuozzo: it works well enough for macroexpansion in Emacs.

20:45 acuozzo: Ah, OK. I was hoping to plug something into my editor (nvi -- the BSD-licensed vi clone).

20:46 Thanks :-)

20:46 technomancy: the clojure.pprint is a start, but it's not usable out of the box

20:46 acuozzo: I suppose that it needs to be tweaked some?

20:47 Also, I noticed the clojure-refactoring project on Github (I think it was Github, at least). Has anyone toyed with turning this into a standalone CLI refactoring tool?

20:51 scottj: acuozzo: nothing released. I think the non-elisp parts were extracted to parsley

20:51 acuozzo: Is parsley on Github?

20:52 Yes, it is. Looking now

21:37 drewolson: this may not be the right place, but i'll take a shot: anyone know a good way to go about getting your clojars password reset? I sent an email a few days ago but haven't heard anything back.

22:50 srid: could someone tell me where in this code is the compiler error "ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number" coming from? clojure compiler error messages are so unhelpful. http://dpaste.com/614485/

22:54 dnolen: ,(+ 1 [])

22:54 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>

22:54 dnolen: ,(<= 1 [])

22:54 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>

22:54 dnolen: srid: ^

22:55 srid: that exception should give you a precise line number as well.

22:55 srid: dnolen: oh, yes, that's what I thought at first. but neither x nor n in `(<= x n)` are vectors.

22:56 joegallo: on the second recursive call (that is, the third call overall), x is a vector.

22:56 srid: n is always a number. and x cannot be a seq (because, it must be matched by the above cond)

22:56 joegallo: [3 [4 5] 6]

22:56 (and then things blow up)

22:57 dnolen: srid: Clojure errors while initially cryptic are never wrong.

22:57 joegallo: ,(seq? [1])

22:57 clojurebot: false

22:57 dnolen: only two places in you program that error can happen line 15 and line 16

22:57 joegallo: a vector is not a seq, precisely. it is seqable. (or something like that)

22:57 srid: ah

22:58 * srid was doing http://4clojure.com/problem/112

22:58 srid: so I should use (vector?) .. but I'd prefer to have a generic is-this-collection function.

22:58 dnolen: coll?

22:58 clojurebot: Reader syntax of collections has gotchas

22:58 dnolen: ,(coll? ())

22:58 clojurebot: true

22:58 srid: replace seq? with vector? made the compiler happy. no warnings.

22:58 dnolen: ,(coll? [])

22:58 clojurebot: true

22:59 srid: nice

23:00 alandipert: dnolen: are or-patterns and subexpr matching WIP?

23:00 dnolen: alandipert: no if those don't work, bug, example?

23:01 srid: wow, that program was correct after first run.

23:01 all I had to fix was a compiler warning

23:01 dnolen: the only serious bug I want to fix is the lack of backtracking.

23:01 alandipert: dnolen: examples in readme

23:01 dnolen: alandipert: ? they don't work?

23:01 * srid attempts to create a tail recursive version

23:03 alandipert: dnolen: or rather, the or-pattern example doesn't work because of an unrelated omission (no y and z)

23:03 and the subexpr example doesn't work for me for reasons i don't yet understand

23:03 dnolen: oops typo thx, fixing now

23:04 alandipert: "as patterns" is the other one, i managed to work things out using the test as example

23:04 dnolen: another typo

23:05 alandipert: both fixed now

23:05 alandipert: actually the second one isn't sorry

23:05 alandipert: i demand a refund :-)

23:08 the expansion demonstration under 'about' also doesn't work, but maybe doesn't need to

23:11 dnolen: alandipert: changed the about expansion wording

23:12 alandipert: cool, thanks!

23:14 dnolen: alandipert: you did discover a bug tho, vector patterns of different lengths don't work, thx for the feedback.

23:14 alandipert: no prob, i hope to one day come to you with an actual patch

Logging service provided by n01se.net