#clojure log - Nov 01 2010

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

0:00 rata_: technomancy: IIRC you said me some days ago how to change the indentation of forms in swank-clojure and, IIRC again, it was with the define-clojure-indent elisp macro, but it doesn't work anymore

0:04 phobbs: ,(seq? [])

0:04 clojurebot: false

0:05 phobbs: ,(seq? '(1 2 3))

0:05 clojurebot: true

0:11 rata_: ping?

0:11 clojurebot: PONG!

0:15 ymasory: what's the difference between the signatures "(a & b)" and "(a b*)"?

0:16 qbg: I think Clojure is making my ability to deal with state weaker; I cannot seem to convert a small program from using PersistentVectors to using byte arrays...

0:16 ymasory: Not much

0:17 The first one would appear in the arg vector of a function

0:18 quizme: how do you do optional arguments gracefully ?

0:18 like if I want to pass in an options map into a function

0:20 qbg: Do you want a literal options map or not?

0:20 ymasory: qbg: how would the second one appear?

0:21 qbg: The argument vector would be something like [required args & options]

0:22 And then inside you have (let [{:keys [values i care about] :defaults {:values 5 ...}} options] ...)

0:22 I mean :or instead of :defaults

0:22 And values instead of :values

0:23 (let [{:keys [values i care about] :or {values 5 ...}} options] ...)

0:24 quizme: qbg hmmm

0:24 qbg: ,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b]) :a 4)

0:24 clojurebot: EOF while reading

0:24 qbg: ,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b])) :a 4)

0:24 clojurebot: [4 2]

0:24 qbg: ,((fn [& opts] (let [{:keys [a b] :or {a 1 b 2}} opts] [a b])))

0:24 clojurebot: [1 2]

0:25 quizme: cool

0:25 thanks

0:34 qbg: In your first example, where the user provided the option :a as 4, what if we wanted to multiply 4 by 2 first within the let block?

0:38 qbg: Only if it is provided?

0:38 _seanc_: Any thoughts to as why I get this exception when running lein uberjar: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil (jar.clj:17) ?

0:43 ymasory: thanks

0:44 rata_: is there any place where to learn how use/import/require work? (besides doc)

0:45 I really don't understand why this doesn't work (or how to solve it) and am getting frustrated

0:51 absurdo: anybody know how to get more meaningful error messages with emacs+slime+swank-clojure? i'm not seeing line # information in stacktraces. it's very difficult to tell exactly where any exceptions are occurring when i eval code in the repl.

0:55 quizme: qbg: yeah

1:01 qbg: am i asking for too much?

1:12 replaca: rata_: still there?

1:12 rata_: replaca: yes

1:12 replaca: there's not a really clear write-up that I've seen (except in the joy of clojure), but I'm happy to lay it out for you

1:13 are you using them inside the ns macro or on the command line?

1:14 (oh, and I assume by "how they work" you mean how to get them to do what you want, not how are they implemented inside the clojure system)

1:15 rata_: yes, I'm using them inside the ns macro

1:16 (both are interesting for me... if I need to learn the latter to solve the problem, then I'll try to learn it)

1:16 s/for/to/

1:16 sexpbot: <rata_> (both are interesting to me... if I need to learn the latter to solve the problem, then I'll try to learn it)

1:16 replaca: ok, let's start with the simple stuff: import allows you to reference java classes and is not releated to clojure symbols at all (:import [java.util.Date])

1:16 (ah, you shouldn't need to know the impl)

1:17 rata_: not even related to defrecord?

1:17 replaca: nope, defrecords get pulled in from clojure (I think? hmm, now I'm wondering about that)

1:18 require will make sure a namespace is loaded, but doesn't pull the names into your current namespace

1:19 so (:require [clojure.zip]) lets you say things like (clojure.zip/branch? node)

1:20 use does a require + it loads the names into your current namespace

1:20 rata_: yes... I wasn't sure it allow to do something like (require 'x) (x.Record. ...)

1:20 replaca: so (:use [clojure.zip]) lets you say (branch? node)

1:20 rata_: but it allows you to do so indeed

1:21 replaca: ahh

1:21 it's not x/Record. in that case? I haven't played with records much yet

1:22 rata_: :use doesn't let you use records... at least (use '[x :only (Record)]) doesn't work

1:22 replaca: and then you can refine them: (:use [clojure.zip :only [branch children]]) pulls just those two

1:23 Raynes: Something weird that I noticed: &| (use '[clojure.contrib.json :as json]) |& &| (json/pprint-json nil) |&

1:23 clojurebot: In Ordnung

1:23 sexpbot: (use '[clojure.contrib.json :as json]) ⟹ nil

1:23 (json/pprint-json nil) ⟹ nullnil

1:23 Raynes: It's odd that you can use :as in use. It seems to kind of defeat the purpose.

1:23 replaca: and (require [clojure.zip :as zip]) lets you say (zip/branch? node)

1:24 Raynes: yeah, but I think you can then also say (pprint-json nil) there

1:24 since you've used it

1:24 Raynes: &(pprint-json nil)

1:24 sexpbot: ⟹ nullnil

1:24 Raynes: Oh.

1:24 It's still kind of odd.

1:24 replaca: well, it does a require first. But I tend to agree.

1:24 clojurebot: use vs require is (:use [lib :only [a b c]) or (:require [lib :as alias]) -- (:use lib) is only for playing around

1:25 Raynes: Boy, he sure is talkative lately.

1:25 * Raynes runs off.

1:25 replaca: rata_: so was require + defrecord where you were stuck?

1:26 rata_: it was :import

1:26 I was importing the classes generated by defrecord

1:26 probably that was what was wrong

1:27 replaca: yeah, I *think* the thing there is that the classes created by defrecord don't exist in exactly the same way that regular java classes do, since they are generated on the fly when the clojure code is compiled.

1:28 rdsr: rata_ how about defining a simple "make" function which would create a record and return it

1:28 replaca: import expects to use the classloader in the usual Java way

1:28 rdsr: "make" would be present in the same ns in which you have defined the record

1:28 rata_: I'll try first with require

1:29 replaca: rdsr: I don't think you need to do that. Just use require and don't get too distracted by the . at the end of the constructor function

1:29 rata_: That is working for you, right?

1:29 rdsr: replaca: hmm will try that

1:30 rata_: I must change things at some places yet

1:30 LauJensen: Morning guys

1:31 rdsr: morning

1:32 rata_: morning LauJensen

1:37 writing c/handler-case instead of handler-case mess up the indentation :(

1:37 (and highlighting of the word)

1:40 replaca: Hey LauJensen

1:41 rata_ was asking about how to refer to a record defined in another namespace and I recommended require, but that's not working in my little test case. Can you enlighten us?

1:42 LauJensen: replaca: Best not refer to the actual record unless you have a specific use-case. Insead call its factory functions

1:43 replaca: the constructor made by defrecord or a factory function you create yourself in the same namespace?

1:44 (I haven't used defrecord much yet, so I'm behind on its nuances)

1:53 rata_: not to disagree with Lau's point (which I think is fundamentally correct), but you can do it. It's more complex than I would have thought and Alex Miller outlines how here: http://tech.puredanger.com/2010/06/30/using-records-from-a-different-namespace-in-clojure/

1:55 rata_: replaca: thanks :)

1:56 so I need require and import

1:56 replaca: yup

1:56 rata_: or maybe it's easier to write a factory function and just require the ns

1:58 replaca: rata_: I'm not sure it's actually easier (I tried Alex's solution and it's pretty easy), but as Lau suggests it's probably better style

1:59 rata_: ok :)

2:00 replaca: As often happens in #clojure, I tried to explain something and ended up learning something instead :)

2:06 technomancy: is lein repl an nrepl?

2:07 rata_: replaca: in this place one's learning all the time :)

2:08 replaca: rata_: indeed!

2:09 amalloy: Any word on conj videos being posted?

2:09 replaca: amalloy: I haven't heard anything yet

2:10 amalloy: C'est la vie. In due time, I guess

2:11 replaca: amalloy: I hope so. I was there and there are a couple I'd like to see again

2:11 and allmost all of them deserve a wider audience

2:12 amalloy: Heh. I was away for the weekend and hoped I'd get a coming-home present

2:12 replaca: ahh, well. As you say, in due time.

2:14 amalloy: Indeed

2:25 Wow, I didn't know about re-seq. That's much nicer than my hacked-up version

2:41 Raynes: respond.clj doesn't look totally thread safe

2:46 Raynes: swap! in respond.clj isn't used in a thread-safe way.

2:46 vibrant: amalloy; http://joyofclojure.com/ <- reading it now, opened my eyes on many things

2:47 and it's like $17 after the discount so it's a sin not to grab a copy

2:48 ubii: just started reading it tonight, good book so far

2:49 amalloy: Glad to hear it, vibrant. Did I recommend it?

2:50 vibrant: amalloy; i'm recommending it :)

3:19 Raynes: $mail amalloy Not entirely certain what you mean. I've never had a problem with it.

3:19 sexpbot: Message saved.

3:23 Raynes: $mail amalloy In any case, if you really care, that particular atom should be disposable. You should be able to just throw the counter in the bot ref.

3:23 sexpbot: Message saved.

4:04 LauJensen: rata_: Sorry I had to duck out. Looks like you got it sorted. FYI, you provide factory fns yourselves, which has at least 3 major benefits, 1) easier import, 2) var-args in constructor, 3) no need to change signature if you add a field to the record

4:08 rata_: LauJensen: I haven't sorted it out yet... it takes some time to change every :use to :require

4:08 (and I'm helping my sister at the same time)

4:18 LauJensen: it doesn't work... I don't know why

4:43 mmmm... the problem was unrelated to the import/require/use thing... I should go to sleep

4:44 bobo_: (require 'rata_.sleep)

4:50 rata_: anyway, it was a good thing to put all those :use and :import as :require... it's supposed to be better style :)

4:52 good night guys

4:58 LauJensen: Hi bobo_, got back alright?

5:00 rdsr: Hi folks, need some help on understanding macros....

5:00 bobo_: LauJensen: yes indeed! except noone replaced php while i was gone

5:01 LauJensen: aww thats a bummer, so you dont get to use your new clojure chops? :(

5:01 rdsr: was reading through joy of clojure (macros chapter)

5:01 but can't really undertand their code

5:01 http://gist.github.com/657857

5:02 basically I'm confused with forms like "'~'"

5:03 bobo_: LauJensen: no not yet, but ive started some evil plans to use incanter. Fits realy well

5:03 raek: hrm, that is actually not a macro, but it kind of works like one

5:04 rdsr: s/"'~'"/'~/

5:04 sexpbot: <rdsr> basically I'm confused with forms like '~

5:04 raek: rdsr: ` "syntax-quote" is a feature that lets you build quoted data structures

5:04 inside it, ~ unquotes

5:04 , (let [x 5] `(foo bar ~x))

5:04 clojurebot: (sandbox/foo sandbox/bar 5)

5:05 rdsr: raek, but what does it mean when you unquote something and quote it again

5:05 like in the above gist

5:06 specfically e.g. `('~ctx '~%))

5:06 raek: the generated code will have whatever is in ctx quoted

5:07 if ctx is foo and % is bar, the generated code will be ('foo 'bar)

5:07 * raek fetches his copy of JoC

5:08 rdsr: thanks raek, but why is that necessary?

5:08 I mean ofcousrse its necessary, but I fail to understand why ? :P

5:11 raek: I'm not acquainted with what that code does...

5:12 you could try evaling the expression inside eval and see what code it generates

5:12 cemerick: LauJensen: did you hear back from jvanzyl?

5:12 rdsr: thanks raek, I'm trying to wrap my head around it :)

5:12 LauJensen: cemerick: http://twitter.com/jvanzyl/status/29216397264

5:13 cemerick: ok

5:13 raek: this is not the most simple example of a macro

5:13 (it isn't even macro)

5:15 hoeck: rdsr: the ('~ctx '~%) places the context-map in a list, leading to the following expression: ('{a 1} 'a), where {a 1} is the context-map ctx

5:15 cemerick: LauJensen: It looks like Antony was the last to touch the Clojure side of pmaven. I'd loop him into whatever discussions you, technomancy, and ninjudd want to have.

5:15 rdsr: yes true, I think the chapter starts with syntax-quote, quote ..etc and hasn't introduce defmacro yet

5:15 raek: I see.

5:15 LauJensen: cemerick: Antony who ?

5:16 cemerick: Antony Blakey; has corresponded on the ML before re: lein/pmaven structure. Also, the last to touch the clojure pmaven impl: http://github.com/sonatype/polyglot-maven/tree/master/pmaven-clojure/src/main/clojure/org/sonatype/maven/polyglot/clojure/dsl/

5:16 hoeck: rdsr: and because the map is expected to contain a mapping from symbols to values, it is quoted so that the symbols are not evaluated themselves

5:17 LauJensen: cemerick: got an email addr?

5:17 rdsr: hoeck, thks for the explanation, makes things definitely cleearer, ...

5:18 hoeck: rdsr: if you call the fn with (contextual-eval '{a 1} '(- a)) it returns -1

5:18 cemerick: LauJensen: Antony Blakey <antony.blakey@gmail.com>, though I'd suggest finding his posts on the subject on the ML, which might be helpful as-is?

5:18 LauJensen: right, thanks

5:18 cemerick: Did you notice a question for you in the latest round of emails?

5:18 raek: (contextual-eval {'a 1, 'b 2} '(+ a b)) expands to:

5:18 (let [a ('{a 1, b 2} 'a) b ('{a 1, b 2} 'b)] (+ a b))

5:19 hoeck: rdsr: if you leave off the single-quote in the contextual-eval defintion `(~ctx '%) you will get an "unable to resolve symbol a" exception

5:19 cemerick: LauJensen: yes; will reply later today

5:19 hoeck: rdsr: hope that helps a bit :)

5:19 LauJensen: great, thanks

5:19 rdsr: defintely!

5:32 fliebel: Good morning(gmt+ … oh damn, daylight saving time, uuhm)

5:33 LauJensen: clojurebot: UGT?

5:33 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

5:36 fliebel: LauJensen: Good one… But it's also helpful to know in which timezone someone is to estimate their state of mind.

5:36 LauJensen: eh...ok

5:36 esj: morning all

5:36 and happy monday

5:37 fliebel: morning esj

5:37 LauJensen: esj: morning! i estimate your state of mind to be nil

5:37 fliebel: oh you're right! its impossible with UGT :(

5:37 clojurebot: please show us that ugt is not broken

5:38 esj: LauJensen: always with a kind word for a fellow traveller :)

5:38 LauJensen: Thats right buddy, how are you doing? :)

5:38 esj: What I said was in response to this

5:38 <fliebel> LauJensen: Good one… But it's also helpful to know in which timezone

5:38 someone is to estimate their state of mind. [10:24]


5:38 esj: I'm great ! I'm 100% free.

5:38 LauJensen: Ah great - So now its time to get busy!

5:39 esj: Exactly. I'm taking November as a 'sabattical' to recover my wits and energies.

5:39 first job is to read 'the reasoned schemer'

5:40 but enough about me. How are you doing ?

5:42 LauJensen: Also doing good. Conj Labs Frankfurt was fun and the DSL discussions gave me some new ideas for ClojureQL

5:42 Also was nice to get to meet sthubner and bobo_ in RL

5:42 fliebel: LauJensen: London is next, right?

5:42 LauJensen: Right!

5:42 esj: I'm in !

5:43 gonna be jetlagged out of my mind, but I'll try my best to keep up

5:43 fliebel: LauJensen: And then Amsterdam? :D

5:43 sthubner: LauJensen: I second that!

5:43 LauJensen: fliebel: Quite possible. Its not settled yet, but I have no better ideas... Unless we should try something fancy like a south pacific island

5:44 esj: great. Just make sure you get some sleep on the plane and you should be fine. cgrand survived anyway :)

5:44 esj: and he had to battle striking Frenchies !

5:44 LauJensen: true - They were no match for his DSL fu though

5:45 fliebel: Have any of you seen this one? http://github.com/honza/clitwi I like the idea, but not the execution. It'd be nice to make a streaming one with Aleph, but I can;t find anything to make oauth work.

5:45 esj: what a name...

5:45 arbscht: LauJensen: south pacific island? I know of one...

5:45 TobiasRaeder: morning everybody :)

5:45 LauJensen: fliebel: Twitter OAth is broken atm. Twitter changed the API sligty, the implementer of the protocol hasn't recovered yet

5:45 esj: morphling: TobiasRaeder

5:45 fliebel: esj: Don't worry, it's just a terminal twitter client in Python.

5:46 LauJensen: Huh? My Twitter client still seems to work.

5:47 LauJensen: fliebel: clj-oauth I mean

5:47 I wasn't prepared for Python questions in #clojure, sorry

5:47 fliebel: LauJensen: I wasn't asking about Python, was I? *confused look*

5:48 LauJensen: Now Im confused, back to coding

5:48 fliebel: LauJensen: While I might want to do such a thing, because people in #clojure seem to be very friendly compared to channels like #python and #macports :(

5:48 zeroflag_: whats the problem with twitter oauth?

5:49 fliebel: LauJensen: But if it was fixed, clj-oauth will work with aleph?

5:49 LauJensen: zeroflag_: The protocol now requires an expiration field in the header, which is reasonably close to current time. This isnt implemented yet

5:49 fliebel: I think so

5:49 zeroflag_: hmm

5:50 i'm using oauthsignpost and i haven't experienced any problem

5:52 fliebel: zeroflag_: I need to sign Aleph requests, so something with Ring is required I think.

6:04 zeroflag_: actually oauth can cause a lot of trouble especially when you have to use it from an desktop application

6:04 and it doesnt provide any extra security in case of an installed app

6:05 i still don't understand why do they try to force it

6:16 fliebel: What do I do with a UnmodifiableMap?

6:17 cemerick: fliebel: anything you can do with a j.u.Map

6:18 fliebel: cemerick: Uh, okay… I can convert those to Clojure maps right?

6:18 cemerick: Is it considered more Clojuric to convert hem, or to get values from them directly?

6:20 cemerick: fliebel: There's rarely any reason to convert them. e.g. (:foo some-map) and (get some-map "other key") both work just fine with all j.u.Maps

6:20 (some-map :key) won't work, but that's not really idiomatic (in part because of this issue)

6:22 fliebel: right, thanks :)

6:32 oh, what is the function to turn [[1 2 3] [1 2 3]] into [[1 1] [2 2] [3 3]]? I did some Python the other day, and they call that zip, but now I lost the Clojure term.

6:32 jjido: interleave?

6:32 raek: ,(map vector [1 2 3] [1 2 3])

6:32 clojurebot: ([1 1] [2 2] [3 3])

6:44 fliebel: Classic problem: I need a custom jar on my path with lein or cake. Last time the solution was to fumble with maven, but I heard there is something new lein with a resources folder?

6:45 raek: resources/ itself is included in the classpath, so not any jars in it

6:46 it is inteded for things that are not source files, but needs to be included in the jar of the project created with lein jar

6:46 fliebel: raek: Then it wasn;t resources, but something else intended for checkouts of other jars or… I can't remember

6:48 raek: well, there's the "checkouts" feature, but that's for other lein/cake projects that are not available as jars yet

6:49 like unreleased or bleeding edge libs

6:50 fliebel: raek: Okay, so what do I do with this jar?

6:51 LauJensen: fliebel: You can put the jar file in your local maven repo using 'cake install' and add it as a dependency

6:52 If you have the source, it might be better to add it as a subproject though, in which case cake will automatically handle everything for you

6:52 fliebel: LauJensen: I have the source. It's not Clojure though.

6:52 LauJensen: Ok, then just go with the jar

7:08 fliebel: I'm playing with incanter, and I have a seq of results from frequencies. Like so: ({7 256} {7 204, 87 52} …) What would be the correct function to plot these?

8:04 I'm doing a few map calls on a huge seq, but map is lazy. So I'm not actually looping over the seq a dozen times, am I? I'm a little worried about speed, because in Python it'd be orders of magnitude faster to do one loop with all the functions.

8:06 LauJensen: fliebel: You can test yourself. Map is chunked-lazy

8:06 &(let [s (map #(print % " ") (range 40))] (first s))

8:06 sexpbot: ⟹ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 nil

8:07 LauJensen: afk

8:07 fliebel: LauJensen: Right, so this will require some (time (dotimes magic I guess.

8:22 Chousuke: fliebel: you're only going over the seq once, really

8:22 but the thunking does add some overhead

8:23 if you can, it might be more efficient to combine the functions somehow and do a single map operation.

8:23 fliebel: Chousuke: Thanks :) I'm fine as long as it's not dog-slow looping over the whole thing a dozen times.

8:24 LauJensen: The "cake install <jar>" is not doing anything I think. Am I right in that it install my current project into the repo? What I need is some random jar in my project ;)

8:28 LOPP: I have a problem installing leiningen

8:28 when I run it on win32 as lein self-install it says that I already have the jar, which is a ridiculous lie

8:41 fliebel: What is this supposed to mean? "Var incanter.core/$data is unbound." I didn't use that thing.

9:16 tonyl: morning

9:27 fliebel: huh? get is failing me.

9:27 user=> f

9:27 {7 101, 87 155}

9:27 user=> (get f 7)

9:27 nil

9:29 tonyl: ,(get {7 101 87 155} 7)

9:29 clojurebot: 101

9:29 rhickey: fliebel: what clojure version?

9:30 fliebel: (map class (keys f))

9:30 fliebel: rhickey: 1.2 I guess

9:30 rhickey: they're bytes :(

9:30 rhickey: there you go

9:31 fliebel: rhickey: Good thinking! Thanks :) Now how do I get the items out of there?

9:32 chouser: (get f (byte 7))

9:32 fliebel: chouser: Great :) Works :)

9:32 rhickey: chouser: hrm, that's more encouraging of using coercions for boxing, won't work in the future

9:33 chouser: rhickey: the boxing is secondary there, isn't it? The point is to coerce to a byte or Byte

9:34 rhickey: chouser: coercions are only for interop overload resolution, a call to get isn't interop

9:35 chouser: hm

9:36 rhickey: (class (int 7)) -> long on master

9:36 er, Long

9:36 chouser: Byte has no methods that take an int or long, so ... should be (get f (Byte/valueOf (byte 7))) ?

9:36 rhickey: or (Byte. (byte 7))

9:37 or, don't use Bytes as keys, or, use 1.3+ where this key type problem is removed

9:37 fliebel: rhickey: I'm using a java lib which gives me a set of bytes and then I do frequencies which gives me a map with bytes as keys.

9:38 rhickey: fliebel: you can get out of bytes ASAP and then get something else as keys

9:38 chouser: I'm reading Steele's RABBIT compiler paper, and the differences in tradeoffs between running on top of JVM vs. on top of MacLISP are fascinating.

9:38 rhickey: fliebel: either way, key + lookup types must match pre 1.3

9:39 chouser: writing Lisps on Lisps is cheating, and far too easy

9:39 fliebel: rhickey: I understand that. I didn't realize they where bytes. So should I do (map int) on the whole bunch somewhere upstream?

9:40 chouser: he seems to use a pretty minimal set of MacLISP features.

9:40 rhickey: fliebel: the point I was trying to make to chouser was that the coercions are not for forcing particular boxed types, so best not to use them that way

9:41 chouser: fliebel: probably not. more like (map #(Integer. (int %)) s)

9:42 fliebel: chouser: Why the seemingly double conversion?

9:42 ,(class (int 2))

9:42 clojurebot: java.lang.Integer

9:42 chouser: fliebel: (int x) is to give you a primitive int for interop -- no long-term guarantee that when boxed you'll get an Integer

9:43 fliebel: so it's use there is just be guarantee a primitive int to pass to the Integer constructor, which will always give you an Integer.

9:43 rhickey: aargh, Silverlight, MS lock-in strategy failure #957

9:43 chouser: rhickey: yeah. were you invested?

9:44 rhickey: chouser: oh, no, I'm not installing that!

9:44 * chouser was in a startup in '99 that essentially died with ActiveX

9:45 rhickey: just a PDC vid I wanted to check out, supposedly Hejlsberg mentioned Clojure

9:45 not worth trashing my machine over

9:45 chouser: heh

9:52 fliebel: as rhickey said, (class (int 2)) on 1.3 currently returns java.lang.Long

9:53 fliebel: chouser: Why is that?

9:54 tonyl: isn't there a long fn already?

9:54 chouser: It's part of 1.3's rather comprehensive rethinking of Clojure number handling.

9:55 for example whole number literals will be primitive longs, autoboxed to Longs

9:57 looselytyped1: fliebel: (I apologize for hijacking the conversation) - As chouser said, this has to do with Clojure 1.3 new approach to numbers (boxed and unboxed) - See http://david-mcneil.com/post/1393750407/clojure-conj-day-1-notes (the section "Rich Hickey - New Clojure Features")

9:58 rhickey: long is a primitive, you need it when you need a long argument for a method that takes a primitive. Long is an object. It is one of several objects that could hold, e.g. 42. There is no rule that says 42 is inherently a Long or Integer. So, when you care, as you do when trying to match Object typed keys prior to 1.3., you need to create the proper box type. Trying to get a particular box type by starting with a particular primitive type is

9:58 mistake

9:59 fliebel: rhickey: Thanks, that makes sense.

9:59 rhickey: It ends up you will rarely care about the boxed types, and only do prior to 1.3. because there get follows Java's use of .equals. In 1.3+ get uses =

10:00 Most interop requires particular primitive types, for which there are the int/long etc coercions

10:39 djpowell: rhickey: which was the silverlight video?

10:40 rhickey: djpowell: http://player.microsoftpdc.com/Session/bb7e628d-5c35-4098-9691-059612d8ebc4

10:42 LauJensen: Im not able to view Silverlight videos, am I missing something?

10:42 nickik: arch linux ftw

10:53 chouser: http://az8714.vo.msecnd.net/presentations/FT09-Hejlsberg.pptx -- slides for The Future of C# and Visual Basic by Anders Hejlsberg

10:53 but I see no mention of Clojure there.

10:55 LauJensen: chouser: And you find that odd in a C# & Visual Basic slidedeck? :) The Conj must have worn you down

10:57 rhickey: http://twitter.com/pholdings/status/29269228642

10:59 ubii: watching the video now, and wow, that is a freaking colorful shirt

11:07 chouser: oh, that's not the talk that was linked to.

11:09 maybe here: http://videoak.microsoftpdc.com/vod/downloads/CLI_Low.mp4

11:21 jc2: (defn fn1 [n] (lazy-seq (conj (fn1 (inc n)) n)))

11:21 Gives me: (nth (fn1 0) 1000000)

11:21 chouser: yep. He essentially describes the desirability of transients, and someone else says "you should look at what's been happening with Clojure"

11:21 jc2: stack overflow

11:21 and: (defn fn2 [n] (lazy-seq (cons n (fn2 (inc n)))))

11:22 gives me: 1000000

11:22 I trying to definitively understand that.

11:24 nickik: chouser: hehe yeah he does

11:25 tonyl: jc2: you are recursively calling the function infinitely

11:26 it is fine you you create it since it is lazy

11:26 chouser: rhickey: http://videoak.microsoftpdc.com/vod/downloads/CLI_Low.mp4 at 10:45

11:26 tonyl: but after you trying to access it, it loses its laziness

11:26 jc2: hmm

11:27 That's why fn1 doesn't work but fn2 does?

11:27 nickik: chouser: he sais clojure has parallel datastructers but thats not really true is it?

11:28 chouser: nickik: depends on what he means, I suppose

11:29 noidi: has anyone here read Land of Lisp yet? http://landoflisp.com/

11:29 chouser: perhaps he's referring to forkjoin stuff on vectors, which I imagine would be very interesting to these guys.

11:29 nickik: no but orderd it

11:30 tonyl: jc2: it is weird that the second one works, unless the n parameter is a collection

11:30 raek: the second one should work fine

11:30 I think conj forces the seq, but I'm not sure why

11:30 nickik: maybe he just means taked about structural sharing

11:30 raek: maybe it calls seq on the argument

11:30 noidi: I'm wondering if reading Land of Lisp would help with Clojure programming

11:30 raek: ...which would force the laziness

11:31 jc2: raek: that's what I was thinking. I couldn't fund any docs about that.

11:31 nickik: noidi: im sure it will.

11:31 raek: anyway, when constructing lazy sequences, cons is the fn you usually use

11:31 noidi: nickik, I hope so, too

11:31 tonyl: ,(source conj)

11:31 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

11:31 tonyl: ~source conj

11:31 raek: so I would consider the second one to be perfectly ideomatic

11:32 jc2: ok. thank you very much raek. :)

11:32 nickik: nordi: the author sais that he tried bring a little of every lisp in the book not just CL. For example you implement lazy lists (like clojure has them)

11:32 raek: although, even more ideomatic would be to use one of the existing fns

11:32 ubii: in the video, Anders says that Clojure's immutable collections are 2x to 3x slower than mutable collections in other languages, then later Herb asks how much do these parallel collections scale across say 24 cores and if this more than makes up the 2x to 3x loss

11:33 raek: jc2: range and iterate can probably be used insted, in your example

11:33 noidi: and then again, even if LoL doesn't teach anything directly applicable to Clojure, it teaches one to read Common Lisp, which would surely help to understand lots of other good resources on functional programming

11:33 AWizzArd: ubii: it depends on how you measure. When you want to copy a 900 MB Hashmap each time a thread modifies it, it would be frickin slow.

11:34 ubii: and when you lock access each time, then only one thread will be working on it anyway, so your 24-core system will effectively be a single-core app.

11:35 raek: since 1.2, range does also have a 0-arg version:

11:35 ,(take 10 (range))

11:35 clojurebot: (0 1 2 3 4 5 6 7 8 9)

11:35 AWizzArd: raek: oh, thx for this info, interesting

11:35 jc2: Yes I know. I had a much more complicated function I was working on that was using conj. I thought to switch to cons and all was well.

11:35 noidi: with all the focus on language performance, one might think that most programmers work on AAA Xbox games :P

11:36 jc2: I was just trying to understand the underlying problem.

11:36 noidi: or scientific computing

11:36 raek: I think you could say that conj is preferred, except when building lazy sequences

11:36 AWizzArd: ubii: also think about this: if you make your data concurrency ready by putting it into an external DB (say, mysql), then guess what kind of data structure that uses on disk…

11:38 raek: jc2: also, if you're playing with lazy sequences (especially regarding when they are being realized), this might be interesting: http://gist.github.com/480608

11:39 chouser: so, conj on a lazy seq does call seq on the lazy seq, forcing that first step

11:40 hiredman: (or first 32)

11:40 jc2: raek: thanks again ;)

11:41 chouser: and cons does not right?

11:41 chouser: right, cons leaves the collection entirely alone

11:42 ubii: AWizzArd: thx, was just curious about the correctness of the first statement and how much of performance might be regained by parallelizing it

11:42 chouser: another reason finger tree's consl should be renamed conjl

11:42 jc2: thanks all, back to work.

11:45 ubii: Erik's (the moderator) shirt, is starting to give me a headache :)

11:45 clojurebot: 'Sea, mhuise.

11:45 fliebel: How can I give the Cake JVM more heap space?

11:46 lrenn: fliebel: ~/.cake/config, add cake.java_opts

11:46 nickik: @ubii these shirts are just his thing. Try to watch his series "interduction to FP"

11:47 lrenn: fliebel: http://github.com/ninjudd/cake scroll down to Custom JVM Options

11:48 fliebel: though I imagine you probably want to give your project JVM more mem, not cakes. All the same, look at the readme on the cake page.

11:48 fliebel: lrenn: thanks

11:50 ubii: nickik: thx, I will check it out

11:53 nickik: ubii: http://lambda-the-ultimate.org/node/3642

11:55 ubii: nickik: that one is much less painful on my eyes

12:16 tonyl: I can

12:16 AWizzArd: ubii: I don’t think that those immutable data structures have disadvantages for parallelism. They are just not efficient for some of their operations. So, this is affecting more the concurrency aspect.

12:20 tonyl: what does non-promoting operators and bigint contagion?

12:20 are non-promoting operators only use for the specific types, like you can only add (+) a long with another long?

12:24 jarpiain: ,(class (+ 1 Long/MAX_VALUE))

12:25 clojurebot: java.math.BigInteger

12:25 jarpiain: in 1.3 that would throw an overflow exception instead of promoting to bigint

12:26 tonyl: ok, do in 1.3 it should the operators would only accept nums from the same type?

12:26 *so

12:27 jarpiain: in 1.3 you could write (+ 1N Long/MAX_VALUE) where 1N is a bigint literal

12:27 tonyl: got it

12:27 cool

13:07 nickik: whats the easies way to creat a xml from some clojure data i have?

13:09 fliebel: Ouch, I had to quit my irc client because a Clojure app was taking up all my memory.

13:10 If I remove the take 100 it takes a whole lot more files and hangs at 2gb of memory.

13:10 http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj

13:12 Does anyone have an idea how to reduce memory usage?

13:13 It opens 5mb divided over 2000 binary files and operates on the bytes read.

13:15 AWizzArd: fliebel: I did not study your code, but on first sight it could have to do with fr looking at the head of a sequence.

13:15 Can you not doseq through the file-seq?

13:17 fliebel: AWizzArd: I don't think file-seq is the problem, the resulting blocks are. Every file contains 16*16*128 blocks.

13:18 AWizzArd: file-seq is not a problem, but fr pointing on the head of a seq of blocks

13:19 fliebel: AWizzArd: When is something "holding onto the head of a seq"?

13:21 AWizzArd: fliebel: when you have (let [x (map f data)] ...)

13:22 Then x is pointing to the head of the seq. If f consumes much ram, then you force all data to be in ram at the same time.

13:22 If you would instead (doseq [x data] (f x) ...) then the used ram can be released after working on each element.

13:23 Chousuke: if the seq is realised while the local binding is in effect.

13:23 AWizzArd: there you go

13:23 Chousuke can put it into elegant words :-)

13:24 fliebel: ...

13:25 LOPP: does holding onto head of the seq consume any more memory than if I had a java list with same contents?

13:26 AWizzArd: not really

13:26 maybe 150 bytes more compared to a java.util.ArrayList or whatever, but nothing substantial

13:26 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

13:27 fliebel: AWizzArd: What confuses me: "If f consumes much ram" but f is only the head, that doesn't consume much ram, does it?

13:27 AWizzArd: f could be a function that returns 700 megabyte hashmaps

13:28 if data contains 100 elements then we would require nearly 70 gigs of ram for (count (map f data))

13:28 fliebel: AWizzArd: So how does it help to have 700mb of hashmaps in memory instead?

13:29 AWizzArd: fliebel: for example, i once implemented a parser for a data format that was similar to csv.

13:30 I first had a (let [lines (map process-line (read-lines "file"))] ...) where file was around 3 gb in size.

13:30 In the body of the let I iterated over lines

13:30 That was not good, as this realized the whole file over time.

13:30 chouser: that doesn't necessarily hold the head anymore

13:31 AWizzArd: in the body I had something like (doseq [line lines] ...)

13:32 Later I updated my code to not hold the had of all lines of the file, and it was able to run in a 64 MB default Client JVM.

13:33 fliebel: AWizzArd: You mean you just did (doseq (read-lines… instead?

13:33 AWizzArd: yes, something similar

13:33 (in fact I was using pmap instead of doseq)

13:34 fliebel: AWizzArd: Great, so now you have 3gb of lines in memory, right?

13:34 AWizzArd: In some sense yes.

13:34 Not at one moment.

13:34 But within the 9 minutes of processing I had all 3gb in ram.

13:35 only a few kb at any time

13:37 fliebel: AWizzArd: wait… I'm reading the docs more carefully now...

13:40 AWizzArd: Are there other functions besides doseq that do not retain the head?

13:44 AWizzArd: fliebel: map does not necessarily do this

13:44 only when you explicitly store its head somewhere.

13:45 As in (let [head (map f data)] ...)

13:46 If you just have a (map f data), which would be kind of useless in a functional programming language, when f is side-effect-free (as it should), then in that case it is also fine.

13:46 Also (apply concat (map ...)) can be an indicator that mapcat is useful.

13:46 chouser: (let [xs (map #(vec (repeat 1e3 %)) (range))] (doseq [x xs] (prn (first x)))) ; no longer blows the heam

13:46 heap

13:55 AWizzArd: chouser: okay, I think I had something similar and in earlier versions of Clojure this was not so good.

13:55 chouser: yes

14:26 amalloy: is there a convenient built-in way of adding metadata to an object that might already have metadata, or do i have to merge the maps myself?

14:27 chouser: amalloy: vary-meta

14:27 nickik: im not sure but i think with-meta does that

14:27 amalloy: nickik: it doesn't

14:27 but apparently vary-meta does. nice

14:28 raek: hrm. interesting

14:29 fliebel: Does reduce retain its head? If not, how can I doseq and still ret some results out of it?

14:30 amalloy: fliebel: reduce isn't lazy. i don't understand the question

14:31 argh damn. i can't attach meta to an int, of course

14:31 raek: fliebel: reduce does not retain the head.

14:32 fliebel: raek: Thanks, I think it fits my case better than doseq.

14:32 raek: oh wait..

14:32 hrm

14:32 well, I think it doesn't

14:32 probably beacause of the locals clearing thing

14:33 usually, it's not the about whether a function retains the head, but rather whether the caller retains the head

14:33 amalloy: fliebel: what is your goal here?

14:34 digash: amalloy: you can attach metadata to int ,(meta 'int) ha ha

14:34 fliebel: amalloy: To get this thing to run within my 2gb of memory ;) http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj

14:35 AWizzArd just explained me that the thing retains its head and that I should probably use doseq, but doseq doesn't give me any data back, reduce does.

14:36 raek: Can I test if it does?

14:37 apgwoz: can clojure symbols contain non ascii characters?

14:37 raek: hrm, I think concat forces the first cons of each seq you give it

14:37 apgwoz: yes

14:37 amalloy: fliebel: your (blocks) function looks weird. the lazy-seq isn't doing anything lazy, is it?

14:37 apgwoz: i thought so, does swank-clojure not support it?

14:38 or, actually, i guess swank in general

14:38 raek: apgwoz: slime and swank-clojure use latin1 as the default encoding

14:38 you can configure that

14:38 apgwoz: ah, ok.

14:38 technomancy: =(

14:38 fliebel: amalloy: lazy-cat expands to concat-ing lazy-seqs, my goal here was not to read all those files at once.

14:38 apgwoz: raek: i'll search for the config param. thanks

14:39 technomancy: it's ok. it's not your fault!

14:40 raek: apgwoz: in .emacs: (custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))

14:40 apgwoz: raek: oh sweet. thanks

14:40 ordnungswidrig: hi!

14:40 amalloy: fliebel: but...map is lazy already. it wasn't going to read them in all at once anyway, and wrapping (lazy-seq) around something with no recursion doesn't seem to buy you anything. are you worried about map chunking or something?

14:41 raek: export JAVA_OPTS=-Dswank.encoding=UTF-8

14:41 amalloy: if so i'd suggest either turning off chunking for this segment of code, or using (delay) instead of (lazy-seq) to make it clear what the goal is

14:42 raek: apgwoz: I'm a bit uncertain about ^^, but you should set that java option in some way

14:42 fliebel: amalloy: but concat isn't… I'll look at it.

14:42 apgwoz: raek: ok. is there a way to set that in the project.clj?

14:42 (for leiningen)

14:43 amalloy: fliebel: oh wow i missed the apply concat. just use &|(doc mapcat|&

14:43 sexpbot: java.lang.Exception: EOF while reading

14:43 amalloy: &|(doc mapcat)|&

14:43 sexpbot: java.lang.Exception: Unable to resolve symbol: | in this context

14:43 fliebel: amalloy: I've already done that offline.

14:43 amalloy: bah. okay, i forget the syntax

14:43 ordnungswidrig: are there clojure libraries for generic optimization algorithms? I mean not depending on the problem domain?

14:44 I think of branch-bound or genetic algorithms

14:44 raek: apgwoz: I would put that in .bashrc or something, since it's not something that's tied to the project itself

14:44 mfex: fliebel: how does the lazy-seq in blocks work?

14:44 amalloy: fliebel: concat is lazy

14:44 apgwoz: raek: but, if the project is using unicode symbols, then it's project specific..

14:45 i guess the option isn't necessarily used then though...

14:45 raek: apgwoz: this only affects the slime-swank connection

14:45 apgwoz: clojure source files are always UTF-8

14:45 slime defaults to latin1 for historical reasons, I guess

14:46 technomancy: more like hysterical reasons

14:46 raek: true.

14:46 apgwoz: raek: i know, but if i have swank-clojure in :dev-dependencies (yes, I know this is no longer necessary) it'd sort of make sense.

14:46 either way, i'll check and verify that this all works

14:46 amalloy: fliebel: but if your files are huge, then chunking (in both map and concat) may bite you

14:46 apgwoz: raek: thanks

14:46 raek: apgwoz: well, other developers would have to look at the options in you project, and change their emacs settings to match it

14:47 apgwoz: raek: i suppose...

14:48 raek: you can also do: lein swank localhost 4005 ':encoding' '"UTF-8"'

14:48 apgwoz: sort of related: this is also another reason that having an nREPL-mode for emacs make sense. modern defaults.

14:48 raek: ah, perfect

14:48 raek: yech @ the quoting, though...

14:49 technomancy: I don't think you need to quote the keyword

14:50 raek: apgwoz: also, note that lein repl uses JLine, which has no support for UTF-8 *at all*, so don't use lein repl to see if things work

14:50 chouser: fliebel: do you know where in your code you're running out of memory?

14:50 fliebel: chouser: no

14:50 apgwoz: raek: i noticed that

14:50 technomancy: raek: well it only falls back to jline if you don't have rlwrap

14:50 raek: ah, I see

14:51 chouser: fliebel: you might try to figure that out -- leave things off the end, or print something in-between likely areas and see how far it gets

14:51 apgwoz: raek: lein swank 4005 localhost :encoding '"UTF-8"' <-- you had the port and host backwards

14:51 fliebel: chouser: Isn;t there some kind of java tool to look at this?

14:51 raek: apgwoz: to test if the encoding is configured correctly: (seq "日本語") should yield a sequence of *three* characters

14:51 apgwoz: (unless i'm running an out of date lein)

14:52 chouser: fliebel: btw, (apply concat (map ...)) is (mapcat ...)

14:52 raek: hrm, right.

14:53 apgwoz: raek: rock! it works.

14:53 thanks again for all the help

14:53 raek: great!

14:53 np :)

14:53 fliebel: chouser: You're the third to say that, but thanks anyway :)

14:54 * apgwoz loves this community. so helpful and supportive

14:55 mfex: fliebel: does the blocks function work on its own?

14:56 fliebel: mfex: how do you mean? It works if i give it a file, and it still works if I use 100 files.

14:56 raek: ah, with rlwrap installed, lein repl works perfectly with UTF-8

14:56 mfex: fliebel: ok

14:58 fliebel: chouser: it gets to the point where it's going to realize all the lazy seqs ;)

14:59 alpheus: Is there a way to get access to the variables used in pre and post conditions when the assertion fails?

15:00 Even a printed representation of the values would be nice.

15:05 sthuebner: LauJensen: did you get your head around the PMaven thing?

15:06 LauJensen: sthuebner: I was busy reading on it just now actually

15:06 chouser: alpheus: get to them from where?

15:06 sthuebner: I was studying it the other day to.

15:07 fliebel: I think I found the killing line: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33 Taking the first item from this one realizes the whole thing, if I'm correct.

15:07 sthuebner: since I'm not familiar with Leiningen, I'm not sure, if those two worlds are trying to achieve the exact same thing

15:07 LauJensen: sthuebner: Let me put it this way. If technomancy heard you say that, he would likely kill you :)

15:07 sthuebner: :-)

15:08 amalloy: fliebel: i still think map chunking is the problem. have you checked that out?

15:08 ordnungswidrig: I think I asked some time ago but I got no answer, Any Ideas why "Fontifying *SLIME Compilation*... (regexps……………………………………………….)" takes longer than the compilation itself? (Aquamacs on OS X)

15:08 sthuebner: so, to put it differently: PMaven is doing exactly one thing: describing the POM model in a different way

15:08 not more, (maybe less ;-) )

15:09 fliebel: amalloy: I don't think 32 files will kill it, I can do 100 files just fine, and at 2000 files chunks of 32 aren't going to matter much.

15:09 Derander: ordnungswidrig: same issue in regular emacs on osx, btw.

15:09 LauJensen: sthuebner: yea, minus the plugin story

15:09 amalloy: ah. you can do 100 at a time? interesting

15:10 ordnungswidrig: Derander: it takes nearly a second

15:10 amalloy: (apply map vector some-seq) shouldn't realize the whole thing at once

15:10 fliebel: amalloy: Well, I can put a take 100 on the file-seq and it still works.

15:10 alpheus: chouser: when the java.lang.AssertionError is thrown, I'd like to be able to inspect the values in the slime debugger

15:11 amalloy: fliebel: can you map vector over 100 things? also, are you sure you want map vector rather than map vec?

15:11 fliebel: amalloy: well, I run that on a partition of 128, so taking the first seq of that takes the first item of *all* partitions.

15:11 sthuebner: plugins in PMaven: only sofar as they are declared the usual way - just different syntax

15:12 fliebel: amalloy: Yea, very sure. What I'm doing there is picking every 128th item and then the next-every-128, so taking one takes all items 128 appart.

15:13 amalloy: &(doc rake-nth)

15:14 sexpbot: java.lang.Exception: Unable to resolve var: rake-nth in this context

15:14 amalloy: &(doc take-nth)

15:14 sexpbot: ⟹ "([n coll]); Returns a lazy seq of every nth item in coll."

15:14 fliebel: ,(apply map vector (partition 3 [[1 2 3] [1 2 3] [1 2 3]]))

15:14 clojurebot: ([[1 2 3]] [[1 2 3]] [[1 2 3]])

15:14 amalloy: fliebel: ^^?

15:14 fliebel: wait...

15:14 (apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))

15:14 ,(apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))

15:14 clojurebot: Invalid number: 3 1

15:14 fliebel: grrr

15:16 amalloy: fliebel: i see

15:16 &(apply map vector (partition 3 [1 2 3 1 2 3 1 2 3]))

15:16 sexpbot: java.lang.NumberFormatException: Invalid number: 3 1

15:17 fliebel: amalloy: yea, but that is not what I want. What I did is like 128 times take-nth 128, so 128 seqs of 1 2 3 will become 3 seqs with 128 items each.

15:17 amalloy: So this takes all but the last 127 items when taking the first one. not very good.

15:18 ordnungswidrig: Derander: (setq font-lock-verbose nil)

15:23 fliebel: What is the difference between lazy-cat and concat?

15:26 Derander: ordnungswidrig: thanks

15:29 chouser: lazy-cat is a macro and so can postpone evaluating its arguments until their needed.

15:29 mfex: fliebel: do you have any test files somewhere or know where I can find world files?

15:29 chouser: concat is a function, so all its args are evaluated eagerly, though each result isn't forced until needed.

15:30 Plouj: wait, clojure in cold fusion?

15:30 what?

15:30 clojurebot: what is cells

15:31 amalloy: fliebel: for what it's worth, it might still be chunking that's the issue. with concat and map both chunking 32, you might be realizing 1024 elements at a time

15:31 fliebel: amalloy: Hrm, okay, what do I do about that?

15:33 amalloy: fliebel: wrap your map elements with delay? it looks like that's what your lazy-seq ends up doing, though, so i'm not sure delay would make a difference

15:34 vibrant: Exception in thread "main" java.lang.Exception: Can't use qualified name as parameter: coords/amt (coords.clj:18)

15:34 what am i doing wrong? :)

15:34 amalloy: i guess the issue is that lazy-seq automatically derefs, while delay shouldn't automatically force

15:34 chouser: vibrant: you've got a parameter in a macro named amt when it should be amt# or a gensym

15:35 amalloy: vibrant: you're using a macro like `(defn foo [args] stuff)

15:35 should be args#

15:35 vibrant: chouser; if i use amt# it doesn't work either

15:35 i want to use amt in the body passed to the macro

15:35 ordnungswidrig: how would I idiomaticaly generate all heads of a seq? i.e. (1) (1 2) (1 2 4) (1 2 4 8) for the seq (1 2 4 8)

15:35 amalloy: vibrant: gist or it didn't happen :)

15:35 chouser: but you get a different error, or on a different line, right?

15:35 fliebel: Now I'm getting a classic java.lang.StackOverflowError :(

15:35 That's to much recursion, right?

15:36 amalloy: fliebel: yes

15:37 vibrant: amalloy; http://paste.lisp.org/display/116144

15:37 now it says it can't resolve symbol amt#

15:39 LOPP: ok I have leiningen and emacs

15:39 how do i connect them

15:39 chouser: ,(reductions conj [] [1 2 4 8])

15:39 clojurebot: ([] [1] [1 2] [1 2 4] [1 2 4 8])

15:40 amalloy: vibrant: amt# is only accessible within the macro that declares it

15:40 drewr: LOPP: try `lein swank` then M-x slime-connect RET RET RET

15:40 sdeobald: Has anyone here used ant FTP through lein/lancet? maven-ant-tasks doesn't seem to come with the ftp task and it's not immediately obvious how to include it.

15:41 amalloy: the body of real-to-gfx should be #(* real2gfs-ratio %)

15:41 vibrant: amalloy; yea i deducted that :) but how do i solve it then?

15:41 tonyl: chouser: I keep forgetting reductions exist, thanks for the reminder of the day

15:41 amalloy: or something. i'm not sure what you're trying to do

15:41 chouser: tonyl: np :-)

15:41 vibrant: amalloy; generating a bunch of functions which handle sequences by calling themselves on items from the sequences

15:42 chouser: vibrant: probably best to pass in the name of the fn arg just like you do the name of the fn itself

15:42 amalloy: vibrant: or use clojure.walk? you're just walking a seq

15:42 vibrant: chouser; yea that's a last resort.

15:42 chouser: (defseqable-converter real-to-gfx [amt] (* real2gfx-ratio amt))

15:43 vibrant: no, that's a clean macro. :-)

15:43 vibrant: hehe

15:43 chouser; ok i got your point :)

15:43 ordnungswidrig: re

15:43 chouser: ,(reductions conj [] [1 2 4 8])

15:43 clojurebot: ([] [1] [1 2] [1 2 4] [1 2 4 8])

15:43 chouser: ordnungswidrig: ^^^

15:43 LOPP: drewr: it says swank is not a task

15:43 ordnungswidrig: thanks

15:44 amalloy: &(clojure.walk/walk inc list [[1 2 3] [[6]] 1])

15:44 sexpbot: java.lang.ClassNotFoundException: clojure.walk

15:44 LOPP: drewr: I can use lein repl

15:44 zakwilson: Is there a rough ETA for 1.3's release?

15:44 LOPP: but that creates a whole repl

15:44 klang: LOPP: add :dev-dependencies [[swank-clojure "1.2.1"]] to project.clj

15:45 djpowell: what is the deal with jira. it says my username has been taken - is this cause it was ported over from assembla? if so is my password the same, or do i need to get it reset to something?

15:45 drewr: LOPP: what's :dev-dependencies have in project.clj?

15:46 LOPP: none

15:46 drewr: look at leiningen's project.clj for an example

15:46 zakwilson: Is there a rough ETA for 1.3's release?

15:46 drewr: djpowell: I had the system email me my auth info

15:47 LOPP: :dependencies [[org.clojure/clojure "1.2.0"]

15:47 [org.clojure/clojure-contrib "1.2.0"]]

15:47 :dev-dependencies [[swank-clojure "1.2.1"]]

15:47 )

15:47 djpowell: the self-service password reminder thing?

15:47 that didn't seem to work for me :(

15:47 ordnungswidrig: chouser: is there a overview of idtiomatic seq handling in clojure?

15:47 LOPP: I have added it

15:47 drewr: djpowell: maybe you signed up originally with a different email address

15:47 LOPP: it still says swank is not a task

15:47 drewr: LOPP: you added it here too ;-)

15:47 ordnungswidrig: chouser: in haskell i would ask hoogle for a type signature

15:48 klang: LOPP:

15:48 LOPP: run lein deps again

15:48 djpowell: drewr: don't think so, cause I know what my assembla one is

15:49 LOPP: doesn't work

15:49 ogh

15:49 djpowell: zakwilson: not heard an eta for 1.3. wonder if pods will be in it...

15:50 LOPP: lein deps projectname doesn't work, says wrong number of arguments

15:50 zakwilson: I see I just double-posted. I'm having a large amount of latency here.

15:50 fliebel: Can anyone explain me how to solve a stack overflow error while I'm not actually calling functions recursively? Can a map within a reduce blow the stack?

15:50 LauJensen: LOPP: If you're building on Windows I strongly recommend using Cake: http://github.com/ninjudd/cake/wiki/cake-on-windows

15:50 djpowell: drewr: ah found the jira email. my username is my email - oh i didn't expect that

15:51 zakwilson: It looks like 1.3 is going to have some nice forkjoin integration. I'm interested to see how much that speeds up a certain computation I'm running.

15:51 LOPP: isn't cake a bit complicated

15:51 djpowell: oh - jira usernames are centralised things? I thought it was just for the clojure site

15:52 chouser: ordnungswidrig: the best I have to offer are the categorizations here: http://clojure.org/sequences#toc5

15:52 LauJensen: LOPP: Its a drop-in replace for lein on simple builds. They differ in tasks primarily, where cake is still simpler than lein imo

15:53 vibrant: humm..

15:53 i just found that (seq? [1]) returns false

15:53 :)

15:53 clojurebot: @ splices in a seq and foo# is a symbol, not a seq

15:53 amalloy: &(coll? [1])

15:53 sexpbot: ⟹ true

15:53 LOPP: oh I just needed to change the folder to the project one

15:54 djpowell: vibrant: yeah, collections are seq-able, but not themselves seqs.

15:54 LauJensen: &(seq? '(1))

15:54 sexpbot: ⟹ true

15:54 raek: ...with the exception of PersistentList, which is its own seq. </nitpicking>

15:54 djpowell: ,(col? (seq [5]))

15:54 clojurebot: java.lang.Exception: Unable to resolve symbol: col? in this context

15:54 djpowell: ,(coll? (seq [5]))

15:54 clojurebot: true

15:55 djpowell: ah interesting

15:55 ,(supers (class (seq [5])))

15:55 clojurebot: #{clojure.lang.Seqable clojure.lang.IChunkedSeq clojure.lang.Sequential clojure.lang.Obj java.lang.Iterable clojure.lang.ISeq java.lang.Object java.util.List java.util.Collection clojure.lang.IMeta ....

15:55 ordnungswidrig: chouser: I see, I know the list but it's hard to find the idomatic way

15:56 djpowell: ,(class (seq [5]))

15:56 clojurebot: clojure.lang.PersistentVector$ChunkedSeq

15:56 ordnungswidrig: chouser: last question (i hope): how can I flatten a seq of seqs but only for one level deep?

15:56 chouser: ordnungswidrig: there's definitely some kind of rule-based filtering system going on in my head that I'd like to capture somehow at some point.

15:56 ordnungswidrig: apply concat

15:56 ordnungswidrig: *doh* I always tried vector

15:58 tonyl: chouser: that list would be an interesting post

15:59 chouser: I'd love to have a decision tree people could follow to find a small set of functions that are likely to be useful for any give seq-lib problem

15:59 tonyl: which list?

15:59 tonyl: that kind of rule-based filtering system for dealing with seqs

15:59 fliebel: chouser: It's called namespaces, but no, lets just put every function in clojure.core.

15:59 chouser: but all my attempts to capture anything more details than "the seq library" categories hasn't worked out.

16:00 LOPP: hm I get class not found exception in repl when attempting to (use ) the namespace of my lein project

16:00 ordnungswidrig: clojure.core is large

16:00 fliebel: ordnungswidrig: 508 functions...

16:00 chouser: fliebel: but it's by no means cleanly partitionable. Even the large vague categories I came up with have overlaps.

16:00 ordnungswidrig: fliebel: there is still room :_)

16:01 chouser: but when I'm trying to solve a problem like ordnungswidrig proposed, I quickly find myself choosing between just two or three functions. I don't know how to share the process I use to get to that point.

16:01 I do know of a couple useful questions, like: does an output value rely on previous values?

16:02 fliebel: chouser: So the actual problem is the "100 functions on one datatype" philosophy instead of "10 functions on 10 datatypes", like Python.

16:02 chouser: if it does, you can ignore almost everything except iterate, reduce, reductions, and loop/recur

16:02 fliebel: hm, possibly.

16:03 fliebel: chouser: In Python I just do a dir on the object I'm working with and get a dozen or so useful functions, plus ±100 in the stdlib.

16:03 chouser: but of course ordnungswidrig's problem didn't clearly require previous state beyond what map-indexed can profive

16:04 fliebel: heh. ±100

16:04 ordnungswidrig: chouser: would you elaborate on your process for another example?

16:04 chouser: ordnungswidrig: a specific example?

16:04 I actually had a map-indexed solution first before trying again with reductions.

16:05 ordnungswidrig: chouser: all subseqs of a seq? [1 2 3 4] -> [] [1] [1 2] [1 2 3] [1 2 3 4] [2] [2 3] [2 3 4] ...

16:05 fliebel: chouser: Does your method involve knowing 508 functions, or useful searching criteria?

16:05 ordnungswidrig: chouser: thats interessting, I thought of map-indexed first

16:06 chouser: ordnungswidrig: I thought map-indexed seemed reasonable until I had a working solution. required ignoring fn args, inc, let for the input coll -- altogether too messy to be desirable.

16:07 so, we have a function that gives you the heads of a seq, just need to do that for each sub-seq, right? so map of one on the other might do it.

16:07 fliebel: chouser: I got it! If funcions can be in multiple namespaces at onec, then you could qualify them vaguely and still have something that works, so they are all in core, but only some inclojure.som-property. So it's mor elike tags than categories.

16:07 chouser: so, first we need tails of a seq. I know I've done this before...

16:07 fliebel: you want this mapped out in the code rather than just some doc-reference mechanism??

16:08 ordnungswidrig: fliebel: that sounds nast

16:08 y

16:08 fliebel: chouser: Yea, I really think a core ns of 508 items sucks.

16:09 chouser: so, there will be as many tails as elems, which suggests reductions

16:09 tonyl: I'm used to it

16:09 ordnungswidrig: chouser: I see

16:09 tonyl: I program in PHP too :P

16:09 chouser: but the first element of the return seq needs the whole seq, so that actually won't work at all

16:09 fliebel: well, maybe a ns query language would do.

16:09 tonyl: there is a clojure.contrib.find-namespace ns

16:09 chouser: so that actually suggests something that has access to the whole input from the beginning, like iterate

16:10 tonyl: that gives some query functionalities

16:10 chouser: indeed, (iterate rest coll) gives what we want, but fails to stop, as it always does, so (take-while identity ...)

16:10 LOPP: I don't get it. When running "lein swank" what do I have to do, to have the project contents entered into the repl

16:11 chouser: er, seq

16:11 noidi: LOPP, (use 'your.app.some-ns)

16:11 chouser: ,(map #(reductions conj [] %) (take-while seq (iterate rest [1 2 3 4])))

16:11 clojurebot: (([] [1] [1 2] [1 2 3] [1 2 3 4]) ([] [2] [2 3] [2 3 4]) ([] [3] [3 4]) ([] [4]))

16:12 chouser: now I check the problem description again and see if I'm close. :-)

16:12 noidi: LOPP, or what do you mean by have the project contents in the repl?

16:12 fliebel: IMPORT FROM clojure.core WHERE returns == seq && idempotent

16:12 ordnungswidrig: chouser: nice

16:12 chouser: so I have extra empty vectors and an extra level of nesting

16:13 LOPP: thank you

16:13 chouser: mapcat solves the nesting. either think of it directly or do (apply concat (map ...)) and then recognize that is just mapcat

16:13 LOPP: (use 'project.core) worked

16:13 (use [project.core :reload]) didn't

16:14 chouser: ,(mapcat #(rest (reductions conj [] %)) (take-while seq (iterate rest [1 2 3 4])))

16:14 clojurebot: ([1] [1 2] [1 2 3] [1 2 3 4] [2] [2 3] [2 3 4] [3] [3 4] [4])

16:14 Vinzent: LOPP, (use ['project.core :reload])

16:14 LOPP: :)

16:14 btw

16:14 jcromartie: is there an idiomatic way to implement user-defined exceptions?

16:14 chouser: jcromartie: consider clojure.contrib.condition

16:14 LOPP: if I change the source files, how do I get the changes in

16:14 noidi: LOPP, when you change project.core, you can re-evaluate the file with C-c C-k

16:14 jcromartie: hm cool

16:14 noidi: LOPP, or a single form with C-c C-c

16:14 jcromartie: ooh wow, that's way better than exceptions :) Lispy

16:15 chouser: ordnungswidrig: so I guess if you really want the [] on the front, just cons it on.

16:15 LOPP: ok

16:15 thanks

16:15 rata_: hi

16:15 noidi: chouser, is c.c.condition prefered over c.c.error-kit?

16:16 ordnungswidrig: chouser: that was insightful

16:16 mfex: fliebel: what do you want to plot with clomian? # of each type of block?

16:16 fliebel: mfex: Type of block per layer.

16:17 chouser: noidi: if you don't need continue or continue-with, absolutely. and maybe even then.

16:17 fliebel: mfex: But I'm blowing the stack somewhere around here: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33

16:17 mfex: fliebel: a partition of 128 blocks is a layer?

16:18 chouser: ordnungswidrig: really? I'm glad you thought so. seems like a mess to me.

16:18 noidi: chouser, good to know, thanks. good think I just started using error-kit yesterday, so I can easily change to condition :)

16:18 ordnungswidrig: chouser: we can agree on "an insightful mess"

16:18 fliebel: mfex: no, they're stored in columns of 128, so I go through the columns and add the block to the correct layer.

16:18 Vinzent: Is there plans to implement named routes in compojure?

16:19 noidi: chouser, maybe error-kit's docstring should mention c.c.condition?

16:19 chouser: noidi: you did see error-kit's giant warning at the top?

16:19 mabes: I remember hearing something from technomancy that lein has javac built-in support now (i.e. lein-javac is not needed).. any idea if that is correct and how one would use it?

16:19 noidi: yes, I saw the giant warning, but I didn't know that there's something better and less giant warningy available :)

16:20 mabes: the sample project.clj show how to use AOT but I don't know if that covers javac issues...

16:22 chouser: perhaps I do more back-tracking in my decision tree than I realized. I have even less idea how to capture that. :-P

16:23 fliebel: Can someone explain me why I'm getting a stack overflow here? http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33

16:23 alpheus: Wow. Learned a lot of clojure in the 71 short lines of robert.hooke.

16:25 noidi: chouser, that sounds like trying to figure out what keys you are pressing when coding in Vim or Emacs :)

16:25 i.e. impossible

16:25 mfex: fleibel: I have a plot with the data from http://www.minecraftforum.net/viewtopic.php?f=1012&t=31046, but I'm not sure that I understand what layers are

16:25 chouser: noidi: heh

16:26 noidi: and a similar go-to answer: read some docs, practice, repeat until satisfied. :-P

16:30 noidi: I like to think about that sort of fuzzy thought process as taking a lump of data, and sculpting the wanted data structure out of it by using the seq functions as tools

16:31 I constantly check the REPL and think "oh, I need to get that part sorted out" and add a function, "there, that looks better. and now I need to fix that thing..."

16:31 bhenry: fliebel: what is freqs getting passed?

16:31 fliebel: bhenry: a kick ass seq of bytes.

16:32 rata_: should I have accessor fuctions for my records? or is it good style to use the keywords directly?

16:33 chouser: rata_: keywords are best I think

16:33 itistoday: how can i get emacs to run something prior to slime going up and running after doing 'slime-connect'? i'm experiencing an odd conflict with autopair that's pretty much hosing emacs, and i'd like to selectively disable it for slime. here's what I've tried so far: http://paste.pocoo.org/show/284523/

16:33 rata_: chouser: thanks :)

16:34 chouser: noidi: yeah, that sounds right. But i'm not randomly trying each of the 100+ seq-related functions randomly in that process.

16:34 _seanc_: What IDEs do you guys use for your Clojure work? I really like Textmate, but everything I read Clojure related seems to use Emacs. What's so cool that I'm missing out on?

16:34 lancepantz: _seanc_: most of us use emacs, some use java ides

16:34 rata_: I use emacs... swank-clojure is cool

16:35 itistoday: _seanc_: i use emacs, but if you don't want to use emacs i recommend IntelliJ IDEA with the laclojure plugin

16:35 i should say, i'm 'trying' to use emacs ... if i can get this problem fixed...

16:35 rata_: _seanc_: something I like a lot about swank-clojure is (swank.core/break)

16:36 amalloy: _seanc_: emacs is a fab lisp editor. super-customizable; understands lisp code to autoformat, autodoc, autocomplete; has a repl you can use without leaving the editor window...

16:36 _seanc_: What exactly is swank?

16:36 lancepantz: _seanc_: there is a pretty impressive textmate bundle for clojure as well http://github.com/swannodette/textmate-clojure

16:36 rata_: _seanc_: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml

16:37 _seanc_: swank is like a emacs "plugin" for clojure

16:37 _seanc_: lancepantz: I have that bundle actually, I'm just wondering if I'm missing out on something more :)

16:37 rata_: it shows you fns arglist in the minibuffer (at the bottom of the window)

16:38 you can send a function to the repl to test it

16:38 or compile an entire file with just 3 keystrokes

16:39 in emacs you don't need the mouse at all, which is very handy for programming I think (you can use it though if you like)

16:40 _seanc_: rata_: Very cool, I'll have to read more into how to get Emacs up and running with Clojure on a mac

16:41 amalloy: rata_, _seanc_: you don't need the arrow keys either, which has been even more important for me, since i rarely use the mouse anyway

16:41 _seanc_: I'm trying to play with my first Compojure app and every tutorial seems only show how to compile and run in Emacs

16:41 rata_: amalloy: I haven't learned that yet... how do you move without the arrow keys?

16:42 amalloy: C-p,n,f,b are the basic ones

16:42 rata_: _seanc_: have you looked at the emacs-starter-kit?

16:42 amalloy: rata_: use M- to move faster, in general

16:42 _seanc_: I did on github, but to be honest, I wasn't exactly sure I knew what I was looking at

16:42 ubii: _seanc_: you might want to check out Aquamacs - http://aquamacs.org/

16:42 fliebel: bhenry: Any helpful comments on the thing?

16:42 amalloy: M-v, C-M-v for page up, down

16:44 er, C-v and M-v, that is

16:44 bhenry: fliebel. not really.

16:44 rata_: amalloy: those doesn't work on my emacs

16:45 bhenry: fliebel: is there simple code that will generate something that's suitable for blocks so i can play with just that function?

16:45 amalloy: rata_: are you using a mac or something?

16:45 not that that should matter

16:45 fliebel: bhenry: One moment...

16:45 rata_: amalloy: no, I'm on archlinux

16:46 C-v pastes and M-v does nothing

16:47 amalloy: sounds like cua mode. the traditional emacs cut/copy/paste are C-w, M-w, and C-y

16:47 if you don't mind losing those you could askin in #emacs; i'm not an expert here

16:48 or check out C-h t for the interactive tutorial, which might be smart enough to use your current keybindings

16:48 fliebel: bhenry: (take 1e3 (concat (repeat (shuffle (concat (range 0 100) (range 20 90)))))) make 1e3 some higher for heavier load.

16:50 rata_: amalloy: I use C-e, C-r and C-y for cut/copy/paste and C-w for deleting the last word

16:50 what's cua mode?

16:50 itistoday: ah, setq-default worked, but setq did not for some reason

16:50 amalloy: rata_: http://www.emacswiki.org/CuaMode#toc1

16:51 fliebel: bhenry: No, I am wrong… wait

16:51 bhenry: haha okay

16:52 amalloy: rata_: getting used to moving around with modifiers+letters was painful for a week or two, but once you get used to it it's much more efficient than the arrows because you don't have to find your place on the keyboard after moving around

16:53 fliebel: bhenry: (apply concat (take 1000 (repeat (shuffle (concat (range 0 100) (range 20 90)))) ))

16:53 rata_: amalloy: yes, I'd like to have my hands always near the "home row"

16:54 could it be cua mode the reason why C-_ doesn't work for undo?

16:55 amalloy: rata_: could be. you might also try C-/. you should ask in #emacs how to reset stuff to the "standards"; i can'

16:55 t really help you there

16:55 apgwoz: anyone know what font the clojure logo uses?

16:56 fliebel: bhenry: raising 1000 to 100000 gives the overflow.

16:56 rata_: I visited that channel some time ago but didn't like the chat there

16:57 amalloy: rata_: yeah, it's not as friendly as #clojure, but they're usually willing to help out in my experience. you could also look around on google, of course

16:58 bhenry: fliebel: i got outofmemory error not stackoverflow

16:58 tonyl: fliebel: I used as a dummy data (vec (range 10000)) and the freqs fn works fine for me

16:58 i am going to try with your dummy data

16:58 apgwoz: it it just Arial?

16:59 fliebel: bhenry: That is even weirder, but more logical.

16:59 bhenry: maybe i changeed the wrong thing

17:00 fliebel: bhenry: Can I see the changes?

17:00 bhenry: i did.

17:00 i changed the inner range 100 to 100000

17:00 fliebel: okay

17:02 this is as far as I can get without the error: (freqs (apply concat (take 34200 (repeat (shuffle (concat (range 0 10) (range 3 7)))) )))

17:02 tonyl: I took that number of ranges, so you'd nee a few extra zeroes to get the expetion.

17:03 chouser: anyone here know "matchure"?

17:05 nm

17:08 tonyl: fliebel: when I get to a 1e6 is when I get the SO error

17:09 thickey: apgwoz: Avenir

17:09 tonyl: is that how many bytes you are trying to process

17:09 apgwoz: thickey: ah, nice!

17:09 clojurebot: excusez-moi

17:10 fliebel: tonyl: Yea, I guess so. It's about 4 mega bytes.

17:10 tonyl: oh yeah mmm

17:11 itistoday: in the emacs slime repl, how do i go up in history?

17:11 hitting the up arrow just causes the cursor to move up

17:11 amalloy: itistoday: M-P

17:11 fliebel: tonyl: I just can't see how a function that is not recursive ends up blowing the stack, after an insane amount of loops.

17:12 itistoday: amalloy: thanks! what about down?

17:12 amalloy: M-n, of course! p is usually the opposite of n :)

17:12 itistoday: amalloy: didn't know that... is that an emacs convention?

17:13 amalloy: itistoday: sorta. C-p<revious> and C-n<ext> move up and down lines

17:13 joegallo: Eh, it shows up in readline, too. And some other places. Not really sure who started it.

17:13 bobo_: ctrl+up-arror works aswell

17:13 tonyl: fliebel: I can't see the problem since you are holding 128 bytes at a time

17:13 amalloy: itistoday: and if you're looking for a specific thing in the history, you can type in the beginning of it before hitting M-p - it will scan through only history entries that match

17:13 itistoday: amalloy: cool thanks for the tip!

17:14 fliebel: tonyl: I bet it's some gotcha that keeps some sort of closure open or makes a recursive call every chunk, so that it takes an insane amount of bytes to overflow. I think some Clojure guru might say "oh, but you just nee to… because of…"

17:15 jaley: can anyone tell me what, in practice, i might store in an atom vs a ref? i'm trying to figure out what the best thing to do with a session key is...

17:15 tonyl: yeah i am thinking the same, I am guessing it has to be with using reduce with map, but I've done it before. maybe I am wrong

17:17 maybe if you run the map fn in parallel

17:18 fliebel: good point...

17:18 tonyl: fliebel: I used pmap instead of map and it did finish with 1e6

17:18 raek: jaley: if you need it to be coordinated/transactional => ref, if you don't need it, but expose it to users that might => ref, else => atom

17:18 tonyl: but the duration time was 2.52 mins instead of 4 secs in my machine

17:18 fliebel: tonyl: It's cheating, but threads get their own stack.

17:18 amalloy: tonyl, fliebel: what's the code that causes the problem? i took fliebel's latest (apply concat (take x ...)) and it works for up to x up to 4e6 for me

17:19 fliebel: amalloy: http://github.com/pepijndevos/Clomian/blob/master/src/clomian.clj#L33

17:19 amalloy: but i used frequences from core instead of incanter's freqs, since i don't have invanter

17:19 neotyk: puredanger: http://clojure.org/community please add http://ams-clj.github.com/

17:19 amalloy: oh haha

17:19 k

17:20 tonyl: i used just a range 1e6 and the freqs fn gave mea SO error

17:20 jaley: raek: thanks! so dosync is not required to call swap! on an atom?

17:20 amalloy: yeah, i didn't notice the defn of freqs there. trying again

17:20 abedra: cemerick: you around?

17:20 amalloy: jaley: right. dosync is for refs exclusively

17:20 joegallo: puredanger: also, http://www.meetup.com/Clojure-PGH/ to community, too. :)

17:21 itistoday: halp! http://paste.pocoo.org/show/284551/

17:21 amalloy: tonyl, fliebel: i get a heap space error, not stack overflow

17:21 jaley: amalloy: thanks. in that case i probably want a ref so that requests are not made while the session token is renewed

17:21 tonyl: amalloy: what was your input?

17:21 itistoday: what am I doing wrong? isn't that how you destructure..? I ran C-c C-k to compile the thing too...

17:21 amalloy: (freqs (apply concat (take 3420000 (repeat (shuffle (concat (range 0 10) (range 3 7)))) )))

17:22 itistoday: just delete the x

17:22 itistoday: amalloy: oh....

17:22 lol

17:23 horray!

17:23 puredanger: neotyk: done

17:23 itistoday: have any of you played myst?

17:23 puredanger: joegallo: done

17:23 fliebel: amalloy: take of a few zeroes, I think you just used to big a seq for your memory rather than blowing the stack.

17:23 neotyk: puredanger: thank you!

17:23 joegallo: puredanger: rocking, thanks!

17:23 amalloy: fliebel: ah, i see

17:25 fliebel: tonyl, amalloy: Using pmap avoided the problem for me. It's now chumming along at 200mb of memory and 170% cpu. But I said avoid because threads get their own stack.

17:26 tonyl: yeah, a bit of cheating, but I couldn't think of anything else. kind of new to this.

17:26 fliebel: I'm okay with it, I'd just like to know what happened.

17:28 amalloy: fliebel: i agree that's kinda weird - i don't see why stack should be a problem. you could make your code a fair bit less ugly by using update-in and fnil instead of this assoc/inc thing

17:29 &(update-in {} [:not-there] (fnil inc 0))

17:29 sexpbot: ⟹ {:not-there 1}

17:29 fliebel: amalloy: Thanks, I didn't know about fnil

17:29 amalloy: That's what you get with a cor ns with 508 functions.

17:30 amalloy: fnil and juxt are applicable to a surprising number of problems

17:30 jcromartie: fliebel: wow really 508 functions?

17:30 fliebel: amalloy: I know about juxt, but never used it.

17:30 jcromartie: yea

17:31 amalloy: &((juxt * +) 4 5)

17:31 sexpbot: ⟹ [20 9]

17:32 amalloy: other useful juxts are:

17:32 &((juxt quot rem) 100 7)

17:32 &(map (juxt identity inc) (range 5))

17:32 sexpbot: ⟹ [14 2]

17:32 ⟹ ([0 1] [1 2] [2 3] [3 4] [4 5])

17:33 fliebel: amalloy: I was somehow under the impression juxt would divide the arguments over the functions...

17:34 amalloy: Oh, fibonacci with juxt is going to be awesome :)

17:34 amalloy: fliebel: nah, juxt isn't much good for fibonacci

17:34 http://rosettacode.org/wiki/Fibonacci_sequence#Clojure

17:36 fliebel: amalloy: Let's see...

17:36 amalloy: speaking of which, i was timing the rosettacode implementation for various inputs, and i seemed to be getting N^2 behavior instead of N. anyone know why, or if i'm just crazy?

17:39 fliebel: amalloy: I think pmap is very inefficient for my problem, I'm only doing an assoc, and starting treads for that :P

17:39 amalloy: yes, pmap is going to waste a huge amount of time

17:40 looking at the implementation of reduce, it does seem like it might actually overflow on large chunked sequences

17:42 fliebel: amalloy: so can I dechunk my list?

17:43 * defn wonders if technomancy has put in any leiningen easter eggs

17:43 defn: time to investigate...

17:45 clizzin: Is there a way I can convert a vector of values into a series of those values so that hash-map will take them as arguments? e.g. if v is [1 2 3 4], i want to eventually get {1 2, 3 4}, but (hash-map [1 2 3 4]) isn't valid while (hash-map 1 2 3 4) is. thanks!

17:46 defn: fliebel: ive been working on something i call "Nutterson", which takes a bit of a different approach to templating :)

17:46 fliebel: defn: cool :)

17:46 defn: it uses hiccup templates and helper functions inside the template

17:46 amalloy: &(apply hash-map [1 2 3 4])

17:46 sexpbot: ⟹ {1 2, 3 4}

17:47 amalloy: fliebel: do you have JoC?

17:47 clizzin: amalloy: ah, that makes sense. thank you!

17:47 fliebel: amalloy: A what?

17:47 amalloy: joy of clojure

17:47 defn: so template.clj looks like [(defn capitalize! [s] (.toUpperCase s)) [:html [:head [:title (capitalize! title)]] [:body body]]]

17:47 fliebel: amalloy: yea, but havn't read it yet.

17:47 amalloy: see chapter 12, search for seq1 if you have the pdf. he builds a de-chunking function

17:49 * tonyl the joy of clojure book was delayed til february ... :(

17:50 fliebel: amalloy: same thing is on his blog, but it looks hackish :(

17:50 defn: fliebel: ive enjoyed your contributions to the overtone mailing list btw

17:50 overtone is a really cool piece of software

17:51 fliebel: defn: Yea, it is :)

17:51 defn: my girlfriend does not like it very much yet

17:51 * defn needs to get better at building his synths :)

17:51 fliebel: defn: *grin* (:use [overtone headphones])

17:52 defn: haha does that exist

17:53 fliebel: defn: No, but you can try a hardware hack, like plugging 2 small speakers in your audio card and hanging them on your head ;)

17:53 defn: lol

17:53 very funny :)

17:59 fliebel: defn: Is the new project on github yet?

18:01 defn: fliebel: no ive changed my mind a lot and haven't completely committed to that style of templating

18:02 i want to make it possible to use HTML, hiccup, enlive, or haml templating

18:02 im just not sure how i want to organize it all -- still hammocking on it

18:02 fliebel: defn: Cool, let me know when it's done :)

18:06 wut? chunked-seq? returns false for everything I try.

18:08 amalloy: &(chunked-seq? (map identity (range 100)))

18:08 sexpbot: ⟹ false

18:08 amalloy: &(chunked-seq? (seq (map identity (range 100))))

18:08 sexpbot: ⟹ true

18:08 amalloy: fliebel: ^^

18:09 fliebel: interesting...

18:09 amalloy: but i think chunking is supposed to be an "implementation detail"

18:09 fliebel: amalloy: yea, but I want to get rid of it for the reduce thing.

18:12 amalloy: so I'm not using chunked seqs after all in my reduce, so that can't be the issue.

18:13 amalloy: fliebel: what? map always returns chunked seqs

18:13 fliebel: &(chunked-seq? (map identity (range 50)))

18:13 sexpbot: ⟹ false

18:13 fliebel: amalloy: ^^

18:14 amalloy: and throw a (seq) around that

18:14 reduce calls seq before it works on the datga

18:14 fliebel: amalloy: OKay, then I give up :(

18:21 Compact reproduction of my problem:

18:21 &(reduce #(map + %1 %2) (partition 5 (range 1e6)))

18:21 sexpbot: java.lang.StackOverflowError

18:25 raek: could it be a bug in the ChunkedSeq implementation of InternalReduce?

18:25 amalloy: fliebel: great. you've isolated the problem to something generic that seems like it "ought" to work. now you can post that to the google group or file a bug report

18:26 nickik: has somebody made a clojure style for the latex listings package?

18:26 fliebel: great, but it's late over here, so I'll put it on the todo list for tomorrow.

18:28 good night! (UGT)

18:30 raek: ,(letfn [(range2 [i n] (lazy-seq (when (< i n) (cons i (range2 (inc i) n)))))] (reduce #(map + %1 %2) (partition 5 (range2 0 1e5))))

18:30 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.StackOverflowError>

18:31 raek: seems to happen for non-chunked seqs too?

18:33 jarpiain: &(reduce #(doall (map + %1 %2)) (partition 5 (range 1e6)))

18:33 sexpbot: ⟹ (99999500000 99999700000 99999900000 100000100000 100000300000)

18:36 raek: interesting.

18:36 jarpiain: without forcing (map + ...) it builds a stack of lazy seqs (map + (map + ... %2) %2) and forcing that smashes the stack

18:38 raek: this makes perfect sense.

18:41 amalloy: for a given value of "sense", anyway

18:43 raek: at least, it explains why the stack overflow occurs

18:44 amalloy: yes

18:51 tonyl: ping?

18:51 clojurebot: PONG!

18:58 tonyl: jarpiain: how is (reduce #(map + %1 %2) (partition 5 (range 1e6))) force the seq and with doall doesn't if doall retains the head?

18:59 amalloy: tonyl: they both force it eventually. doall forces each map incrementally, whereas if you don't do that reduce builds up a huge recursive set of calls to resolve, and forces them all at once

19:02 tonyl: oh alright, that shine some light to me trying to understand all the do* forms thanks

19:03 arohner: tonyl: in general, the important thing to remember is whether something holds a reference to the head of a lazy seq

19:03 if something holds the head, the whole list *has* to stay in memory, where as if you do something that doesn't reference the head, the nodes can be GC'd when they're no longer referenced

19:04 amalloy: arohner: that's not really the relevant thing here, i think

19:04 tonyl: I am trying to build a mental map of that.

19:04 amalloy: doall holding the head is in fact a disadvantage; the reason we need it is that it forces each element, not that it holds the head

19:05 tonyl: so doall deals with returned values (which forces the elements) instead of resolving recursive calls

19:13 amalloy: tonyl: that's how it looks to me. you could probably do the same thing without holding onto the sequence head, via some trickery like (first ((juxt first last) the-seq))

19:14 since juxt is eager it should find the last elt of the seq without holding the head, and you'll be taking the first element rather than the seq itself, so it should be available for GC

19:16 (and all my "shoulds" should probably be taken with a grain of salt. don't build nuclear power plants on this advice)

19:16 tonyl: hehe i understand

19:17 amalloy: wow, thanks for the explanation. junx looks very interesting too.

19:18 amalloy: tonyl: you should join the juxt fan club, founded by raek

19:19 tonyl: did he created that fn?

19:19 amalloy: http://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/seen.clj#L49

19:19 raek: heh, no... :) I just like it

19:19 amalloy: no; raek, technomancy, and i are always going on about how great it is

19:19 tonyl: hehe

19:20 amalloy: tonyl: juxt in action at the link above

19:21 tonyl: thanks amalloy

19:21 i'll see how junx can help me in some of my code

19:21 amalloy: heh, junx. it'll only work if you spell it juxt tho

19:22 tonyl: :P true

19:26 amalloy: $whatis CA

19:26 sexpbot: CA = The Clojure contributors agreement: http://clojure.org/contributing

19:26 amalloy: oh cool, i'm finally on that list

19:32 raek: amalloy: congrats!

19:33 amalloy: raek: thanks!

19:34 Kenjin: hello

19:34 nickik: with C x u i can make a undo in emacs

19:34 what if i want to make like 10 in a row

19:34 is there a faster way then C-x u C-x u C-x u ......

19:35 amalloy: nickik: C-10 C-x u

19:35 nickik: ah ok thx

19:35 amalloy: nickik: also, usually C-/ and C-_ are faster ways to get at undo

19:36 nickik: thx, very usefull

19:37 mrBliss``: nickik: http://www.emacswiki.org/emacs/UndoTree

19:48 amalloy: nickik: C-u <num> <cmd> will send cmd a numeric argument. C-<num> and M-<num> are shorthand for that; they probably always work, but i'm not a long-time emacs user

19:49 nickik: k

19:50 i'll have to keep that in mind

20:54 amalloy: Raynes: ping?

21:06 tonyl: ping?

21:06 clojurebot: PONG!

21:50 tonyl: ping?

21:50 clojurebot: PONG!

21:50 tonyl: why?

21:50 clojurebot: http://clojure.org/rationale

21:50 tonyl: how?

21:50 clojurebot: with style and grace

21:50 tonyl: what?

21:50 clojurebot: what is short for ,(doc ...)

21:50 tonyl: what is source?

21:51 what source

21:51 what is source

22:20 Raynes: amalloy: Hey. I should be on quite a bit tomorrow. I have a new bed and a bookcase to put together tonight, so I'm not going to be around. Plus one bed to take down, a room to rearrange, and my back is already killing me. :(

22:20 I'll talk to you probably tomorrow. <3

22:21 amalloy: Raynes: no worries. i was just looking for some ideas on implementing stuff

22:22 Raynes: amalloy: I have a few moments.

22:24 amalloy: i was trying to come up with a way for swap! to check a predicate and leave the old value if the predicate is false. easy enough; but i couldn't find a way to discover whether the swap had "failed"

22:24 i tried attaching ::succeeded key to the value's meta, but since the value is a java.lang.Integer...

22:27 i could include another, local atom and swap! it with true or false, but surely there's a way to do this without introducing more mutability

22:28 Raynes: anyway, that's where i am now

22:28 Raynes: amalloy: Sorry, had to run off for a second.

22:29 amalloy: You could just throw it in the ref and not even bother with the atoms.

22:30 But, I guess that doesn't really solve your problem.

22:31 ;)

22:31 amalloy: heh, no it doesn't

22:32 Raynes: Anyways, I'm going to run. I've got a back to finish breaking.

22:32 ;|

22:32 amalloy: g'night! lift with your knees!

22:49 anyone else have a clever solution to this? i want to speculatively adjust an atom, leaving it alone if the new value doesn't satisfy some predicate. that i can do, but how can i find out, from outside the swap!, whether the atom changed or not?

22:53 tonyl: I'm just learning about the stm, sorry can't help much

22:54 hiredman: atoms don't use the stm

22:54 ,(doc add-watch)

22:54 clojurebot: "([reference key fn]); Alpha - subject to change. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Wh...

22:55 tonyl: mm really, obviously need to learn more

22:55 * tonyl needs more time to learn more

23:28 subu: some help please

23:28 I'm trying to install clojure-contrib in ubuntu

23:28 is this the right place to ask for help?

23:29 arohner: subu: yes, it is

23:29 subu: oh ok

23:29 I cloned the git repo for clojure-contrib

23:30 and then did 'mvn package'

23:30 _seanc_: If you create a project with lein new, how can you navigate to the lib directory when using file?

23:30 subu: following the instructions here http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

23:30 amalloy: subu: are you using cake or lein, or just plain clojure?

23:30 ah. lein, sounds like

23:30 subu: plain clojure

23:30 I think

23:31 but I cannot find a target directory which is supposed to contain clojure-contrib.jar

23:31 amalloy: this page is somewhat out of date; it's not nearly as complex as all this

23:31 tonyl: subu: I followed this simple tutorial and works for me http://riddell.us/ClojureOnUbuntu.html

23:31 subu: oh ok

23:32 tridd3ll: used to be in the target directory

23:32 tonyl: night

23:32 tridd3ll: I wrote that tutorial... a while back though :-)

23:32 subu: hmmm ok

23:32 now there is no target directory

23:32 tridd3ll: this was a newer one: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

23:33 but this is all manual... there are other ways

23:33 amalloy: subu: you can download http://github.com/technomancy/leiningen/raw/master/bin/lein, and put it on your PATH. then lein self-install will download everything you need

23:33 subu: thanks alan, I'll do that

23:33 tridd3ll: and I haven't used these techniques in a while

23:33 subu: ok

23:37 amalloy: anyway, once lein is on your path, you should be able to start a project and get a repl:

23:37 $ lein new myproj

23:37 $ cd myproj && lein repl

23:39 subu: cool, that works

23:41 amalloy: hey subu, how'd you know my first name? find me on the google group or something?

23:41 subu: hmm.. I played with Michael in New Orleans, and found you on google groups

23:42 and asked him if you were alan@malloy.org

23:42 amalloy: huh. are you the subu who plays in palo alto sometimes?

23:42 subu: yup

23:42 amalloy: aha

23:56 TheBusby: amalloy: another Alan! I rarely run across anyone else with the same spelling.

23:56 amalloy: TheBusby: irish?

23:57 (mine is)

23:57 TheBusby: amalloy: no, my family has been in the US a long time.

23:57 amalloy: oh, so's mine. but the name and spelling are an influence of my irish ancestors

23:58 TheBusby: ahh, didn't realize that might be the case

Logging service provided by n01se.net