#clojure log - May 23 2010

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

0:00 scgilardi: a mouse crossed technomancy's path once... once.

0:11 johnmn3: looking at Lau B. Jensen's prototurtle blog entry (http://bestinclass.dk/index.clj/2010/04/prototurtle-the-tale-of-the-bleeding-turtle.html), I noticed the example of defrecord has no default implementation. Just a signature. He could have built the protocol first and built the defrecord with an implementation, right?

0:14 _na_ka_na_: Hi all

0:15 Any one answer http://groups.google.com/group/clojure/browse_thread/thread/ea39801f8e907640 ?

0:31 johnmn3: _na_ka_na_: sorry, I don't know about that

0:31 _na_ka_na_: johnmn3: thx for looking anyway

0:34 johnmn3: is reify, deftype, or defrecord preferred over proxy now?

0:36 technomancy: johnmn3: reify replaces most uses of proxy

0:37 johnmn3: clojure.org/datatypes: "reify is preferable to proxy in all cases where its constraints are not prohibitive."

0:37 bah, thanks technomancy

0:38 that page also says: "mutability should be the default

0:38 and is the only option for records"

0:39 but lau put's gui components into defrecord... which are mutable. perhaps it means only the keys are immutable?

0:43 technomancy: no, records are immutable

0:49 johnmn3: technomancy: k, thanks

1:05 I'm trying to translate a java class to clojure. this class has fields that aren't passed to the constructor but are created in the body of the class.

1:05 they can be accessed like object.myString

1:06 the constructor for the class, though, only takes one gui component.

1:08 technomancy: johnmn3: if you are just learning Clojure, I'd advise against making a gui app your first project.

1:08 johnmn3: is it possible for the implementation within a defrecord to generate an accessible field? or do they all have to be specified in the params to the defrecord?

1:10 yea, I hear ya, technomancy. I just really want to make this program. It's a lot of fun

1:10 technomancy: sure, don't let me dissuade you from having fun. =)

1:10 johnmn3: dealing with GUIs arent.

1:12 oh, I'm thinking about this all wrong. this example I've been working with.. it starts with an abstract class, then another extends it.

1:14 rich stated not to extend concrete implementations (if I read that correctly). so this example doesn't map to clojure that way

1:15 "you cannot derive datatypes from concrete classes, only interfaces"

1:16 meaning, I won't be able to create a "default implementation" and then extend that implementation by simply adding or changing method definitions.

1:16 if I understand correctly

2:08 hsuh: hm, clojure.org not working

2:26 johnmn3: how does one refer to fields from within a record's definition?

2:26 like this:

2:26 (defrecord R [arg] P (foo [] arg))

2:26 or:

2:26 (defrecord R [arg] P (foo [] (:arg this)))

2:26 ?

2:41 hoeck: johnmn3: I would prefer to use the former, except when the fieldname clashes with an argument name

2:42 there is even a third possibility (least preferred, I guess): (.arg this)

2:45 johnmn3: hoeck: in that example "arg" is not an argument to the method.. the method is trying to refer to the value of the field. so that is allowed?

2:48 hoeck: of course, (.arg this) refers to the field named "arg", though it seems that it prefers to call a method "arg" if both, the method and the field exist

2:49 johnmn3: ok.. that makes things easier

2:51 and if one of the methods calls another method within the same type/protocol, we use the literal word "this"?? like, (.other-method this)

2:51 ?

2:51 hoeck: no, the this is defined in the signature of the method

2:52 (defrecord X [..] P (method [this, args ...] ))

2:52 johnmn3: well, as per Lua Jenson's prototurtle example, he put "this" in the signature of the protocol, but not the record.

2:53 http://bestinclass.dk/index.clj/2010/04/prototurtle-the-tale-of-the-bleeding-turtle.html

2:53 sexpbot: "Best In Class: ProtoTurtle - The tale of the bleeding turtle"

2:53 hoeck: yeah, there used to be a :this parameter to the defrecord some weeks ago

2:53 johnmn3: aaah

2:54 ok, so keep the "this" param in both the protocol and the record/datatype?

2:55 hoeck: the :this parameter is gone, and each method takes the current object as the first argument

2:56 johnmn3: ok

2:57 so does that mean I have to do this: (defrecord R [arg] P (foo [this] (:arg this))) ??

2:57 hoeck: note how Lau, in extend-protocol, uses destruction on the first argument to move (the actual "this" argument)

2:57 right, or (foo [_] arg)

2:58 or (foo [t] (:arg t))

2:59 johnmn3: in your first example there.. clojure knows that arg is a field on the record?

3:00 I see what you're saying about the destructuring there

3:01 hoeck: yeah, because the thing is defined in a defrecord context: (defrecord X [arg] P (foo [_] arg))

3:02 johnmn3: cool.. thanks hoeck!

3:09 danlarkin: I destruct my args all the time

3:09 they're like nooooooooo and I'm like destructttttttttt

3:09 hiredman: your args are very destructive

3:10 arg(ument)s

3:21 emptist: (* 10 20)

3:21 clojurebot: *suffusion of yellow*

3:21 Fossi: :D

3:21 pjstadig: (* 1 1)

3:21 clojurebot: 1

3:21 danlarkin: ,(dinc 1)

3:21 clojurebot: java.lang.Exception: Unable to resolve symbol: dinc in this context

3:21 danlarkin: WHAT

3:21 pjstadig: heeh

3:22 $(dinc 1)

3:22 sexpbot: DENIED!

3:22 danlarkin: sexpbot I hate you

3:23 pjstadig: $learn sexpbot and danlarkin are feuding

3:23 sexpbot: My memory is more powerful than M-x butterfly. I wont forget it.

3:23 drewr: $(println "/me huggles danlarkin")

3:23 sexpbot: => /me huggles danlarkin nil

3:23 pjstadig: $sexpbot

3:23 sexpbot: Command not found. No entiendo lo que estás diciendo.

3:23 danlarkin: $(System/exit 1)

3:23 sexpbot: DENIED!

3:24 Fossi: what the hell is M-x butterfly?

3:24 danlarkin: $#=(System/exit 1)

3:24 sexpbot: Command not found. No entiendo lo que estás diciendo.

3:25 danlarkin: $(list #=(System/exit 1))

3:25 sexpbot: EvalReader not allowed when *read-eval* is false.

3:26 Fossi: i doubt you can break it *that* easily

3:28 danlarkin: that was ingenious!

3:28 pjstadig: $*clojure-version*

3:28 sexpbot: Command not found. No entiendo lo que estás diciendo.

3:28 danlarkin: $(clojure-version)

3:28 sexpbot: => "1.2.0-master-SNAPSHOT"

3:29 pjstadig: $System

3:29 sexpbot: Command not found. No entiendo lo que estás diciendo.

3:31 danlarkin: $(dotimes [_ 30] (doto (Thread. #((fn this [] (try :foo (finally (this)))))) .start))

3:31 sexpbot: DENIED!

3:32 johnmn3: $(read-string '(System/exit 1))

3:32 sexpbot: DENIED!

3:32 johnmn3: $(read-string '(+ 1 1 2))

3:32 sexpbot: DENIED!

3:34 johnmn3: $(future (inc 1))

3:34 sexpbot: DENIED!

4:13 dysinger: sexpbot: $(+ 1 1)

5:36 johnmn3: is there a clojure.contrib that auto-resolves imports?

7:17 hoeck: johnmn3: what do you mean by "auto-resolving" imports

7:30 angerman: if I have a set of functions f1,...,f4 and a value x. How'd I construct (x, f1(x), f2(f(1(x),....,f4(f3(f2(f1(x)))))

7:30 ?

7:33 Borkdude: maybe use (indexed [f1 f2 f3 f4]), comp and use (for [r (range 4)] (range r))

7:34 hmm, don't even have to use indexed

7:35 ,(for [r (range 4)] (range r))

7:35 clojurebot: (() (0) (0 1) (0 1 2))

7:35 angerman: Borkdude: hmm that's right. I'm still wondering weather or not one could just use the last value.

7:35 Borkdude: ,(doseq [r (range 5)] (range r))

7:35 clojurebot: nil

7:35 hoeck: wild guess: (reductions #(apply %2 %1) x [f1 f2 f3 f4]) ???

7:36 Borkdude: hmm

7:36 angerman: hoeck: that sounds not too bad

7:36 Borkdude: hoeck: that might be it

7:37 angerman: ,(let [f #(%+1)] (reductions #(apply %2 %1) 1 [f f f f]))

7:37 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

7:37 Borkdude: ,(let [f #(inc %)] (reductions #(apply %2 %1) 1 [f f f f]))

7:37 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

7:38 Borkdude: ,(let [f #(inc %)] (reductions #(%2 %1) 1 [f f f f]))

7:38 clojurebot: (1 2 3 4 5)

7:38 hoeck: ,(reductions #(apply %2 %1) x [f1 f2 f3 f4])

7:38 clojurebot: java.lang.Exception: Unable to resolve symbol: x in this context

7:39 hoeck: ,(reductions #(%2 %1) 10 [inc inc inc dec])

7:39 clojurebot: (10 11 12 13 12)

7:39 Borkdude: great :)

7:39 hoeck: right, the apply was wrong

7:39 Borkdude: I'll have to save this example for my Twitter account @cleotd

7:39 hoeck: yes, reductions is cool, and its even in core now!

7:40 angerman: hm.

7:40 Borkdude: I already had it scheduled, but this is a nice application of it

7:41 angerman: Hm. #(%2 %1) is #(%2 %) :D

7:42 Borkdude: not much improvement in readability imho;)

7:42 angerman: 1 char saved on twitter :D

7:42 Borkdude: angerman: haha that's true

7:45 is there a set that allows for duplicate values, otherwise called a bag in clojure?

7:46 angerman: While I did hear about that bag structure from a fellow student. I still don't really get what I'd use it for

7:46 Borkdude: angerman, Euler problem 5

7:46 I have to remember that I need thrice a factor 2

7:47 let me explain my problem some more

7:47 the factors of 8 are [2 2 2]

7:48 the factors of 4 are [2 2], so if I join the common factors of 8 and 4 I have to get [2 2 2]

7:50 angerman: so you basically have key:count?

7:50 well of factor:mulitple

7:50 Borkdude: angerman: I could do it like that

7:51 I might as well do that

7:52 is there a simple update, instead of update-in?

7:54 can I do: (update-in map [factor] inc), without having to check if factor is already there

7:54 and if it's not there, it will be inserted with default value 1

7:57 I mean like this: (defn update-or-insert [m k f d]

7:57 (if (contains? m k)

7:57 (update-in m [k] f)

7:57 (assoc m k d)))

7:57

7:58 (update-or-insert {} 3 inc 1) => {3 1}

7:58 (update-or-insert {3 1} 3 inc 1) => {3 2}

8:00 Chousuke: Borkdude: you could also wrap inc so that it handles nil.

8:02 hoeck: Borkdude: deftype rocks for such datastructure creations

8:02 Borkdude: http://gist.github.com/410875

8:06 Borkdude: Chousuke: ok - hoeck: tnx, will look into it later.

8:06 gtg now

8:17 angerman: ok, just a very qick and extemely stupid reality check.

8:17 Assume M to be a square Matrix.

8:18 if \lambda v = M v. v Is eigenvector for eigenvalue \lambda, no?

8:22 moshisushi: hello! i wanna discuss side effects.. is it up to the programmer to make sure that side effects are avoided inside of transaction?

8:23 angerman: me shoots himself

8:24 just in case anyone is going to use decomp-eigenvalue from incanter

8:25 don't try to get the eigenvectors using nth on the (:vectors part of the result). Your are going to get the rows of the eigenvector matrix instead of the eigenvetors you'd want. :/

8:35 hoeck: moshisushi: right, the programmer takes care

8:40 Chousuke: moshisushi: you can use the io! macro to mark code blocks that do IO

8:40 moshisushi: if such code is executed in a transaction, an exception is thrown

8:41 angerman: hmm. Clojure + JReality + Incanter is quite some fun :D

9:19 what does "no dispetch macro for: p" mean?

9:20 I assue it chokes on `(let [#ps (. ~ev getPointSet)

9:20 I though #ps was for gensym

9:21 ahh post

9:21 not pre

9:51 moshisushi: Chousuke: ah

9:51 Chousuke: because quoting the "programming clojure" book: In Clojure, side effects are

9:51 explicit and unusual. do is one way to say “side effects to follow.”

9:52 but i would say that (defn foo [] (println "hello")) is a function that returns nil, and happens to have the side effect of printing

10:02 Chousuke: moshisushi: right.

10:03 moshisushi: though if you want to be precise, it's not a function, it's a procedure. :)

10:04 and its return value is irrelevant.

10:05 moshisushi: Chousuke: ugh, i'm not quite sure i understand the difference :)

10:05 Chousuke: the point the book tries to make I think is that side-effects should be rare and isolated, not commonplace like in imperative and object-oriented languages.

10:06 moshisushi: Chousuke: right. i come from a Haskell background so i just have to loosen up my approach to side effects :)

10:07 in that STM, there's just no way to sneak in an io operation in a transaction

10:07 Chousuke: moshisushi: a procedure is something that has side-effects. a function doesn't.

10:07 but usually people just say "function" and "pure function" :P

10:08 yeah, the type system takes care of that.

10:08 but clojure doesn't have that, so the programmer has more responsibility

10:09 moshisushi: Chousuke: well there are benefits to not having to fight a type system too.. so i guess io! is sufficient :)

10:09 Chousuke: yeah.

10:10 moshisushi: Chousuke: "defn is a macro that makes defining functions a little simpler."

10:10 i think the terminology is a bit messed up :)

10:10 Chousuke: how so? :)

10:11 you can define functions without defn

10:11 moshisushi: Chousuke: yeah but you just said that defn creates procedures :)

10:11 or well, procedures is maybe not part of the clojure lingo at all

10:12 Chousuke: well yeah, *I* make the distinction sometimes but most people don't

10:13 moshisushi: yeah ok hehe.. so defn is pretty much def:ing an implicit lambda function?

10:13 Chousuke: yeah

10:13 hmm

10:14 I think clojurebot will complain to me if I try to demonstrate it

10:14 $(macroexpand '(defn foo [x] 1))

10:14 hm, what happened to sexpbot's evaluator :P

10:14 moshisushi: Chousuke: just paste it and i'll try for myself in emacs

10:15 Chousuke: moshisushi: well, try the above.

10:15 moshisushi: user> (macroexpand '(defn foo [x] 1))

10:15 (def foo (clojure.core/fn ([x] 1)))

10:15 Chousuke: macroexpand is useful :)

10:15 moshisushi: yeah, a fn

10:15 Chousuke: C-c C-m does macroexpand in emacs I think

10:15 hm

10:16 moshisushi: Chousuke: yeah it does

10:16 much cleaner too

10:17 i.e, no unnecessary namespace stuff, it looks

10:17 Chousuke: did it expand to fn*?

10:17 moshisushi: (def foo (fn ([x] 1)))

10:18 that's the expansion with SLIME Macroexpansion

10:18 Chousuke: hmm, I guess you have the pretty-printer working then

10:18 moshisushi: Chousuke: probably.. i have a pre-packaged thing called Clojure Box

10:18 emacs+slime+whatnot

10:19 Chousuke: I wonder if there is a way to turn off pretty-printing for the macroexpand. sometimes it matters :)

10:19 well, the namespace-dequalification anyway

10:20 sometimes you might want to generate code from a macro that explicitly does not have qualified symbols and that makes it hard to tell if you've succeeded or not

10:20 moshisushi: Chousuke: if i use (macroexpand 'myfun) i don't get prettyprinting

10:20 Chousuke: I suppose that's good enough.

10:21 moshisushi: unless there's something in (def foo (clojure.core/fn ([x] 1))) that's also prettyprinted

10:22 * angerman thinks macros are quite useful to cut away java boilerplate

12:32 chouser: I just added a var to my repl config so I can (set! *pprint* false) when necessary

12:33 * kotarak can't help, but mention that VC repl has this for half a year. ;P

12:49 programble: hm...

12:50 kotarak: sososososo

12:54 chouser: VC?

12:54 oh, sorry

13:00 kotarak: chouser: yeah, it's not perfect. But it has some nice things under its belt. :)

13:39 replaca: moshisushi: yeh, prettyprint is built into slime, but not included in the regular macroexpand

13:57 moshisushi: replaca: i see! thnx

14:12 OForero: hi

14:13 I am wondering if there is any command that can reset a REPL (connected through Swank)

14:14 instead of having to stop and start it

14:38 Borkdude: how do I create a sorted-map from a map?

14:39 I have a function (factors), that takes a number and keeps a map of the factors found so far... is it better to use a sorted-map to begin with? I only need to have the end result sorted

14:40 kotarak: Borkdude: (into (sorted-map) the-map)

14:47 Borkdude: kotarak: do I have to return a sorted-map everywhere in the factors fun, or there a more clever way to do it?

14:47 http://gist.github.com/411154

14:47 I could use an inner fn and then sort its return val

14:48 kotarak: (doc fnil)

14:48 clojurebot: I don't understand.

14:48 kotarak: pff

14:52 Borkdude: well you can use a sorted-map to begin with.

14:52 Borkdude: but don't ask me, what is better

14:53 Borkdude: kotarak: ah well, I only have to replace {} with (sorted-map)

14:53 not too bad

14:59 if you try this code: (doseq [in (repeatedly #(read-line)) :while in] (print in))

14:59 is there any way to get out of this?

15:00 kotarak: no

15:01 Borkdude: you can do (let [stop? (atom false)] (doseq [in (repeatedly #(read-line)) :while (and in (not @stop?))] (print in)))

15:01 Borkdude: and reset! stop? to true from some other thread

15:15 Borkdude: kotarak: yes, tnx

15:27 btw, I don't know why, but if I begin a line with ; in clojure-mode, type and press enter, the line gets indented 40 positions

15:43 OForero: lein help is failing with this message

15:43 http://paste.pocoo.org/show/217486/

15:43 any idea of what could be broken_

15:43 angerman: how do I join two lists?

15:50 hmm. ok. I had reduce and cons mixed up :/

15:53 Raynes: $(concat [1 2 3] [4 5 6])

15:53 sexpbot: => (1 2 3 4 5 6)

15:53 angerman: $(concat '(1 2 3) '(4 5 6))

15:53 sexpbot: => (1 2 3 4 5 6)

15:53 angerman: aye

16:04 pedroteixeira: anyone knows how to call something like (apply new Class [arg1 arg2])

16:04 ?

16:08 is "new" a normal function or macro, or is it a special reader macro?

16:10 Raynes: (doc new)

16:10 clojurebot: I don't understand.

16:10 Raynes: pedroteixeira: It's a special form)

16:11 pedroteixeira: ok, thanks.. trying to figure it out how to instantiate a class with a Seq of args.

16:11 will just use reflection for now..

16:11 triyo: you can wrap the special form in fn form and then apply...

16:24 Borkdude: Is (not (some pred ...)) the same as (every? pred ...), I guess so yes?

16:27 chouser: no

16:28 hm.

16:28 triyo: hehe

16:28 chouser: no

16:29 ,(not (some odd? [2]))

16:29 clojurebot: true

16:29 chouser: ,(every? odd? [2])

16:29 clojurebot: false

16:29 chouser: (not (some ...)) is the same as (not-any? ...)

16:37 Borkdude: chouser: of course, doh

16:37 useful to know, there is not-any

16:37 with question mark

16:38 One more question, is :default and :else more or less the same in cond?

16:40 chouser: sure, anything that's always true would work, including 'true'. But :else is idiomatic -- please use it.

16:40 Borkdude: ah yes, alright

16:42 If I find myself doing a lot of (first (filter pred coll)), should I use a different construct maybe?

16:47 mabes: ,(source find-first)

16:47 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

16:47 mabes: ,(doc find-first)

16:47 clojurebot: "clojure.contrib.seq-utils/find-first;[[pred coll]]; Returns the first item of coll for which (pred item) returns logical true. Consumes sequences up to the first match, will consume the entire sequence and return nil if no match is found."

16:48 mabes: Borkdude: ^ find-first does what you are doing

16:48 Borkdude: mabes, great, tnx

17:28 OForero: what will be the equivalent of overriding toString?

17:29 I want to have a different print routine for one of my defined strings

17:41 empt: are there any free but complete book for latest clojure?

17:42 Raynes: The closest thing to a 'book' around is the ociweb tutorial.

17:42 That's free, anyway.

17:43 empt: ok I'll check to find if I've looked at it before

17:43 Raynes: Otherwise, you have The Joy of Clojure (7 chapters in the MEAP already).

17:43 http://java.ociweb.com/mark/clojure/article.html

17:43 sexpbot: "Object Computing, Inc. - Java News Brief - March 2009"

17:43 Borkdude: empt: I got a free ebook

17:43 empt: hi Borkdude

17:43 Borkdude: empt: from someone on Twitter, let me search his address

17:44 empt: satish.talim@gmail.com, just send him a mail and he'll send you his ebook

17:45 empt: thank you and Raynes

17:45 Borkdude: empt: don't know how good this ebook is, haven't read it

17:46 empt: that's ok thanks

17:48 OForero: is there any way to make println behave differently for a self defined struct_

17:48 ?

17:53 riddochc: OForero: Differently how?

17:54 OForero: I have a stuation were structs reference eachothers .. and if I do println at the REPL ends up in a stack overflow

17:55 I was wondering if I can then define a custom println (that does not do a deep print) for one of them

17:56 riddochc: Ah, you want to set *print-length* or *print-level*

17:57 That controls a lot of the printing functions, including println. Generally helpful at the REPL.

17:58 OForero: ##

17:59 do I just def them_

18:03 riddochc: I think you want to use (set! *print-length* ...)

18:03 They're already def'd.

18:11 ihodes: hi all – is anyone familiar with String->java.util.Date->String kinda stuff?

18:13 or could point to where i might find some nice info on it?

18:18 people are less chatty then they used to be?

18:21 Raynes: At the moment.

18:39 dnolen: ihodes: have you look at the Joda time Clojure wrapper?

18:40 ihodes: I have not–where is that at?

18:40 dnolen: ihodes: http://github.com/clj-sys/clj-time

18:40 ihodes: oh nice, that looks like it may work

18:41 thank you very much. i have an additional question, though. i'm having trouble calling static methods in clojure: i (import (java.text.DateFormat)) and then, for example, cannot for the life of me figure out how to call... getTimeZone, for instance.

18:41 is there something i'm missing?

18:42 dnolen: DateFormat/getTimeZone

18:42 ihodes: (. DateFormat getTimezone) or (. java.text.DateFormat getTimezone) or (DateFormat/getTimeZone) all don't work

18:42 java.lang.NoSuchFieldException: getTimeZone (NO_SOURCE_FILE:17) is what i get

18:45 dnolen: ihodes: getTimeZone is not a static method

18:46 try (DateFormat/getDateInstnace)

18:46 ihodes: crap.... i'm sorry then :\ . I'll try that, then

18:47 dnolen: ihodes: (. (DateFormat/getDateInstance) getTimeZone)

18:47 works for me

18:47 ,(. (java.text.DateFormat/getDateInstance) getTimeZone)

18:47 clojurebot: #<ZoneInfo sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]>

18:47 quizme: what is ->> ?

18:48 Borkdude: ,(doc ->>)

18:48 clojurebot: "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."

18:48 ihodes: works for me! thank you so much

18:48 dnolen: ,(->> "last" (str "second") (str "first"))

18:48 clojurebot: "firstsecondlast"

18:50 dnolen: ,(macroexpand '(->> "last" (str "second") (str "first")))

18:50 clojurebot: (str "first" (clojure.core/->> "last" (str "second")))

18:50 dnolen: ,(macroexpand '(str "first" (clojure.core/->> "last" (str "second"))))

18:50 clojurebot: (str "first" (clojure.core/->> "last" (str "second")))

18:53 leifw: anyone familiar with clj-processing or know where I can find people that do?

18:53 I'm getting a segfault in X when I try to run one of the examples

18:53 I could swear I got it working once but never again

18:54 dnolen: liefw: what os are you on?

18:54 leifw: linux

18:55 ubuntu, kernel is 2.6.32

18:55 X version is 1.7.6

18:55 dnolen: hmm, I've only tried it on os x

18:55 leifw: dang

18:55 I really really want this working :-/

18:56 ooh looks like it's somewhere in the intel drivers

18:56 blech

18:56 dnolen: fwiw, Penumbra is pretty nice if you want to do interactive graphics and it's known to work on windows/linux/os x

18:56 leifw: ooh I'll have to check that out

18:57 the eclipse plugin?

18:57 dnolen: http://github.com/ztellman/penumbra

18:58 leifw: aha

18:58 neato

18:59 dnolen: it's opengl, but penumbra makes it enjoyable/fun, comes with examples of Tetris (< 250 LOC) and Asteroids (< 500 LOC)

18:59 leifw: cool

18:59 I'll have to try that out

19:00 dnolen: on ubuntu, it "just worked" for me.

19:00 well under parallels anyway :)

19:00 somnium: dnolen: what video card?

19:00 dnolen: NVIDIA GeForce GT 330M

19:01 somnium: ah

19:02 I never suspected open source intel drivers could crash X so often when I got this laptop :/

19:02 quizme: new discovery for me: (for [x (range 2) y (range 3)] [x,y])

19:02 :)

19:02 dnolen thanks

19:03 dnolen: quizme: np

19:10 Borkdude: ,(for [x (range 10) y (range 5) :when (= y 4) :while (< x y) :let [p (* x y)]] p)

19:10 clojurebot: (0 4 8 12)

19:18 dnolen: I was impressed by this Haskell snippet: let rightTriangles' = [ (a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2, a+b+c == 24] , from learn you a haskell

19:18 ,(let [r (range 1 11)] (for [c r b r :while (< b c) a r :while (< a b) :when (and (= (+ (* a a) (* b b)) (* c c)) (= (+ a b c) 24))] [a b c]))

19:18 clojurebot: ([6 8 10])

19:23 Borkdude: ,(for [c (range 1 11) b (range 1 c) a (range 1 b)

19:23 :when (and (= (+ (* a a) (* b b)) (* c c))

19:23 (= (+ a b c) 24))]

19:23 [a,b,c])

19:23 clojurebot: EOF while reading

19:23 Borkdude: damnit

19:24 ,(for [c (range 1 11) b (range 1 c) a (range 1 b) :when (and (= (+ (* a a) (* b b)) (* c c)) (= (+ a b c) 24))] [a,b,c])

19:24 clojurebot: ([6 8 10])

20:02 riddochc: Hmmm... Var clojure.core/unquote is unbound.

20:09 somnium: ,~42

20:09 clojurebot: java.lang.IllegalStateException: Var clojure.core/unquote is unbound.

20:10 somnium: ,(macroexpand '~42)

20:10 clojurebot: (clojure.core/unquote 42)

20:12 somnium: ,(binding [unquote (fn [x] (* x x))] ~42)

20:12 clojurebot: 1764

20:21 riddochc: Hm. So it's only bound within a macro's backquoted list, for my purposes. Must be a local function in the macroexpansion, then.

21:07 defn: is it correct to use the term niladic these days?

21:09 durka42: can I set java.library.path for lein repl?

21:11 got it - $JAVA_OPTS

21:25 somnium: niladic?

21:36 defn: somnium: i believe it comes from APL

21:36 niladic, monadic, dyadic

21:36 (computing) Of an operator or function in a program, having no arguments.

21:37 ^-niladic

21:41 pastorn: i wanna try clojure out... is there a .deb somewhere that gives me all i need?

21:44 silly me

21:44 TheBusby: Ubuntu 10.04 appears to have a something in the repo, more detail here: http://bit.ly/b1dO1l

21:44 sexpbot: "Clojure Programming/Getting Started - Wikibooks, collection of open-content textbooks"

21:44 pastorn: there was a 'clojure' package (apropos didn't say anything)

21:45 in the repl, is there a 'reload' command?

21:47 TheBusby: ,(doc load-file)

21:47 clojurebot: "([name]); Sequentially read and evaluate the set of forms contained in the file."

21:49 pastorn: how do you program in clojure? i'm used to mostly doing haskell

21:49 so i write som stuff in gvim, alt-tab to the repl; :r to reload and test my new functions

21:49 then back to the source file and write more stuff

21:50 is that the way you work when programming clojure as well?

21:50 TheBusby: I use emacs, but I think clojurebox does that for Vi

21:50 nmind

21:50 pastorn: TheBusby: nah, i'm pretty comfortable with the unix principle

21:50 TheBusby: the link I provided earlier has a section on setting up clojure and vim

21:50 pastorn: (it should do one thing and do it well)

21:51 my editor is my editor and the repl is the repl... also: don't know any of vims window splitting commands

21:52 TheBusby: more details here if you're interested, http://kotka.de/projects/clojure/vimclojure.html

21:52 sexpbot: "Kotka : Projects : Clojure : VimClojure"

22:09 pastorn: hang on here...

22:09 (map + [1 2 3] [4 5 6])

22:09 that doesn't make sense... that's zipwith

22:12 it feels weird that it takes three arguments :/

22:15 tomoj: it's n-ary zipWith :)

22:15 pastorn: haha

22:15 there's zipWith as well?

22:16 tomoj: zipWith from haskell I meant

22:16 pastorn: yeah

22:20 so where should i start reading to learn clojure? what's good? wikibooks?

22:20 (the wikibooks doesn't seem to have a very consistent design :( )

22:20 *wikibooks articles*

22:27 TheBusby: i can't get ,(doc load-file) to work

22:27 ,(doc Test.clj) <-- this doesn't work :(

22:27 clojurebot: java.lang.ClassNotFoundException: Test.clj

22:28 pastorn: almost; i get "Unable to resolve var"

22:39 TheBusby: pastorn: does (doc use) work?

22:39 load-file is clojure core, at least in 1.1.0

22:39 pastorn: it seems to print some help stuff

22:40 TheBusby: arg, brb

22:40 pastorn: do i need to declare a module name in the file for this to work?

22:41 this is my file: http://paste.lisp.org/display/100334

22:42 reload that page now...

22:48 defn: pastorn: how do mean module name?

22:48 as in a namespace?

22:48 pastorn: defn: something like that

22:49 defn: like (ns pastorn.hello-world)

22:49 pastorn: in haskell if you have i.e. Stack.hs, then the first line in that file should be "module Stack where"

22:49 defn: are you planning on reusing your hello [name] function in other places? ;)

22:49 pastorn: so that when you import you write 'import Stack' and not 'import "Stack.hs"'

22:49 defn: pastorn: short answer is: it depends

22:50 pastorn: defn: no, i just wont clojure-repl to reload my file in which i've placed some new functions

22:50 defn: (load-file "myfile.clj")

22:50 pastorn: java.lang.Exception: Unable to resolve symbol: define in this context (Test.clj:7)

22:50 defn: err i think, maybe im thinking elisp

22:52 pastorn: are you using "define" somewhere in your Test.clj?

22:52 pastorn: oh siht

22:52 defn: ;)

22:52 pastorn: yay!

22:52 defn: going back to a movie, ill try and check back if you need anything

22:52 ciao

22:52 pastorn: i've been playing around some in DrScheme, so i'm a bit damaged...

22:52 defn: hey no worries

22:52 enjoy your clojure :)

22:53 pastorn: hehe

23:00 what is this? no long comments?

23:01 Raynes: pastorn: (comment comment goes here)

23:01 pastorn: haha

23:01 nasty :D

23:01 Raynes: You can also comment out individual forms with #_.

23:02 But that's usually only useful for debugging.

23:02 pastorn: Raynes: form = (expr) ?

23:02 (+ 1 2 #_3) ;; cool

23:03 Raynes: $(println #_"this one just snuck in here." "ohai")

23:03 $(println #_(meow) "ohai")

23:03 sexpbot: => ohai nil

23:03 => ohai nil

23:03 pastorn: Raynes: what's the $?

23:04 Raynes: It tells sexpbot to evaluate whatever is passed to it in parens. If you need to evaluate something that isn't in parens, you can use $eval (e.g $eval 'meow)

23:04 We also have clojurebot, which does evaluation as well with , as the prepend (e.g ,(println "hai"))

23:05 pastorn: eval/apply are the same as the ones in scheme?

23:05 Raynes: Never used Scheme.

23:05 pastorn: looking here: http://java.ociweb.com/mark/clojure/article.html#Syntax

23:05 sexpbot: "Object Computing, Inc. - Java News Brief - March 2009"

23:05 pastorn: there's no lambda?

23:06 Raynes: $(apply + [1 2 3 4 5])

23:06 sexpbot: => 15

23:06 dysinger: like we need another bot in here :/

23:06 pastorn: in haskell you're able to do 'map (\x -> x + x*x) [1,2,3,4])'

23:06 s/)'/'

23:06 Raynes: $((fn [x] (* x x)) 10)

23:06 dysinger: Yeah, it's only been in here for around two months now.

23:06 sexpbot: => 100

23:07 Raynes: pastorn: fn is lambda.

23:07 pastorn: oh, nice

23:07 dysinger: Raynes - why what's the point - we already have had clojurebot for years

23:07 pastorn: $(map (fn [x] (+ x (* x x)) [1 2 3 4 5])

23:07 sexpbot: EOF while reading

23:07 pastorn: $(map (fn [x] (+ x (* x x)) [1 2 3 4 5]))

23:08 sexpbot: DENIED!

23:08 pastorn: :(

23:08 dysinger: annoying

23:08 pastorn: ,(map (fn [x] (+ x (* x x)) [1 2 3 4 5]))

23:08 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$map

23:08 pastorn: ,(map (fn [x] (+ x (* x x))) [1 2 3 4 5])

23:08 clojurebot: (2 6 12 20 30)

23:08 pastorn: there we go :)

23:09 Raynes: dysinger: At least a few people thought the title scraping was useful, and sexpbot does do a few things that clojurebot doesn't. Doesn't matter, I'll take him out of here. I'm tired of all the remarks.

23:09 pastorn: ,(map (+ %1 (* %1 %1)) [1 2 3 4 5])

23:09 clojurebot: java.lang.Exception: Unable to resolve symbol: %1 in this context

23:09 pastorn: ,(map #(+ %1 (* %1 %1)) [1 2 3 4 5])

23:09 clojurebot: (2 6 12 20 30)

23:10 pastorn: i'll stop spamming now :)

23:10 sexpbot: Bai!

23:10 dysinger: We've all written bots

23:10 I have also

23:10 pastorn: can you reload clojure code for running programs like in erlang or scheme?

23:10 dysinger: having several of them in the room is ... not needed

23:10 dnolen: pastorn: yup

23:11 programble: having you in the room is ... not needed

23:11 no offense

23:11 but it is true

23:11 dysinger: lol

23:11 Raynes: dysinger: Until yesterday, nobody seemed to care. Hell, people seemed to like him a little. It's alright. He's gone, wont be coming back.

23:11 :)

23:11 programble: so i think your argument proves useless

23:11 pastorn: dnolen: and it doesn't involve weird hacks like in haskell (where you need to import the compiler to make it work)

23:11 ?

23:12 dysinger: programble: whatever

23:13 dnolen: pastorn: nope. everything you enter in the REPL in Clojure is compiled

23:13 pastorn: dnolen: but what if it's a big nasty function that i need to have in a file?

23:14 can the calls to that function be replaced with the new definition on runtime?

23:14 dnolen: pastorn: use an IDE that lets you send only that definition to the REPL

23:14 pastorn: yes.

23:14 pastorn: nice :)

23:16 you're much friendlier in here than in #scheme :)

23:34 programble: danlarkin and dysinger are butt-buddies, rite?

23:37 dysinger: hello?

23:39 dysinger: programble: ignored

23:39 what are you guys ? 12 ?

23:41 programble: dysinger: are you and danlarkin?

23:57 rava: good eve

23:59 any way in emacs/swank-clojure to find out what line in the source file is causing the compile to blow?

Logging service provided by n01se.net