#clojure log - Aug 30 2010

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

0:18 notsonerdysunny: Hello everybody, I am trying to get a simple java code (about 10 lines in clojure ) which uses jReality ported to clojure. This is my attempt has been kind of half way successfull. The corresponding github-repo link is git://github.com/sunilnandihalli/jRealityTutorial.git

0:19 The project is nicely set up to work with leiningen .. so simple "lein deps && lein native-deps" should get it started. after that I just execute the sexp in the emacs editor ..

0:22 When the code runs, it opens the ui and shows what is intended in a rather unpleasing way with the flickers and all. when I look at the terminal output it tells me that jogl.jar may not be in the class path.. I have however added it to the :native-dependencies and it does download and extract it . I do see the corresponding shared object files .. but I don't understand why it still says it...

0:22 ...is not finding the jogl.jar .. can Anybody help me?

0:33 Raynes: notsonerdysunny: If nobody answers you here, try (if you haven't already) posting your question in the google group (linked in the channel's title). It's late for a lot of people here.

0:35 ihodes: Raynes: you got any experience with append-spit? i've used it without trouble in the past, but now i keep getting "Cannot change an open stream to append mode." errors.

0:36 Raynes: ihodes: I had that exact same problem a while back. I believe it's a long-standing bug.

0:36 ihodes: shit. i'm using it in production code.

0:36 though it works fine there…

0:37 Raynes: It may not be, but I remember having that issue a while back. I can't remember what I did about it. I think I ended up using writers directly or something.

0:37 ihodes: i guess i could just implement it myself…

0:37 yeah

0:37 FileOutputStream will do it for me.

0:38 which is my cue to go to bed for tonight. i've learned that hacking with java in the last night does wonders for my stress levels. terrible, terrible wonders.

0:38 technomancy: does anyone else get no sound on this page? http://www.youtube.com/watch?v=OONlGVGStSE

0:38 ihodes: confirmed: no sound

0:38 technomancy: cool

0:40 you never know with freaking flash

0:41 not that sound would do me much good in a korean tutorial

0:45 ihodes: i was wondering the same thing… but yeah, flash is a bane

0:45 Raynes: posted a Q re append-spit on SO

0:48 Raynes: ihodes: Cool.

1:08 notsonerdysunny: thanks Raynes I think I will post it google groups.

1:50 pdk: (+ 76.73 350.44 49.27 34.94)

1:50 ,(+ 76.73 350.44 49.27 34.94)

1:50 clojurebot: 511.38

2:01 _na_ka_na_: hey guys .. i want to implement a function f which works over 2 function-closures f1, f2 ... but I want to keep f1, f2 private only to f (no one other than f should know of f1,f2) .. whats the way to do that?

2:04 wwmorgan: ,(doc defn-) ; <- _na_ka_na_

2:04 clojurebot: "([name & decls]); same as defn, yielding non-public def"

2:04 noidi: _na_ka_na_, or you can define f in a letfn block

2:05 (letfn [(f2 [a b] (+ a b))] (def f1 [...] (f2 ...)))

2:05 something like that

2:06 or, if f is the only one using f1 and f2, you can put the letfn inside f

2:09 _na_ka_na_: but is it okay to put a let on top level ?

2:09 what if someone reloads my ns

2:09 remember that f1, f2 are closures

2:10 so on reloading ns .. they shouldn't get redef ..

2:13 pdk: you can put a let on the toplevel _na_ka_na_

2:14 wwmorgan: ,(doc defonce) <- _na_ka_na. You can combine this with setting :private to true in the function's metadata to get a private var that's not redefined when the namespace is reloaded

2:14 clojurebot: "([name expr]); defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated"

2:14 pdk: that's how you can define closures on the toplevel :p

2:15 Raynes: Oh, so that's what defonce is for.

2:15 Cool.

2:16 That would have been insanely useful about 4 months ago.

2:20 _na_ka_na_: wwmorgan: i want to do something like ..

2:20 (defn gen-closure []

2:20 (let [a (atom nil)]

2:20 [(fn [] @a) (fn [v] (reset! a v))]))

2:20 (let [[f1 f2] (gen-closure)] (defn f ...))

2:20 now how do i utilize defonce to define f1, f2 only once

2:25 wwmorgan: _na_ka_na_: I think I'd do it this way http://paste.lisp.org/display/114042

2:27 _na_ka_na_: wwmorgan: but then getter and setter might be utilized by other fns also in my ns .. i dont want that .. i want getter, setter to be private to f

2:27 and i don't want to put f in a separate ns for this reason alone

2:29 wwmorgan: _na_ka_na_: Like this? http://paste.lisp.org/display/114042#1

2:30 _na_ka_na_: wwmorgan: exactly!! thanks

2:30 wwmorgan: happy to help :-)

2:31 gko: What format would you use to store data readable by Clojure and Common Lisp?

2:32 _na_ka_na_: gko: data needs to be human readable ?

2:33 gko: _na_ka_na_: it would be something like a DSL, but actually no, as it's actually just def/setq...

2:34 _na_ka_na_: so, before, it was simple, just (load "data.lisp")...

2:35 _na_ka_na_: where data.lisp sets some variables (lists describing the structures of data format).

2:36 _na_ka_na_: gko: but how would that be readable by clojure?

2:38 gko: _na_ka_na_: yeah, maybe I could use just "name value" and read/eval each line...

2:39 _na_ka_na_: without going XML or similar.

2:39 _na_ka_na_: gko: hmm .. that's one way .. why don't you wana go xml/json/bson way ?

2:40 that way data is readable by other systems 2

2:51 gko: _na_ka_na_: I'm trying to avoid xml/json/bson... anyway, I guess it would have to be like this...

2:52 Bahman: Hi all!

3:12 notsonerdysunny: what does this mean "Please note that messages from new members to this group are moderated (in order to prevent spam), so please be patient awaiting your first messages to appear." .. does somebody actually read the messages before appearing on the group?

3:14 http://gist.github.com/557124 is the paste of the email I sent this morning to the clojure-google-group.. (and it still has not appeared on the forum) .. can somebody help me with this?

3:24 Chousuke: notsonerdysunny: the moderation is only for the first message.

3:24 notsonerdysunny: it's read and approved by a moderator

3:27 notsonerdysunny: Chousuke: The message I posted this morning about 4 hrs ago is still not there on google groups

3:27 :(

3:29 kjeldahl: (load-file "ants.clj") gives me "java.lang.Exception: Unable to resolve symbol: setColor in this context (ants.clj:234)". Any clues for newbie?

3:29 notsonerdysunny: It looks like I have trouble using jogl (java and opengl) I found a bunch of jogl-jars on clojars.org.. Can anybody tell me which is the right one to use? I am using linux

3:30 lenw: kjeldahl: what does your line 234 look like ?

3:30 kjeldahl: (defn fill-cell [#^Graphics g x y c]

3:30 (doto g

3:30 (setColor c)

3:30 (fillRect (* x scale) (* y scale) scale scale)))

3:31 Chousuke: kjeldahl: old style syntax. you have an old version of ants.clj

3:31 a really old version :P

3:31 kjeldahl: Oh. Thanks, I'll dig up a newer one.

3:31 lenw: kjeldahl: yes get a new version !

3:35 kjeldahl: Any pointer to the official location of ants.clj? The one in Google Clojure Group is from 2008...

3:37 Found workable version on http://www.lisptoronto.org/past-meetings/2009-05-clojure-ants-demo

4:07 LauJensen: Good morning all

4:09 mrBliss: Top of the morning to you

4:10 Raynes: Good morning.

4:11 hoeck: good morning

4:11 Raynes: LauJensen: You've got mail!

4:12 LauJensen: Odd

4:12 Raynes: -> (/ (.getRawOffset (java.util.TimeZone/getDefault)) 3600)

4:12 sexpbot: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.util.calendar)

4:17 LauJensen: Raynes: has -> replaced $ ?

4:17 Raynes: LauJensen: Yes.

4:18 LauJensen: Why? Did you start doing Groovy ?

4:19 Raynes: Heh, nosir. Anything that begins with the prefix ($ in this case) is a typical command. You can only do so much with commands. Before ->, when we had $( it was a normal command. That's why I needed $eval to be able to evaluate stuff that didn't start with a parenthesis.

4:19 -> is a hook so it's handled differently.

4:19 sexpbot: java.lang.Exception: Unable to resolve symbol: is in this context

4:19 Raynes: Indeed.

4:20 LauJensen: Ok - Makes no sense to me why $( couldnt be a hook

4:22 Raynes: Because anything starting with the prefix is a normal command. It doesn't make sense to make a hook look for $( which would appear to be a normal command, but would behave differently. And, It would look weird doing stuff like $('()

4:22 -> '()

4:22 sexpbot: => ()

4:24 Raynes: it*

4:24 I digress. It's 3:24AM and I need to be up in a few hours. I'm off to sleep. <3

4:24 LauJensen: Ok :) Good night

4:32 * cobol_expert is away. Or is he?

4:33 * cobol_expert is back. Or is he?

4:44 LauJensen: Is there something nice in contrib for download binary files? Would slurp* work?

4:45 mrBliss: I always use (with-open [input --inputstream-- output --file--] (copy input output)) (pseudo-clojure-code)

4:45 LauJensen: mrBliss: alright, that doesn't tell me much about whats in contrib though

4:45 mrBliss: copy in clojure.java.io or clojure.contrib.io

4:47 LauJensen: slurp* only works for text, copy might do the trick

4:52 java.net.URL isn't implemented for copy, hrmf

4:52 mrBliss: (-> -the-url- (URL.) (.openStream) (BufferedInputStream.)) is what I do

4:53 I've reused my download function more times than I can count

4:53 LauJensen: Should go into contrib - In my mind its a missing feature of the io lib

4:53 mrBliss: I agree

4:56 LauJensen: (defmethod copy [URL File] [^java.net.URL input ^File output]

4:56 (copy (-> input .openStream BufferedInputStream.) output))

4:58 Chousuke: heh

5:00 mrBliss: I didn't even know you could omit the parentheses in -> or ->>

5:00 LauJensen: mrBliss: Everything thats not a list gets coerced into one

5:00 The exception being the first arg I think

5:01 mrBliss: (doto mrBliss (memoize ^^))

5:01 LauJensen: hehe

5:03 mrBliss: LauJensen: are you gonna make a ticket for it?

5:03 LauJensen: Not if you are going to :)

5:04 mrBliss: If you have an account for Assembla, i'll grant you permission ;-)

5:05 I haven't got one (yet?)

5:05 LauJensen: You can make one quite easily, and I don't have the time right now - If I don't forget I might follow up late this week

5:06 mrBliss: Ok I'll do it (after I had my exam @ 1pm)

5:07 clojure or clojure.contrib? copy is present in both

5:07 LauJensen: contrib

5:44 notsonerdysunny: Has anybody used jogl in your projects before? if so can you please help me with http://gist.github.com/557124

5:54 LauJensen: notsonerdysunny: It sounds like you haven't set the LIBRARY_PATH to point to your native deps (the .so files)

6:05 notsonerdysunny: LauJensen: doesn't lein automatically set those paths when it is launching the swank server?

6:17 LauJensen: Not that I know of, but you can check it, theres an environment variable which makes lein print out all paths

6:17 I forgot what its called

6:26 notsonerdysunny: I just saw your fluid-dynamics for clojure blog.. Are you a cfd-er yourself? We work in Meshing ..

6:26 LauJensen: *

6:27 LauJensen: cfd'er ?

6:28 notsonerdysunny: LauJensen: I was just wondering if you work in Computational Fluid Dynamics ..

6:28 LauJensen: No no, I just like swirly things so I thought it'd be fun for the blog

6:28 :)

6:30 notsonerdysunny: :) but its cool you have done some benchmarking and all. I will read it..

6:31 LauJensen: notsonerdysunny: Yea, the blogpost is good if you want to learn about profiling, optimizing math heavy code etc. For learning Fluid Dynamics you should read Jos Stams paper instead. For a more beautiful Clojure solution, wait until I get a snapshot of the current Master branch, wherein you can pass primitives between functions. A lot of the pain in that blogpost comes from not having that ability

6:34 Also be aware, that Zach Tellman took my code and implemented it with Penumbra, which yielded 50 FPS on an 800x600 board - yea! :)

6:34 notsonerdysunny: LauJensen: I actually work in CFD .. It was nice to find something in clojure for CFD

6:35 LauJensen: Oh really - Perhaps you should contribute version2, because in terms of Clojure code its not very idiomatic. You could make muuuch nicer abstractions without loosing the performance

6:38 notsonerdysunny: it does not look like zach has his verion on the github.. or does he?

6:38 LauJensen: Yea, he put it into the test/ demos/ section of penumbra

6:38 under gpgpu

6:39 notsonerdysunny: oh ic

6:39 LauJensen: have you used jReality? scenegraph library..

6:39 do you have any comments on it?

6:40 LauJensen: Haven't tried it yet

6:48 notsonerdysunny: LauJensen: I tried setting LIBRARY_PATH and LD_LIBRARY_PATH to the directories that contain the shared-object files .. but it seems to behave exactly same before...

6:51 LauJensen: ok - I don't know whats up :(

6:52 fullets: notsonerdysunny: Which OS?

6:52 notsonerdysunny: Linux

6:52 ubuntu 8.04

6:52 Java 1.6

6:59 LauJensen: I wonder if I put an embedded DB like Derby into a jar file, will the program be able to both read/write to it ?

7:01 notsonerdysunny: fullets: *

7:02 fullets: notsonerdysunny: Ah, I just thought that if you were running on a Mac you'd want to set DYLD_LIBRARY_PATH instead, but alas it's not that easy :(

7:03 notsonerdysunny: fullets: thanks for trying to help :)

7:05 LauJensen: I hate to ask this, but what are the recommended git tools for Windows?

7:23 bobo_: LauJensen: git bash worked ok for me

7:24 but for some reason, everything is a hasle to install in windows

7:30 LauJensen: So Im trying to download the JDK and I get this "Your download transaction cannot be approved, please contact Customer Service" - O_o ?

7:34 bobo_: yeh, someone had a great idea it appears, but people are working on it if you belive twitter

7:36 LauJensen: ?

7:43 bobo_: ?

7:43 bobo_: oh, i can hardly understand myself what i wrote

7:44 i saw several people had problems with downloading it

7:44 some people claimed they are working to fix it

7:47 LauJensen: It seems that the popular theory is that their geo-ip lookup is failing

7:47 So, I went to download.com instead

7:52 malcolmsparks: Does anyone here use Maven to release artefacts to clojars?

7:52 LauJensen: malcolmsparks: cemerick does

7:52 malcolmsparks: I've been googling and can only see how this is done with lein or scp.

7:53 can anyone show me a pom.xml with the required voodoo?

7:55 manniche: @LauJensen: As far as I recall, the short answer to your derby question is: yes. But only one process is allowed to access a derby db at the time.

7:55 LauJensen: manniche: great - and yes, derby has zero concurrency story

7:56 manniche: yeah, midly irritating in a debug scenario...

7:58 LauJensen: Well. It can be annoying if you're using cake, since cake stays in the background, effectively blocking access. Other than that I've never had any problems with it, neither debugging it, since it borks saying "Cant establish connection", so it can only be one thing basically

7:58 malcolmsparks: Isn't there something in the clojure-maven project that can help you out?

7:59 bobo_: and there should be some scp plugins to maven?

8:06 malcolmsparks: LauJensen: there's nothing I can find in clojure-maven-plugin pertaining to clojars specifically - yes I can use scp (maven-exec-plugin) but then there's the job of working out all the parameters - I wondered if anyone here has gone through that effort

8:06 LauJensen: malcolmsparks: There are 2 guys from this community, that I know of, who use Maven. Its not my impression that Maven is generally something which is invested a lot of time in

8:06 malcolmsparks: I'm happy writing a Maven plugin tailored to clojars but don't want to bother if someone already has this in progress

8:07 LauJensen: ok - so I assume everyone else uses leiningen? if that's the case I'll switch over

8:07 LauJensen: malcolmsparks: I would check with cemeric of stuartsierra when America wakes up

8:07 malcolmsparks: thanks

8:07 LauJensen: malcolmsparks: Most people use lein exclusively I think, I use lein and cake

8:13 Anybody know the equivalent of 'which' on Windows 7 ?

8:14 bobo_: cake looks realy nice

8:18 LauJensen: If they can just match lein feature for feature, then it has a huge advantage in that it install rather easily on Windows

8:18 bobo_: looks like it can do more then lein?

8:21 LauJensen: Right now I think it has an edge on lein. The thing about technomancy is that when he gets going, he goes fast :)

8:22 Actually I was a bit dismayed that they forked instead of worked together. But thats how it goes.

8:42 Any windows users here?

8:45 Good :)

8:46 bobo_: noone dares to admit it to youo

8:51 LauJensen: I just needed to see how some code could run

9:06 Bahman: Hi all!

9:08 solussd: Hi!

9:09 zmila: clojure still is ill about docs, see new function http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/keep-indexed

9:29 AWizzArd: LauJensen: interesting to note, BitBucket moves away from EC2: http://blog.bitbucket.org/2010/08/25/bitbucket-downtime-for-a-hardware-upgrade/

9:31 LauJensen: AWizzArd: They just needed bigger dedicated hardware :)

9:31 Dunno why they couldnt have that at EC2

9:32 AWizzArd: probably could, by getting more Quadruple instances for a fantasy price

9:50 amatos: Rather dumb question: how do I remove a value from a vector (that is how do I create a new vector without a given element in)?

9:51 I don't want to remove by index, I want to remove a specific element that I know is on the vector

9:55 AWizzArd: amatos: you will have to code your own solution for that.

9:56 amatos: I guess that I can do a filter then make it a vector again, just seems should be an easier way to do it

9:56 I would use sets if they kept insertion ordering

9:56 thanks

9:57 LauJensen: ,(replace {3 5} [1 2 3 4 5])

9:57 clojurebot: [1 2 5 4 5]

9:57 MayDaniel_: amatos: http://github.com/ninjudd/ordered-set

9:57 LauJensen: amatos: pass replace a map where the key is the old val and the val is the new val

9:57 vu3rdd: amatos: something like this? (into [] (remove #(= % 2) [1 2 3]))

9:57 AWizzArd: you can use remove

9:57 and call vec on it

9:58 vu3rdd: ,(into [] (remove #(= % 2) [1 2 3]))

9:58 clojurebot: [1 3]

9:58 LauJensen: guys, why not use replace? Thats what its there for

9:58 AWizzArd: there is no fn provided for this by Clojure, because vectors are not a good data structure to do that stuff

9:58 amatos: vu3rdd, AWizzArd, that is what I was thinking yes

9:58 AWizzArd: LauJensen: I think he wants to get rid of an element, not replace it

9:58 amatos: yes, that is true

9:58 AWizzArd: amatos: maybe you can use a set?

9:58 amatos: Sets don't preserve insertion order

9:58 MayDaniel_: http://github.com/ninjudd/ordered-set

9:58 AWizzArd: one guy here implemented sets that do

9:58 MayDaniel_: They do.

9:59 AWizzArd: yes, ninjudd did that

9:59 amatos: MayDaniel looking at ordered-set now. thanks

9:59 ordered set will do what I need. thanks!

10:00 AWizzArd: When chouser will be done with FingerTrees then those could be used as well :)

10:04 amatos: yes, that sounds great. Hopefully they will be in soon

10:04 LauJensen: dont hold your breath, its a lot of work

10:05 AWizzArd: The basics are there. But getting those beasts to be efficient and fast is the real issue.

10:05 amatos: yes, indeed.

10:22 fliebel: Is there anything for getting a sliding window from a list? so for example (sliding-window 2 (range 5)) would return [0 1] and then [1 2] and [2 3] and so one.

10:23 chouser_: fliebel: partition

10:24 fliebel: chouser: nice, didn;t know about the step thing. I suppose setting that t one gives me what I want?

10:25 chouser: ,(partition 2 1 (range 5))

10:25 clojurebot: ((0 1) (1 2) (2 3) (3 4))

10:26 chouser: if that's what you want, then yes. :-)

10:26 fliebel: :) thank you

10:52 I solved project euler problem 11 in Clojure. Is there anyone who wants to look at my code, to see if it is good Clojure?

10:52 http://gist.github.com/557505

10:56 I havnt' done a lot of Clojure lately, but it looks okayish to me, and it works.

11:05 mrBliss: LauJensen: I use Clojure/Emacs/Zsh on Linux, OS X and Windows. To be somewhat productive on Windows you have to install Cygwin.

11:06 ssideris: does defrecord allow you to define just one constructor?

11:06 LauJensen: mrBliss: If you must have Windows installed, it runs best when you boot from an Arch live CD :)

11:07 mrBliss: I use a Ubuntu VM for my coding, but I wrote a couple of programs to manage my movie/tv show collection in Clojure and all of my media is on my Windows desktop so, I have no choice.

11:08 chouser: ssideris: defrecord defines exactly two constructors for you

11:08 * ssideris re-reading the doc

11:09 AWizzArd: chouser: which are those?

11:09 chouser: "Two constructors will be defined, one taking the designated fields followed by a metadata map (nil for none) and an extension field map (nil for none), and one taking only the fields (using nil for meta and extension fields)."

11:10 ssideris: so any extra constructors should be added as methods...

11:11 AWizzArd: chouser: thanks, I see this now too

11:11 chouser: ssideris: you can't really do that.

11:12 ssideris: ah ok

11:12 chouser: if you want to provide ways to create instances of your record, provide them as regular clojure functions

11:12 these are sometimes called "factory functions"

11:12 ssideris: ok thanks. sadly, I'm familiar with the concept of factories

11:13 chouser: I prefer to think of them as helper or convenience functions. :-)

11:14 factory sounds like it sits there spewing stuff. but it's really just a pure function that takes some args and returns an object.

11:15 ssideris: there is a great rant somewhere about factories and frameworks in java

11:15 here: http://discuss.joelonsoftware.com/default.asp?joel.3.219431

11:16 cemerick: ah, the hammer-factory-factory thread

11:17 karmazilla: a function of raw materials to a product?

11:19 ssideris: chouser: the pattern where you define "factories" where arguments that are not mentioned by the caller are filled with nils looks like a prime candidate for a macro to me

11:20 if only i knew how to write them :-)

11:20 chouser: cemerick may have written that one for you already

11:21 cemerick: ssideris: http://cemerick.com/2010/08/02/defrecord-slot-defaults/

11:21 chouser: Ironic that a macro of mine that I'm fairly uncomfortable with is in such demand. :-|

11:22 ssideris: cemerick: thanks, I'll try and understand it before using it

11:22 well I guess ist shows that there is a gap in the language...

11:22 chouser: maybe, but there's also something oddly familier or fitting about that.

11:23 ssideris: a gap between the language and what we think we want it to be

11:23 whether the gap is in the lanuguage or our thinking isn't indicated.

11:23 ssideris: i thought the point of lisp was that it's programmable so it can be what you want it to be!

11:23 chouser: and when what's involved is rhickey's language and my thinking, I too become fairly uncomfortable

11:24 ssideris: well, yes. but be careful what you wish for. :-)

11:25 ssideris: haha, point taken

11:25 fliebel: chouser: would you mind explaining your implementation of project euler 11? http://clojure-euler.wikispaces.com/Problem+011

11:26 ssideris: is there any way to get a bit more information out of exceptions? like a line number for example?

11:30 chouser: (.printStackTrace *e) will give you more information than you want.

11:30 ssideris: thanks

11:31 fliebel: chouser: Am I right to assume you used a 2D vector, instead of an 1D one, like most implementations I've seen?

11:32 chouser: fliebel: not sure about the others, but mine is 2D vector yes

11:33 fliebel: chouser: Good, the eliminates the issue where you can get results that wrap around the edges.

11:34 chouser: How does this work? (partial map list)

11:34 chouser: fliebel: I keep things in bounds with the :while

11:35 fliebel: chouser: Ah, looking at the one below yours :P

11:35 chouser: where's (partial map list) ?

11:35 oh, sorry

11:35 yeah, I just saw it

11:36 fliebel: yours is even more magic, using a string instead of a vector...

11:36 ah, your splitting it up in parts of 20

11:36 starts to make sense...

11:37 chouser: right, to build a 2D vector

11:37 fliebel: I just did this one: http://gist.github.com/557505 but it's bad, because it wraps.

11:37 chouser: I prefer not to manually edit the input data, hence parsing the string in clojure

11:38 mine avoids wrapping (or otherwize falling off the edge) with the :while clause in the 'for'

11:38 fliebel: chouser: I'm still trying to untangle the rest of the process

11:39 *practicing inward-out-reading*

11:39 chouser: :-)

11:40 yx is a vector of lenght two, coordinates.

11:41 so reduce nth grid yx is a sneaky way of saying (nth (nth grid y) x)

11:41 or (get-in grid yx)

11:42 fliebel: *copys code over to vim to have rainbow parens*

11:42 chouser: so just fetching yx from the grid.

11:43 huh. I guess if I used 'get' instead of 'nth' I wouldn't have needed the :while at all

11:44 fliebel: where?

11:44 clojurebot: where is your source code

11:45 chouser: the nth in reduce, the :while in for

11:45 oh, nm. nil is no good

11:45 fliebel: so what is the difference?

11:45 chouser: ,(nth [] -1)

11:45 clojurebot: java.lang.IndexOutOfBoundsException

11:45 chouser: ,(get [] -1)

11:45 clojurebot: nil

11:46 chouser: JoC has a handly little chart for this I think

11:47 fliebel: I'm going to translate your code to human language to make it understandable for myself… I suck at understanding Clojure code...

11:47 chouser: I think reading code is inherently harder than writing code, regardless of the language.

11:49 fliebel: true, but clojure has this inside-out style, which I'm not used to anymore.

11:49 I *love* ->

11:50 ssideris: i just don't get -> yet :-)

11:50 fliebel: what is delta-yx for?

11:50 cemerick: good code shouldn't be heavily nested IMO

11:51 fliebel: cemerick: So how do you avoid nesting?

11:51 cemerick: I don't find that I need to *avoid* it. It's just a matter of avoiding the lisp equivalent of spaghetti code

11:52 hrm, I am full of contradictions. :-/

11:52 My point being, if you're doing (foo (bar (baz (other-fn 5) x) y) z) q), you're not doing anyone any favors.

11:53 Use -> and friends, or break out individual expressions into a series of let-bindings so as to keep things clear.

11:54 chouser: fliebel: http://gist.github.com/557593

11:55 fliebel: chouser: this is your code redone with -->?

11:55 chouser: yeah

11:55 fliebel: nice

11:55 chouser: and with get-in instead of reduce nth, so I don't need the :while

11:55 'for' essentially nests loops for each clause, right?

11:56 sx is the starting x location, the column.

11:56 fliebel: I think so...

11:56 yea, I see

11:56 chouser: for each column, sy is the starting y location

11:56 for each sx,sy starting position, delta-yx is the direction to go to find 4 in a row

11:57 fliebel: ah

11:59 so take 4 returns 4 2-length tuples of positions in the given direction

12:04 *thinking out loud* what happens when the index is out of bounds… it returns 0 for that index… so you can actually have a set like '(23 0 0 0)… which doesn't really matter because it'll be low anyway…. and then you apply * to that and get the max of the whole bunch. yay!

12:05 chouser: sounds like you got it.

12:06 fliebel: yea, thanks for explaining and the ->> version :)

12:06 chouser: :-)

12:06 I'm sure my original solution predates ->>

12:07 fliebel: And I for myself feel (code (like (this))) is easier to write/grow, while ->> is better for reading.

12:08 Raynes: fliebel: Indeed. I typically write it like the former and then change it to the latter.

12:08 I don't have a habit of thinking backwards.

12:09 fliebel: Raynes: That is a strange thing to say, as (code (nested)) is actually more backwards than (-> nested code)

12:10 Turns out I'm also full of contradictions...

12:10 Raynes: fliebel: Not necessarily.

12:11 fliebel: If you're used to writing code that way, it's going to seem much less backwards than the opposite.

12:12 fliebel: okayokay, I get it… real men don't read lisp, they think lisp :P

12:12 (just like real man don't eat honey, they chew bees)

12:12 Raynes: :)

12:14 fliebel: So maybe lisp is just like towers of hanoi… *tries to come up with another stupid analogy*

12:23 attacking the next problem… (15)

12:25 arnorhs: I'm also attacking problems

12:26 fliebel: arnorhs: euler problems, or 'real' ones?

12:28 arnorhs: real ones

12:28 I don't do math

12:28 I do meth

12:29 fliebel: methamphetamine? :P

12:29 (that's what my dictionary said when I clicked on meth)

12:35 mcav: is there a function to split a string into chunks of length N? I don't see anything in clojure or clojure.contrib; i'll do it manually otherwise, but seems like something would be in core or contrib already

12:35 mrBliss: ,(partition 2 "hello mcav")

12:35 clojurebot: ((\h \e) (\l \l) (\o \space) (\m \c) (\a \v))

12:36 mcav: yeah, that's how i'd do it if there wasn't a string-specific function... is there any kind of performance penalty with all those seqs?

12:36 (as opposed to java string.substring)

12:37 mrBliss: mmm, you could do some small benchmarks to see if it matters

12:38 mcav: yeah, will do, ty

13:04 fliebel: chouser: did you write more of those euler solutions in Clojure?

13:31 ssideris: is this the best way to go from list to vector? (apply vector l)

13:31 h l is a list

13:32 Chousuke: ssideris: (vec l) is enough.

13:32 ssideris: ah, thanks

13:34 fliebel: How do I create an integer from a char? (Integer. \1)

13:36 chouser: ,(Character/digit \1 10)

13:36 clojurebot: 1

13:39 chouser: ,(read-string (str \1))

13:39 clojurebot: 1

13:39 chouser: ,(Integer/parseInt (str \1))

13:39 clojurebot: 1

13:39 fliebel: ,(Integer. (str \1))

13:39 clojurebot: 1

13:40 chouser: ,(Character/getNumericValue \1)

13:40 clojurebot: 1

13:40 fliebel: ,import this

13:40 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/import

13:40 fliebel: lol

13:41 ssideris: has anyone used the clj-swing macros?

13:44 fliebel: ,(map #(new Integer (str %)) (\3 \4 \5 \6 \7))

13:44 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn

13:44 fliebel: same for all the other options

13:44 :$ oops

13:45 '

14:07 chouser: ,(map #(Character/getNumericValue %) [\3 \4 \5 \6 \7])

14:07 clojurebot: (3 4 5 6 7)

14:07 chouser: ,(map #(Character/getNumericValue %) "34567")

14:07 clojurebot: (3 4 5 6 7)

14:08 chouser: ,(Integer/parseInt (apply str [\3 \4 \5 \6 \7]))

14:08 clojurebot: 34567

14:08 fliebel: How does Clojure handle octal numbers?

14:10 hiredman: fliebel: very well

14:11 mrBliss: ,(= 010 8)

14:11 clojurebot: true

14:11 fliebel: nice

14:12 mrBliss: or for a arbitrary base:

14:12 ,(= 10r7 7)

14:12 clojurebot: true

14:13 fliebel: ,3r120

14:13 clojurebot: 15

14:35 florianjunker: Can I use transients with transactions?

14:37 chouser: florianjunker: yes, if you're careful

14:37 florianjunker: chouser: What does careful mean in this context?

14:38 chouser: florianjunker: changing a transient is a side-effect as far as a transaction is concerned

14:38 florianjunker: So, it needs to happen inside of an agent?

14:38 chouser: florianjunker: so if you're changing a transient inside a dosync, you probably need to make sure that transient is created inside the same dosync.

14:38 that's another option

14:39 fliebel: Ugh, it's to late to attempt math...

14:40 ,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))] (apply + (concat (multi-of 3 1000) (multi-of 5 1000))))

14:40 clojurebot: 266333

14:40 fliebel: = wrong answer according to euler

14:40 florianjunker: Is there any easily accessible information about the amount of memory that clojure uses for its various data structures?

14:41 chouser: florianjunker: hm, not that I know of.

14:43 fliebel: Strange…

14:44 ,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))] (apply + (concat (multi-of 3 10) (multi-of 5 10))))

14:44 clojurebot: java.lang.Exception: Unable to resolve symbol: <  in this context

14:44 fliebel: huh.. that was supposed to give 23

14:45 ,(letfn [(multi-of [nr maxi] (take-while #(< % maxi) (iterate #(+ nr %) nr)))](apply + (concat (multi-of 3 10) (multi-of 5 10))))

14:45 clojurebot: 23

14:45 fliebel: as the example suggests

14:45 som I'm lost as to why the real thing, with 1000 is claimed to be wrong by euler

14:46 ah, *eurekea*

14:46 give me a set...

14:47 yay

14:56 scottj: How do read some input from a user? (read-line) doesn't wait for me to type anything

14:57 chouser: scottj: slime?

14:57 scottj: chouser: yeah

14:58 chouser: it's getting in your way. :-/ I'm not sure how to do it with slime.

14:58 scottj: ok. with pre-lein there was an inferior lisp buffer that you could use when slime messed with stuff but I think that's gone now

15:06 Is there something like file-truename from elisp, where you could do (slurp (file-truename "~/foo")) for handling ~?

15:09 ans: so is anyone working on some xlib bindings for clojure?

15:10 scottj: ans: going to write a wm? :)

15:10 ans: scottj: toying with the idea

15:11 scottj: ans: maybe there's something in java.

15:12 ans: scottj: im looking into that now

15:17 chouser: ans: http://github.com/abrooks/prion/blob/master/src/prion.clj

15:17 raek: haha! http://blog.fogus.me/2010/08/30/community-standards/

15:17 chouser: ans: hardly anything there yet, but maybe some ideas.

15:17 raek: implicit self reference is the best kind of humor...

15:22 LauJensen: fogus: thats an instant classic :)

15:22 abrooks: ans: I may have missed the context (chouser pointed out that I should weigh in) but I'd suggest using xcb bindings instead of xlib.

15:23 ans: abrooks: why xcb

15:24 abrooks: Maybe chouser already said that and I'm being redundant. In any case, there's example code using an older version of clj-native to call the native libxcb here: http://github.com/abrooks/prion

15:24 ans: xlib is a synchronous library, xcb is asynchronous. xcb is also a much more modern (albeit somewhat less featured) replacement for xlib.

15:25 ans: In current Xorg, the xlib interfaces are written on top of xcb.

15:25 fliebel: LauJensen: I went to bed yesterday, halfway your testing of Clojure for your game after the C++ Decision. Any news?

15:25 abrooks: ans: http://xcb.freedesktop.org/

15:25 scottj: is there a shorter way to write (let [{:keys [a b]} amap] [a b]) ?

15:27 chouser: scottj: (map amap [:a :b])

15:27 scottj: chouser: thanks

15:27 LauJensen: fliebel: The news is that you were so tired, that you forgot it was Bjering who was testing :)

15:28 chouser: scottj: of course that's a lazy seq not a vector, but may be close enough.

15:28 abrooks: ans: http://github.com/abrooks/prion/blob/master/src/prion.clj is currently a port of the last example on this page: http://xcb.freedesktop.org/tutorial/ (with all the XCB wrapping, some idiomatization and example all mashed together, ew.)

15:28 fogus: Let it be known that I do not disparage anyone their personal style -- only that I wish to point out that there is a cost associated with it

15:29 fliebel: LauJensen: You are right… you know the outcome? :P

15:30 LauJensen: fliebel: He's going with C++ since Java has a bug for which the root cause cannot be determined

15:34 * kencausey gives fogus a thumbs up

15:34 kotarak: the methods of reify are closures, aren't they?

15:34 chouser: kotarak: the whole thing is a closure, essentially.

15:35 kotarak: k

15:36 shrinking is hairy, it seems...

15:37 chouser: ???

15:37 kotarak: quickcheck style shrinking. For testing purposes. Tries to minify an counterexample for a test.

15:37 chouser: hm.

15:56 leafw: I am looking for an ide to develop clojure in--using vim at the moment. Any recommendations other than emacs?

15:56 to dev clj code, that is, not clj itself!

15:57 kotarak: leafw: vim obviously :)

15:57 leafw: kotarak: I am afraid I let you down on that offer in the mailing list. vim clj baffles me .I use it only for syntax coloring

15:57 slyrus: leafw: emacs

15:57 kotarak: leafw: ccw

15:58 leafw: by the way your memoize functions are very nice. kotarak: uder what license is that code in your webpage?

15:58 LauJensen: leafw: http://bestinclass.dk/index.clj/2010/03/clojure-ides-the-grand-tour-getting-started.html

15:58 leafw: ccw sounds like counterclockwise ... eclipse?

15:58 LauJensen: thanks

15:59 kotarak: leafw: Normally I use MIT license, but since the memoize function is a product of the community I would say EPL is fine.

15:59 leafw: kotarak: a note to that effect in the webpage would be great :) And thanks

15:59 raek: Eclipse – Counterclockwise, Emacs – clojure-mode, SLIME, swank-clojure, Idea – La Clojure, Netbeans – Enclojure, Textmate, Vim

16:01 leafw: raek: the point on IDE was, does any really work? Makes life painless? Expands all function names, knows how to go to the declarations, can tell me something is wrong (particularly with namespaces)?

16:02 gotta go, bbl ~ 2h

16:02 kotarak: I'm not sure about the last one, I think the other points are all covered (also with VC)

16:02 Clojure has a quite good position IDE-wise. (considering its age)

16:02 raek: I only have experience with emacs, so don't think I have any useful stories for you

16:02 leafw: kotarak: I know, I am just spoiled.

16:12 scottj: leafw: imo the eclipse plugin is currently the best

16:13 and in my experience it works better than the scala plugin!

16:25 jfields: is there a fn that takes nil and returns nil (or an empty list) or takes an element and returns that element in a list?

16:26 kotarak: jfields: #(when % [%]) is approximation

16:28 jfields: thx

16:28 kotarak: jfields: pay attention to boolean false...

16:29 jfields: kotarak, yep. thanks

19:01 mrSpec: Hello! I have problem with connection to DB "No suitable driver found for jdbc:postgresql://localhost:5432/" I've added postgresql's jdbc to CLASSPATH, what else should I do?

19:04 scottj: make sure you have the right connection string

19:07 arohner: mrSpec: you might also need to do (. Class (forName "org.postgresql.Driver"))

19:08 mrSpec: I hope string is ok. I'm trying run example from http://groups.google.com/group/clojure/browse_thread/thread/176a11847601cc5a/445026a02e302837?pli=1

19:09 org.postgresql.Driver [Thrown class java.lang.ClassNotFoundException]

19:11 arohner: mrSpec: that sounds like postgres isn't on your classpath. Have you restarted the clojure process since you added the jar?

19:11 or your classpath isn't what you think it is

19:13 mrSpec: ok, now I've tried run it from shell, not emacs

19:13 java.lang.ClassNotFoundException: org.postgresql.Driver (NO_SOURCE_FILE:0)

19:13 hm so maybe something wrong with my classpath :S

19:16 but there cant be anything wrong I think, $CLASSPATH contains clojure/postgresql-8.3-604.jdbc4.jar

19:21 arohner: mrSpec: how are you starting the clojure process?

19:21 mrSpec: java -jar clojure.jar

19:22 arohner: mrSpec: aha! -jar ignores $CLASSPATH and -cp

19:22 mrSpec: start like java -cp clojure.jar:postgres.jar clojure.main

19:24 mrSpec: ah, but unfortunately still the same problem java.lang.ClassNotFoundException: org.postgresql.Driver (NO_SOURCE_FILE:0) :/

19:25 arohner: mrSpec: are you sure the path to the postgres jar is correct? that really should work

19:28 mrSpec: ah, now I see I have some problem with clojure contrib. I'll add it to classpath too.

20:00 arohner: everything works! thanks :)

20:02 arnorhs: heh, arohner is almost an anagram of my name :)

21:55 ihodes: anyone here able to give me a hand with an Elive questio?n

21:55 Enlive* make that

21:59 scottj: ihodes: just ask question

22:05 ihodes: well, Enlive is html-escaping content i format with a snippet when I use emit*, but if i leave off the emit* and just print the node sequence, it shows the content formatted regularly with HTML. when I use emit* on that seq of nodes, just that content is html-escaped, whilst the rest of the template remains properly formatted

22:06 ah i see that when i have a list of nodes, the tags aren't in place for the content i'm adding. e.g. it considers <p> a piece of content, not a tag.

22:07 so is there a function like content (from Enlive) that will keep the HTML formatting? substitute almost does it

22:09 take it back, substitute doesn't do it. what i'm trying to do here is select the :body of my template, and put the result of a snippet in it. that snippet needs to take in a string of HTML and place it between its <section> tags: the problem is, it does that, but the HTML tags aren't considered as node delimiters: instead they're considered all part of the content string, and so they're escaped in the result of my template i'm spitting to

22:09 file.

22:44 found it by searching through the source: html-content

23:16 pdk: ,(+ 76.73 49.27 34.94 350.44 60.97)

23:16 clojurebot: 572.35

23:38 technomancy: is (System/getProperty "user.home") ever going to be different from (System/getenv "HOME")?

23:41 also, is it possible for that to ever be nil?

23:43 bmh: technomancy: yes. It is possible for them to differ

23:44 getenv pulls the environment variable HOME.

23:44 technomancy: bmh: so if someone's been monkeying with it?

23:44 bmh: If I `export HOME=foo`, then getProperty will return the path to my homedir, while getenv returns foo

23:45 technomancy: For very small values of monkeying and someone ;-)

23:45 technomancy: I'll just stick with getProperty then

23:45 no idea why I was checking both here... must have been late

23:47 bmh: technomancy: In a more mundane case, I believe that they can differ if you're su'ed to another user

23:47 Hm. Looks like it's the case with fakeroot, but not with su. Your mileage may vary.

Logging service provided by n01se.net