#clojure log - Jan 04 2010

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

0:01 rikthevik: hi, i've got a quick question about unpacking lists and vector

0:01 in erlang i'm used to saying Foo, Bar = MyListWithTwoItems

0:02 is there a way to do this in a let statement? something like (let '(foo, bar) list-with-two-items)

0:03 piccolino: (let [[foo bar] list-with-two-items] ...)

0:04 Lots of other things you can do with that, see here: http://clojure.org/special_forms#toc4

0:06 rikthevik: this is exactly what i needed. thanks much

0:06 piccolino: No problem.

0:46 rikthevik: also...

0:46 clojure rules!

1:11 KirinDave: I am a loser for not knowing but..

1:11 How would I programatically get the documentation and arglists for a function?

1:11 I thought I could go (meta fun-name) and get it all.

1:12 But evidently that's not it?

1:12 wooby: (doc <function>)

1:12 clojurebot: excusez-moi

1:12 wooby: hehe

1:12 KirinDave: wooby: doc returns nil

1:12 hoeck: KirinDave: (meta #'<varname>)

1:12 wooby: oh, it must write to stdout

1:13 KirinDave: Ahh.

1:13 Why the #'?

1:13 hoeck: KirinDave: functions don't have metadata (yet)

1:13 KirinDave: So what does #' doe?

1:13 Err, do?

1:13 hoeck: and the #' returns the var behind the symbol varname

1:13 ,`#'map

1:13 clojurebot: (var clojure.core/map)

1:13 KirinDave: Ah.

1:13 hoeck: ,(meta #'map)

1:13 clojurebot: {:ns #<Namespace clojure.core>, :name map, :file "clojure/core.clj", :line 1705, :arglists ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]), :doc "Returns a lazy sequence consisting of the result of applying f to the\n set of first items of each coll, followed by applying f to the set\n of second items in each coll, until any one of the colls is\n exhausted. Any remaining items in other colls are ignored. Function\n

1:14 KirinDave: So it returns the binding itself?

1:14 hoeck: yes, kind of

3:54 rdsr: I all I'm having a little trouble with processing xml in Clojure.

3:55 Can someone point me as to where to paste my code so that I can share it over here?

3:55 wooby: rdsr: http://paste.lisp.org/

3:56 rdsr: thk u wooby

3:56 wooby: np

3:57 lisppaste8: rdsr pasted "processing xml with clojure" at http://paste.lisp.org/display/92976

3:58 rdsr: I can't get this to work. the ids vector is always empty

4:05 unfo-: why not use clojure.xml.parse or lazy-xml from contrib?

4:05 rdsr: I tried parse but its very slow (the file is huge) Haven't tried lazy xml

4:06 Also I just want to extract the atom ids and nothing more. I think xml/parse parses the whole thing into memory

4:06 Not sure about lazy-xml

4:14 lisppaste8: rdsr pasted "processing xml with clojure-2" at http://paste.lisp.org/display/92977

4:15 rdsr: Sorry I should have been more clear

4:15 pasted the code again

4:17 wooby: rdsr: so you just need IDs you said?

4:18 i haven't done any xml stuff in clojure but i'd like to, i'll try and bang something out with lazy-xml

4:19 rdsr: yes

4:19 never really tried lazy-xml. I also look into it. Thanks

4:23 (use '[clojure.contrib.lazy-xml])

4:23 oops! wrong window ! :D

4:23 sorry

5:06 LauJensen: Morning all

5:07 wooby: good morning

5:08 does the 'no ctor' error generally mean, 'wrong args passed to java method?'

5:12 rdsr: Thks for suggesting wooby. I was able to get the ids from lazy-xml.

5:12 But the previous code still bothers me. I can't find anything wrong there

5:13 Anyways using lazy-xml solved my other xml problems also :)

5:13 wooby: rdsr: awesome!

5:14 rdsr: i wouldn't worry about it, it looked pretty messy dealing with sax

5:14 rdsr: I guess so

6:19 vu3rdd: which is the swank-clojure version used by folks? the one from technomancy or the one from jochu? I am using the one from jochu and slime from http://git.boinkor.net/gitweb/slime.git

6:19 But technomancy's version seem to be actively developed.

6:20 seths: technomancy's fork works great for me

6:21 vu3rdd: seths: ok. I am planning to package swank-clojure for Debian and push it into the official debian archives. I will start using technomancy's version and package it.

6:22 seths: vu3rdd: awesome!

6:55 vu3rdd: seths: I had a quick look at technomancy's version of swank-clojure.

6:56 What I don't like about it is that it tries to do a lot of things like downloading the jar files etc..

6:57 It has got some hard coded jar file paths and versions. I feel that they are best decided by some external program (like the package management system provided by the OS).

6:58 I will most likely be packaging jochu's version, as it is simple and clean and works with the upstream slime. I haven't tested technomancy's swank with upstream slime though.

7:44 seths: vu3rdd: understood about the hardcoded versions

7:44 but I would think that those are pending tweaks

7:45 and that the tm fork is the better medium to long term option

7:45 I am just a happy user, but I have tweeted him about the news

7:48 vu3rdd: seths: ok. I am also planning to write to him and jochu on this before I decide to package it.

7:49 The problem I see with all these tools built around clojure is that they seem to live in their own world, in which dependencies are hard coded.

7:50 while they make it easy for the user, it makes the life of a distro developer hard.

7:51 I believe this is true of Java and Ruby world as well? I am just an old C/Un*x hacker and probably that's why my thinking is a bit screwed up. :-)

7:51 fanatico: vu3rdd: it's a very young community. as the platform matures these packaging issues will take care of themselves.

7:53 vu3rdd: fanatico: yes, I am sure it will.

7:53 raph_: Hi there. i have a big problem with clojure.contrib.sql

7:53 vu3rdd: clojure community is great. I am very addicted to it..

7:53 raph_: i think it's a bug but i'm not very sure

7:54 I'm running quite a big fn that does around a thousand updates. For each updates it reopens a connection with (with-connection

7:54 vu3rdd: seths: My thoughts on packaging are summed up in this thread as well - <https://lists.ubuntu.com/archives/ubuntu-devel/2009-January/027272.html>

7:54 seths: vu3rdd: great, thanks

7:54 raph_: after a certain number of requests the system locks out. I tried with Sqlite and Mysql and it does a similar thing with boths

7:55 vu3rdd: I would love to hear from the Clojure community on how to solve this problem.

7:56 seths: vu3rdd: I think that technomancy has been a big proponent of ELPA

7:56 http://tromey.com/elpa/

7:56 The Emacs Lisp Package Archive

7:57 his emacs-starter-kit uses it

7:57 unfortunately it's not integrated with GNU/Emacs yet but there may be plans

7:57 fanatico: the parallel delivery stategy always made the most sense to me. once debian/ubuntu/*distro is no longer the "platform", it makes sense to hand off packaging responsibilities.

7:58 seths: (integrating package.el with GNU/Emacs that is)

7:58 vu3rdd: seths: yes, I had been looking at it as well. I read from Tromey's blog that elpa is going to be in the Emacs mainline

7:59 fanatico: ELPA is a great example. Managing elisp files with debian never felt natural or simple, so most people ended up with an ad-hoc "whatever works" scheme.

8:00 vu3rdd: fanatico: I have never felt so. I believe elpa takes the control away from the user. If you are editing your .emacs, you always know what you are doing.

8:01 I am using a "manual" setup for slime/swank/clojure-mode for the past few weeks and have never faced any major issues because of the fact that it is manual.

8:04 seths: vu3rdd: I was trying a manual setup to get a SLIME repl for the new branch

8:04 even wrote a rakefile to help: http://bitbucket.org/seths/clojuggle/

8:05 but it was solved best by leiningen and swank-clojure-project

8:05 vu3rdd: seths: I haven't tried the "new" branch yet.

8:05 fanatico: right, but the cruft builds up over time. I'm sure my .emacs.d directory has lots of out-of-date files in it, because I can't be bothered to make monitor every place I downloaded it from. It's the same kind of fragility you see on systems where everything has been manually compiled (but obviously, to a lesser extent).

8:06 vu3rdd: I am definitely going to take a deeper look at technomancy's branch tonight.

8:08 seths: cheers all

8:10 fanatico: and it has effects on the platform itself. elisp, with all it's very obvious flaws (regexps, lack of lexical scope, namespaces, etc), will never have a chance to correct these issues because the thought of updating all that legacy code w/o a packaging mechanism in place is insane.

8:16 gfour: hello!

8:20 i entered this on the clojure REPL: (class "\a") and it doesn't return to the prompt after the error, is it normal?

8:23 chouser: gfour: yes, unfortunately, for some exceptions thrown by the reader

8:24 your repl is still inside the string where you were when the exception was thrown

8:24 try typing " and pressing enter

8:38 gfour: thank you!

8:48 cark: a little question : if i want to execute a clojure function from the command line, what would be the "java -cp lib/* clojure.main <something here>" command line to give ?

8:53 gfour: cark: what if you use unix pipes: echo "(println \"hello\")" | clojure will run the (println "hello") code

8:53 cark: right that would work, anyways in the meantime i'll just do : java -cp lib/* clojure.main myscript.clj

8:54 chouser: java -cp build/clojure/clojure.jar clojure.main -e '(println "hi")'

8:54 cark: ah thanks !

8:55 where is that documented ?

8:55 chouser: java -cp build/clojure/clojure.jar clojure.main -h

8:55 :-)

8:55 cark: ah right, ok now i feel dumb

9:19 wilig: LauJensen: Thanks for the screen casts Lau. Being completely new to Clojure I was able to implement a tiny web app in a few hours.

9:23 LauJensen: wilig: Wow - That sounds great :)

9:24 wilig: LauJensen: It was! It's a really productive environment.

9:25 LauJensen: I have a small patch for clojureql, how should I submit it? (Currently clojureql doesn't support boolean columns)

9:27 LauJensen: Email it my way, I'll add it

9:36 wilig: LauJensen: On it's way.

9:36 LauJensen: I just got it, thanks! I'll have a look at it asap

9:39 Looks good, thanks!

9:41 wilig: Heh, hard to mess up 3 lines to code too badly. Thanks for the quick response!

9:42 LauJensen: wilig: I just need to clear a merge request before I push it, hope you will be a little patient :)

9:43 wilig: LauJensen: Please take whatever time you need. I'm back to work today so it's Python all day long. I probably won't get a chance to play more until the weekend.

9:43 LauJensen: Ok great

9:49 the-kenny: Anyone aware of a good java-ide for emacs? I don't want to go back to eclipse

9:49 I just want things like auto-completion for methods, classes etc. and import-management

10:22 cemerick: interesting that (-> \c int byte) works, but not (-> \c byte)

10:24 I wonder if that's intentional

10:25 ohpauleez: yes, because byte attempts to cast to Number

10:25 stuartsierra: Java chars are 16-bit, maybe that's why.

10:28 cemerick: ohpauleez: yeah, I see that. Trying to fix the wrongs of the past, perhaps. ;-)

10:29 ohpauleez: ahh, gotcha. It has to do with not using the primitive types

10:29 I just started digging into it right now

10:30 http://java.sun.com/javase/6/docs/api/java/lang/Character.html

10:32 cemerick: I doubt it has anything to do with primitives or not -- more about whether the "tower" should have chars mixed up in it, even for environments that don't conflate chars with numbers.

10:32 ...or, that's my hypothesis, anyway.

10:32 hiredman: cemerick: it does have to do with primitives

10:33 cemerick: oh?

10:33 ohpauleez: because you can cast a char with (byte) in Java

10:33 hiredman: primitives are more, uh, fluid? about casting and what not

10:33 ohpauleez: but not a Character to Byte (which is a subclass of Number)

10:34 but you can do in-part casting, by getting the integer value, (Integer), and then pushing it to byte (Byte)

10:34 if you used just primitives, you could directly do (byte) on a char

10:34 rhickey: do we want a tag of 1.1 or 1.1.0 for the release git tag?

10:35 ohpauleez: 1.1.0 is my vote, fwiw

10:35 hiredman: seems like it should match whatever the *clojure-version* is

10:36 cemerick: hiredman: yeah, I was fundamentally just noting that int is polymorphic, even over Objects. The int/byte fns are fns, so there's no primitives anyway.

10:38 ohpauleez: cemerick, if you can represent the single chars as Strings, you might be able to parse them directly into bytes.

10:40 stuartsierra: rhickey: 1.1.0

10:55 By the way, 1.1.0 isn't in Maven central yet. Has it been submitted?

10:55 rhickey: 1.1.0 tag is up

11:36 technomancy: the-kenny: unfortunately there isn't one

11:41 stuartsierra: Contrib 1.0.0 Release Candidate 1 is up.

11:41 ZIP: http://clojure-contrib.googlecode.com/files/clojure-contrib-1.0.0-RC1.zip

11:42 branch: http://github.com/richhickey/clojure-contrib/tree/1.0.x

11:42 tag: http://github.com/richhickey/clojure-contrib/tree/1.0.0-RC1

11:49 the-kenny: technomancy: :(

12:07 Strange - paredit is broken in my repl

12:12 noidi: the-kenny, I've never had any luck with using paredit and clojure-mode in the repl :P

12:12 the-kenny: noidi: paredit is partly working, never tried clojure-mode

12:12 noidi: () works perfectly, removing of [] is broken

12:30 stuartsierra: Contrib 1.1.0 Release Candidate 1 is up.

12:31 replaca: the-kenny: I've had the same issue with paredit at the repl. Never dug in enough to figure it out. But it's not just you!

12:31 the-kenny: replaca: mh ok

12:31 Maybe I'll try to fix it someday

12:36 arohner: the-kenny: paredit mode works for me on the slime repl

12:36 I don't have a hook for it yet, so I had to do M-x paredit-mode

12:36 but since my repl buffer never closes, I only had to do it once :-)

12:36 the-kenny: arohner: And if you insert a [, will it insert the missing ] and if you delete the [, will it delete the ] too?

12:36 arohner: yes

12:37 the-kenny: That's strange

12:37 mithraic: Hi. So, I'm new to the clojure world, but have been around Scala for a longish while.

12:37 We have a raging debate at work at the moment whether to implement something new in Scala or Clojure.

12:37 Arguments for Scala are relative syntactic familiarity, maturity, and option-to-be-imperative

12:37 arguments for Clojure are that syntax-less-ness will keep things tidy and quicker to learn, and that STM will help avoid snafus in going parallel

12:37 arohner: mithraic: you know which side this channel will come down on :-)

12:37 mithraic: Any comments/thoughts?

12:38 I'm genuinely curious. I think both languages are quite nice (though i'm less familiar with clojure)

12:38 wooby: mithraic: i was obsessed with scala for a few months, but core simplicity of clojure is what's sold me and i'm not looking back

12:38 mithraic: i haven't used either for 'production' but i do have a new personal rule, avoid any language that allows you to solve towers of hanoi with the type system

12:39 Chousuke: :P

12:39 ~scala

12:39 clojurebot: scala

12:39 hm

12:39 clojurebot: :(

12:39 clojurebot: Excuse me?

12:40 mithraic: wooby: :)

12:40 technoma`: mithraic: option-to-be-imperative is only going to feel like an advantage for a month at most. then it's an albatross around your neck.

12:40 Chousuke: You *can* write imperative code in Clojure. it's just done through Java interop, and it's not very idiomatic at all :/

12:42 mithraic: so, one thing that's come up for me writing in Python (bear with me)

12:42 stuartsierra: I think it comes down to type systems. If you like complex static typing (some people do) then Scala it is. If you like dynamic types, go for Clojure.

12:42 mithraic: is (just where stuartsierra is headed)

12:42 wooby: mithraic: out of curiosity, do you have any people familiar with lisp on your team?

12:42 mithraic: is that type systems can be a kind of guaranteed-to-be-correct documentation

12:42 * the-kenny had some problems with the dynamic type system paired with bad planning of the project...

12:42 the-kenny: But it shouldn't happen with :pre and :post :)

12:43 mithraic: which we've found frustrating sometimes in python -- the 'where did this thing come from' problem

12:43 wooby: no, though the fella leading the charge for clojure learned LISP from alan perlis back in the day

12:43 Chousuke: Well, python is different from clojure in that it still has classes

12:43 stuartsierra: Dynamic typing allows you to be careless sometimes, it's true.

12:43 Chousuke: Idiomatic clojure code works mostly with simple values

12:44 maps, vectors, lists, and other simple things.

12:44 mithraic: yeah, though don't you end up with maps-of-lists-of-vectors and that sort of thing?

12:44 _fogus_: mithraic: I've been using Scala professionally for about a year and a half, and Scala type decls have been pretty nice as far as documentation go

12:44 Chousuke: mithraic: sometimes

12:45 mithraic: the work, incidentally, would mostly be with probability distributions of various kinds. bayesian inference, EM, MCMC, that sort of thing.

12:45 Chousuke: hmm

12:46 mithraic: how does clojure do with JVM primitive types?

12:46 sorry for being so ignorant

12:46 Chousuke: you can use them in loops.

12:46 stuartsierra: Writing *efficient* math-heavy code in Clojure can be tricky, and often loses the functional/immutable benefits.

12:46 Chousuke: function arguments are always boxed.

12:46 there's incanter though.

12:47 * gravity would like to see more docs on writing that sort of efficent math-heavy code

12:47 stuartsierra: Chousuke: Yes, but Incanter uses Java matrix libs.

12:47 Chousuke: Well, yeah.

12:49 stuartsierra: I would suggest writing low-level numeric routines in Java and using Clojure as a high-level driver.

12:49 wooby: that's a cool approach

12:51 Chousuke: I think primitive support for functions will happen after cinc, and the timeline for that is still unknown ;P

12:51 stuartsierra: Yes, I believe we will get to the point where you can write fast numeric routines (not just loops) in Clojure, but that point is still some ways off.

12:52 _fogus_: mithraic: Here a post comparing Scala and Clojure... totally fair comparison too. ;-) http://blog.fogus.me/2010/01/04/comparing-lines-of-code-scala-and-clojure-fud-version/

12:53 Chousuke: ;P

12:53 * _fogus_ Secretly hopes this will push people toward Clojure.

12:54 ohpauleez: Well, fwiw, I was co-learning scala and clojure

12:54 and immediately fell in love with Clojure

12:54 mithraic: _fogus_: very nice.

12:54 ohpauleez: and it has since slowly risen to be one of my favorite languages to work in

12:54 replaca: Q: does anyone know how to enumerate a set of resources in your classpath? I am loading a directory ./templates/static/..., into my jar and I want to be able to spit all those files to a particular location at runtime. I know how to do that once I have a list of resource names, but I would rather not hard code that list.

12:54 * ohpauleez is an established python guy

12:55 piccolino: fogus, that page is basically why I left Scala for Clojure.

12:55 Felt like I was still writing Java.

12:55 _fogus_: piccolino: Of course, that blog post is a joke. That's about as far from idiomatic Scala as you can get without breaking the compiler.

12:56 piccolino: Oh, I didn't read it.

12:56 That is still in line with my experience of Scala, though.

12:58 _fogus_: Scala's biggest fault IMO is that it provides too many ways of doing complementary things -- which can trip people up

12:58 stuartsierra: replaca: You can't enumerate the classpath.

12:59 piccolino: I also didn't like that the type system can start to fail you with things you can't do, due to the type erasure that happens.

12:59 mithraic: yeah, it has a pastiche of syntactic styles.

12:59 well, the Manifest support can patch up erasure to a pretty good extent.

13:00 piccolino: Yeah, I guess I was doing the thing they can't do.

13:00 Can't remember exactly, though, but I tried manifests.

13:00 mebaran151: it seems like functional and object oriented programming have always been opposites: objects are all about encapsulated state while functional programming is all about avoiding that state to begin with

13:01 replaca: stuartsierra: so I need to know the exact name of a resource in order to get it?

13:01 wooby: mithraic: have you seen the latest rich hickey talk, 'are we there yet?'

13:01 Chousuke: oh, right.

13:01 ohpauleez: wooby: link?

13:02 wooby: http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

13:02 Chousuke: Rich's talks are good for converting people :P

13:02 ohpauleez: thanks

13:02 he converted me :)

13:02 mebaran151: he gives amongst the best presentations of any programmer I've seen

13:03 mithraic: wooby: thanks, i'll look

13:03 wooby: i agree, this latest one completely floored me

13:03 Chousuke: mebaran151: well, you could have Objects that don't hold any *mutable* state

13:03 wooby: he's almost like the charles manson of programming talks, i'm totally under his spell now lol

13:03 ohpauleez: hahaha

13:03 stuartsierra: replaca: yes

13:03 somnium: do delays/lazy-seqs qualify as mutable?

13:04 stuartsierra: replaca: or just pull directories from the classpath and traverse the filesystem

13:04 Chousuke: somnium: lazy seqs are persistent. they might be created from a mutable source, but once realised, the seq itself never changes... so, no?

13:04 somnium: delays are similar.

13:04 * stuartsierra leaves

13:04 rhickey: somnium: no, since you can't go back and change them

13:06 mebaran151: Chousuke, then Objects are basically scoping modifiers, which are probably best handled via things like lets

13:07 somnium: rhickey: is there a reasonable way to approach implementing them via deftype at present?

13:09 rhickey: somnium: ah, you mean, do they use mutation internally - yes, they do, and no, you can't implement via deftype at present

13:10 replaca: stuartsierra: 'k, thanks!

13:12 somnium: rhickey: I wrote a clojure-special-form to js compiler that gingerly macroexpands forms and emits js, and it works better than I anticipated. I tried to write a macro to emulate deftype using closures for immutability, but lazy-seq I could only manage with a mutable field.

13:13 rhickey: somnium: delay and lazy-seq do caching that requires a once-only mutation

13:14 I haven't yet decided how to expose support for this - early versions of reify had volatile support, but that's kind of raw

13:16 somnium: rhickey: related to license, Im hoping to put the core compiler on github in the near future under eclipse, but to get the seq fns from core working I had to directly edit clojure.core, is it okay just to include clojure's own license in that?

13:17 rhickey: though they both emit a form of clojure, I dont know much about licenses and Im not a contributor so I thought I should check

13:20 rhickey: somnium: a modified/derived version of clojure.core will fall under the original Clojure license

13:32 somnium: rhickey: roger, thanks

13:33 cemerick: my code is so littered with -> and ->>, I'm starting to worry it constitutes a smell.

13:33 LauJensen: cemerick: Thanks for that 'all my functions take 316 args' - it was a good read :)

13:34 cemerick: Sure. Never thought it would bring out the hordes to the degree that it did. ;-)

13:35 jasapp: cemerick: link?

13:35 cemerick: jasapp: http://muckandbrass.com/web/display/~cemerick/2009/12/30/All+my+methods+take+316+arguments%2C+and+I+like+it+that+way

13:35 jasapp: cool, thanks

13:36 chouser: cemerick: I've noticed a trend that direction in my code as well.

13:37 cemerick: I'm not at all sure it's bad though. It's actually a form of strictness -- everything within ->> has to follow the pattern.

13:37 so when you're reading it, that's one less detail you have to keep in mind. You know each step will take a seq and apply if via the ->> rules

13:38 cemerick: oh, and then -?>

13:38 * cemerick swoons

13:38 cemerick: we just need -?>> now

13:38 mebaran151: would the alternative huge number of let bindings be smell?

13:38 cemerick: mebaran151: oh, that'd definitely be worse. I just worry when I start edging towards using something too much.

13:39 rhickey: I think the placeholder versions of -> and ->> are on much shakier footing than -> and ->>

13:39 mebaran151: I find breaking things in let pipelines makes it easier for me to remember what I was doing

13:39 cemerick: rhickey: placeholder?

13:39 chouser: -$>

13:39 or whatever. -%>

13:39 _fogus_: rhickey: You mean -$> -$>> ?

13:39 rhickey: various people have proposed -$> etc

13:40 cemerick: oh, right

13:40 _fogus_: nevermind

13:40 rhickey: I'm opposed

13:40 _fogus_: As am I

13:41 cemerick: clojure.template opened the door, certainly.

13:41 _fogus_: -$> -$>> presuppose too much information on the pipeline contents

13:42 chouser: also could never work well with destructuring, so better to just leave them out.

13:42 rhickey: -> has a clear analogue in concatenated member calls, and ->> in stream pipes, they are easy to understand

13:42 * chouser smiles evilly

13:42 LauJensen: rhickey: Is the funding graph on Cloure.org updated?

13:43 _fogus_: Question, is there any reason why -> and ->> not do -?> and -?>> by default?

13:43 rhickey: _fogus_: I don't understand

13:44 LauJensen: it's pretty close to current

13:44 _fogus_: That is, besides the fact that it's probably bad form to swallow exceptions

13:44 LauJensen: k

13:44 ohpauleez: _fogus_: I think that's the reason

13:44 Personally, I want to know when the system fails and how it fails, and optionally tell it pass me null

13:45 _fogus_: ohpauleez: I thought I was missing something else

13:45 ohpauleez: ahhh, nope you got it

13:45 chouser: _fogus_: -?> doesn't actually swallow exceptions though, right?

13:46 ohpauleez: rhickey: When I get my signing bonus for this new job, I'm writing out my check :)

13:46 chouser: having -?> as the only behavior might be a problem since -> doesn't generally assume anything about the type of the object being passed along.

13:46 rhickey: ohpauleez: great - thanks!

13:46 ohpauleez: also, the offer still stands whenever you want me to do corporate outreach

13:47 chouser: I guess ->> techinically doesn't either, but if it's used for something other than a seq I'd be a bit suspicious. Which suggests that having ->> short-circuit on nil be default might not be so bad.

13:47 rhickey: chouser: what if the last call is into?

13:48 chouser: :-(

13:48 nevermind.

13:49 _fogus_: chouser: Hmmm, good question. I always assumed that it did, which is why I never used it. I thought it was equivalent to `(try (-> ~@forms) (catch NullPointerException _# nil))

13:50 chouser: _fogus_: It appears to just check the return value at each step, and if it's nil, bail out.

13:52 .?. is I suppose the most useful by default, since (.foo nil ...) is sure to throw something.

13:52 _fogus_: chouser: Cool. Which is another way to avoid some NPEs

13:53 chouser: but knowing where it threw, that is what stage failed, might be really useful, so ... bleh.

13:53 _fogus_: agreed

13:56 * stuartsierra returns

13:56 the-kenny: stuartsierra: What value? nil?

13:58 * stuartsierra returns :burp

14:14 LauJensen: ~source -?>

14:15 eeh?

14:15 fliebel: Hey, cool, is -?> in contrib?

14:16 LauJensen: defnilsafe is a cute macro

14:17 fliebel: How about a variant of -$> ?

14:18 ieure: Hey, I just wrote my first practical Clojure app. I’d really like it if some of you dudes could take a look and let me know what I could do better.

14:18 It’s at http://github.com/ieure/Twidoop

14:24 LauJensen: ieure: Looks nice and well layout - You seem to use excessive 'do' statements though. 'when' and 'doseq' don't need it

14:24 s/layout/layed out

14:28 pjackson: ieure: no tests :)

14:30 ieure: pjackson, Yeah - that’s going to get fixed.

14:31 LauJensen, Okay. I thought it was idiomatic to wrap side-effecting stuff like the print and flush calls in do - is that not the case?

14:32 LauJensen: No, you can use do with statements which dont take entire bodies, like (if (= x 5) (do (stmt 1) (stmt 2)) (stmt 3))

14:32 but with 'when' its implicit (when (stmt 1) (stmt 2)), no need for do

14:32 technoma`: ieure: doseq/when have the same implications

14:32 ieure: technoma`, Okay.

14:33 technoma`: when you see them, you know there will be side-effects involved

14:33 tolstoy: If I have a big string number, "342342342342342342", what's the good Clojure way to turn that into a number?

14:33 LauJensen: ,(Integer. "342342342342342342")

14:33 clojurebot: java.lang.NumberFormatException: For input string: "342342342342342342"

14:33 LauJensen: no luck

14:33 tolstoy: Is there a nice type independent way to do it?

14:34 ieure: technoma`, I know doseq always indicates side-effects, but is that really true of when? I thought that was just basic flow control.

14:34 LauJensen: ,(BigInteger. "342342342342342342")

14:34 clojurebot: 342342342342342342

14:34 tolstoy: (As in, I don't care if it's an Integer, Long or BigNumber.)

14:34 stuartsierra: tolstoy: read-string

14:36 tolstoy: Ah, okay.

14:36 fliebel: What is some processor intensive stuff I can write in a few lines to test something?

14:37 the-kenny: fliebel: Fibonacci numbers

14:37 fliebel: thanks

14:38 technoma`: ieure: actually that can be a style thing. multiple statements in when does indicate side-effects, but some people use when for single-body clauses rather than if

14:39 ieure: technoma`, Got it.

14:40 Well, I’m glad my first real foray into Clojure isn’t terrible. It’s been handling the full Twitter firehose for around a week now, and has been 100% stable. Which rocks pretty hard.

14:41 stuartsierra: fliebel: searching for primes

14:46 tolstoy: Is there an equivalent to the Math.round for Clojure? Just want the integer part of a division on a big, uh, integer.

14:47 I get back: 43535345435345/10, which is kinda not what I really need in order to convert that to a string.

14:47 Knekk: try (Math/round 1.2)

14:47 ,(Math/round 1.2)

14:47 clojurebot: 1

14:47 hiredman: ,(.numerator 43535345435345/10)

14:47 clojurebot: 8707069087069

14:47 KirinDave: tolstoy: Any java method is obtainable in clojure.

14:48 hiredman: ,(pr-str 43535345435345/10)

14:48 clojurebot: "8707069087069/2"

14:48 hiredman: ,(read-str "8707069087069/2")

14:48 clojurebot: java.lang.Exception: Unable to resolve symbol: read-str in this context

14:48 hiredman: ,(read-string "8707069087069/2")

14:48 clojurebot: 8707069087069/2

14:49 tolstoy: Okay. I was hoping there was more Clojure-like ways to do some of this. No prob.

14:50 mebaran151: is there anyway to increase the size of the agent thread pool?

14:52 hiredman: why?

14:54 fliebel: What the heck does this mean? Exception in thread "main" java.lang.ClassFormatError: Invalid method Code length I admit I'm doing stuff you usually don't...

14:54 hiredman: your functions are too big

14:54 fliebel: hiredman: what is the limit of a function?

14:55 hiredman: fliebel: ideally you should look at your function and say "omg, this is three pages long, maybe I should break it up"

14:55 in the non-ideal case, the length is restricted to whatever the jvm bytecode limit is

14:56 fliebel: hiredman: the truth is that I'm using apply with about 100 seqs turned into one let ;)

14:56 hiredman: http://bugs.sun.com/view_bug.do?bug_id=4262078

14:56 fliebel: uuuhm 1000

14:56 hiredman: that sounds pretty horrible

14:56 why would you put yourself through that?

14:57 fliebel: hiredman: it is, but don't worry, I'm not going to use it. I wanted to see what would happen... and get reliable numbers for (time) by doing it an awful amount of times.

15:00 ordnungswidrig: hi all

15:01 fliebel: hiredman: doing fibonacci numbers with -> is not good :D

15:05 hiredman: fliebel: why?

15:07 unfo-: why does clojurebot use /notice?

15:09 hiredman: darned if I know...

15:13 fliebel: hiredman: for fun...

15:13 hiredman: fliebel: why is it not a good idea?

15:14 fliebel: hiredman: because that gave the above error.

15:14 Actually it was not -> but a custom macro… I'm now trying -> but I'm afraid that'll blow the stack.

15:24 In which order are macro's expanded?

15:24 somnium: fliebel: outside-in, opposite of fns

15:25 fliebel: or rather, as the reader reads them, contrary to fn evaluation

15:25 pjackson: Is there a function to recursively macroexpand a form?

15:25 somnium: ,(doc mexpand-all)

15:25 clojurebot: "clojure.contrib.macro-utils/mexpand-all;[[form]]; Perform a full recursive macro expansion of a form."

15:25 fliebel: somnium: So can I write fn in a -> macro?

15:25 pjackson: Thanks.

15:25 somnium: fliebel: sure, just wrap in extra parens

15:26 fliebel: somnium: huh?

15:26 somnium: (unless youre passing it its argvec through some convoluted mechanism)

15:26 rbe: hi

15:27 somnium: ,(macroexpand '(-> [foo] (fn (print foo))))

15:27 clojurebot: (fn* ([foo] (print foo)))

15:27 somnium: (macroexpand '(-> [foo] ((fn (print foo)))))

15:27 ,(macroexpand '(-> [foo] (fn (print foo))))

15:27 clojurebot: (fn* ([foo] (print foo)))

15:27 somnium: bah

15:27 ,(macroexpand '(-> [foo] ((fn (print foo)))))

15:27 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

15:28 rbe: need some help... how can i get the name of a function when no var exists?

15:28 somnium: ,(macroexpand '(-> [foo] ((fn [x] (print x)))))

15:28 clojurebot: ((fn [x] (print x)) [foo])

15:29 rbe: example:

15:29 ,(let [f [+ - *]] (for [y f] {(:name (meta (var y))) (y 1 2)}))

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

15:29 fliebel: somnium: I think I understand…

15:29 somnium: fliebel: sorry for the mess, ^^ thats what I meant by extra parens are needed

15:30 fliebel: somnium: Unless I want to add something to the final fn* thing...

15:30 somnium: fliebel: right

15:31 ,(let [f '[+ - *]] (for [y f] {(:name (meta (resolve y))) (y 1 2)}))

15:31 clojurebot: ({+ 2} {- 2} {* 2})

15:32 rbe: thx somnium

15:33 somnium: rbe: you have to have the symbol though, if youve got the actual fn (as an argument for example), its not possible afaik

15:33 rbe: hm i get: java.lang.ClassCastException: clojure.core$_PLUS___4509 cannot be cast to clojure.lang.Symbol with your example??

15:34 somnium: rbe: the vector is quoted

15:34 technoma`: does anyone else prefer not using recur in contexts in which TCO is not required?

15:34 rbe: ah ok

15:34 technoma`: I have this notion in my head that using recur is a way of signalling to readers "this operation must not consume stack", but I'm not sure if that's a convention or something I just made up myself. =)

15:35 hiredman: best just use reduce and map and never think about it

15:36 rbe: somnium: when i use that in my code the functions (y in my example) does not get evaluated..it's always nil

15:36 just my own functions instead of + - *

15:38 somnium: rbe: if you do (defn foo ...) and then (resolve 'foo) it should work

15:40 rbe: somnium: now the name of the fun resolves to nil...

15:42 with (resolve foo) it worked... but the (foo param) gets me nil....

15:42 hiredman: functions don't have names

15:43 Knekk: remember, there is no function.

15:43 Neo

15:43 hiredman: there are functions

15:43 they just don't have names

15:43 rbe: but a var has got...

15:43 Knekk: must be a glitch in the Matrix

15:44 hiredman: functions are values, like the integer 1, which does not have a name, but can be bound to a name

15:44 pjackson: Knekk: You're thinking of spoons, I think.

15:44 Knekk: oh right

15:44 spoons

15:44 pjackson: Isn't it ironic when all you want is a spoon but all you can find is a function.

15:45 hiredman: what is a spoon?

15:45 Knekk: (defn spoon [] nil)

15:45 rbe: ok... i define a list of functions (def funs [fun-a fun-b])

15:45 hiredman: there is no spoon! only a function that transforms the present state into a future state where a spoon apears to have operated

15:45 somnium: :-)

15:46 rbe: then i want to apply every function to one argument, producing a map with {:fun-name result}

15:46 hiredman: rbe: fun-a is a a fn or a var, or a symbol resolved to a var, or what?

15:46 somnium: rbe you need the symbols, which can resolve to vars, which can resolve to fns

15:46 rbe: fun-a was defined earlier by (defn fun-a [arg] ...)

15:47 fliebel: hiredman: Using -> indeed causes a "Exception in thread "main" java.lang.StackOverflowError"

15:47 somnium: so unquoted fn-a is the fn that the the var named by 'fn-a resolves to

15:47 not a fn named fn-a!

15:47 rbe: what is the sound of one hand clapping?

15:48 hiredman: rbe: basically, you need to quote the vector to prevent resolution so you can do your own resolution

15:48 arohner: functions do have names

15:48 (fn foo [] ...)

15:49 rbe: ok when i quote the vector the name resolution succeeds, but the function call no longer takes place... how to do it then?

15:49 hiredman: arohner: that is a self reference and entirely opaque

15:50 rbe: I don't know I haven't really been paying attention to the code you are using

15:50 rbe: here it some code

15:50 (defn fun-a [arg] ... )

15:50 (defn fun-b [arg] ...)

15:50 hiredman: pastebin

15:51 rbe: ok ...

15:51 hiredman: I imagine you are now applying the symbols as functions

15:51 which won't give you an error because symbols are IFns

15:51 but it won't give you the results you want

15:52 ,((resolve '+) 1 2)

15:52 clojurebot: 3

15:52 hiredman: ,('+ 1 2)

15:52 clojurebot: 2

15:52 hiredman: ,(:+ 1 2)

15:52 clojurebot: 2

15:52 rbe: http://pastebin.com/d2b5b571d

15:53 hiredman: rbe: so when you quote the vector, the name f in the for now refers to a symbol, not the function in the var named by that symbol

15:53 so you need to resolve f and apply

15:54 rbe: ah the resolve again... thanks a lot

15:55 arohner: or just ((resolve 'foo) 42)

15:59 fliebel: I can generate fibonacci number up to 900 faster than contrib :D

16:00 For low numbers mine is at least twice as fast, for 900 10/11 msec and over 900… stacktrace.

16:02 hiredman: ~fib

16:02 clojurebot: Excuse me?

16:02 hiredman: clojurebot: fib is reply See #haskell

16:02 clojurebot: In Ordnung

16:02 hiredman: bah

16:04 fliebel: What do you think about it? http://gist.github.com/268866

16:05 hiredman: fliebel: I will be impressed when you find something that blazing fast generation of fibs is good for

16:06 fliebel: hierdman: I won't, my code is another hack, but it was fun...

16:06 I think it's more useful to be able to have fibs 'til infinity.

16:07 hiredman: how is that useful?

16:09 fliebel: hiredman: I think there are more applications needing a fib above 900 than applications depending on fib speed, but I also think there are very few applications relying on fib at all..

16:09 hiredman: I just wanted to write fib using -> :D

16:09 hiredman: fliebel: name one

16:10 fliebel: hiredman: I don't know any application using fib, except rosseta style stuff.

16:10 arohner: fliebel: that is pretty cool

16:10 fliebel: arohner: thanks

16:10 arohner: personally, I learned something from (-> (take n infinite-seq))

16:11 why is that a macro though?

16:11 fliebel: arohner: what?

16:11 arohner: just the idiom

16:11 it was new to me

16:11 fliebel: arohner: It's a macro because -> is :D

16:12 arohner: I could not do the ~@ magic with a normal function.

16:13 ieure: Right - you can only use that with syntax-quote, I think.

16:16 arohner: what's the process for committing to contrib?

16:18 hiredman: basically the same as for clojure

16:19 arohner: so you have to get someone to commit for you?

16:19 make a ticket, etc?

16:20 fliebel: hiredman: that is… writing a letter to rhickey containing your usernames and a signed license agreement?

16:20 hiredman: yes

16:21 fliebel: it's not a "letter" it's the contributors agreement

16:21 technoma`: have you seen http://blog.bigsmoke.us/2007/06/11/microsoft-batch-file-meets-bash-shellscript ?

16:21 fliebel: hiredman: so you download a pdf somewhere?

16:22 hiredman: clojurebot: ca?

16:22 clojurebot: CA is Contributor Agreement: http://clojure.org/contributing

16:34 technoma`: hiredman: that is fiendish

16:45 hiredman: http://www.music.mcgill.ca/~sinclair/content/blog/a_functional_game_loop_for_glut_in_scheme_using_continuations mmmm

17:05 arohner: is there a way to detect that a var is in a binding? i.e. doesn't have its root value?

17:06 ah, .getRoot

17:08 optimizer: rlwrap java -Dswt.library.path=/usr/lib/jni clojure.main <-- great for running "clojure"

17:08 but how do I get "clojure test.clj" to run test.clj?

17:08 instead of haing ot copy/paste in tets.clj?

17:09 arohner: ,(doc clojure.main/main)

17:09 clojurebot: "([& args]); Usage: java -cp clojure.jar clojure.main [init-opt*] [main-opt] [arg*] With no options or args, runs an interactive Read-Eval-Print Loop init options: -i, --init path Load a file or resource -e, --eval string Evaluate expressions in string; print non-nil values main options: -r, --repl Run a repl path Run a script from from a file or resource - Run a script from standard input -h, -?, --help Print this help m

17:10 arohner: it looks prettier on your own screen

17:10 optimizer: whoa, much nicer

17:10 arohner: but you should be able to just add test.clj to the cmd line, assuming it's in your classpath

17:11 optimizer: arohner: it works; nice; thanks

17:12 arohner: great

17:19 michaeljaaka: hi clojure people

17:19 mebaran151_: what's the best way to recursively list files in a directory in Clojure?

17:20 hiredman: ,(doc file-seq)

17:20 clojurebot: "([dir]); A tree seq on java.io.Files"

17:20 hiredman: tree-seq

17:20 michaeljaaka: I want to write qsort just as learning example of Fp

17:20 hiredman: someone file a bug

17:20 michaeljaaka: http://gist.github.com/268915

17:20 have something like this

17:20 but can't find out why getting exception

17:20 anyone would like to help?

17:25 optimizer: is there a book like "Beautful Clojure" that just shows lots of beautiful Clojure code?

17:28 somnium: optimizer: maybe print out clojure.contrib.monads?

17:28 mitchellh: optimizer: No official book like that yet, I would say Clojure is still a bit too new :)

17:29 michaeljaaka: ok, I have manage to fix my code

17:29 this is it http://gist.github.com/268924

17:29 don't know why but nested let didn't work

17:30 optimizer: how do I get swt.jar?

17:30 hiredman: core.clj is usually pretty nice

17:31 optimizer: I believe swt has some native code components

17:31 michaeljaaka: you have too many parens

17:31 michaeljaaka: noticed that, thanks

17:32 clojure people you are great!

17:37 mebaran151_: hiredman, when did treeseq get added?

17:38 hiredman: long long ago in the great before time

17:42 * the-kenny likes tree-seq

17:54 jasapp: does anyone know if there is code somewhere to go from an xml zipper back to xml?

17:54 mebaran151_: I learn something new every day

17:55 hiredman: clojure.xml/emit

17:56 jasapp: emit doesn't work on zippers, does it?

17:59 yeah, it doesn't look like it

18:00 hiredman: well, you call root on the zipper

18:01 jasapp: nice, thanks

18:01 hiredman: emit emits to *out* so you might want to rebind it or use with-out-string

18:18 tolstoy: When slime-compiling a file, using some code in another module like (ns bar (:use lib.foo)) what has to be in the classpath?

18:19 Do each of your clj files have to be on the classpath as well as each jar?

18:19 Is there something about Slime that makes you not able to compile files that way? Maybe need to load it or something first?

18:21 hiredman: ~namespace

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

18:23 somnium: tolstoy: you should only need bar.clj and lib.foo.clj/jar/class on the classpath

18:23 tolstoy: Hm.

18:23 What about when using slime (with a standalone swank using slime-connect)?

18:24 somnium: tolstoy: the classpath is the classpath is the classpath afaik

18:24 tolstoy: I mean, I "get" namespaces, which is why I don't understand why I can't ^c^k.

18:24 hiredman: what makes you think you get namespaces?

18:25 tolstoy: hiredman: Ah, you're saying they're inherently incomprehensible as currently implemented?

18:25 hiredman: no

18:25 tolstoy: I have ${PWD}/src/lib/foo.clj on the classpath. I have ${PWD}/src/lib on the class path.

18:26 In foo.clj, I have (ns lib.foo ....)

18:26 somnium: whats the warning on single-legment namespaces about?

18:26 hiredman: and thus it is proven

18:26 somnium: don't use them and expect them to work

18:26 somnium: hmm

18:26 hiredman: when do they break?

18:27 tolstoy: hiredman: Ah, thanks for the help! Your snark is clearing it right up for me!

18:27 hiredman: it has to do with how namespaces are translated into classes/packages and the java default package

18:27 tolstoy: hey, you where the one that claimed to understand namespaces

18:28 did you read what clojurebot barfed out for you at all?

18:28 tolstoy: hiredman: I don't understand namespaces at all. They mean nothing to me. I *thought* I was complying with exactly what clojurebot said.

18:29 hiredman: as an excercise in communication, can you repeat back to me what you think clojurebot said?

18:29 tolstoy: Ah, my classpath doesn't have to root of the package hierarchy in it.

18:30 somnium: hiredman: hmm, I haven't encountered a problem thus far, do you know an example offhand where they break? (I was just thinking to use one, so this is good timing)

18:30 hiredman: somnium: I don't

18:31 Chousuke: somnium: single-segment namespaces are prone to collision. I think that's about it :P

18:31 tolstoy: hiredman: I made a typical mistake (that I've not made in years. Sorry!

18:31 ~classpath

18:31 clojurebot: classpath is (System/getProperty "java.class.path")

18:31 hiredman: there was some change in AOT compilation long ago that brought this about and the move from "clojure" to "clojure.core"

18:31 somnium: Chousuke: is that all? :D

18:31 well, a little preemptive renaming never hurt anyone I guess

18:32 Chousuke: I guess the clojure standard is to use two-segment namespaces.

18:32 clojure.core etc ;P

18:33 I guess single-segment namespaces would also break when gen-classing

18:34 I don't really know the java package/class naming stuff and how namespaces relate to those, so I can't say for sure.

18:34 hiredman: clojurebot: logs?

18:34 clojurebot: logs is http://clojure-log.n01se.net/

18:36 hiredman: http://clojure-log.n01se.net/date/2008-11-13.html#14:28 <-- there'ish

18:36 not very in depth though

18:37 the-kenny: #{"fleetdb"} :D

18:38 Looks like clojurebot is using sets there :)

18:38 Chousuke: heh

18:38 hiredman: sets and clojure.set/difference

19:34 aldebrn: Anyone yet thought to create a units system in Clojure using metadata? So measurements can be represented as m/s vs ft/hr, radians vs degrees, etc.?

19:36 technomancy: aldebrn: unfortunately you can't add metadata to final classes yet. =(

19:39 aldebrn: I don't know what final classes are in Clojure but :(

19:40 * aldebrn erases sign: "This workplace has been unit-related bug-free since [0] days"

19:42 technomancy: aldebrn: java defines its numeric classes as "final", which means they can't be extended

19:48 aldebrn: Oh, that tears that idea :-/

19:51 arohner: aldebrn: though you'll be able to do that after metadata is a protocol

19:52 maybe

19:52 aldebrn: Clojure is such a fast-moving target!

20:42 ndimiduk: from within (ns foo (:gen-class)), how do I access foo.class?

20:44 i'd like to pass the .class of the generated class as a parameter. saying (. instance method foo) doesn't work.

20:45 compiling throws an exception saying Unable to resolve symbol foo

20:52 optimizer: i have swt.jar installed; how do I get clojure to recognize and use it?

21:00 chouser: ndimiduk: you probably need a package name on that class. (ns pkg.Foo (:gen-class))

21:00 then you should be able to use pkg.Foo as the class anem

21:00 name

21:00 optimizer: just make sure that swt.jar file is mentioned in your classpath

21:07 * arohner sighs. for is *lazy*

21:08 arohner: I just fixed a bug in my code caused by improperly using for. I should be "old enough" by now

21:10 hiredman: I think I used for once in clojurebot

22:06 joshua-choi: Hey, is there a function so that "space" -> \space, "newline" -> \newline, etc.?

22:11 chouser: ,(read-string (str \\ "newline"))

22:12 clojurebot: \newline

22:14 chouser: ,char-escape-string

22:14 clojurebot: {\newline "\\n", \tab "\\t", \return "\\r", \" "\\\"", \\ "\\\\", \formfeed "\\f", \backspace "\\b"}

22:14 tomoj: that's slick

22:15 chouser: ,char-name-string

22:15 clojurebot: {\newline "newline", \tab "tab", \space "space", \backspace "backspace", \formfeed "formfeed", \return "return"}

22:17 chouser: ,(some (fn [[c s]] (when (= s "newline") c)) char-name-string)

22:17 clojurebot: \newline

22:20 chouser: joshua-choi: take your pick

22:20 hiredman: ,((clojure.set/map-invert char-name-string) "newline")

22:20 clojurebot: \newline

22:23 alexyk: is there anything in stdlib to merge two sorted vectors in sorted order?

22:26 chouser: ,(reduce into (sorted-set) [[1 2 3] [4 5 6]])

22:26 clojurebot: #{1 2 3 4 5 6}

22:26 piccolin1: We would all be totally screwed without chouser.

22:26 hiredman: that would lose duplicates

22:26 chouser: I suppose merging two sorted vectors should be possible in O(n)

22:26 ah, good point

22:26 and that reduce is O(n log n)

22:27 hiredman: since into uses reduce?

22:27 chouser: alexyk: I don't know of anything that does exactly what asked.

22:27 sounds interesting though.

22:27 piccolino: Shouldn't it be possible to insert into a sorted vector without a lot of copying with the vector structure?

22:28 If that function were written?

22:28 chouser: hiredman: no, because each item is inserted individually into the sorted set -- doesn't leverage the fact that the inputs are sorted.

22:28 piccolino: nope, can't change either of the input vectors, so you'd still need a whole new vector

22:29 piccolino: Oh, whoops, I was just thinking on a slightly related note, about a single item being inserted.

22:29 And insert in the persistent sense.

22:31 chouser: hm.. could operate on seqs -- two in, one out

22:33 alexyk: hiredman: I can lose dups allright

22:34 but, I may as well keep them, so elegance would win

22:35 hiredman: merging sorted vectors is never going to be elegant

22:40 lisppaste8: Chouser pasted "sorted-seq-merge" at http://paste.lisp.org/display/93006

22:40 joshua-choi: @chouser: Thanks a lot; char-name-string was exactly what I needed

22:41 hiredman: a vector is already an ordered associative thing, and each element is associated which it's place in order

22:41 chouser: alexyk: that should do it, though it might be faster to just stuff your two vectors into an array and call Java's sort method on it.

22:44 alexyk: thanks!

22:45 chouser: wasn't as interesting as I'd hoped. heh.

22:47 lazy-seq takes all the fun out of it

22:49 joshua-choi: How does one invert a map: {:a 2, :b 3} -> {2 :a, 3 :b}?

22:51 hiredman: if you scrollup you will see

22:51 arohner: ,(doc clojure.set/map-invert)

22:51 clojurebot: "([m]); Returns the map with the vals mapped to the keys."

22:51 hiredman: spoiler

22:51 joshua-choi: Wow, I didn't see that; thanks

23:11 arohner: paredit is great. now I want it to auto-indent my code

Logging service provided by n01se.net