#clojure log - May 07 2009

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

0:29 lisppaste8: eee pasted "ugly transition for 15-puz" at http://paste.lisp.org/display/79806

0:29 eee: so here's my ugly function

0:30 oh, I missed durka42

0:30 wondered if there's a better way

0:31 in imperative language I could add all that apply as I found out they applied

0:33 think I know one thing to clean it up

0:43 lisppaste8: eee annotated #79806 "less ugly?" at http://paste.lisp.org/display/79806#1

1:10 eee: i'm stuck again

1:10 sent a function as arg

1:11 tried to call function and it says wrong number of argumentd

1:11 s

1:11 but I see two being called on it, and two being defined

1:11 so I probably need some more syntax like hashes somewhere

1:24 benatkin: anyone know if there's a way to step in between clojure and Java libraries? For example, could I make it so (java.util.Date.) gives me a fixed date instead of the current date?

1:25 hiredman: why?

1:27 benatkin: for testing APIs. say I have a function that generates a formatted calendar, and I can give it a month and year, or leave it blank and it will give me the current month and year. I could write a test and make it always return May 2009, and that way I would know what to expect.

2:08 Lau_of_DK: Morning guys

3:09 hiredman: ,(+ (mod (/ (.getTime (Date.)) 1000 86.4) 1000) 42)

3:09 clojurebot: 340.39431712962687

9:35 nakyss: motd

10:25 AWizzArd: stuartsierra: hi

10:25 stuartsierra: hi

10:26 AWizzArd: Did you notice the private chat window?

10:43 lisppaste8: stuartsierra pasted "fix for partition-by" at http://paste.lisp.org/display/79828

10:47 twism: ww... how do i check if a val is an instance of a clojure map?

10:47 ,(instance? #^Map {})

10:47 clojurebot: java.lang.Exception: Unable to resolve symbol: Map in this context

10:48 rhickey: ,(map? {:a 1})

10:48 clojurebot: true

10:48 twism: thanks rhickey

10:48 brain freeze

11:02 konato: hello stuart

11:04 stuartsierra: hi

11:05 stuhood: heya

11:05 konato: i'm the one having difficult with run-tests in emacs

11:06 i did post a new message on the clojure group.

11:06 rev 773 still doesn't help me

11:06 but thank you very much for your help

11:07 i can still survive since i can tests using REPL in a shell.

11:09 I really love your test-is framework

11:09 stuartsierra: Which problem are you still having - the wrong number of arguments to "report"?

11:09 konato: yes this one

11:11 I think it's more related to a component with emacs slime-repl...

11:11 Because, it work in a repl with the shell

11:12 stuartsierra: I just committed another bug fix to test_is.clj, probably not related.

11:12 rev. 774

11:13 konato: I'll try it

11:19 I'm on rev 774 and still got the error:

11:20 Stuart, I will put the log on Google

11:21 stuartsierra: I can't reproduce this, so I'm guessing it's something related to your classpath.

11:24 konato: I will continue to look into, specially the classpath

11:24 Thanks

11:33 with vim-clojure how to evaluate a clojure line

11:51 Hi Stuart, it does work in vim, shell repl but not in emacs.

11:52 stuartsierra: Got to be the swank-clojure classpath, then. Different versions of contrib.

11:58 stuhood: has contrib hit 1.0 yet?

11:59 stuartsierra: it hasn't been discussed much

11:59 durka42: should probably tag something to be distributed with core 1.0, no?

12:02 Chousuke: the libraries in contrib are in varying states of readiness though.

12:02 replaca: it keeps coming up here, but it's a little problematic since contrib potentially works with multiple clojure revisions

12:02 Chouser_: there should still be a branch

12:03 stuartsierra: in theory, but until core trunk diverges from 1.0, I don't see much need.

12:03 Chouser: especially ... right

12:03 replaca: stuartsierra: Hey, as long as you're here, we were noticing some issues in c.c.json.write the other day

12:03 stuartsierra: hit me

12:04 Chouser: especially when clojure post-1.0 gets a feature and something in contrib starts to use it.

12:04 replaca: stuartsierra: where it wasn't writing the right stuff

12:04 stuartsierra: I'd have to go reproduce it - it was in the middle of a big file

12:04 stuartsierra: also, it never injects newlines

12:04 stuartsierra: replaca: let me know; I'll need an example, at least

12:04 replaca: that's a feature

12:05 replaca: stuartsierra: so I had a 1/4 MB file on a single line

12:05 which seemed odd

12:05 stuartsierra: I figured, there are loads of JSON pretty-printers, I didn't need to write another one.

12:06 replaca: I'll go reproduce it, but in the meantime I was wondering if you'd done a compare and contrast with danlarkin's swag at in in clojure-json?

12:06 stuartsierra: no

12:08 replaca: ok. It seems like he's done a lot of work on "json-compliance" but I haven't looked at the issue too closely myself

12:08 stuartsierra: danlarkin's supports arbitrary types

12:08 mine doesn't

12:09 replaca: One of my concerns was whether there was a reason to have two or whether we should focus on one

12:09 under the "batteries included" model

12:09 (which JSON would seem to be part of nowadays)

12:10 but maybe there are good reasons for two that I just don't know

12:10 danlarkin: stuartsierra: it would be nice if we could bring all the features and "json-compliance" of clojure-json into contrib.json and eliminate the need for clojure-json altogether

12:10 stuartsierra: I don't really care; I just wanted something fast and simple in contrib.

12:10 I tried to follow the spec at www.json.org as closely as possible.

12:11 replaca: also, I had suggested implementing pretty printing for JSON with c.c.pprint which should be pretty easy and orthogonal

12:11 but I in the middle of rewriting the dispatch right now to make it easier to do things like that

12:11 stuartsierra: seeing how complex c.c.pprint was made me not want to do it in c.c.json

12:12 replaca: stuartsierra: yeah, the idea is to use the pprint dispatch to print other things and have all that complexity in one place

12:12 stuartsierra: if you can make that work, go for it.

12:12 replaca: cause good pretty printing is *hard*!

12:14 :-) cool, I think what I'll do is do a fork of clojure-json (since it's standalone) and roll in pprint dispatch then we can all discuss

12:14 stuartsierra: ok

12:14 replaca: stuartsierra, danlarkin: thanks

12:14 danlarkin: sounds good to me

12:15 replaca: and now back to our regularly scheduled program, "is there a version of contrib for 1.0?"

12:15 to be followed at 10AM with today's episode of "git vs. hg: my dvcs is better than yours"

12:15 kotarak: Wasn't one rev tagged? 753 or something?

12:21 stuartsierra: nothing in SVN

12:24 chrizel: hi, I'm doing the "Programming Clojure" example about compile - it uses duck-streams but I'm getting ClassNotFoundException when compiling duck-streams -- what could be the problem?

12:25 contrib is in classpath, it even seems to make a single class file on every compile but aborts with java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.duck_streams$file_str__XX

12:28 stuartsierra: Is the "clojure.compile.path" property set to a directory that is also on the classpath?

12:35 chrizel: stuartsierra, thank you, clojure-contrib.jar was obviously not compiled with classes

12:37 kotarak: chrizel: "ant -Dclojure.jar=/path/to/clojure.jar" should compile contrib with AOT compilation.

12:38 technomancy: dear ant: here's a hint: the path to clojure is _always_ ../clojure/clojure.jar

12:38 kotarak: technomancy: is that so?

12:39 replaca: for small values of always

12:39 but it would be nice to get all the packaging stuff working so we could know/figure that out

12:40 chrizel: kotarak, thx, i've figured it out now at least there is no problem with duck-streams anymore -- makes all sense now

12:41 technomancy: kotarak: it would make a good default value

12:41 danlarkin: that's the path on my system :)

12:42 durka42: i use ../clojure.jar

12:42 kotarak: replaca: I have posted a patch which adds Ivy support to contrib, since I use it I have no trouble with small (a few kb) jars containing parts of contrib. I got no feedback however. :/ At least not on the list, some positive feedback came via pm. It seems that maven will become the packaging system for Clojure...

12:43 So I use: ant -f build+ivy.xml and don't care where the clojure.jar is...

12:45 chrizel: Shouldn't it be possible to find the clojure.jar on the classpath automatically? (Java newbie here...)

12:47 stuartsierra: if it's there, but Ant has its own classpath

12:48 chrizel: oh, that's right

12:49 replaca: kotarak: yeah, I've been meaning to get around to looking at that and understanding maven, ivy, etc. But I haven't got there yet...

12:50 kotarak: soon, I hope, cause this stuff is important

12:50 technomancy: replaca: you can take a look at the clojure-pom project on github; it's pretty straightforward: http://github.com/dysinger/clojure-pom

12:50 replaca: ~seen dnolen

12:50 clojurebot: dnolen was last seen quiting IRC, 1006 minutes ago

12:51 technomancy: I'm not a fan of writing XML for stuff like this, but if the XML's written for you it works surprisingly well.

12:51 replaca: technomancy: cool. I want to look at all this stuff in some depth. I've never done anything with packaging in Java beyond ant

12:52 technomancy: the ideal solution would be something that could wrap an existing solution like mvn in a syntax that's a little more appealing

12:52 stuartsierra: As far as Java goes, Maven or Ivy are about the only games in town. Both are very XML heavy.

12:52 technomancy: if handling deps becomes straightforward, there's less incentive for contrib to be "the great big bucket-'o-code that everyone depends on"

12:52 stuartsierra: yes

12:53 technomancy: stuartsierra: luckily generating XML from s-expressions is not in the least bit difficult. =)

12:54 stuartsierra: Yes, but I expect calling the Java APIs directly will be the more flexible route.

12:54 dysinger: it would be cool to have a project.clj instead of pom.xml

12:54 and have that just be a wrapper for maven

12:54 technomancy: yeah, that's probably the best long-term solution. generating XML would be a "let's get it working quickly" hack

12:55 dysinger: the maven api can be hacked to suck in a pom.xml from memory instead of disk I bet.

12:55 technomancy: I have a perfect name for a clojure app that generates pom.xml files...

12:55 pomegranate

12:55 dysinger: I did a project called pomegrante with jruby / maven :)

12:55 stuartsierra: Take it one step further, call it Persephone.

12:55 dysinger: where I was doing the same thing

12:56 but eventually I got distracted by buildr and then finally when that didn't work I gave up.

12:56 maven + jruby was teh slow and painful

12:57 technomancy: stuartsierra: so that means mvn is Hades?

12:57 * technomancy isn't sure he follows

12:57 stuartsierra: Persephone was (if I recall) the goddess who was trapped in Hades because she ate a pomegranate there.

13:02 technomancy: ah, gotcha

13:04 stuartsierra: I thought of calling it "craven".

13:16 t345: how do you use classes from -contrib on the repl?

13:17 replaca: t345: add contrib to your classpath then (use 'clojure.contrib.duck-streams) or whatever

13:17 cp2: goose-streams

13:17 t345: do I need to do (use) ?

13:17 might explaing why it didn't work

13:18 looks like clojure.jar's classes are default-use'd

13:18 replaca: t345: yup

13:18 only clojure.core

13:18 t345: another one

13:18 is it an error in build.xml that not all contrib libs are compiled into the jar?

13:19 it's easy to patch, but I didn't want to post a patch that won't be accepted

13:19 cp2: contrib is not part of clojure

13:19 thats why it's 'contrib' =p

13:19 t345: cp2: into clojure-contrib.jar

13:19 cp2: oh

13:19 t345: many dirs are omitted fromt he list in build.xml

13:19 replaca: t345: it is an error, but it doesn't matter too much cause the cljs are all there

13:20 t345: yeah but a patch would be accepted. I will create one....

13:20 replaca: t345: and clojure will load the cljs as happily as the classes

13:20 kotarak: ant there are things like miglayout which depend on third party things...

13:20 s/ant/and/

13:20 t345: replaca: pre-compiling still makes sense, doesn't it?

13:20 technomancy: it'd be great if str-join were in core

13:21 considering you need it to do simple things like reverse a string

13:21 replaca: t345: yeah, it improves performance

13:21 t345: replaca: I will whip up a patch in minute....

13:21 is Google Code the original repo?

13:21 kotarak: yes

13:21 t345: I think so

13:21 ok

13:21 git svn clone it is then...

13:22 kotarak: t345: do you have a contributor aggreement sent in?

13:22 t345: what?

13:22 why?

13:22 this is not FSF or Sun

13:22 or Apache

13:22 or eclipse

13:22 kotarak: Do contribute patches you have to sign a contributor agreement.

13:22 s/Do/To/

13:23 t345: I will use Scala, then, thanks

13:23 kotarak: http://clojure.org/contributing IIRC.

13:23 t345: CRAZY

13:23 might make sense

13:23 but too much effort

13:24 Chousuke: :p

13:24 technomancy: barriers to contribution are no fun

13:24 kotarak: Was one sheet of paper and an envelope...

13:24 t345: it's just a simple build.xml diff

13:24 rsynnott: 6apart keeps nagging me about sending in one of those

13:24 gnuvince: technomancy: I imagine tracking down ownership 7 years from now is even less fun.

13:24 technomancy: IIRC the reason Sun and FSF require one is so that they can use their considerable legal resources to defend the project. but that doesn't even apply here.

13:24 rsynnott: they're not that often seen on non-company-controlled projects

13:25 t345: Signed-Off-By was Ok for my git and kernel patches

13:25 hmm

13:27 can't I just send the patch to a dev and he will also sign-it off and it's ok?

13:27 it's non-substantial plumbing

13:27 Chousuke: I don't think that works :/

13:27 the CA thing is a nuisance sometimes

13:27 rsynnott: ah, but then you'd have to assign copyright to HIM

13:27 see how this works? :)

13:28 technomancy: t345: it's not about making sure it is good code, it's about who owns the copyright.

13:28 t345: copyright for build.xml? come on

13:28 technomancy: =(

13:28 replaca: t345: or you can just ask a dev to fix it - we don't really need a patch on this one

13:28 Chousuke: t345: go complain to legislators :P

13:28 replaca: I've had it on my list for a few weeks (since I noticed it) but it hasn't gotten to the top

13:28 Chousuke: t345: copyright even applies to what we write *here*

13:28 t345: ok then please make sure that everything that's compilable is compiled via build.xml.

13:29 replaca: I will send you a scret diff and you will not mention who wrote it :D

13:29 replaca: you got it!

13:29 gotta run - talk to you all later

13:32 Chousuke: I suppose it'd be possible to drop the requirement for a CA in the future, but that's up to Rich.

13:33 t345: where is rich?

13:33 gnuvince: NYC

13:33 rhickey: what's the question?

13:33 t345: hey

13:34 kotarak: clojurebot: bat light

13:34 clojurebot: No entiendo

13:34 t345: rhickey: is it Ok to submit a trivial build.xml patch without signing the postal mail agreement?

13:34 rhickey: t345: no

13:34 technomancy: according to the FSF, anything under ~5 LOC is probably not subject to copyright to begin with

13:35 rhickey: why not send in a CA?

13:35 Chousuke: "probably" is not very assuring :/

13:35 danlarkin: everything created in the USA is automatically copyright it's creator, no matter the size or scope

13:35 that sentence is copyright me

13:35 t345: too much hassle for something trivial and non-substantial non-clojure code

13:36 kotarak: In Germany you can't give up your copyright. No public domain here...

13:36 t345: it's much more work to discuss this actually

13:36 :)

13:36 technomancy: Chousuke: even if it is, if it's trivial to reimplement, then there's no danger of it becoming a legal issue in the future.

13:36 rhickey: t345: true, then you can just 'suggest' the change on the group

13:36 technomancy: I think that's the FSF's reasoning at least; they let me send in trivial patches before my paperwork had gone through.

13:37 t345: rhickey: with a "this is what I mean" diff? or literal explanation?

13:37 technomancy: danlarkin: sure, but you'd have a hard time defending your copyright on a five-word sentence.

13:37 t345: rhickey: I am used to posting patches instead of explaining something which looks like a whishlist

13:38 rhickey: t345: sending in a CA is a one-time thing, if you think you'll have multiple patches that's the way to go

13:38 danlarkin: technomancy: correct, especially messages posted to a public forum like this, almost any use would be fair use. The point is that legally, I owned the copyright as soon as typed the keys

13:38 t345: I will do that if I ever need to change a .clj or .java file, promised

13:39 rhickey: no one person's convenience is more important than the project having sound stewardship and provenance

13:40 Chousuke: t345: so what library in contrib is not getting compiled by default? :/

13:40 t345: before we discuss too long

13:40 at least json.*

13:40 let me try if that helps at all with my repl classnotfound errors....

13:41 technomancy: danlarkin: yeah, I think you're right about that, but the end result is the same as it applies to this project.

13:44 t345: hmm (use 'clojure.contrib.json.read) still yields nil

13:44 oh wait

13:44 Chousuke: that's what it should do

13:44 kotarak: It's supposed to yield nil

13:44 t345: ok

13:45 ok, class is found

13:45 so the compiling was the problem

13:45 anyway, it's ok for me and I trust yhat you guys will fix build.xml for all cases where it's missing

13:45 thanks for talk :D

13:45 it's appreciated

13:48 and yes if I ever want to contribute to Clojure-Contrib I will read the agreement and if it's sound will send it in but first have to make some money to pay for the postal service :P

13:50 hmm, no single reply, I've made you guys ignore me. cool.

13:51 technomancy: t345: send me your address; I'll send you a stamp. =)

13:51 t345: :D

13:51 from the first sentence in ca.pdf I am not sure I even agree or am fine to sign it

13:52 no time to think about it

14:04 Chousuke: there are surprisingly many libraries that don't get compiled :/

14:04 probably from before there was AOT compilation :

14:35 cp2: hehe http://gianturl.com/

14:35 novel idea

14:35 wish i came up with it

14:36 technomancy: what's the status on making regexes callable?

14:36 I noticed it's on the todo

14:37 rhickey: technomancy: there are some problems with the idea, it seems like we can have callable regexes or Pattern-compatible regexes, and the latter is more useful

14:37 kotarak: cp2: http://dickensurl.com/

14:37 cp2: haha

14:37 neat

14:38 technomancy: rhickey: you mean making it so #"foo" isn't a native Java type?

14:39 but still uses the same syntax?

14:39 rhickey: technomancy: that would be the tradeoff

14:40 stuhood: it isn't until you build a language on the JVM that you start noticing all the final classes

14:41 is that because the implementation is actually native to the JVM implementation?

14:41 technomancy: it's tempting to think about hacking the JVM to just ignore "final" declarations.

14:41 who needs 'em anyway? =P

14:41 Chouser: how useful is a Pattern regex compared to a callable regex that provides all the same methods as Pattern?

14:42 technomancy: Chouser: seems like the only advantage is that there's less overhead

14:42 but maybe I'm missing something

14:42 rhickey: Chouser: it's very useful in APIs that take Patterns

14:42 stuhood: i don't know: this seems ackward: (#"matchme" "matchme")... would it execute a 'find' or a 'match'?

14:43 Chouser: The place I've most often wanted to pass in an actual Pattern is to String's .split() method -- but it doesn't take Patterns at all, only regexes in Strings. :-P

14:43 stuhood: that's the next question. :-)

14:43 stuhood: Chouser: you can do Pattern/split

14:44 Chouser: stuhood: sure. and thus also could do ClojureRegex/split

14:44 stuhood: true...

14:44 Chouser: I think calling a ClojureRegex should be the same as re-seq

14:44 stuhood: yea, i don't know how often patterns cross API boundries

14:47 rhickey: The group would be a good place to feel out how many people care that #"regexes" are Patterns

14:47 stuhood: rhickey: which APIs have you seen Patterns passed around in?

14:48 * rhickey tries to avoid regexes

14:48 technomancy: as long as there's a convenient way to get the Pattern from a #"regex", it seems like a step forward

14:48 Chouser: I'd love to see an concise s-expr alternative to regex.

14:48 stuhood: what is the benefit, aside from becoming callable? that really only eliminates 5 characters from the call

14:50 technomancy: stuhood: yeah, and callable maps "only" eliminate four characters vs using "get", but it's a huge win.

14:50 stuhood: "huge"...

14:50 Chouser: it means you can pass around the object rather than a thunk

14:54 danlarkin: well I am in favor of the idea... but passing a thunk versus non-thunk is not an issue if the callee can use them the same way

15:02 drewr: I wonder if scsh has a sexp-based pattern system.

15:03 Sounds like something it would do.

15:03 kotarak: drewr: it has, IIRC

15:19 chrizel: Does someone know how to solve Emacs+Slime+clojure-mode problems with stdout in other Java threads? (e.g. when an ActionListener in Swing does println, nothing gets printed in the Emacs window but in an external repl it works without a problem)

15:28 tashafa: what ever happened to 'recur'

15:29 ,doc recur

15:29 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/doc

15:29 tashafa: ,(find-doc recur)

15:29 clojurebot: java.lang.Exception: Unable to resolve symbol: recur in this context

15:29 dliebke: ,(doc recur)

15:29 clojurebot: java.lang.Exception: Unable to resolve var: recur in this context

15:29 dliebke: hmm

15:30 replaca: dliebke: recur is special

15:30 dliebke: yeah, but I can run (doc recur) on my system without an exception

15:30 stuhood: http://clojure.org/special_forms#toc10

15:32 replaca: dliebke: and it tells me it's special :). You'll have to ask hiredman why clojurebot has a prob with it

15:32 dliebke: yep, it just says, Please see http://clojure.org/special_forms#recur

15:33 replaca: ,(find-doc "recur")

15:33 clojurebot: ------------------------- clojure.core/loop ([bindings & body]) Macro Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target. ------------------------- clojure.core/trampoline ([f] [f & args]) trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f with

15:34 replaca: tashafa: find-doc takes a string

15:34 hiredman: ,(doc recur)

15:34 clojurebot: java.lang.Exception: Unable to resolve var: recur in this context

15:34 hiredman: *shrug*

15:39 ,(doc if)

15:39 clojurebot: "([tst & etc]); "

15:39 hiredman: ,(doc if*)

15:39 clojurebot: java.lang.Exception: Unable to resolve var: if* in this context

15:39 hiredman: (if*)

15:39 ,(if* nil 1 2)

15:39 clojurebot: 2

15:40 cp2: hrm?

15:40 hiredman: clojurebot's doc lookup doesn't handle special forms

15:40 (I guess)

15:41 tashafa: replaca: thanks

15:41 Chousuke: ~source if

15:42 ah, right, the lazy seq thing.

15:42 hiredman: Yeah

15:49 replaca: hiredman: can you do source straight into contrib now?

15:51 hiredman: replaca: I, uh, no

15:51 replaca: :-)

15:52 hiredman: `any blockers or just hasn't gotten to the top of the list?

15:53 hiredman: no blockers, just got pushed back

15:53 replaca: ok

16:00 cemerick: has anyone seen a couchdb wrapper yet?

16:01 danlarkin: cemerick: I have started one

16:01 replaca: danlarkin: make sure it has lots of pron!

16:02 danlarkin: d'oh, I knew it was missing something

16:03 replaca: danlarkin: if it's good for Ruby, Clojure should have it too

16:03 cemerick: danlarkin: we're thinking of using couchdb. if/when you've got something on github, we'll be happy to bang on it. Which java driver are you wrapping?

16:04 danlarkin: cemerick: no java driver, just using clojure-http-client (which hopefully soon becomes clojure.contrib.http.client)

16:05 jwinter: this one? http://github.com/technomancy/clojure-http-client/tree/master

16:06 danlarkin: jwinter: yes

16:22 hiredman: ~def file

16:22 is there a function with the same name in multiple contrib namespaces?

16:24 kotarak: I think, one was renamed to file-str.

16:24 maybe duck-streams and java-utils?

16:25 hiredman: I am just looking for a function with the same name so I can see how it looks when clojurebot encounters it

16:25 it should just give multiple urls, but I would like to test it

16:27 kotarak: Isn't there also something in clojure.set? replace or something? I vaguely remember some clash there...

16:27 durka42: ~def next

16:28 ~defn zip/next

16:28 clojurebot: I don't understand.

16:28 durka42: ~def zip/next

16:28 ~def clojure.zip/next

16:29 hiredman: well thats not contrib

16:30 durka42: true

16:32 hiredman: but anyway, clojurebot does contrib source lookups now

16:32 ~def add

17:02 hoeck: chrizel: regarding your slime-thread-printing problem, its solveable by binding *out* in each thread to the value of *out* slime uses

17:02 chrizel: or use a custom println function

17:02 lisppaste8: hoeck pasted "slime-println" at http://paste.lisp.org/display/79852

17:03 kotarak: hoeck: Hi. I pushed the changes to the lazymap repo. Since I had to do some changes you will get a new head when pulling...

17:03 benatkin: ~def import

17:04 hoeck: kotarak: well, now I know that there is a rebase command :)

17:04 kotarak: hoeck: :) I'm not sure it helps in this case. ;)

17:08 chrizel: hoeck, thanks

17:18 kotarak: ,(doc repeatedly)

17:18 clojurebot: "([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it"

17:26 replaca: ~def pprint

17:26 hiredman: nice!

17:32 def ~conj

17:32 ~def conj

17:33 technomancy: o O ( google code doesn't support syntax highlighting on clojure, but github does? )

17:34 replaca: hiredman: there aren't any dups in contrib (from my quick scan) but there are some funcs (in generic.collections) that "override" core funcs

17:34 hiredman: like conj above

17:35 hiredman: right now I have it fallback, if it cannot find a symbol in core, look in contrib

17:36 replaca: hiredman: makes sense - the contrib version might just confuse folks

18:15 hiredman: another idea: maybe for contrib you should prefix the var with the ns and then we could look at contrib in addition to core and it would be "obvious"

18:16 hiredman: possible

18:17 I don't want to touch the source lookup stuff anymore unless I set aside time to refactor

18:17 replaca: easy for me to say! :-)

18:23 eyeris: I think I've configured clojure-mode and swank-clojure properly, but I must have made a mistake because I am not getting syntax coloring. Could someone take a look at my .emacs file? (I am super new to emacs) http://pastebin.ca/1415781

18:23 clojure-mode.el is in my .emacs.d. This is emacs 23

18:24 ctdean: If you say M-x font-lock-mode in a .clj buffer, what happens?

18:25 eyeris: It says Font-Lock mode disabled

18:25 Doing it again enables.

18:25 ctdean: cool, at least that is working right

18:26 technomancy: eyeris: if you're new to Emacs I'd recommend using the Emacs Starter Kit, installing clojure-mode via ELPA, and then using M-x clojure-install

18:26 that should handle all the tricky bits for you

18:27 eyeris: I tried using clojure-install last night. I thought it worked when I was using emacs-gtk but now I am working remotely, over a text terminal.

18:28 technomancy: eyeris: clojure-install will set up communication with a clojure subprocess; it doesn't affect things like syntax highlighting

18:28 that's just clojure-mode by itself

18:28 eyeris: Okay, well then clojure-install won't help me because I want clojure-mode to give me highlighting

18:29 I don't know what this ELPA is.

18:29 technomancy: eyeris: ELPA is a package manager for elisp

18:30 eyeris: what does M-: major-mode RET show in the minibuffer if you do it from your .clj file?

18:31 eyeris: fundamental-mode

18:32 ctdean: well, that's not right

18:33 Try M-x clojure-mode

18:33 eyeris: I just used the ELPA to install it and now it works.

18:33 ctdean: great!

18:34 eyeris: Is there a way to make the M-x buffer history persist between executions?

18:35 ctdean: Don't know

18:35 technomancy: eyeris: probably; you could search emacswiki.org

18:36 in general it's not that helpful if you've got Emacs sessions that last weeks

18:43 eyeris: quit

19:04 technomancy: hiredman: there's a third clojure user in Seattle now. exciting times.

19:05 * technomancy is outnumbered by Kevins

19:39 eee: i have, maybe, a weird question: is there a way to make something equal nothing?

19:39 what I mean

19:39 is

19:39 [nil 'a]

19:39 ,[nil 'a]

19:39 clojurebot: [nil a]

19:39 eee: isn't quite right

19:39 danlarkin: whoah, another clojure user in Albany... small world!

19:40 eee: i want to say that under some condition, a variable is nothing

19:40 then when you do [nothing a] .... you get [a]

19:41 same as if you concat "" to "hello world", you get "hello world"

19:41 ,[,'() 'a]

19:41 clojurebot: [() a]

19:41 danlarkin: eee: no

19:41 technomancy: eee: you could use binding on =, but that would break things horribly

19:42 ctdean_: You want to pass two arguments to a vector and have it the size of the vector be 1?

19:42 hiredman: eee: use if

19:42 (if a (conj b a) b)

19:43 eee: i want to say, "let foo equal (if such and such [adfasdf] else nothing)"

19:43 hiredman: ,(let [a nil b [1]] (if a (conj b a) b))

19:43 clojurebot: [1]

19:43 hiredman: ,(let [a 2 b [1]] (if a (conj b a) b))

19:43 clojurebot: [1 2]

19:44 hiredman: nil is nothing

19:44 well

19:44 lisppaste8: eee pasted "need to check previous state in history" at http://paste.lisp.org/display/79862

19:44 hiredman: nil has the semantics of "nothing" if you ever want "nothing" to be useful

19:45 eee: my problem

19:46 is that my history gets previous transitions

19:46 added again

19:46 I only want option1, say, if I the history doesn't already have option1

19:47 i could put the if statements all over the place below the let, too

19:47 hiredman: (if (-> history (.conatins option1)) ...

19:48 eee: ahh

19:48 actually (first option1)

19:49 since option1 is a new history

19:49 option1 and option3 are alternative realities

19:49 of the whole new history

19:49 after the transition

19:49 hiredman: (if (-> history first (.conatins option1)) ...

19:50 eee: (if (-> history (.conatins first(option1)))

19:50 not that?

19:51 so in the case statements

19:52 where I have [option1 option3]

19:53 i'd have [(if ..... option1 ()) [(if ......]

19:53 and I'd have the same problem

19:53 the possibility of having

19:53 [nil nil]

19:53 or at least

19:53 [nil aasdfasdf]

19:53 so then i'd need to stop out all the nills

19:54 nils

19:54 ahhhh filter

19:54 ,(filter #(= nil %1) [nil])

19:54 clojurebot: (nil)

19:55 eee: ,(filter #(not= nil %1) [nil])

19:55 clojurebot: ()

19:55 eee: cool

19:55 opposite of filter?

19:59 (doc keep)

19:59 clojurebot: I don't understand.

20:00 durka42: i believe #(not= nil %1) is identity

20:00 and the opposite of (filter whatever coll) is (filter (complement whatever) coll)

20:00 eee: i've seen it

20:01 someone has, like 'keep or somthing

20:01 durka42: maybe something in seq-utils?

20:02 apparently not

20:02 Chousuke: or (remove whatever coll)?

20:02 eee: that'd be cool, too

20:03 Chousuke: ,(remove identity [nil 1 2 3 nil])

20:03 clojurebot: (nil nil)

20:03 eee: ,(remove nil [nil 5 6 nil 7])

20:03 clojurebot: java.lang.NullPointerException

20:03 Chousuke: hmm

20:03 opposite of what I wnated

20:03 eee: ,(remove 'nil [nil 5 6 nil 7])

20:03 clojurebot: java.lang.NullPointerException

20:03 Chousuke: ,(remove nil? [nil 1 2 3 nil])

20:03 clojurebot: (1 2 3)

20:03 Chousuke: eee: it must be a predicate

20:03 eee: ,(remove nil? [nil 5 6 nil 7])

20:03 clojurebot: (5 6 7)

20:03 eee: sweet

20:03 * durka42 notes that (defn remove [pred coll] (filter (complement pred) coll))

20:03 Chousuke: :)

20:04 eee: :)

20:05 Chousuke: ,(= 'nil nil); hmm

20:05 clojurebot: true

20:06 eee: i found an old conversation in here where you guys already told me 'compliment'

20:06 Chousuke: ,(symbol "nil") ; this would fool people

20:06 clojurebot: nil

20:06 eee: i don't even remember, but google does

20:06 sorry to rehash

20:06 Chousuke: don't worry.

20:06 I forgot complement exists, too

20:07 eee: ,(remove-if #(nil? %1) [nil 5 6 nil 7])

20:07 clojurebot: java.lang.Exception: Unable to resolve symbol: remove-if in this context

20:07 Chousuke: it's just remove :)

20:08 also #(nil? %1) == nil?

20:11 reminds me... I had to code a bit of perl earlier, and it was quite painful.

20:11 I haven't used perl before, and I kept trying to do clojurey things

20:12 perl has map and such but it's... weird.

20:14 eee: ,(remove nil? [nil 5 6 nil 7])

20:14 clojurebot: (5 6 7)

20:14 eee: dang turned into a list

20:14 Chousuke: a seq

20:14 gnuvince_: seq

20:14 Chousuke: it's lazy

20:14 eee: ,(vector (remove nil? [nil 5 6 nil 7]))

20:14 clojurebot: [(5 6 7)]

20:14 eee: dang

20:14 gnuvince_: vec

20:14 Chousuke: (into [] (remove nil? [nil 3 4 nil])); not lazy

20:15 gnuvince_: ,(vec (remove nil? [nil 5 6 nil 7]))

20:15 clojurebot: [5 6 7]

20:15 eee: ,(into [] (remove nil? [nil 5 6 nil 7]))

20:15 Chousuke: ,(into [] (remove nil? [nil 3 4 nil])); I am lazy

20:15 clojurebot: [3 4]

20:15 [5 6 7]

20:15 Chousuke: I think into [] looks nicer than "vec"

20:15 I wonder if they perform the same too

20:16 eee: vec is right but vector is wrong

20:16 wow

20:16 Chousuke: vec is short for apply vector

20:16 gnuvince_: vec turns a seq into a vector

20:16 eee: i would agree that into [] is more descriptive

20:16 gnuvince_: vector takes its arguments and yields a vector

20:17 eee: and self documenting etc

20:17 Chousuke: ,(time (dotimes [i 100000] (into [] (take 100 (iterate inc 0))))

20:17 clojurebot: EOF while reading

20:17 Chousuke: ,(time (dotimes [i 100000] (into [] (take 100 (iterate inc 0)))))

20:17 hmm

20:18 clojurebot: Execution Timed Out

20:18 Chousuke: too much :(

20:18 ,(time (dotimes [i 10000] (into [] (take 100 (iterate inc 0)))))

20:18 clojurebot: "Elapsed time: 843.441 msecs"

20:18 Chousuke: ,(time (dotimes [i 10000] (vec (take 100 (iterate inc 0)))))

20:18 clojurebot: "Elapsed time: 651.112 msecs"

20:19 durka42: it looks like vec punts to java so that isn't so surprising

20:19 lisppaste8: eee pasted "train wreck transition function" at http://paste.lisp.org/display/79866

20:20 eee: doesn't work now

20:20 error

20:20 durka42: .contains

20:21 eee: it's there

20:21 Chousuke: it says conatins in the code :p

20:21 eee: oh

20:21 i'll search

20:21 cause that's the error, too

20:21 !

20:22 duh

20:25 in some environments that people have, can you actually step though the code and also stop where breaks occur like in common lisp?

20:25 cause I gotta null ptr ex somewhere

20:26 i wonder ...

20:27 ,(-> [] (.contains 'a)

20:27 clojurebot: EOF while reading

20:27 eee: ,(-> [] (.contains 'a))

20:27 clojurebot: false

20:28 eee: ,(-> [a] (.contains []))

20:28 clojurebot: java.lang.Exception: Unable to resolve symbol: a in this context

20:28 eee: ,(-> ['a] (.contains []))

20:28 clojurebot: false

20:30 durka42: eee: i don't know about stepping through (maybe a java debugger) but you can easily get stacktraces

20:32 eee: i gotta run in some other environment I think

20:32 clojure-dev ain't got that

20:34 Raynes: Clojure-dev still doesn't have autoidentation :\

20:35 eee: true

20:35 but color parens is nice

20:35 durka42: vimclojure does :)

20:36 eee: i never got all the vay to setting that up

20:36 i like vim

20:37 i use a somewhat old mac with tigre

20:37 tiger

20:37 and a broken "port" configuration

20:37 durka42: heh

20:37 * durka42 has a macbook

20:37 durka42: i use vimclojure with macvim

20:37 eee: and vim does have the stack trace?

20:38 clojurebot: Gesundheit!

20:38 eee: is yours tiger?

20:38 durka42: em

20:38 leopard i think

20:38 10.5 is leopard, yes?

20:38 you can have stacktraces anywhere

20:38 eee: ye

20:38 so i can't get it

20:38 durka42: the repl binds *e to the last exception, like *1

20:38 eee: from you

20:39 nice

20:39 guess I'll work on that

20:39 durka42: also contrib.stacktrace

20:39 eee: ok

20:40 guess i gotta go for a few

20:40 thanks for the help, as always

20:49 found problem

20:50 if result was swapped with else

20:50 or contains logic backwards

20:50 :)

21:04 i just realized how to parallelize this a-star search

21:41 Victorr: hi, does clojure read some .file in the home directory by default?

21:42 I'm looking for a place to put some handy repl functions...

21:44 dliebke_: it looks for files on the classpath

21:45 Victorr: dliebke_, I want clojure to automatically (use) this file

21:45 eee: the (use) thing is at the clojure level but

21:46 the way I look at it

21:46 clojure is a java program

21:46 or at least a jvm program

21:46 a universe inside a universe

21:47 so (use) is in the inner universe. but that universe has a classpath

21:47 dliebke_: you can create a user.clj that will be called automatically when the repl starts up

21:47 eee: oh I see

21:47 interesting

21:48 Victorr: that is what I need, will it get loaded if it is in the classpath, or do I need to put it somewhere

21:48 dliebke_: it just needs to be on the classpath

21:48 Victorr: thanks dliebke_!

21:54 dliebke_, user.clj works when I launch the repl from the command line, but not from slime, would you happen to know how to make it work?

21:54 dliebke_: unfortunately, I don't use slime. sorry :(

21:55 Victorr: np, thanks

22:27 memoize: what's the difference between cons and list* ?

22:27 stuhood: ,(doc list*)

22:27 clojurebot: "([item & more]); Creates a new list containing the item prepended to more."

22:28 stuhood: ,(doc cons)

22:28 clojurebot: "([x seq]); Returns a new seq where x is the first element and seq is the rest."

22:28 stuhood: list versus sequence...

22:28 memoize: oh!

22:28 stuhood: they both probably implement the same java interfaces, but they have different base classes

22:28 memoize: too subtle for me right now

22:29 stuhood: ASeq vs PersistentList

22:30 memoize: (cons 1 [2]) and (list* 1 [2]) return a Cons object, when I use (class) on them

22:34 list* is cons passed to a private function spread; i'm not sure what spread does

22:35 durka42: ~def clojure.core/spread

22:35 it looks like it walks the list re-consing it

22:38 memoize: when would i use list* over cons? i'll look at how core uses list*

22:39 durka42: i think the functions ending in * are generally not intended to be used at all

22:40 memoize: i'll take that advice and move on, thanks

22:41 durka42: it seems like core only uses it before things that would avoid are defined

22:41 but i don't know my way around core

22:49 Victorr: ,(list* 1 2 [3])

22:49 clojurebot: (1 2 3)

22:49 Victorr: memoize, that is the difference between it and cons

22:49 ,(cons 1 2 [3])

22:49 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$cons

22:50 Victorr: durka42, I'm not sure about your comment that "functions ending in * are generally not intended to be used at all"

22:50 for some functions, it means something akin to "act on many" (or at least it does for Scheme)

22:51 durka42: well, thinks like fn* and if* that are even more special than special forms

22:51 in scheme and CL, i agree, but i don't think it's a common naming scheme in clojure

22:51 Victorr: ,(doc if*)

22:51 clojurebot: java.lang.Exception: Unable to resolve var: if* in this context

22:52 Victorr: ok, but list* at least seems to follow that rule

22:56 hiredman: generally let* is a special form and let is a macro that uses let*

22:57 memoize: Victorr: thanks, i didnt read the functional sigs carefully

23:04 Victorr: memoize, glad to be of help. In general, I find that the docs for functions suck

23:06 I wonder if Rich requires a licensing agreement before sending patches for documentation..

23:08 memoize: im going through core, grouping functions, distinguishing when to use this or that, giving practical examples

23:08 Victorr: docs be part of the code, so yeah

23:18 durka42: memoize: that sounds very useful

23:18 see also:

23:18 ~examples

23:18 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

23:26 Victorr: memoize, that looks very good. I think it would be even more useful if it was part of the documentation of functions in the source code. If you want to do that, I would be happy to help

23:27 Drakeson`: is there a book on clojure that does not assume you already know java?

23:30 hiredman: java is not that hard to pick up, knowing some is good because you will want to wade through javadocs

23:33 Drakeson: hiredman: I happen to know some lisp, so it is irritating to "think in java". I guess it would be great if there is a book/document that starts by assuming no knowledge of java.

23:34 many people don't know java, afterall

23:36 hiredman: if thinking in java is not something you want to do, then don't

23:37 but learn a little java

23:39 Drakeson: Is it possible to teach someone clojure as their _first_ programming language?

23:39 (that's what I want to try to do)

23:39 hiredman: sure

23:41 danlarkin: I always thought lisp would make a great first programming language

23:41 hiredman: yeah

23:41 I mean lisp + functional = super simple

23:41 danlarkin: totally

23:42 Drakeson: danlarkin: you are not the only one :) scheme had been tought as the first prog lang in MIT for ages.

23:42 hiredman: but clojure has a lot of rather advanced features that, uh, would not go over well with a new programmer

23:42 all that emphasis on concurrency

23:43 Drakeson: hiredman: that's simple. You don't go over advanced features when you teach to a new pupil.

23:43 durka42: yeah you can leave those out for a while

23:43 and then, BAM! look at pmap

23:44 Drakeson: You can always see how much they can grasp, and slow down or speed up accordingly.

23:45 Now my question: Is there a Clojure book suited for "programming newbies"?

23:45 hiredman: there is only one clojure book

23:45 there will be more in the future

23:45 but now there is only one

23:46 durka42: one book to rule them all

23:46 Drakeson: I haven't read that, does he really assume Java knowledge? Is the book usable for newbies?

23:46 hiredman: many mountains, one volcano

23:47 I haven't read it

Logging service provided by n01se.net