#clojure log - Aug 09 2010

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

0:00 jetlag: (#{true} x)

0:02 arbscht: or is arguably more idiomatic though, at least in lisps. I think a variation of it goes by the name of "elvis operator" in other languages

1:07 lalanick: hi

1:08 i tried for hour now to get the following enum into clojure:

1:08 http://www.jmonkeyengine.com/doc/com/jme/app/AbstractGame.ConfigShowMode.html

1:08 but it just wount work, nested protected generic ...

1:08 anyone has an idea?

1:09 arbscht: lalanick: what have you tried and what was the error?

1:10 lalanick: 1 sek

1:12 AbstractGame$ConfigShowMode/AlwaysShow

1:12 but it just wount recognize that its an enum

1:14 once i've imported the enum i can call it with a "slash", is that right?

1:28 arbscht: lalanick: did you import the enum?

3:25 old_sound: hi, which library would you recommend for AMQP and XMPP with clojure?

4:22 defn: old_sound: prolly going to require a java library

4:22 or at least i dont know of a clojure XMPP lib. offhand

4:22 old_sound: I saw a couple that are just wrappers around java libs

4:23 defn: smack?

4:23 old_sound: there's a rabbitmq one, that is just a wrapper around the java client, I think i saw the same for XMPP

4:23 I can't remember

4:23 defn: http://gist.github.com/70695

4:23 ^hiredman's handy work

4:24 old_sound: nice

5:04 defn: old_sound: :)

5:06 notsonerdysunny: what is a good package to help access java-native-interface in clojure?

5:12 ordnungswidrig: notsonerdysunny: that's some double-foreign-language integration :-)

5:17 notsonerdysunny: ordnungswidrig: clojure-jna is an option .. but I wanted to know what others have to say ...

5:18 ordnungswidrig: notsonerdysunny: I have no idea of java and native libs. I remember having tried a java serial io lib ages ago

5:28 LauJensen: Good morning all

5:29 ordnungswidrig: hi LauJensen

5:47 old_sound: good afternoon…

8:47 defn: There's a dichotomy here that is oft forgotten--

8:47 oops

8:52 lpetit: defn: hello, so who's "the jackpot for your preface/foreword" ? :)

8:59 LauJensen: Laurent mon ami! Salut, ca va?

9:02 lpetit: LauJensen: hello dear :)

9:05 defn: lpetit: I think you have the wrong person :)

9:05 lpetit: do you mean fogus or chouser?

9:06 lpetit: defn: Yes, I keep doing the same error, mistaking you and fogus*

9:06 defn: sorry, buddy

9:07 defn: lpetit: no problem -- im happy to be mistaken for fogus

9:07 ;F

9:08 lpetit: defn: anyway, has the name of the preface/foreword of JOC been revealed ? :)

9:09 defn: lpetit: not to my knowledge! I didn't know it was a tantalizing topic.

9:09 lpetit: defn: I'm over emphasing things sometimes :)

9:09 defn: Foreword (to be announced)

9:10 They should name it "On Madison Square Clabango..."

9:11 and talk about the history of Clojure, the real life characters behind it.

9:11 chouser: that particular topic cannot be over emphasised.

9:11 well, perhaps it can, but it's still pretty incredible. I'm stoked.

9:11 defn: First part joking, second part serious.

9:12 lpetit: chouser: what a buzz :)

9:12 chouser: :-)

9:13 defn: chouser: I know you guys are wrapping up, but FWIW I'm really a fan of you, fogus, etc. (see: http://clojure.org/contributing)

9:13 Fogus has been doing his (take ...) which I really have enjoyed

9:14 It would be nice to know your histories as well-- Coders at Work, but clojure-centric.

9:14 chouser: we were each interviewed recently -- did you see those?

9:14 lpetit: chouser: let's start a guessing game ?

9:14 chouser: not much detail I guess.

9:15 lpetit: you can guess, but I don't think I can confirm or deny anything.

9:15 lpetit: chouser: I like to play. And I'm not afraid of loosing :-)

9:15 chouser: if it were for Rich himself, you would be very pleased and honored, but not stucked.

9:15 chouser: so I think it's not Rich

9:16 LauJensen: I wouldn't be surprised if it was Bill Joy :)

9:16 lpetit: chouser: to be stuck is something. Could it be the father of Lisp himself ?

9:17 * lpetit can imagine chouser giggling and refraining from either confirming or denying :-)

9:17 chouser: :-)

9:18 defn: chouser: yeah, not enough content :) I'm interested in sort of the evolution of how people come to be programmers, what the germ of the whole idea is for them...

9:19 chouser: defn: well, Coders at Work is all interviews, right? All you need is an interviewer who will ask *exactly* the questions you want asked. hm, who would that be....

9:19 _na_ka_na_: hey guys, is there something like jdepend for Clojure ?

9:20 chouser: defn: but I do think fogus isn't done with the "take n" interviews yet. I've enjoyed them so far.

9:20 _na_ka_na_: which produces dependency metrics / etc

9:21 well mostly I just want a pretty graph of namespace dependencies for my project

9:21 any ideas ?

9:21 defn: http://github.com/gcv/dgraph

9:23 maybe not what you want...

9:24 _na_ka_na_: ya, I looked at that, its not

9:24 I tried jdepend, but it doesn't work for clojure

9:24 I'll write a small script myself - just wanted to check if there's already something similar

9:24 defn: you want a graph of all your uses and requires, yes? not the underlying java impl?

9:24 _na_ka_na_: yup

9:25 defn: yeah I think that'd be a good project actually

9:25 _na_ka_na_: I'll dump an xml file, then convert into a .dot file .. then into an image

9:25 defn: is .dot graphviz??

9:25 er no that's .viz i think

9:26 chouser: .dot is graphviz

9:27 _na_ka_na_: graphviz

9:32 defn: _na_ka_na_: if you write that please share. clojure.contrib.graph looks a little less scary and could be helpful i think

9:33 _na_ka_na_: defn: definitely

9:33 spariev: _na_ka_na_: have you tried this - http://github.com/hugoduncan/lein-namespace-depends

9:34 _na_ka_na_: spariev: wow thanks, i'll try

9:35 spariev: _na_ka_na_ : np, just found it in my watched repos list )

9:36 LauJensen: hey javascript gurus - whats the idiomatic js fn to validate a format like hh:mm ? like a js version of scanf

9:46 so few javascript gurus in #clojure :|

9:47 ordnungswidrig: LauJensen: i think the idiomatic form would be a regex

9:47 LauJensen: ordnungswidrig: yea thats what I would go with if everybody was mute :)

9:48 ordnungswidrig: LauJensen: "12:34".matches(/^\d\d:\d/d$/) reads idiomatic for me

9:48 LauJensen: Yea ok.. I just dont like regex :)

9:50 ordnungswidrig: LauJensen: a powerful tool when used wisely

9:50 LauJensen: ordnungswidrig: yea, like the dirty bomb of programming

9:50 ordnungswidrig: LauJensen: dirty bomb?

9:51 LauJensen: ordnungswidrig: I think its a term used about suitcase nukes

9:51 lpetit: LauJensen: place the right level of indirection so that all your regex are clearly separeted from the rest of your code

9:52 LauJensen: lpetit: the guys at the first conj labs actually wrote a regex DSL, where native Clojure data compiled to regexs - was very cool

9:52 ordnungswidrig: LauJensen: I see

9:52 LauJensen: …which wouldn't be a very compact DSL compared to regex.

9:53 lpetit: LauJensen: yes, I've heard of that

9:53 ordnungswidrig: If you know your regexen well, you read it like code

9:53 LauJensen: ordnungswidrig: no of course you dont do that aiming for compactness, but aiming to learn how to wield protocols effeciently :)

9:53 ordnungswidrig: …up to a certain level of complexity

9:53 defn: ordnungswidrig: content is important

9:53 context*

9:53 ordnungswidrig: ah, you beat me to it

9:53 ordnungswidrig: LauJensen: or if you have to generate regexen at runtime

9:54 (whoever want to do this) I mean, like generating SQL

9:54 LauJensen: ordnungswidrig: yea, I was just telling you the motivation for doing that lab at Conj Labs

9:54 lpetit: LauJensen: how related is this to your initial question ?

9:55 LauJensen: Its not

9:55 lpetit: do you consider your initial question answered ?

9:55 ordnungswidrig: LauJensen: back to your question: you could use the clojure-to-js compiler to build some verification code

9:56 LauJensen: lpetit: Not if you have a better one :)

9:56 lpetit: I don't think js cross-browser libraries place an abstraction level over that.

9:57 ordnungswidrig: Is there something like dateformat / simpledateformat as js lib?

9:57 LauJensen: ordnungswidrig: What you pasted dindn't fly in Chromes JS repl, this returns null "57:55".match("/[0-9][0-9]:[0-9][0-9]/");, as did it with \d - any idea whats up ?

9:58 ordnungswidrig: You can (must?) omit the string quoting of the regex. /../ is a js literal for regex

9:58 ff konsole wouldn't match on "/xxx/" but only /xxx/

9:59 javascript reader magic :)

9:59 LauJensen: ordnungswidrig: without the string, it wouldnt eval

10:00 ordnungswidrig: "57:55".match(/[0-9][0-9]:[0-9][0-9]/)

10:00 Evals in my chrome js console

10:01 LauJensen: that works here as well, s/matches/match

10:02 ordnungswidrig: Oh there was a typo in my intial paste: /d instead of \d

10:02 LauJensen: yea I noticed, but thanks for the tip

10:03 lpetit: btw, IIRC you keep up with Chrome, is that an emacs bindings plugin for it yet ?

10:03 lpetit: LauJensen: ??

10:04 ordnungswidrig: LauJensen: I use vimium for chrome which is nice if you know your vi bindings

10:05 LauJensen: well, i dont :)

10:05 I use Conkeror

10:07 edbond: Did someone use http://projectfortress.sun.com/Projects/Community/ ? The guy wants to do parallel calculations from java, choosing fortress vs clojure.

10:07 ordnungswidrig: LauJensen: Conkeror looks nice

10:07 LauJensen: ordnungswidrig: Yea Ive been very happy with it

10:08 ordnungswidrig: fortress is weird stuff

10:09 LauJensen: edbond: Ive heard a lot about fortress, spoke with one of the guys working on it, but never used it. It doesnt have the same ambitions as Clojure exactly

10:09 ordnungswidrig: regarding syntax it's like the opposite of sexp and homoiconicity

10:09 (did anybody say APL?)

10:09 LauJensen: ordnungswidrig: nope, nobody said APL

10:10 But Im not sure that Fortress has much pratical application yet? Last time I heard it was still just for research

10:13 ordnungswidrig: LauJensen: that was my impression, too

10:14 LauJensen: they throw in a lot of non-mainstream concepts, like "free', adjustable syntax, parallelsim, stm or tx at a language level

10:16 LauJensen: To me there are really 2 worlds, Clojure and the rest. I went to a lecture with one of the top dogs from Java, who had examed Java, Scheme, JavaFX, Fortress and many others. And concluded that when looking at a function definition it was unclear exactly what was going on, so the solution was to invent a new language for 'annotations', which would go into Java, so I could do String name @for user names in GUI@ = "Frank". And everybody

10:16 would know what that string was for. I didn't want to embark on telling me that perhaps a more concise and expressive programming language was the way to go, so I just waited it out :)

10:16 'telling him'

10:21 ordnungswidrig: I think it's from the chapter on macros in "Practical Common Lisp": my favorite Lisp quote "an abstraction emerges"

10:21 Isn't this the essence of programming? Building abstractions (and know when to stop)

10:21 LauJensen: Well, that an Emacs

10:24 ordnungswidrig: LauJensen: well, you might be right.

10:24 LauJensen: I'm a bad judge, as I use viper-mode

10:25 LauJensen: Yea - The thing that got me hooked on Lisp was the idea of transforming a humans thought into that of a computers, and making that process as direct as possible

10:25 I was very aware, that in C# the route was very very indirect

10:25 Of course much more goes into development, but on the personal level its a huge driver

10:26 ordnungswidrig: I'm program in java for a living at the moment. And it feels so… so much "ceremony" and "protocol"

10:29 s/m i/mming i/

10:29 sexpbot: I'm programming in java for a living at the moment. And it feels so… so much "ceremony" and "protocol"

10:29 ordnungswidrig: uh, nice

10:29 sexpbot is a rexegbot

11:28 Bahman: Hi all!

11:31 chouser: hi

11:37 LauJensen: Does anybody have a one-liner floating around, for pulling out a field containing seconds in integer, as hh:mm from a mysql db ?

11:39 pdk: so you want the seconds out of a hh:mm:ss formatted string

11:39 LauJensen: no, I have an integer like '7200' and I want and SQL statement which returns 02:00

11:42 raek: I really like the chapter on functional programming in The Joy of Clojure

11:51 LauJensen: SELECT SEC_TO_TIME(time) FROM table => seconds to hh:mm:ss

11:54 pdk: raek given how tjoc has come along so far would you say that it'd be a worthy purchase for someone who's already got practical clojure

11:54 pclj at times seems to be closer to a pocket reference

12:02 (doc case)

12:02 clojurebot: "([e & clauses]); Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result-expr (test-constant1 ... test-constantN) result-expr The test-constants are not evaluated. They must be compile-time literals, and need not be quoted. If the expression is equal to a test-constant, the corresponding result-expr is returned. A single default expression can follow the clauses, and its va

12:02 pdk: (doc sort)

12:02 clojurebot: "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."

12:13 raek: pdk, I haven't read practical clojure, but I guess so, yes. for me, it has been a "ok, I get clojure. I wanna learn more" kind of book

12:13 if that was of any help

12:14 pdk: thatd be good

12:14 the macro chapter in pclj for example just gives you the syntax and 2 example usages

12:16 raek: ok, JoC is more, well, "passionate" about the things it includes

12:19 pdelgallego: Hi, can anyone point me to a good configuration of emacs and clojure? I am looking for somthing more advance that the getting starter

12:22 pdk: pdelgallego most folks use slime/swank with emacs/clojure

12:23 you could ask someone here on *nix how to set it up on those systems but if you're on windows you can download it all packaged together, just google clojure box

12:24 pdelgallego: pdk, I read about swank. I am on a linux box.

12:24 pdk: hmm

12:24 i couldn't tell you first hand how to set it all up on *nix but a lot of folks here can

12:25 just need to wake em up :p

12:25 pdelgallego: ok, I was wondering if there was any other option before install it

12:26 pdk: probably just slime though it seems slime/swank work together

12:26 pdelgallego: pdk, Do you use emacs ? or any other option?

12:27 pdk: just gvim + vimclojure right now since for the moment i wanted something i could more or less use like a regular text editor but still with proper lisp indentation

12:29 pdelgallego: pdk to build the project do you use leiningen? this looks like a lot of new tools to learn.

12:29 pdk: i haven't really looked into leiningen/maven/cake etc since i havent started a major project yet :p

12:30 again therell be plenty of users of those in here

12:36 LauJensen: Is there a lot of people using cake?

12:43 pdk: there's a github repository for cake

12:43 clojars.org has some stuff to make it easier to pull stuff from it through leiningen/maven

12:45 LauJensen: pdk: Yea I know, Ive heard of cake, just not heard of anybody using it

12:45 Would be great if somebody would blog a little about it

12:46 hmm, guess I could do that, if its awesome enough :)

12:56 Do people still hook into apache.commons.fileupload for handling fileuploads with ring?

13:06 ordnungswidrig: anybody used http://nestedvm.ibex.org/

13:06 with clojure?

13:18 tridd3ll: pdelgallego: saw your comment before in the log... this might help if you're looking for a tutorial on a linux setup: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

13:21 danlarkin: pdelgallego: it can be a little easier than that if you use ELPA

13:23 mebaran151: I have a quick little patch for clojure.contrib to fetch generated keys along with a query using the JDBC interface. How can I submit this?

13:23 danlarkin: also there's not really a need to clone clojure or contrib if you're gonna make them leiningen dependencies

13:27 technomancy: danlarkin: but that's too easy; it can't be right.

13:27 the longer the instructions, the more likely they are to be accurate! QED.

13:28 danlarkin:

13:28 that's unicode END OF PROOF

13:28 technomancy: well done.

13:28 LauJensen: I think you guys need a break :)

13:32 mebaran151: I'm also having a strange emacs wherein fn becomes a strange pink looking f

13:32 danlarkin: mebaran151: for that you can blame technomancy :)

13:32 mebaran151: oh

13:33 anyway to disable it

13:33 just makes it harder for me to scan

13:33 I often name varables that hold functions f

13:33 technomancy: contact your healthcare provider if redness or itchiness symptoms appear in your closures.

13:33 mebaran151: hahaha

13:34 I mean it's a cute trick (as my coworkers would so very very kawaii)

13:34 *so => say

13:34 technomancy: comment out a form near the end of starter-kit-lisp.el with font-lock-add-keywords

13:34 * technomancy should make that a hook so it's easier to remove

13:40 mebaran151: ah alright

13:40 see it only sometimes does it

13:40 sometimes I get a pink f with no n

13:40 sometimes I get fancy pink f with no n

13:41 sometimes I get a fancy black f with an n

13:52 dpro: hi

13:53 chouser: dpro: hi

13:53 dpro: I'm tearing my hair out over failing dependencies when trying to get lein swank to work

13:53 always complains about a missing org.apache.maven:super-pom:jar:2.0 artifact

13:54 tried different version numbers in the project config, lein stable/devel ... same

13:55 tridd3ll: technomancy, danlarkin: ok, you win, I won't point another person at my pointless tutorials... I'm obviously doing it all wrong

13:55 mebaran151: thanks technomancy

13:56 where's the best place to get writeup about deftype: I'm porting some old code

13:56 danlarkin: tridd3ll: no need to be defensive :-/ we're on the same team

13:56 mebaran151: and I thought it might be useful to combine two deftypes into one

13:57 say I had a a deftype that did Add and Substract and another that implemented multiply and divide and I wanted to make a type called say SimpleArithmetic that used both

13:58 LauJensen: tridd3ll: I think your tutorial covers a lot of ground, keep up the good work.. please :)

13:58 mebaran151: I know I'd probably have two protocols and maybe even a third protocol called Field that represented the combination of all these different method signatures

13:59 basically, I don't know how you combine and inherit types and protocols

14:01 hiredman: you don't

14:01 (inherit)

14:02 tridd3ll: danlarkin: sorry to be defensive, but not everyone uses ELPA, or is an expert on git, maven, etc. and it does demonstrate both command line and emacs integration... and it gets old to have to explain that every time given the comments that follow every mention of this approach

14:03 danlarkin: tridd3ll: forgive my naïveté

14:04 your tutorial is better than mine! (ie. no tutorial)

14:04 technomancy: tridd3ll: those tutorials are good for people who need to install manually for some reason. that just seems like a special case to me.

14:05 tridd3ll: danlarkin: :-)

14:05 lpetit: Hello all

14:05 I've questions on how to enhance a code that's using clojure zippers

14:07 mebaran151: hiredman, how do you combine then?

14:07 lpetit: Here's the problem: I've a datastructure that follows xml-zip conventions: :tag and :content keys. I use this for representing the parse tree some source code (okay, it's some clojure file source code)

14:07 mebaran151: or am I sort of not getting the point of the protocol work at all

14:09 tridd3ll: technomancy: agreed, I guess I only point it out here and there when I see someone on linux saying they would like help... this method is just the way I go about things, even though sometimes there is technically an easier/faster way (but sometimes with more magic)

14:09 lpetit: Now I have this clever additional keys :count (which gives the size in chars of the node, including the size of subnodes), and :cumulative-children-count (which gives a vector of the cumulative counts of the children of the node: e.g. at some node with a first child of count 4 and a second child of count 6, :cumulative-children-count gives [0 4])

14:10 Problem: I want to leverage my :cumulative-children-count info to be able to go to the loc at a particular offset, by dichotomy, and not by sequentially following the children seqs

14:10 qbg: mebaran151: Why do you want to inherit protocols?

14:10 lpetit: chouser: ^^ I'm pretty sure you've reached the problem before ?

14:11 mebaran151: so my use case is basically this: let's say I'm writing a server that can add different things

14:11 technomancy: tridd3ll: sure; I like it when people help newbies; I just don't want people to be intimidated by the apparent unnecessary complexity.

14:11 tridd3ll: technomancy: it's actually just a exerpt from my personal wiki which I made available on my blog... so I'm not really trying to provide the best/easiest approach for new users

14:11 mebaran151: so my first stab is I design a protocol to add and substract the real numbers

14:12 lpetit: I've some ideas on how to enhance the situation. Basically, this involves adding 2 primitive clojure.zip ops: one for getting the count of a branc loc's children (using count, so could adapt to the underlying data structure of the children: seq or vector ...)

14:12 technomancy: tridd3ll: oh, I see the official instructions are linked now; that should help a lot; thanks.

14:13 mebaran151: and a deftype with the implementation

14:13 tridd3ll: technomancy: right which is why I should probably refrain from pointing it out unless it specifically could help the situation... hard not to though since I provide little other help to others here :-)

14:13 mebaran151: now I want to build a thing that can add substract multiply and divide

14:13 I have an addition substracton deftype and a multiply divide deftype

14:13 lpetit: and the other primitive being a function allowing to jump directly at a given children index (again, if possible, leveraging the datastructure characteristics of the underlying children container)

14:13 Thoughts ?

14:13 tridd3ll: technomancy: since I don't get as much time with clojure as I'd like

14:13 mebaran151: I want to combine them into a math deftype

14:13 how do I do that?

14:14 qbg: mebaran151: What do the deftypes actually represent?

14:14 mebaran151: do I just follow a container pattern and delegate to the original types or is there an easier way

14:14 well in my sytem

14:14 they represent differnt sets of server operations

14:14 and I'd like to combine them to actually represent the fully fledged server

14:15 pdelgallego: technomancy, tridd3ll so how I install swank and make it work with emacs. I use ELPA for other packages.

14:15 tridd3ll: LauJensen: thanks! ... fellow Arch user right?

14:15 qbg: mebaran151: Do you have some example code on how you are using it?

14:15 LauJensen: tridd3ll: thats right

14:15 qbg: It sounds like you are making the problem more difficult than it needs to be

14:15 herdrick: say, is there a (drop-first n seq) somewhere in the libs?

14:16 raek_: drop?

14:16 ,(drop 3 [1 2 3 4 5])

14:16 lpetit: LauJensen: ever used clojure zippers ?

14:16 clojurebot: (4 5)

14:16 pdelgallego: technomancy, If I try to install swank with the cljr it tells me that I an artifact is missing.

14:16 mebaran151: I very well may be

14:16 LauJensen: lpetit: sure - We had a whole lab on them at Conj Labs Brussels :)

14:16 mebaran151: what I'd like is a great simple write up on these new features

14:16 I feel my OOP training is starting to take over a little too much

14:16 herdrick: raek: oh, oops, thanks

14:17 qbg: mebaran151: From what you are describing, it almost sounds like a map of functions might be what you want instead

14:17 lpetit: LauJensen: great, so you probably have an interesting idea / comment / suggestion concerning my above problem ^^^;-)

14:18 mebaran151: qpg, it was previously a map of functions

14:18 but I'd like to more formally document the interface

14:18 tridd3ll: pdelgallego: like we were just speaking of, my approach is pretty specific and doesn't use ELPA at all... if you are going that route, I would follow the documentation with that approach... but I would think you would use leiningen to start the swank server (as outlined in my approach) and then connect to it from emacs (also as outlined.)

14:19 qbg: mebaran151: Exploiting polymorphism is the way to do it

14:19 pdelgallego: ok, tridd3ll Im going to try that.

14:19 dpro: tridd3ll: where can I find "your approach" ?

14:20 LauJensen: lpetit: No, I think your right in seeing that the current zipper implementation isnt geared for it, but the best way to implement it .. hmm

14:20 tridd3ll: dpro: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

14:20 * dpro finds ELPA incredibly messy

14:20 raek_: pdelgallego: it happened to me once that the dependency downloading thingy thinks that some obviosly existing artifacts are missing (for example, clojure). at that time, removing everything in ~/.m2 solved my problem

14:20 LauJensen: ELPA is horrible

14:21 dpro: tridd3ll: cheers

14:21 pdelgallego: LauJensen, I agree with you. I avoid it if I have the option.

14:21 tridd3ll: for the record, I don't use ELPA because I'm more of a control freak about the config side, not because I tried it and didn't like it

14:21 raek_: luckily, it's doable to set up clojure-mode and slime without elpa

14:22 if one detests it...

14:24 tridd3ll: dpro: this really is two different configs though, one for command line repl and then one for emacs... all of the steps are not really required... but it does demonstrate how the different pieces work

14:25 dpro: tridd3ll: ah I *think* I got it working ... just let me check if I can connect from emacs ...

14:25 mebaran151: qpg, what do you mean?

14:26 qbg: mebaran151: Protocols are all about polymorphism

14:26 mebaran151: so there really isn't any idea of implementation inheritance

14:27 or do I just wire it up differently outside of deftype and friends

14:27 dpro: closer, closer ... the repl isn't answering but I'm connected, it complained about a version mismatch but I guess once I fixed that I'm good to go

14:27 mebaran151: dpro, slime always complains about version mismatch

14:27 you can ignore that

14:27 tridd3ll: dpro: I think it always says that

14:28 technomancy: that's a bug in slime; just ignore it. you can setq slime-protocol-version to make it go away.

14:28 qbg: If you need to implement a protocol on multiple types where the implementations are largely the same, you would make use of extend

14:29 But that does not seem like the right solution to me from what I've heard so far

14:29 dpro: ah ok, well now the repl /looks/ fine but it doesn't answer, and even when in clojure-mode C-x C-e evaluates it as elisp ..

14:29 * raek_ tries to figure when #'juxt is useful

14:29 dpro: technomancy: thx

14:30 thunk: dpro: Your repl is hanging? It's probably the slime-autodoc bug. You need to (unload-feature 'slime-autodoc).

14:31 This is getting to be a real problem.

14:31 raek_: ,(let [pop-peek (juxt pop peek) stack [1 2] [stack arg1] (pop-peek stack) [stack arg2] (pop-peek stack)] (conj stack (+ arg1 arg2)))

14:31 clojurebot: [3]

14:33 pdelgallego: raek_, you was write, after cleaning ~/.m2 the problem disappear.

14:33 raek_: great!

14:42 oh, how neat. here the author of juxt eplains its rationale: http://groups.google.com/group/clojure/browse_thread/thread/c960ec89bd0a85ac

14:44 mebaran151: qpg I think I get it now

14:44 thanks

14:45 LauJensen: raek_: theres a lot of good stuff like that on the list, also the story behind reductions

15:01 lpetit: hello, question 'bout the implementation of vectors, w/regards to subvec

15:02 pdk: vectors are implemented as arrays if i recall lpetit

15:02 otherwise theyd be kinda redundant :p

15:02 lpetit: subvec "shares structure" with the initial vector. But is there a chance that over time, parts of the initial vector that are not referenced anymore by subvecs are gcd ?

15:02 pdk: not at all

15:03 qbg: IIRC, it holds a reference to the entire initial vector

15:03 lpetit: pdk: see the very recent (today, yesterday ?) discussion on clojure's l for more info

15:03 qbg: :(

15:03 Nikelandjelo: Is there built in data structure, which allows randomly retrieve and delete elements from it? Vectors and lists doesn't allow to delete random element (as I know), and sets doesn't allow to get random element.

15:04 qbg: Nikelandjelo: maps?

15:04 Nikelandjelo: qbg: How can I get random key in map?

15:05 pdk: step over (keys map) and stop at a random point

15:05 lpetit: qbg: so starting to use subvec in a general way with possibly big datastructures is kind of a recipe for disaster

15:05 qbg: By random do you really mean random?

15:05 Nikelandjelo: qbg: Yes :) like (rand-int ...)

15:05 Chousuke: Nikelandjelo: there is no such data structure, unfortunately

15:05 qbg: lpetit: Yes; as the doc for subvec says, no trimming is done

15:06 pdk: (let [keylist (keys mymap)] (nth keylist (rand-int (count keylist)))) perhaps

15:06 Chousuke: a map with integer keys might work though

15:06 but it has a fair bit of overhead :P

15:06 lpetit: qbg: chouse Oh chouser, when will your finger tree be ready ? :-)

15:06 pdk: what's the scoop on this finger tree

15:09 qbg: You could pair a map and a vector of keys together...

15:09 Nikelandjelo: I thought about (let [shuf-seq (shuffle my-seq)] ...) (first shuf-seq) - to get random, (rest shuf-seq) to delete it. But it also a bit strange

15:09 lpetit: pdk: finger trees are even better than vectors in lots (all ?) of areas, allowing to delete items in the middle of them, insert in the middle of them, and, hopefully, create a sub-finger-tree from an existing one with structural sharing, but as few as possible (when sub vectors are just a reference to the existing vector, and a range within this vector)

15:11 Chousuke: I wonder what happened to chouser's finger tree implementation

15:11 last time I heard anything of it, it was working but needed polish, or something

15:13 qbg: Nikelandjelo: Since you want a random element, I presume you don't care about the order of the elements in the structure?

15:14 Nikelandjelo: qbg: Yes

15:14 qbg: Just use a vector then

15:14 Nikelandjelo: qbg: With shuffle?

15:14 qbg: When you want to delete an element, replace it with the one at the end and shrink the vector

15:14 Nikelandjelo: qbg: Hm :)

15:14 qbg: Use (rand-int) to get a random index

15:16 lpetit: Chousuke: hopefully it'll be polished and released with the book publication, since it's mentioned several times in it, if I remember correctly

15:16 Chousuke: Maybe chouser will get it included in 1.3 too :P

15:18 lpetit: Chousuke: working with cgrand on the parsley reader, and finger trees would have been useful more than once already

15:18 s/parsley reader/parsley parser/

15:18 sexpbot: Chousuke: working with cgrand on the parsley parser, and finger trees would have been useful more than once already

16:15 mebaran151: what's the best way to test if one vector is a subvector of another

16:22 lpetit: mebaran151: consecutively testing for equality the vector with subvectors of the same length starting from increasing indexes ?

16:22 lozh: boyer-moore works for finding a string within a string, not sure off the top of my head if it generalises to vectors

16:23 mebaran151: lpetit, I was thinking maybe there was a library function

16:23 I'm basically doing that now

16:23 except I do an element loop

16:23 Chousuke: mebaran151: subvectors in clojure are instances of a special class, aren't they?

16:24 mebaran151: hmmm?

16:24 all I meant was I have the vector [:a :b :c] and [:a :b]

16:24 Chousuke: ah, I was thinking of subvec :P

16:25 lpetit: ,(subvec [:a :b :c] 2 3)

16:25 clojurebot: [:c]

16:25 lpetit: ,(subvec [:a :b :c] 2 8)

16:25 clojurebot: java.lang.IndexOutOfBoundsException

16:29 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (count s)) (range 0 (- (count v) (count s)))))) [1 -1] [1 ])

16:29 clojurebot: nil

16:29 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (count s)) (range 0 (- (count v) (count s)))))) [1 -1] [1 2 3])

16:29 clojurebot: nil

16:30 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (count s)) (range 0 (- (count v) (count s)))))) [1 2] [1 2 3])

16:30 clojurebot: true

16:30 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (count s)) (range 0 (- (count v) (count s)))))) [2 3] [1 2 3])

16:30 clojurebot: nil

16:30 lpetit: :-(

16:30 ,((fn [s v] (some #(= s %) (map #(subvec v % (count s)) (range 0 (inc (- (count v) (count s))))))) [2 3] [1 2 3])

16:30 clojurebot: nil

16:32 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [2 3 4] [1 2 3 4])

16:32 clojurebot: true

16:32 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [2 3 4] [])

16:32 clojurebot: nil

16:32 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [] [])

16:32 clojurebot: true

16:32 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [1] [])

16:32 clojurebot: nil

16:32 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [1] [1])

16:32 clojurebot: true

16:32 lpetit: mebaran151: there we are ^^^

16:34 mebaran151: I don't think subvecs are the best way to go actually

16:34 I'm just looping through the old fashioned way

16:35 testing for an element that matches the first element

16:35 then saving that offset and testing the rest

16:36 alexyk: ninjudd: ping

16:36 ninjudd: alexyk: yo

16:36 lpetit: mebaran151: does your algo work with eg. (subvec? [1 2 3] [1 1 2 3]) ?

16:37 alexyk: finally am back to clojure from haskell and ocaml, trying cake! how do I *stop* a cake's jvm when done with a project for a while?

16:37 lpetit: ,((fn [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s))))))) [1 2 3] [1 1 2 3])

16:37 clojurebot: true

16:37 ninjudd: cake stop

16:37 alexyk: ninjudd: cake help doesn't show that

16:37 mebaran151: let me check

16:37 ninjudd: or 'cake kill --all' will stop all cake JVMs

16:37 mebaran151: yep

16:37 it fails

16:37 heh, lpetit you got me

16:37 lpetit: mebaran151: hehe :-p

16:37 mebaran151: I guess I could try for the next element

16:38 but I suppose them I'm just doing the subvec way

16:38 alexyk: ninjudd: why is there 2 servers per project, one use 'cake, another use 'bake ?

16:38 lpetit: mebaran151: you'll end up reimplement vector equality

16:38 ninjudd: alexyk: yeah, i took the implicit system tasks out of cake help. probably a mistake

16:39 alexyk: ninjudd: you can list them after a banner "make sure you're not an idiot to use these: ..."

16:40 ninjudd: alexyk: so cake's dependencies don't pollute your project JVM (http://wiki.github.com/ninjudd/cake/faq)

16:40 alexyk: ninjudd: so it uses full maven internally like lein, right? meaning it will download to my maven repo, and it will try it first?

16:41 mfex: mebaran151: (defn subvec? [subv v] (some #(= subv %) (partition (count subv) 1 v)))

16:41 ninjudd: alexyk: yes

16:41 mebaran151: mfox

16:41 that's fancy

16:41 alexyk: ninjudd: so I go to git and clone cake; then switch there, do cake help, it starts downloading cake libraries. Gets 0.3.6. Then cake compile says nothing; I assume it's self-build, equivalent to lein self-install?

16:42 mfex: inspired by the [1 2 3] [1 1 2 3] case from lpetit

16:42 alexyk: how do we show clojure version from repl?

16:43 lpetit: mfex, mebaran151: beware the partition stuff will turn this into some O(nxM) complexity

16:43 chouser: alexyk: (clojure-version)

16:43 could use subvec instead of partition

16:43 lpetit: (defn subvec? [s v] (some #(= s %) (map #(subvec v % (+ % (count s))) (range 0 (inc (- (count v) (count s)))))))

16:44 chouser: that was my initial implementation offering ^^^

16:44 chouser: though it'd be O(nm) anyway. = is n, some is m

16:44 lpetit: chouser: oh yes :-(

16:44 ninjudd: alexyk: yes, it downloads cake's dependencies automatically

16:46 alexyk: chouser: is there a raw IRC log, un-html-ized?

16:47 I need to process it and hate to de-htnl-ize it, though I could

16:47 chouser: alexyk: updated manually by request earlier today: http://clojure-log.n01se.net/clojure-logs.tar.bz2

16:47 alexyk: chouser: very nice, thx! you may want to just keep raw available separately

16:48 lpetit: ,(-> (clojure.zip/xml-zip {:tag :root :content [{:tag :any :content ["foo" "bar"]} "bar"]}) clojure.zip/down clojure.zip/right)

16:48 clojurebot: ["bar" {:l [{:tag :any, :content ["foo" "bar"]}], :pnodes [{:tag :root, :content [{:tag :any, :content ["foo" "bar"]} "bar"]}], :ppath nil, :r nil}]

16:48 lpetit: ,(-> (clojure.zip/xml-zip {:tag :root :content [{:tag :any :content ["foo" "bar"]} "bar"]}) clojure.zip/down)

16:48 clojurebot: [{:tag :any, :content ["foo" "bar"]} {:l [], :pnodes [{:tag :root, :content [{:tag :any, :content ["foo" "bar"]} "bar"]}], :ppath nil, :r ("bar")}]

16:48 chouser: yeah, I suppose. Originally I didn't because the raw logs had multiple channels mixed in, but they should all be sanitized now...

16:48 alexyk: chouser: kind of cute to see the first day :)

16:48 chouser: :-]

16:49 my first day. The channel had been around for some weeks or months already.

16:49 lpetit: chouser: ^^^is it true to guess that left nodes are stored in vectors in order to be able to append/remove from the tail, and right nodes stored in a list in order to be able to append/remove from the start ?

16:49 alexyk: chouser: ah ok.

16:50 crontab: mebaran151: for large vectors I think the Knuth-Morris-Prat or similar fast string search algo might be more efficient

16:50 chouser: lpetit: I don't know -- I don't think I've ever looked that deeply at the implementation of zip

16:51 alexyk: ninjudd: wow, evil speed! cakr jar is just like, here's your jar, whatever

16:51 cake

16:52 omg, cake's in ruby

16:52 a Balrog in Clojure city

16:52 lpetit: chouser: oh ok. FYI, I'm trying to add the missing primitive so that I'll be able to traverse down a structure by dichotomy on the children when that makes sense (e.g. the passed children function when creating the zipper returns something that we can do dichotomy on, e.g. a slight modification of xml-zipper, etc.)

16:53 chouser: what do you mean by "by dichotomy"?

16:54 ninjudd: alexyk: we chose ruby because it is more platform independent than bash

16:54 alexyk: ninjudd: true, you need to talk to ports and launch stuff

16:54 ninjudd: alexyk: in fact, cake mostly works in windows even

16:54 lpetit: chouser: take a loc which represents a node with lots of children, and you want to go to the loc corresponding to the middle child

16:55 chouser: lpetit: ok, interesting.

16:55 ninjudd: alexyk: but most of cake is written in clojure. only the client script is in ruby

16:55 alexyk: ninjudd: I now have a dual-boot environment on my MacBook, with Windows 7, and share my maven repo and run IDEA in each. Will be cool to run cake in both too.

16:56 lpetit: chouser: I added an overloaded version of clojure.zip/down which takes a second argument. Works similarly to the original down, but would call some additional (split idx children) function passed when creating the zipper

16:57 alexyk: ninjudd: so to share jvm, I must run cake command from the project directory, correct?

16:57 chouser: it'll be faster than just walking to the idx?

16:57 or is that not the point?

16:57 ninjudd: alexyk: or any subdir of your project

16:57 alexyk: otherwise, cake will use the global JVM based in your home directory

16:58 alexyk: ninjudd: so say I have a file test.clj. What do I do to load it into teh project jvm?

16:58 cake compile?

16:58 ninjudd: just put it in project_dir/src

16:58 alexyk: ninjudd: I did, now I edit it, it's changed.

16:59 or I added a .clj file after cake started

16:59 lpetit: chouser: it's the point. Imagine the parsetree for clojure/core.clj. Maybe 400 top level nodes. If I can find the index of the node I want by dichotomy, and then calling (down root-loc idx) jumps directly to the right loc, splitting the vector in the middle, I can expect some gain

16:59 ninjudd: cake will reload automatically

16:59 lpetit: chouser: hopefully

16:59 alexyk: ninjudd: even if I drop a new .clj?

16:59 ninjudd: yeah, when you run another command

17:00 or you can run 'cake reload' to do it explicitly

17:00 lpetit: chouser: when my experiment is finished, if something generic emerges, I'll post something on the ml

17:00 alexyk: ninjudd: should be in cake help for sure! :)

17:01 chouser: lpetit: cool

17:01 alexyk: is there any use to cake install itself into maven repo? or teh binary pointing in git is fine?

17:01 lpetit: chouser: so, how is John Mac Carthy in the real life ? Is he smart ? Tall ? ;)

17:02 chouser: lpetit: nice try

17:02 ninjudd: alexyk: not sure i understand. let's discuss in #cake.clj

17:02 lpetit: :-D

17:33 how do I jump out of 2 recurs at once ? (does this make sense, or do I need to go to bed ? :) )

17:33 s/2 recurs/2 loops

17:34 * lpetit is gonna go to bed

17:58 igms: Hello, what is the best way to get clojure on osx with all the proper configs.. I've used ClojureX before, but I see that it is discontinued

18:12 dnolen: igms: what dev environment do you use?

18:13 technomancy: igms: I think clojureX was deprecated in favour of cljr, which people seem to like.

18:13 haven't used it myself.

18:14 igms: dnolen: textmate with clojure bundle

18:15 technomancy: so I was just looking at clj from liebke

18:15 dnolen: igms: I would use cake. cljr is not so nice on OS X. I'm working on supporting basic slime-ish commands in TextMate with cake.

18:17 igms: on os x installing cake is a cinch, sudo gem install cake

18:17 leifw: so it's a piece of what, then?

18:19 igms: dnolen: thanks I'll give it a try

18:21 dnolen: igms: technically it's a build tool, but the out of the box REPL is really, really stellar, and JVM startup times are less of an issue because it uses persistent VMs.

18:29 * mebaran151 wishes Ubuntu didn't break rubygems so badly

18:29 mebaran151: lein repl I reember used to provide a decent repl too

18:46 are ther eanything like active record schema migrations for clojure and sql backed database work?

18:47 wolfjb: is there something like progn in clojure?

18:47 scottj: wolfjb: do

18:48 wolfjb: ah, thanks

18:56 why does main have - in front of it? (ie why -main)? are there other functions with a preceding dash? where would I read about them? I did a search for -main on the clojure site which didn't return anything

18:57 anars: did anyone successfully run clojure-clr on mono?

18:57 mebaran151: wolfjb, I think -main is an artifact from older versions of control where generating java types was a little harder

18:58 it let's you specify that certain methods in the namespace are not going to mangled (like main) so that you can use them as the main entry point to an application

18:58 anars: I got it running on windows, but afaik the MS DLR does not work on mono; it includes the DLR as a part of the .NET 4 profile.

18:59 wolfjb: mebaran151: thanks. I did try to remove the - from -main but I got an error when I tried to run the uberjar created by lein.

18:59 it seemed to be needed

18:59 is this going to change?

19:00 I'm using version 1.1.0 of clojure

19:00 mebaran151: yeah

19:00 you need the -

19:00 wolfjb: alrighty

19:00 mebaran151: to make sure the method doesn't get mangled

19:00 otherwise I think lots of numbers could get attached to the end and things like that

19:00 wolfjb: ic

19:00 mebaran151: it really only affects ahead of time compiling

19:01 telling the Clojure compiler to basically make a static method that it links to the var that actually holds your main method

19:01 wolfjb: cool, thanks for the explanation!

19:01 I was looking for it and just didn't find it

19:01 much appreciated

19:01 :-)

19:06 lpetit: chouser: yeah, having implemented dichotomy utility fn for my zipper gives a real gain. Not timed it accurately, but from subjective tests, e.g. reindenting the 4000's line of my file (starting from a pre-existing parse tree) is half a second with no dichotomy, and feels instantaneous with dichotomy

19:06 chouser: hm, excellent.

19:08 lpetit: OMG, 1 am here, I'm exhausted. cu guys

19:52 mebaran151: is there away to specify a default value for the constructors of a deftype

21:21 chouser: mebaran151: you almost always end up needing your own function for creating them anyway, so you can use that to specify default values.

21:21 mebaran151: ah alright

21:21 thanks

21:22 also, is there a convenience method from hashmap to defrecord (say for the returned results from clojure.contrib.sql)

21:23 chouser: hm... last I heard one was planned but did not yet exist.

22:02 defn: is there a way to enumerate all of the possible namespaces that are defined?

22:03 for instance, i open a REPL: (ns foo.bar) (defn baz [] nil) (ns foo.boo) (defn booz [] true)

22:03 spewn: ,(all-ns)

22:03 clojurebot: (#<Namespace clojure.contrib.sql.internal> #<Namespace dk.bestinclass.clojureql.util> #<Namespace clojure.set> #<Namespace hiredman.clojurebot.simplyscala> #<Namespace clojure.contrib.macro-utils> #<Namespace clojure.contrib.seq> #<Namespace hiredman.sandbox> #<Namespace hiredman.schedule> #<Namespace clojure.contrib.generic> #<Namespace hello-from-rae¨k> #<Namespace opennlp.nlp> #<Namespace clojure.pprint> #<Namespace hi

22:03 defn: spewn: thanks

22:03 ns-list might be more helpful tbh

22:03 (as a name)

22:48 arohner: is there a drop-nth anywhere?

22:48 just asking before I write my own

23:16 Voting: I'm an old LISP programmer from lisp machine days... can anyone give me a sense of the populariy and growth of Clojure?

23:17 and the best things for me to read to get to be really good with Clojure, esp. calling existing Java code?

23:18 Raynes: Voting: Not claiming it to mean much, but when I first joined about a year and a half ago, there was an average of 120 people in this channel. Now it averages around 260 at the peak of the day.

23:18 ~max

23:18 clojurebot: maxine is http://research.sun.com/projects/maxine/

23:18 * Raynes forgot the command. ._.

23:18 Voting: Raynes: heartening for a guy like me to see lisp seeming to come back!

23:19 Raynes: :)

23:20 If you're looking for books, there are several around. Practical Clojure is the latest book in print. The Joy of Clojure is an awesome book, but it wont be in print until around November. The book is finished save for technical review, and it's available as an MEAP through manning if you preorder the print version or buy the ebook version.

23:20 There is also a tutorial here: http://java.ociweb.com/mark/clojure/article.html

23:20 Voting: Where can I find docs about how OO is done in Clojure... do people like it?

23:20 Raynes: It's a fairly comprehensive introduction.

23:21 Voting: nice!

23:21 lancepantz: Voting: I second the joy of clojure

23:21 rhudson: I'll third that.

23:21 Voting: ah, ok, thanks folks!

23:21 Raynes: Clojure isn't an object oriented language. You don't do traditional OO in Clojure. Clojure offers extremely flexible polymorphism through multimethods. Also, records and protocols.

23:21 arbscht: Voting: about OO: http://clojure.org/state

23:21 Voting: Joy would be good for a person w/ a big common lisp background?

23:22 Raynes: Voting: It'd be perfect, I'd say.

23:22 rhudson: The project web site is well worth looking at: clojure.org, especially all the links down the left-hand side

23:22 Voting: how do clients seem to feel about a clojure implementation of there software?

23:22 Raynes: If you're interested in the rationale for Clojure not being OO, check out the link arbscht gave. I believe Rich Hickey has addressed it in some screencasts and presentations as well.

23:24 Voting: how easy is it to call Java code and to get called by java? do I have to do lots of overhead crap to do it or is it easy? (I'm talking about PROGRAMMER efficiency rather than run time efficiency.)

23:24 rhudson: It's both

23:25 ,(System/currentTimeMillis)

23:25 clojurebot: 1281410793564

23:26 rhudson: http://clojure.org/java_interop

23:26 You might find this comparison (to CL & Scheme) useful: http://clojure.org/lisps

23:28 new Foo( bar.baz() ) ==> (Foo. (.baz bar))

23:35 Voting: what about programming env stuff like leiningen and slime, etc?

23:35 where can I read about that sort of thing?

23:37 rhudson: Leiningen: http://github.com/technomancy/leiningen

23:38 slime I don't know; I'm not of the emacs persuasion

23:39 Here's a survey of using Clojure with various programming environments: http://www.assembla.com/wiki/show/clojure/Getting_Started

23:47 igms: Newb question: To write some sort of a server in clojure, would I need to tap into JVM or look for like a 3rd party lib written in clojure?

23:54 scottj: igms: either.

23:54 Raynes: igms: If you're talking about a web server, there is stuff like Aleph and ring-jetty-adapter around. I believe there is a library in contrib for regular servers.

23:55 lancepantz: igms: you're probably interesting in compojure and ring

23:56 igms: Well more like a basic tcp listener or tcp client .. not so much the web stuff

23:56 so networking in general

23:57 Raynes: igms: In that case, check in contrib. I'm almost certain there is *something* there for that sort of thing.

23:57 igms: thanks

Logging service provided by n01se.net