#clojure log - Dec 05 2009

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

0:00 _ato: (.getURLs (.getContextClassLoader (Thread/currentThread)))

0:00 ^ that might work for add-classpath stuff

0:07 alexyk: _ato: thx!

0:14 did clojure-maven-plugin disappear from build.clojure.org/snapshots?

0:16 slyrus_: duper: common lisp, #lisp

0:16 cemerick: alexyk: huh, I didn't know it was ever there

0:16 alexyk: cemerick: my bad

0:16 cemerick: but now I can ask you about importing << :)

0:17 cemerick: that was fast :-)

0:17 alexyk: IDEA did a load-file on your goodies, says, #'commons.clojure.strint/<<

0:18 cemerick: alexyk: did you hit a snag?

0:18 alexyk: now I'm in my own namespace user=> still

0:18 it works with full name, but I can't rename it into the current namespace in repl

0:18 cemerick: oh -- just (use 'commons.clojure.strint) if you're at a repl

0:18 alexyk: I'm sure it works fine in a new script, but I want a way to get it into repl without modifying classpath

0:19 or restarting the repl

0:19 folks suggested (alias '<< #'commons.clojure.strint/<<) -- fails

0:19 and a version of (defmacro << {your #'commons.clojure.strint/<< tortured})

0:19 cemerick: that's not necessary -- 'use' doesn't work?

0:19 alexyk: didn't work either

0:20 cemerick: that doesn't make sense

0:20 alexyk: the file is not on my classpath as I pasted it into IDEA :)

0:20 cemerick: oh, oh

0:20 I don't know anything about how IDEA's clojure stuff works

0:20 alexyk: I'm generally curious about importing things from other namespaces in repl

0:20 it was loaded into repl with (load-file ...)

0:20 and created << in its own namespace

0:21 and it works fine! :)

0:21 cemerick: then (use 'commons.clojure.strint) should bring << into user (or whatever ns your repl is in)

0:21 *ns*, I should say

0:21 alexyk: (use 'commons.clojure.strint) => java.io.FileNotFoundException: Could not locate commons/clojure/strint__init.class or commons/clojure/strint.clj on classpath: (NO_SOURCE_FILE:0)

0:22 it's not compiled yet as was loaded as-is

0:22 cemerick: and that's after using load-file?

0:22 alexyk: with (load-file ...) :)

0:22 yep

0:22 cemerick: huh

0:22 there's a lot of things that could be getting in the way there.

0:22 I haven't used load-file in about a year :-)

0:23 alexyk: this is general, I understand no aspersions are cast on the fine-crafted << programming

0:23 cemerick: heh

0:23 alexyk: yeah, IDEA did it after clicking on "run file in repl"

0:23 cemerick: I'll overlook your Scala flame-bait, this time, there :)

0:23 cemerick: oh. Maybe it's running the file in a separate classloader, which would make it inaccessible

0:24 alexyk: it just types (load-file ...) into a repl, I see it

0:24 but anyways it's contrived, I should use it from a script anyhow

0:25 hiredman: alexyk: use won't work if the file is already loaded

0:25 use refer

0:25 use tries to load then refer a namespace

0:25 alexyk: hiredman: (refer '...)?

0:25 hiredman: ,(doc refer)

0:25 clojurebot: "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current nam

0:26 cemerick: alexyk: OK, so I get the same behaviour in enclojure. I really never use load-file, so I guess I don't understand what its semantics are.

0:27 alexyk: hiredman: almost there! my previous attempts defined << in local ns, how do I undefine it?

0:27 hiredman: (ns-unmap *ns* '<<)

0:28 alexyk: eureka!

0:28 (<< "There's ~(seq (range n 90 -1)) bottles of beer on the wall...")

0:28 "There's (99 98 97 96 95 94 93 92 91) bottles of beer on the wall..."

0:28 cemerick deserves one of those! :)

0:29 (refer 'commons.clojure.strint) ; did the trick

0:30 * hiredman uses format

0:30 hiredman: but I guess I am old fashioned

0:30 alexyk: cemerick: your blog says, "you should follow me on twitter..." usually this is written as "follow me on twitter..." :)

0:31 hiredman: there was a blog post somewhere about commanding people to follow you results in more follows

0:31 alexyk: hiredman: I look down on Ruby's interpolation, format is visually separable, but the bottle example is good in terms of -- try to format that

0:32 cemerick: alexyk: I'm aping http://dustincurtis.com/you_should_follow_me_on_twitter.html there

0:32 I could care less about the wording, so...

0:32 hiredman: I've been using format and String.format for too long, and too much. I couldn't take it anymore for certain things.

0:33 hiredman: ,(format "There's %s bottles of bear on the wall..." (prn-str (range 100 99 -1)))

0:33 clojurebot: "There's (100)\n bottles of bear on the wall..."

0:33 hiredman: erp

0:33 ,(format "There's %s bottles of bear on the wall..." (pr-str (range 100 90 -1)))

0:33 clojurebot: "There's (100 99 98 97 96 95 94 93 92 91) bottles of bear on the wall..."

0:33 hiredman: ,(format "There's %s bottles of beer on the wall..." (pr-str (range 100 90 -1)))

0:33 clojurebot: "There's (100 99 98 97 96 95 94 93 92 91) bottles of beer on the wall..."

0:33 cemerick: yeah, sure. It's when there's 10 args that it gets rough.

0:33 hiredman: sure

0:34 which is why you write the function that takes a map and generates the string once

0:34 alexyk: cemerick: nice explanation of twitter :)

0:35 hiredman: cemerick: it's neat macro and everyone likes it

0:35 cemerick: I'm surprised that there's been such a response, but I'm happy others appreciate it.

0:36 alexyk: but you can't avoid () can you

0:36 cemerick: avoid ()?

0:36 alexyk: or ~(seq ...) will fall apart

0:37 hiredman: erm

0:37 it's a function call

0:37 alexyk: can you do: There's 100 99 ... 91 bottles...

0:37 I mean in the result

0:37 format does it in the same way, but interpolation?

0:38 _ato: i guess theres: ~(apply str (range 100 90 -1))

0:38 ugh

0:38 hiredman: ,(format "There's %s bottles of beer on the wall..." (apply str (range 100 90 -1)))

0:38 clojurebot: "There's 100999897969594939291 bottles of beer on the wall..."

0:38 _ato: no that won't give you spaces

0:38 hiredman: you have to use interleave

0:38 or reduce

0:39 _ato: yeah, or join from str-utils2

0:39 hiredman: ,(format "There's %s bottles of beer on the wall..." (reduce (partial str " ") "" (range 100 90 -1)))

0:39 clojurebot: "There's 100999897969594939291 bottles of beer on the wall..."

0:39 hiredman: hmmm

0:39 _ato: ,(format "THere's %s bottles of beer on the wall..." (clojure.contrib.str-utils2/join " " (range 100 90 -1)))

0:39 clojurebot: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.str-utils2

0:39 hiredman: ,(format "There's %s bottles of beer on the wall..." (reduce #(str %1 " " %2) (range 100 90 -1)))

0:39 clojurebot: "There's 100 99 98 97 96 95 94 93 92 91 bottles of beer on the wall..."

0:40 _ato: (require 'clojure.contrib.str-utils2)

0:40 ,(format "THere's %s bottles of beer on the wall..." (clojure.contrib.str-utils2/join " " (range 100 90 -1)))

0:40 clojurebot: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.str-utils2

0:40 _ato: ,(require 'clojure.contrib.str-utils2)

0:40 clojurebot: nil

0:40 _ato: ,(format "THere's %s bottles of beer on the wall..." (clojure.contrib.str-utils2/join " " (range 100 90 -1)))

0:40 alexyk: yes! now will cemerick's << do that? without ()?

0:40 clojurebot: "THere's 100 99 98 97 96 95 94 93 92 91 bottles of beer on the wall..."

0:40 hiredman: same call I would imagine

0:40 where is the url for cemericks code?

0:41 alexyk: http://muckandbrass.com/

0:42 cemerick: alexyk: I don't really think you want to go down that path. If you start adding formatting options to something like <<, the syntax will degrade into misery.

0:42 the permutations expand *really* fast

0:42 hiredman: ,(refer 'commons.clojure.strint

0:42 clojurebot: EOF while reading

0:42 hiredman: ,(refer 'commons.clojure.strint)

0:42 clojurebot: nil

0:42 hiredman: ,>>

0:42 clojurebot: java.lang.Exception: Unable to resolve symbol: >> in this context

0:42 _ato: ,<<

0:42 clojurebot: java.lang.Exception: Can't take value of a macro: #'commons.clojure.strint/<<

0:43 alexyk: cemerick: I want to avoid surrounding parens, that's all

0:43 _ato: ,(<< "hello ~(join \" \" (range 10)) world")

0:43 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character

0:43 cemerick: oh, gawd, it's in clojurebot now :O

0:43 hiredman: _ato: can't have strings inside

0:43 alexyk: right: (<< "There's ~(reduce #(str %1 " " %2) (range 100 90 -1)) bottles of beer on the wall...") => java.lang.IllegalArgumentException: Wrong number of args passed to: strint$-LT--LT- (NO_SOURCE_FILE:0)

0:43 hiredman: cemerick: :)

0:44 alexyk: need to quote is somehow...

0:44 hiredman: use \space

0:44 ,\space

0:44 clojurebot: \space

0:44 hiredman: ,(str \space)

0:44

0:44 _ato: ,(<< "hello ~(join \space (range 10)) world")

0:44 alexyk: clojurebot: breathe

0:44 hiredman: ,(str "a" \space "b")

0:44 cemerick: alexyk: you want the parens, otherwise, you'd be depending on whitespace after your binding name, etc.

0:44 clojurebot: " "

0:44 Unsupported escape character: \s

0:44 Titim gan éirí ort.

0:44 "a b"

0:44 hiredman: ah

0:45 \space isn't going to work either

0:45 alexyk: cemerick: yeah, but I don't want them to be in output!

0:45 cemerick: alexyk: well, that's what you get when you str a seq *shrug*

0:45 hiredman: _ato: format works :P

0:46 alexyk: true

0:46 can live with that

0:46 cemerick: cemerick: retarding clojure programmer productivity WORLDWIDE! :-P

0:46 _ato: ,(<< "hello ~(+ 1 1)")

0:46 clojurebot: "hello 2"

0:47 alexyk: now we can say, take that, Ruby folk!

0:47 cemerick: eh, hardly

0:48 << is an order of magnitude of capability away from #{} and heredocs

0:49 alexyk: ,(<< "hello ~(reverse \"ruby\")")

0:49 clojurebot: "hello (\\y \\b \\u \\r)"

0:49 _ato: ,(str "hello " (reverse "ruby"))

0:49 clojurebot: "hello (\\y \\b \\u \\r)"

0:49 _ato: so much nicer :p

0:50 alexyk: _ato: ambiguous spaces and gluing!

0:50 I see [ " ] and am not sure whether it begins or ends what

0:52 _ato: (<< "hello ~(<< \"nested ~(str \\"world\\")\")!")

0:52 ,(<< "hello ~(<< \"nested ~(str \\"world\\")\")!")

0:52 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: strint$-LT--LT-

0:52 _ato: ok.. I can't pull that off

0:52 too confusing

0:53 ,(<< "hello ~(<< \"nested ~(str \\\"world\\\")\")!")

0:53 clojurebot: "hello nested world!"

0:53 _ato: ah

0:53 heh

0:53 cemerick: oy

0:54 _ato: alexyk: fair enough. I can see the simple variable case, like "hello $foo". But anything more complex quickly becomes ugly

0:55 alexyk: exactly

0:55 (<< "hello ~(<< \"nested ~(str \\\"cemerick\\\")\")!")

0:55 ,(<< "hello ~(<< \"nested ~(str \\\"cemerick\\\")\")!")

0:55 clojurebot: "hello nested cemerick!"

0:56 * alexyk blatant copycatting

0:56 alexyk: now we only need to rot13 the nested string...

0:57 hiredman: ,(+ (mod (+ (int \a) 13) 26) (int \a))

0:57 clojurebot: 103

0:58 hiredman: hmmm

0:58 cemerick: _ato: I suspect the best usage will be stuff like (<< "Hi ~(:name user), you have ~{msg-cnt} messages waiting for you in ~(:inbox-loc user)"), or whatever

0:58 hiredman: ,(char 103)

0:58 clojurebot: \g

0:58 hiredman: ,(+ (mod (+ (int \z) 13) 26) (int \a))

0:58 clojurebot: 102

0:58 hiredman: ,(char 102)

0:58 clojurebot: \f

0:58 hiredman: :|

0:58 ,(+ (mod (+ (- (int \z) (int \a) 13) 26) (int \a))

0:58 clojurebot: EOF while reading

0:59 hiredman: ,(+ (mod (+ (- (int \z) (int \a)) 13) 26) (int \a))

0:59 clojurebot: 109

0:59 hiredman: that's not right

0:59 duncanm: la la la

1:00 hiredman: is that right?

1:01 (yes)

1:03 interferon: how do i do a multiline regex match?

1:05 hiredman: ,(re-find #"foo\nbar" "foo\nbar")

1:05 clojurebot: "foo\nbar"

1:05 hiredman: ,(re-find #"foo\nbar" "foobar")

1:05 clojurebot: nil

1:07 interferon: i have a string that looks like "Account\rfoo"

1:07 but Acc(.*) only gets "ount" in the first group[

1:07 it's either not doing multiline or the \r is confusing it

1:10 hiredman: you aren't writing a csv parser are you?

1:10 (just checking)

1:11 (because really there are a million libraries for that and you should just use one, if that is what you are doing)

1:11 interferon: nope, QIF parser

1:11 ,(re-find #"Ac(.*)" "Account\rxyz")

1:11 clojurebot: ["Account" "count"]

1:12 interferon: i want what's after the line too...

1:13 hiredman: ,(re-find #"Ac(.*)+" "Account\rxyz")

1:13 ,(re-find #"Ac(.*)+" "Account\rxyz")

1:13 clojurebot: ["Account" ""]

1:15 chouser: ,(re-find #"(?s)Ac(.*)" "Account\rxyz")

1:15 clojurebot: ["Account\rxyz" "count\rxyz"]

1:15 cark: Pattern.compile(regexString,Pattern.MULTILINE);

1:15 hiredman: " The regular expression . matches any character except a line terminator unless the DOTALL flag is specified. "

1:15 chouser: (?s) turns on DOTALL

1:16 hiredman: neat

1:17 chouser: "The s is a mnemonic for "single-line" mode, which is what this is called in Perl"

1:17 just to clear things up. :-P

1:18 hiredman: makes total sense

1:18

1:19 slyrus_: so what are we supposed to use now that add-classpath is deprecated?

1:19 hiredman: nothing

1:20 you shouldn't be using add-classpath

1:20 so it's removal should be a nop

1:20 slyrus_: so how do you, say, add a jar to the classpath?

1:20 hiredman: you don't

1:20 there is no reliable way to do it

1:21 add-classpath fails in weird ways in weird places

1:21 slyrus_: i get that. I've got a jar. I want clojure's java process to know about its contents. how do i tell clojure "hey, there's a whole bunch of java classes in this file -- go look in there!"?

1:22 hiredman:

1:22 you just rephrased the question I already answered

1:22 slyrus_: is that some weird unicode smiley?

1:22 hiredman: if you want another answer ask a different question

1:23 unicode ellipsis

1:23 . . .

1:23 slyrus_: i have a jar file, let's call it incanter.jar. i'd like clojure to know about its contents. how can i tell clojure that it should consider looking in incanter.jar for the class files?

1:24 hiredman: slyrus_: put it on your classpath

1:24 slyrus_: great. how do i do that? add-classpath?

1:24 hiredman: -cp or CLASSPATH environment variable

1:24 ~google java classpath

1:24 clojurebot: First, out of 292000 results is:

1:24 Setting the class path

1:24 http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html

1:24 slyrus_: bah. I don't want to do that at the time i start the damn process!

1:25 i want to find the jar later. surely that's what add-classpath used to do, no?

1:25 hiredman: well, you can copy the implementation of add-classpath, just don't expect support when it fails

1:25 slyrus_: i'm confused... are you telling me i have to know the jars I want to use when i _launch the process_?

1:25 hiredman: yes

1:26 JAS415: its the java way

1:26 slyrus_: I thought the whole point of clojure was that it was supposed to make the jvm dynamic!

1:26 cark: you can use wildcard in the classpath

1:26 hiredman: dynamic is a word that encompasses a wide variety of behaviour

1:26 JAS415: you can load whatever clojure code you want :-)

1:26 slyrus_: look, this whole jvm thing is ... interesting, but i expect things to be done the ... right way ... the lisp way. :)

1:27 hiredman: slyrus_: well, sign a CA and submit a patch

1:27 JAS415: oh man

1:27 that would be a heck of a patch

1:27 slyrus_: i guess i was just blissfully ignorantly using add-classpath before and everything seemed ok

1:28 JAS415: rewrote JVM to make it lispy :-)

1:28 hiredman: ~add-classpath

1:28 clojurebot: add-classpath is bad, avoid it. I mean it!

1:28 cark: there are always limitations, even with CL, in practice the classpath stuff is no problem at all

1:28 hiredman: should have asked clojurebot

1:29 JAS415: one time in CL I managed to get myself into a state where the code couldn't be loaded from a file

1:29 because there were like

1:29 forward and backward dependencies

1:30 it was a learning experience :-)

1:30 polypus: same thing happeded to me in C++ but we won't talk about that

1:33 does clojurebot have documentation someplace?

1:33 slyrus_: i'm still in a state of shock here, but i find it hard to believe that there's no better way than to specify the location of the classes at the time the process is started.

1:34 am i missing something really obvious here?

1:34 JAS415: i was in that same state of shock for a while too

1:34 hiredman: polypus: docs for clojurebot? (no)

1:35 slyrus_: JAS415: and then what?

1:35 JAS415: i got really good at writing the bash script to start clojure with whatever jars i want

1:35 :-P

1:35 uh

1:35 also

1:35 what i tend to do

1:35 is i make a deps directory

1:35 hiredman: there is kind of a vague and incomplete list of the various plugins in the readme

1:35 JAS415: and just point java at that with a wildcard

1:36 i end up with a couple copies of certain jars laying around

1:36 polypus: hiredman: ty

1:36 hiredman: I stick jars in ~/.jars and put $HOME/.jars/* on the classpath

1:36 JAS415: but less of a headache to drop the jar into the directory than to rewrite thescript

1:36 cark: ah i do it on a per project basis

1:36 JAS415: i do that to cark

1:37 mostly for startup time

1:37 cark: so that i stay with the same version of libs and clojure

1:37 JAS415: (or at least in my semi-magical understanding it seems to change the startup time)

1:37 hiredman: I tend to move in that direction when I am farther down the road once dependencies have all been figured out

1:37 cark: also when you distribute the project, it's easy, no need to hunt for dependencies

1:38 ah that makes sense

1:38 hiredman: otherwise I just throw everthing in .jars and it's always there if I need it

1:38 JAS415: i built a jar the other day

1:38 that was exciting

1:39 i figured out the voodoo, did it, then promptly forgot :-/

1:40 but you can get all of your deps into a single jar

1:40 cark: JAS415: http://github.com/cark/clj-exe-jar i just take this as a starting point

1:40 JAS415: even clojure and clojurecontrib

1:40 that's a niceity

1:40 cark: run ant and be done with it

1:40 JAS415: oh wow

1:40 cool

1:41 *bookmarked*

1:53 tomoj: I think there were a couple blog entries about it too

1:54 (making executable clojure jars I mean)

2:19 timothypratley1: is there a nice way to call 'read' on a string?

2:20 something like (read "{:a 1, :b 2}") <-- but not

2:22 danlarkin: read-string

2:22 timothypratley1: danlarkin: thanks!!!

3:09 triyo: anyone using Leiningen to compile and build their projects?

3:09 tomoj: certainly someone is?

3:10 _ato: triyo: what's the problem?

3:10 triyo: It would be really cool if there was a command that generates .emacs entries for dev purpose (i.e. load all the deps jars)

3:11 _ato: triyo: do you know about M-x swank-clojure-project ?

3:11 triyo: _ato: no, I don't, how does it work?

3:11 tomoj: I would think that leiningen would work well with swank-clojure-project

3:11 since I learned of both from the same person

3:12 _ato: just run it and it'll ask you for a project directory. Point it at the directory of your lein project and it'll start slime with the correct classpath

3:12 tomoj: does lein download deps into lib/?

3:12 _ato: yes

3:12 tomoj: I still haven't tried it :/

3:13 "maven repositories" scare me

3:13 triyo: _ato: oh great, thats awesome. I'll give it try

3:13 tomoj: I mean, say I have enlive as a dependency

3:13 is it in maven somewhere? if not, will lein help me?

3:14 triyo: _ato: any ideas what swank-clojure-project module comes with? I don't seem to have it installed. I do have clojure slime / swank installed

3:14 _ato: If you run into trouble, you might need to copy ~/.swank-clojure/swank-clojure-1.0.jar into your-project/lib. I think it's supposed to add it automatically, but it doesn't work with my setup for some reason (I've probably broken it somehow when tinkering with my emacs config)

3:14 ah

3:14 triyo: you probably need a newer version of swank-clojure

3:14 triyo: did you install via ELPA?

3:14 triyo: yup

3:15 how do you do update again :>?

3:15 _ato: M-x package-list-packages

3:15 tomoj: I don't need to screw around with swank-clojure jars

3:15 and I don't have a .swank-clojure

3:16 ..maybe I have an old version

3:16 _ato: press "i" on the swank-clojure entry and hit C-c C-c (and pray) ;-)

3:16 tomoj: oh, I have swank-clojure from git

3:16 (and clojure-moe)

3:16 mee: if there other other lurking clojure newbs here, this is good (if slow) http://blip.tv/file/2145329/

3:17 triyo: ok I see swank-clojure 1.0... is that the right ver?

3:17 _ato: tomoj: looks like nobody has uploaded enlive to clojars yet

3:17 tomoj: mee: thanks, always love to find more clojure videos

3:17 _ato: triyo: that's the version I'm running

3:21 triyo: _ato: press "i" on the swank-clojure entry and hit C-c C-c -> C-c C-c undefined

3:21 piccolino: Aren't you supposed to hit X?

3:22 _ato: ah yeah

3:22 that's the one

3:22 triyo: hehe, yup it is

3:22 _ato: C-c C-c is "submit" or "go" in virtually every other mode

3:24 triyo: _ato: greate, it broke my slime :)

3:25 piccolino: Are you using some variant of Emacs 23?

3:25 _ato: piccolino: yeah

3:25 triyo: aww really? :(

3:26 triyo: piccolino: yup, aquamacs

3:26 piccolino: _ato, I was asking triyo. :)

3:26 OK, Aquamacs 2.0?

3:26 triyo: nope, 1.8c

3:26 piccolino: Ah, Slime won't work on that.

3:26 You need one of the 2.0 betas.

3:26 Pre-2.0 is based on Emacs 22.

3:27 triyo: slime was working...it just broke when I installed swank-clojure

3:27 tomoj: hmm

3:27 I thought I had slime+clojure working in a non-beta aquamacs

3:27 triyo: what's the breakage look like?

3:27 piccolino: I dunno, I've only recently come to Clojure, but that was the reason it wasn't working for me, and upgrading Aquamacs fixed it.

3:28 I'm sure regular slime works in 22.

3:28 There was some undefined symbol or function in swank-clojure, as I recall, in 22.

3:29 tomoj: I think I might have had that same problem in gnu emacs

3:29 but I don't remember how I fixed it :(

3:29 _ato: hmm, I guess make sure you've got the latest clojure-mode as well and also try commenting out all the swank/slime-related stuff in your .emacs

3:29 I run it with no configuration at all

3:30 tomoj: huh?

3:30 don't you at least need to specify your clojure src directory? or is there a default?

3:30 _ato: it'll download it

3:30 to ~/.swank-clojure

3:30 tomoj: hm

3:31 I must have an old version I guess

3:31 _ato: and I think it also looks like ~/.clojure

3:31 tomoj: I have to do (clojure-slime-config ...)

3:31 _ato: it does a whole bunch of magic these days

3:31 tomoj: though if I weren't also using slime for sbcl, that'd be all I needed to do

3:31 triyo: clojure-test-mode.el:87:1:Error: You must specifiy either a `swank-clojure-binary' or a `swank-clojure-jar-path'

3:31 oh, thats just clojure-test

3:32 tomoj: I think I will try upgrading, wish me luck :)

3:32 triyo: tomoj: 2.0preview3?

3:32 tomoj: of what, aquamacs?

3:32 triyo: yup

3:33 tomoj: I abandoned my mac a while ago

3:33 triyo: oh i see

3:33 tomoj: the clojure-mode/swank-clojure versions I was using with aquamacs are probably at least a couple months old

3:33 but I'm sure I didn't use a beta version of aquamacs

3:34 triyo: When I run M-x slime -> You must specify either a "swank-clojure-binary" or a "swank-clojure-jar-path"

3:34 _ato: hmm

3:35 I just grepped my .emacs.d for swank-clojure-jar-path and got no hits

3:35 you must have an old version of something still

3:35 triyo: hmm

3:36 would it help to drop all downloaded packages and try fresh install?

3:37 _ato: I have: clojure-mode-1.6, clojure-test-mode-1.3, swank-clojure-1.0, slime-20091016, slime-repl-20091016

3:37 tomoj: do you have a clojure-slime config?

3:37 er, (clojure-slime-config ...)?

3:37 maybe if you're using ELPA stuff this is no longer necessary

3:37 triyo: I upgraded clojure-mode from 1.3 to 1.6

3:38 tomoj: I did a clojure-install in a non-default place and so needed to add a (clojure-slime-config ...) to my emacs config

3:38 _ato: maybe it didn't remove the old swank-clojure and just installed the new one on top or something. I had issues with upgrading stuff through ELPA

3:38 look in ~/.emacs.d/elpa

3:39 tomoj: when using elpa, are you restricted to whatever releases the people in control make? I feel like if I tried to use elpa I'd end up wanting some other fork or patches and wind up abandoned elpa for git anyway

3:39 triyo: yup you right, it hasn't removed the old ver

3:41 _ato: tomoj: well it doesn't stop you installing things manually, but yeah you only get the easy install for stuff that people have packages

3:45 ELPA still seems pretty buggy :-( It's not that great for someone who knows emacs well, but if you're new to it, it at least makes setting things up a bit easier.

3:45 The reason I'm using it is mainly just to try it out cause technomancy was talking about it all the time

3:57 mee: oh wow, ref validators are rad

3:57 triyo: correct me if I'm wrong, but isn't clojure-mode or one of other ELPA packages suppose to download clojure from github automatically?

3:58 _ato: triyo: yeah, it's supposed to happen when you do M-x slime

3:58 if it's not working check if you have a ~/.clojure or ~/.swank-clojure directory and if so rename it

4:00 sweet. javascript has a (weirdly-named) recur: return arguments.callee(arg1, arg2);

4:00 * _ato is adding loop/recur support to scriptjure

5:02 talios: 'lo

5:03 Given a list of [:foo "bar" :bar "foo"] - how can I easily turn that into a map? I thought I saw something in clojure core for that, or I should I just use map or something?

5:07 arbscht: ,(apply hash-map [:foo "bar" :bar "foo"])

5:07 clojurebot: {:foo "bar", :bar "foo"}

5:07 arbscht: like that?

5:07 talios: thats the one ;)

5:08 arbscht: :)

5:09 micampe: I am exploring clojure and I was trying to do it by myself

5:09 why is this giving an error?

5:09 (let [v [:foo "foo" :bar "bar"]]

5:09 (reduce conj {} (partition 2 v)))

5:09 talios: arbscht - first I had maven building clojure code, now I have maven building code WITH maven ( pom.clj ) :)

5:11 _ato: ,(reduce #(conj %1 %2) {} (partition 2 [:foo "foo" :bar "bar"]))

5:11 clojurebot: java.lang.Exception: Unable to resolve symbol:   in this context

5:11 _ato: ,(reduce #(conj %1 %2) {} (partition 2 [:foo "foo" :bar "bar"]))

5:12 clojurebot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry

5:12 _ato: oh right

5:12 ,(reduce conj {} (partition 2 [:foo "foo" :bar "bar"]))

5:12 clojurebot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry

5:12 arbscht: ,(partition 2 [:foo "foo" :bar "bar"])

5:12 clojurebot: ((:foo "foo") (:bar "bar"))

5:12 _ato: ,(reduce conj {} (map vec (partition 2 [:foo "foo" :bar "bar"])))

5:12 clojurebot: {:bar "bar", :foo "foo"}

5:12 arbscht: (conj {} '(:foo "foo"))

5:13 _ato: ,(conj {} '(:foo "foo"))

5:13 clojurebot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry

5:13 _ato: so it looks like conj on a map can only take vectors, not lists

5:13 micampe: thanks

5:13 tomoj: ,(apply hash-map [:foo "foo" :bar "bar"])

5:13 clojurebot: {:foo "foo", :bar "bar"}

5:13 tomoj: ?

5:13 arbscht: talios: interesting!

5:14 talios: arbscht - using a project similar to leiningen's, but this is using the maven3 polyglot apis

5:15 whether I can get anything working enough to include in maven3 who knows ( not sure if this code base will be merged either )

6:06 lisppaste8: nipra pasted "dissoc for a list of keys" at http://paste.lisp.org/display/91630

6:07 _ato: ,(dissoc {:a 1 :b 2 :c 3} :a :b :c)

6:07 clojurebot: {}

6:07 _ato: nipra: ^

6:08 ,(apply dissoc {:a 1 :b 2 :c 3} [:a :b :c])

6:08 clojurebot: {}

6:08 nipra: _ato, ??

6:09 _ato: nipra: your paste?

6:10 just saying a simpler definition would be: (defn dissoc* [map keys] (apply dissoc map keys))

6:11 nipra: _ato, oops.. yes :-)

6:12 my bad

6:12 didn't read the doc well

6:33 cgrand: _ato, tomoj: I think there's a problem with Clojar's search function: http://clojars.org/enlive is up since tuesday

6:35 AWizzArd: About monitors: in the repl i do (def x (Object.)) and then have a function (defn foo [n] (println n) (.wait x) (println "Ending" n)). Now I (dotimes [i 10] (future (foo i))) and then wait a bit and want to (.notifyAll x).

6:36 Why does it throw an IllegalMonitorStateException? What can I do to become the owner of the Monitor?

6:41 _ato: cgrand: ah right, yeah it messes up when there's no description. I'll push a fix out for it tomorrow

6:42 cgrand: _ato: thanks, I'll put a description string

6:43 AWizzArd: (locking x (.notifyAll x))

6:43 AWizzArd: ok, let me try that

6:45 cgrand: AWizzArd: and wrap you .wait in a locking form too

6:45 AWizzArd: ok

6:46 Okay, that works, thanks.

7:17 timothypratley1: ,(str nil)

7:17 clojurebot: ""

7:17 timothypratley1: how do I get "nil"?

7:18 _ato: ,(prn-string nil)

7:18 clojurebot: java.lang.Exception: Unable to resolve symbol: prn-string in this context

7:18 _ato: ,(prn-str nil)

7:18 clojurebot: "nil\n"

7:18 _ato: hmm

7:19 timothypratley1: ah grea thanks _ato!

7:19 ,(pr-str nil)

7:19 clojurebot: "nil"

7:19 _ato: ah

7:47 StartsWithK: can i simulate 'let' form with push/pop-thread-bindings? http://paste.pocoo.org/show/155005/

7:47 _ato: let is implemented differently, it doesn't use vars

7:48 I think anyway. ;-)

7:49 StartsWithK: i'm looking at LetExpr in compiler, and i can see it uses Var/pushThreadBindings

7:50 _ato: I could be wrong, but I'm pretty sure the compiler is using pushThreadBindings there to store a map of the local environment, but that's just a compile-time thing

7:51 it doesn't exist at runtime

7:51 StartsWithK: i see

7:54 _ato: also let bindings are lexically scope while thread bindings are dynamically scoped, so you can't even emulate a let binding with a thread binding

7:55 which means that if you close over a thread binding and then exit the binding form it won't work as you'd expect a let binding to

7:56 ,(binding [inc 5] ((fn [] inc)))

7:56 clojurebot: 5

7:56 _ato: ,((binding [inc 5] (fn [] inc)))

7:56 clojurebot: #<core$inc__4732 clojure.core$inc__4732@1121f65>

7:56 _ato: ,((let [inc 5] (fn [] inc)))

7:56 clojurebot: 5

7:57 StartsWithK: ,(binding [i 1] ((binding [i 2] (fn [] i))))

7:57 clojurebot: java.lang.Exception: Unable to resolve var: i in this context

7:58 _ato: a thread-binding must be on an already existing var, that's why I used "inc"

7:58 StartsWithK: ,(binding [inc 1] ((binding [inc 2] (fn [] inc))))

7:58 clojurebot: 1

7:58 StartsWithK: :) your right, this is not let-like

8:03 _ato: ,(((fn [x] (fn [] x)) 4))

8:03 clojurebot: 4

8:04 _ato: ^ you can a closure to implement let

8:04 (at the expense of generating a whole bunch of unnecessary anonymous functions)

8:04 michaeljaaka: hello mastas

8:04 fast question

8:04 (defn me[ & a ] (if (seq a) true false))

8:04 how to make equivalent with identity

8:04 ?

8:05 (defn me[ & a ] (identity (true? (seq a )))))

8:05 doesn't work

8:05 Chousuke: just (seq a)?

8:05 michaeljaaka: :D

8:05 ehhh, it is time to go out ;D

8:06 _ato: (defn me [& a] (boolean (seq a))) if it absolutely has to return true/false

8:06 michaeljaaka: ok

8:07 yes I wanted to return true or false

8:07 but when I use seq in if

8:07 I should get true/false right?

8:07 the seq won't be evaluated

8:07 _ato: yes

8:07 that's correct

8:08 michaeljaaka: ok, thanks

8:08 StartsWithK: _ato: thanks, would that be a good way to construct let if trying to create one of thoes crazy metacircular evaluators? where environment would be replaced with normaln clojure namespace?

8:08 * StartsWithK is just trying new things..

8:09 _ato: yeah that'd be one way to do it

8:11 also if you say wanted to write something that converts clojure code to say Python and wanted let to behave like it does in Clojure. In Python a local var is accessible anywhere in the function, not just inside the enclosing form.

8:13 StartsWithK: for now what i'll try to do is clojure->clojure with one extra special form so it has to have custom macro expander, i think that will be a good minimal start

8:15 with-local-vars and bindings is not a problem, they realy use push/pop thread-bindings, so there should be no problem

8:23 so (fn [] (let [a 1] (println a)) (println a)) -> (fn [] (let [a 1] (println a)) (let [a nil] (println a)) -> convert to python

8:26 _ato: other way around: (let [a 1] (println a)) -> ((fn [a] (println a)) 1) -> (lambda a: print(a))(1)

8:26 python doesn't have a "let"

8:27 of course the other way to do it is to keep track of your local environment and do clearing of vars and figure out nesting in the compiler, which is faster at runtime and what I think Clojure's compiler does.

8:28 but just turning lets into calls to anonymous functions is a really easy way to implement it

8:44 cgrand: _ato: thanks for the tip, http://clojars.org/search?q=enlive isn't empty anymore

9:21 triyo: I tried doing a clean install of swank-clojure and got this error during install -> swank-clojure.el:37:1:Error: Cannot open load file: clojure-mode

9:23 clojure-mode is a dependent, which it seem to have installed during install using ELPA

9:25 line 37 -> (require 'clojure-mode)

9:28 here is my full output of installing swank-clojure via ELPA: http://pastebin.com/m5d7c2d26

9:33 _ato: stupid ELPA :(

9:33 that's crazy

9:33 it says it compiled it just above, why can't it now find it?

9:33 :/

9:33 triyo: _ato: I am so so so unhappy now :)

9:34 ignore the smiley

9:34 I'll try continue as ELPA says all is installed fine... go figure

9:35 _ato: oh.. well it might be ok actually

9:36 I didn't read the output when I installed it, so I could have got the same thing :-P

9:36 triyo: hehe, can you try reinstall again see if you do get it? *just kidding* :)

9:38 _ato: I just did actually (in a fresh user account)

9:38 clojurebot: a is t

9:38 _ato: got the same error but for slime instead of clojure-mode

9:38 so yeah, looks like that's normal

9:38 triyo: hehe so seems thats ok

9:39 _ato: completely blank user: I pasted the ELPA stuff instead *scractch*, evaled it, did M-x package-list-packages, hit "i" on "swank-clojure", pressed "x". Let it download everything. M-x slime. "y" yes to install Clojure. let it download. Got a REPL

9:40 so that works ok. That's on regular Emacs 23 under Linux though. I don't have a mac handy to try aquamacs

9:41 does clojurebot like parens or something: (scala)

9:41 does clojurebot like parens or something: (in a fresh user account)

9:41 hmm... maybe it's random

9:49 triyo: On "do you want to install clojure y/n? I got -> "Wrong number of arguments: delete-directory, 2"

9:49 grr

9:50 _ato: what instructions do you use to install?

9:50 I must be doing something wrong

9:53 Ok, I think I got it....even better, I think I got it running just the way I wish I did in the first place..

9:54 offby1: ([2 3 5 7] 0) => 2, of course. What's an easy way to make ([2 3 5 7] 10) yield nil? I assume I can either handle the IndexOutOfBoundsException, or else perhaps there's some syntax or something that says "If the element isn't present, return this instead". What do y'all recommend?

9:55 triyo: _ato: I install swank-clojure then I ran swank-clojure-project and pointed to an existing leingen created project I have that has a /lib with all libs including swank-clojure, clojure-lang, etc.

9:55 Chousuke: offby1: pass it a second argument

9:55 ,([1 2] 5 :not-found)

9:55 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector

9:55 Chousuke: hm.

9:55 triyo: _ato: ohh it works 100% now

9:55 Chousuke: oh well

9:55 I guess you need to use get then

9:56 ,(get [1 2] 5 :not-found) should work :P

9:56 clojurebot: :not-found

9:56 offby1: Chousuke: thanks

9:57 cark: any idea when the protocols will be somewhat stabilized ?

9:57 offby1: Chousuke: figured it'd be something easy like that :)

9:57 cark: the "new" stuff

9:58 Chousuke: cark: I think the syntax is pretty much decided now.

9:58 cark: right now i have manu protocol files everywhere with multimethods ... i'd like to convert that to real protocols

9:58 *many

9:59 but i'm a bit shy !

10:14 interferon: ,(defn parse-transactions (txs) (let [records (re-split #"\\r\\^\\r(?m)" txs)](map #(parse-detail (re-split #"\\r(?m)" %)) records)))

10:14 clojurebot: DENIED

10:14 interferon: when i evaluate that i get an obscure "cannot create iseq from symbol" exception

10:14 anyone see anything wrong with it?

10:14 cark: parameters to your function should be a vector

10:15 (defn parse-transaction [txs] ...

10:15 interferon: oh man!

10:15 i feel dumb

10:15 thanks

10:15 used to CL :)

10:15 cark: i still get bitten by that after a year =/

10:24 maddis: is there a way to do negation? like (!nil? foo), meaning "not nil" ?

10:24 interferon: maddis: (not foo)

10:24 is there a good clojure debugger? i love slime, but it seems like i can't do much once i hit an error

10:24 ,(not true)

10:24 clojurebot: false

10:25 interferon: ,(not false)

10:25 clojurebot: true

10:25 cark: you have println

10:25 and if you want to get fancy, go with c.c.pprint !

10:25 seriously : you can use java debugers

10:25 maddis: oh thanks, of course, stupid me

10:26 rhickey: interferon: Java debuggers work well with Clojure -

10:26 interferon: i can still see clojure variables and function names in a java debugger?

10:27 cark: if you like single step hell i guess, i never even tried any debugger with clojure

10:28 rhickey: variables - yes, and function names get a slight but readable mangle. and you can set breakpoints in Clojure code

10:29 interferon: oh how do i set breakpoints?

10:30 and is there a clojure debugger in slime that i'm missing or is that feature not there?

10:30 rhickey: interferon: depends on the debugger - usually just park the cursor on the code

10:31 interferon: I don't think Slime debugging works with CLojure as it does with CLs. It presumes an interleaving of the runtime with execution that doesn't exist in Clojure

10:32 interferon: oh i see what you mean

10:32 okay

10:34 triyo: swank-clojure docs shows that I can keep my CL implementation using: (add-to-list 'slime-lisp-implementations '(sbcl ("sbcl"))) and then running M-- M-x slime which enables me to type the impl name in. However it doesn't have my CL impl, it only has clojure. Am I missing something?

10:35 I just wish to run my working CL slime side-by-side with my clojure env

10:35 interferon: thought you meant something like a "(break)" form

10:37 ,(clojure.contrib.str-utils/re-split #"x.*b(?s)" "fooxy\nzbbar" )

10:37 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.str-utils

10:38 interferon: why doesn't that (?s) modifier make the . match anything?

10:43 ahh needs to be a the front

10:43 ,(re-find #"(?s)x.*b" "fooxy\nzbbar" )

10:43 clojurebot: "xy\nzbb"

10:43 interferon: stay tune, while i answer more of my own questions

10:55 slyrus_: speaking of swank-clojure... has there been any progress on making it run with the current slime CVS HEAD?

10:56 whoops... my window was scrolled back a few screens. we weren't just talking about swank-clojure...

10:56 oh, yes we were... too early for me.

10:59 rsynnott: The slime CVS head tends to be a moving target :)

11:00 It might almost make sense to incorporate swank-clojure into the swank project proper, but I suppose the maintainers mightn't want to do that

11:01 MikeDev: do you need to say return in clojure?

11:02 the-kenny: MikeDev: No.

11:02 The result of the last form us returned from a function

11:10 * slyrus_ is still trying to wrap his head around the fact that he has to have all of his jars/classes available to the jvm at the time he starts the java process...

11:15 MikeDev: Ought one be able to defnine functions with clourebot

11:17 the-kenny: MikeDev: You can always define inline-functions

11:17 ,(let [myfun (fn [a

11:17 clojurebot: EOF while reading

11:17 the-kenny: oop

11:18 ,(let [myfun (fn [a] (inc a))] (myfun 42))

11:18 clojurebot: 43

11:19 MikeDev: so let's syntax is: let [def] expr

11:20 in ML it's let def in expr

11:20 the-kenny: (let [foo 42 bar 23] (list foo bar))

11:20 ,(let [foo 42 bar 23] (list foo bar))

11:20 clojurebot: (42 23)

11:22 MikeDev: for if it's (if (expr) expr expr)???

11:23 the-kenny: (if (expr) expr else-expr

11:23 +)

11:24 Chousuke: actually just (if test-expr then-expr else-expr)

11:24 the-kenny: MikeDev: You can look at the api-docs on clojure.org.

11:24 There are plenty of examples on the site

11:25 MikeDev: I'm looking on clojure.org and the reference section sucks

11:26 the-kenny: http://richhickey.github.com/clojure/clojure.core-api.html

11:26 MikeDev: much better

11:28 Chousuke: let is not described very well by its docstring though :/

11:28 the-kenny: Chousuke: let and every other special form too

11:29 Anniepoo: If some AI oriented person on this list is looking for a modest sized project a nice version of find-doc that had some intelligence would be a cool one

11:29 MikeDev: yeah that happens too but kenny fixed that 4 me

11:30 slyrus_: liebke: you're missing a parenthesis in incanter.el

11:31 MikeDev: can a function return things of 2 completely diff types

11:31 JAS415: yes?

11:31 alexyk: liebke: why did project.clj disappear?

11:32 offby1: is (count x), when x is a list, fast? (i.e., constant-time?)

11:32 Chousuke: MikeDev: a function can return any descendant of Object currently.

11:32 chouser: offby1: yes

11:32 ,(counted (list 1 2 3))

11:32 clojurebot: java.lang.Exception: Unable to resolve symbol: counted in this context

11:32 offby1: chouser: thanks

11:32 Chousuke: offby1: For lists yes, but not for all sequences :/

11:32 chouser: ,(counted? (list 1 2 3))

11:32 clojurebot: true

11:33 Anniepoo: ,#([{:tacos "Yes!"} :deconstructionism 7])

11:33 clojurebot: #<sandbox$eval__5478$fn__5480 sandbox$eval__5478$fn__5480@a6287>

11:33 MikeDev: for example, I'm making a function that will take a url arg and if valid, parse it and return a list of certain elements. If it's not a valid URL, I'd want to have an error of some sort. It would be nice to return either an error string or a list of 0 or more elements

11:34 liebke: alexyk: it is possible I broke the original incanter.el file technomancy contributed, but since I don't use emacs, I wouldn't have noticed. Can you submit the fixed version?

11:34 Anniepoo: while you can do that, why not have it throw an exception?

11:34 MikeDev: because I'm stupid and ont know how

11:34 liebke: alexyk: I removed project.clj until we have a version that can actually build the project

11:34 MikeDev: that prob would be best, yes

11:34 alexyk: liebke: that was slyrus :) I'm using TextMate

11:35 Anniepoo: ah, then there's no time like the present to learn

11:35 MikeDev: :)

11:35 alexyk: liebke: so for *using* incanter, just :dependencies [[incanter/incanter "0.9.0"]] is enough in a project.clj?

11:35 liebke: sorry :)

11:35 slyrus_ can you submit a fixed version of the el file?

11:36 MikeDev: Anniepoo, plus i have to get this done in a timely manner

11:36 liebke: alexyk: yes

11:36 chouser: ,(-> "Something failed" Exception. throw)

11:36 clojurebot: java.lang.Exception: Something failed

11:36 slyrus_: liebke: can you be a bit more specific about what you mean by "submit"? e.g. send you an email with a patch?

11:36 Anniepoo: then use the exception.

11:36 alexyk: liebke: so incanter.jar sucks in all the deps?

11:36 Anniepoo: like that

11:36 MikeDev: i might be able to get a job doing this

11:37 alexyk: liebke: I miss fine-grained histogram control of R. E.g. specifying bucket boundaries...

11:37 liebke: alexyk: patches welcome :-)

11:37 MikeDev: and stop doing PHP content managed websites

11:37 clojurebot: we can't stop here! this is bat country!

11:38 Anniepoo: right now there are a large number of talented programmers who have discovered Clojure, but the message hasn't percolated

11:38 liebke: there are a lot of features I'd like to add to the charts library

11:39 MikeDev: is that exception code above to be considered an expression?

11:39 Anniepoo: to more conservative software devs/cto's/ceo's and so currently there's a shortage of clojure work

11:39 but we all feel your pain

11:39 alexyk: liebke: so these JFreeCharts, are they actively under development?

11:40 liebke: yep: http://www.jfree.org/jfreechart/

11:40 Anniepoo: jfreecharts are a good thing

11:40 liebke: i've only scratched the surface of the jfreechart api

11:41 Anniepoo: and would be a great application for a DSL

11:42 offby1: I've got a loop that's orders of magnitude slower than I'd expect. How might I investigate?

11:42 Anniepoo: ,(import 'java.util.Date)(macroexpand '(.getDay (Date.)))

11:42 clojurebot: java.util.Date

11:42 cark: offby1 set *warb-on-reflection* to true

11:42 then recompile

11:42 Anniepoo: ,(macroexpand '(.getDay (Date.)))

11:42 clojurebot: (. (Date.) getDay)

11:43 Anniepoo: ok, why does that expand to Date. and not (new Date)?

11:43 offby1: cark: aaaaaahhh.

11:44 cark: I'm not sure how to do that, though. I'm currently just loading a file; I don't know how to set the variable before compiling. I doubt it'll suffice to just stick an assignment at the top of the file.

11:44 cark: *warn-on-reflection* actually

11:44 yes it will suffice

11:44 offby1: that too.

11:44 oh!

11:44 ok, I'll try that

11:45 cark: if you have no warning, just show us some of your code =)

11:47 offby1: cark: well, I do have a warning, but it's not blindingly obvious that it's pertinent. So here be the code: http://gist.github.com/249755

11:47 the slow loop is around line 35

11:50 cark: count on a list is O(n)

11:50 err i think

11:50 try passing in a vector instead

11:50 offby1: oh!

11:51 but ... ,(counted? (list 1 2 3))

11:51 ,(counted? (list 1 2 3))

11:51 clojurebot: true

11:51 offby1: I thought that implied it was O(1)

11:51 chouser: count on a PersistentList is O(1)

11:51 cark: ah right, anyways you should test with (seq words)

11:51 offby1: is that the equivalent to Scheme's (not (null? words))

11:51 chouser: offby1: are you using set/union to add a single thing to a set?

11:52 offby1: chouser: I think so, lemme double-check

11:52 cark: offby1 : yes

11:52 offby1: should I use conj?

11:52 chouser: I bet that's slow. try conj instead.

11:52 ,(conj #{1 2 3} 4)

11:52 clojurebot: #{1 2 3 4}

11:52 cark: anyways you're passing in a lazy list, not a persistent list (i think)

11:52 offby1: ,(conj #{1 2} 2)

11:52 clojurebot: #{1 2}

11:52 offby1: hm

11:53 chouser: yeah, don't use (zero? (count words)), just (seq words)

11:53 cark: ,(counted? (filter odd? (list 1 2 3 4)))

11:53 clojurebot: false

11:54 offby1: ,(conj #{"x" "y"} "x")

11:54 clojurebot: #{"x" "y"}

11:54 ikitat: anyone know why `lein swank` would fail with (use 'clojure.test) in the repl?

11:57 cark: offby1 : i wonder why you're not using reduce =/

12:00 MikeDev: ,(re-matches #"<h[1-6]>.*?</h[1-6]>" "<h1>Clow</h1><div><h2>Jure</h2></div>")

12:00 clojurebot: nil

12:01 MikeDev: why?

12:01 It works in perl

12:01 offby1: cark: probably because I didn't know it existed

12:01 cark: hehe =)

12:03 offby1: I stuck (seq words) in instead of (zero?(count words)), but that made the test fail.

12:03 ikitat: ,(re-find #"<h[1-6]>.*?</h[1-6]>" "<h1>Clow</h1><div><h2>Jure</h2></div>")

12:03 clojurebot: "<h1>Clow</h1>"

12:03 MikeDev: yeah ok

12:03 offby1: ,(seq? (list))

12:03 clojurebot: true

12:03 offby1: ,(seq (list))

12:03 clojurebot: nil

12:03 offby1: ,(seq (list 1))

12:03 clojurebot: (1)

12:05 alexyk: liebke: lein deps/repl works fine for an incanter app! nice

12:05 offby1: cark: what is this =/ of which you speak?

12:06 alexyk: so in lein, as opposed to mvn, you specify a top dependency alone, and all the subdeps are included, apparently

12:07 cark: offby1 : err sorry that a smiley

12:08 offby1: ah

12:08 I considered "reduce". Can't remember why I didn't use it

12:08 anyway, using (seq words), despite my earlier protestation, works great; thanks.

12:08 cark: great

12:28 MikeDev: Question: does clojure have an html parser?

12:29 http://clojure.org/libraries sez maybe clj-html?

12:30 but doesnt look like it

12:30 upon further review

12:33 mikem: MikeDev: you could try using a Java library for that (ie: TagSoup)

12:34 MikeDev: k

12:41 chouser: tagsoup is beatiful, and works well with clojure.xml, clojure.contrib.lazy-xml, and then zip and zip-filter

12:42 beautiful

12:43 MikeDev: if you had a big tree structure of an html document, how do you easily pull out certain tags that could be arbitrarily deep

12:45 the-kenny: MikeDev: Xpath

12:45 MikeDev: There's also something in contrib, wait

12:45 c.c.zip-filter

12:45 That's almost xpath, but in clojure-style

12:46 MikeDev: so i have to download tagsoup right?

12:47 wouldnt be standard right?

12:48 the-kenny: tagsoup?

12:51 MikeDev: yes

12:52 the-kenny: What's that?

12:52 MikeDev: I hope this is fine: http://home.ccil.org/~cowan/XML/tagsoup/tagsoup-1.2.jar

12:52 KirinDave: cgrand-r1c: Hey, are you around?

12:53 * KirinDave is having problems with Enlive and was hoping for help.

12:53 MikeDev: can u just use any java class with clojure?

12:53 the-kenny: MikeDev: Yes

12:53 MikeDev: neet

12:54 the-kenny: MikeDev: But you won't need tagsoup.jar or any other external library to use c.c.zip-filter. It's written in clojure and integrated in contrib

12:55 MikeDev: Clojure's Java-Interop: http://clojure.org/java_interop

12:56 MikeDev: kenny: zip-filter can parse HTML and not just XML

12:56 ?

12:56 the-kenny: MikeDev: xhtml is valid xml. "normal" html should be xml too

12:56 MikeDev: html 4 strict isnt

12:56 <br>

12:57 the-kenny: hm... I would give it a try

12:57 Maybe it can handle the special cases of html

12:58 MikeDev: bear in mind that all i need to do is process header tags. dont care about anything else. the only reason I ask about html parsers is that the guys in #perl are saying I suck if I dont use an html parser

12:59 i think I will just use re's

12:59 particularly over something more complicated that might not work anyway

13:11 So if you do (?'Name'pattern) in a re, you are supposed to be able to recall it in the pattern later with \k'Name' ?

13:11 danlarkin: java regexes doen't support named groups

13:12 MikeDev: i see

13:13 KirinDave: Ahah, got enlive working. :\

13:15 I gotta patch that.

13:15 it shouldnt throw a null pointer exception for a missing file.

13:15 This is the problem with direct code generation macro systems. People get so caught up in the codegen logic that it gets difficult to add solid error handling.

13:16 clj needs MBE.

13:19 interferon: i'm having a hard time working with a data structure i've set up. basically, i have a map of vendor names to vendor structs. each vendor struct has an :inventory key that contains a list of inventory structs, each of which contains a name and a quantity

13:20 if i want to adjust the quantity of one product for one vendor, my code becomes somewhat convoluted

13:20 are there any guides to working with complex structures like this?

13:20 arohner: KirinDave: what is MBE?

13:20 chouser: MikeDev: tagsoup parses broken html pages as if they were valid xml, so you can feed that into clojure.xml/parse or clojure.contrib.lazy-xml

13:21 cark: interferon : go bottom-up ... first write functions that work with your inventory structs

13:21 taking the struct as first parameter

13:21 interferon: here's what i have now http://paste.lisp.org/display/91655

13:21 cark: the you can go one level up

13:21 then*

13:22 KirinDave: arohner: PLT Scheme has a different macro system that many people have adopted

13:22 there are even CL libraries for it

13:22 It's called "Macro By Example"

13:22 Or "pattern macros"

13:22 http://docs.plt-scheme.org/guide/pattern-macros.html

13:22 It also is a good way to encapsulate truly hygienic macros.

13:23 arohner: interferon: probably the biggest lesson I've learned about writing clj code is to build composable functions. Small functions with a clearly identified purpose

13:23 cark: interferon : so when you want to go a level up you can use update-in, using your lower level functions

13:24 arohner: interferon: well designed functions play nicely with map, filter, reduce, etc

13:24 or whatever the appropriate core functions for your datastructure is

13:24 interferon: is update-in built-in?

13:25 arohner: yes

13:26 ,(doc update-in)

13:26 clojurebot: "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."

13:26 cark: of course it's not always that simple... but that should get you going

13:27 arohner: KirinDave: thanks. this is probably the first documentation for syntax rule that I've ever understood

13:28 cark: you're using merge when assoc should do the work, or assoc-in or update-in

13:30 in the end you should have an api such that you can (update-vendor "paul" add-inventory "nasal spray" 2)

13:30 or something like it =)

13:31 interferon: can someone explain how -> works?

13:33 cark: ,(-> "hello" count inc)

13:33 clojurebot: 6

13:33 cark: ,(-> "hello" count inc (* 5))

13:33 clojurebot: 30

13:34 cark: ,(-> {:a 1 :b {:c 2 :d 3}} :a :d)

13:34 clojurebot: nil

13:34 cark: ,(-> {:a 1 :b {:c 2 :d 3}} :b :d)

13:34 clojurebot: 3

13:35 cark: ,(:d (:b {:a 1 :b {:c 2 :d 3}}))

13:35 clojurebot: 3

13:35 dulanov: vah, (count (range 100))

13:35 (count (range 100))

13:35 ,(count (range 100))

13:35 clojurebot: 100

13:36 interferon: so it applies functions in a chain?

13:36 KirinDave: arohner: It's not new. PLT Scheme has fabulous documentation, they have for years.

13:36 cark: ,(doc ->)

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

13:36 MikeDev: suppose you *know* that the arg to function will be a list of which you want the second element. can u pattern match on that?

13:36 in ML you can do fun Blah a::list

13:37 cark: interferon : you can use macroexpand to see what a macro does

13:37 KirinDave: MikeDev: You mean, checking type? Or deconstructing objects in the list?

13:37 MikeDev: probably deconstructing

13:37 KirinDave: MikeDev: Because then it's no and yes.

13:38 MikeDev: in ML you can do fun blah a | fun blah a::list

13:38 | fun blah nil

13:38 cark: ,((fn [[_ a]] (inc a)) 10)

13:38 clojurebot: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

13:38 cark: ,((fn [[_ a]] (inc a)) (list 10 11))

13:38 clojurebot: 12

13:38 interferon: update-in is very helpful - thanks guys

13:39 MikeDev: so can I do fn [a b] = b

13:40 the-kenny: MikeDev: Looks like haskell

13:40 cark: that's what i showed or did i misunderstand your question ?

13:41 MikeDev: i guess

13:42 arohner: KirinDave: I hadn't seen PLT's documentation before. I always saw links to either R5RS or some random blog post. Those weren't very good.

13:43 lisppaste8: url

13:43 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

13:43 MikeDev: cark, no yours is a list of 2 i have a list of n which are lists of 2

13:43 i guess i need map

13:43 lisppaste8: arohner pasted "weak reference" at http://paste.lisp.org/display/91658

13:44 arohner: weak-reference seems useful. I wonder if it is worthy to go into contrib

13:45 MikeDev: ,(re-seq #"<h[1-6]>(.*?)</h[1-6]>" "<h1>Clow</h1><div><h2>Jure</h2></div>")

13:45 clojurebot: (["<h1>Clow</h1>" "Clow"] ["<h2>Jure</h2>" "Jure"])

13:45 MikeDev: want the 2nd args

13:45 is that a list of lists?

13:45 the-kenny: MikeDev: Yes

13:45 MikeDev: a list of vectors?

13:46 the-kenny: list of vectors

13:46 now just (map second your-result)

13:46 MikeDev: ,(map (fn [[_ b]] (b)) (re-seq #"<h[1-6]>(.*?)</h[1-6]>" "<h1>Clow</h1><div><h2>Jure</h2></div>"))

13:46 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:46 MikeDev: That is what I thought would work

13:46 ,(map (fn [_ b] (b)) (re-seq #"<h[1-6]>(.*?)</h[1-6]>" "<h1>Clow</h1><div><h2>Jure</h2></div>"))

13:46 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5653$fn

13:47 the-kenny: why (b)

13:47 you try to call the function in b, but b holds a string

13:47 oh.. and you can just use second

13:47 MikeDev: thought that's how fn's are defined syntactialy

13:47 the-kenny: ,(map second (list ["foo" "bar"] ["bla" "foobar"]))

13:47 clojurebot: ("bar" "foobar")

13:47 the-kenny: No

13:48 ,((fn [_ a] a) 42)

13:48 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5668$fn

13:48 the-kenny: ,((fn [_ a] a) 42 23)

13:48 clojurebot: 23

13:48 the-kenny: ,((fn [_ a] (a)) 42 (fn [] 23))

13:48 clojurebot: 23

13:48 the-kenny: ,("foobar")

13:48 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:48 MikeDev: seond will work

13:49 the-kenny: Yes

13:49 solussd: is there a function/macro that prints the code for a function?

13:49 the-kenny: and take a look at the syntax for (fn)

13:49 solussd: e.g. (show-code loop)

13:49 the-kenny: solussd: I think so. Somewhere in clojure.contrib

13:49 repl-utils iirc

13:49 solussd: thanks

13:50 the-kenny: (use 'clojure.contrib.repl-utils)

13:50 arohner: source in repl-utils

13:50 the-kenny: ,(use 'clojure.contrib.repl-utils)

13:50 clojurebot: java.lang.ExceptionInInitializerError

13:50 solussd: yep. found it

14:06 MikeDev: Is there any kind of filter function which will go thru a list, apply a function you create to each item, and return a list of only the items for which your function returned true?

14:07 solussd: yes, filter does that

14:07 the-kenny: MikeDev: (first (filter ...))?

14:07 Oh, I read "only one item"

14:07 sorry

14:07 MikeDev: only *the* items

14:07 didnt see filter in cor

14:07 core*

14:07 solussd: ,(filter #(= 3) [1 2 3 4 5 6 3])

14:08 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5698$fn

14:08 MikeDev: no filter: http://richhickey.github.com/clojure/clojure.core-api.html

14:08 solussd: ,(filter #(= 3 %) [1 2 3 4 5 6 3])

14:08 clojurebot: (3 3)

14:08 the-kenny: ,(doc filter)

14:08 clojurebot: "([pred coll]); "

14:08 MikeDev: that's fine, thx

14:09 KirinDave: Man

14:09 Wtf

14:09 http://github.com/richhickey/clojure-contrib/blob/5055f41c8bc99747392396d622f17f723470858e/src/clojure/contrib/http/agent.clj#L306

14:09 ,(#{:foo :baz} {:foo 1 :bar 2 :baz 3})

14:09 clojurebot: nil

14:09 KirinDave: I'm confused.

14:10 offby1: (printf "foo") goes to stdout. How do I print to stderr?

14:10 MikeDev: printf 2 "foo"

14:10 (maybe)

14:10 arohner: ,(#{:foo :baz} :foo)

14:10 clojurebot: :foo

14:10 arohner: ,(#{:foo :baz} :bogus)

14:10 clojurebot: nil

14:10 KirinDave: Ahh, I see

14:10 arohner: that's checking whether an item belongs to a set

14:10 KirinDave: Yeah, I was reading it backwards

14:10 like, "Can you union two keys with a set for access into a hash?

14:10 solussd: a set is function

14:11 KirinDave: That'd actually be pretty cool.

14:11 offby1: dynamically bind *out*, maybe

14:11 arohner: offby1: yeah

14:11 (binding [*out* error-stream] (println ...)

14:12 MikeDev: if there's a second, is there a third?

14:12 arohner: I think there's a name for stderr, but I don't remember what it is

14:12 oh, *err*

14:12 duh

14:12 offby1: System/err, I'd guess

14:12 arohner: ,(doc *err*)

14:12 clojurebot: "; A java.io.Writer object representing standard error for print operations. Defaults to System/err, wrapped in a PrintWriter"

14:14 MikeDev: ,((fn [z y x] x) ["a" "b" "c"])

14:14 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5772$fn

14:14 offby1: ,(print "hey")

14:15 clojurebot: hey

14:15 offby1: ,(binding [*out* *err*](print "hey"))

14:15 clojurebot: nil

14:15 hey

14:15 offby1: odd, the output vanishes when I try it :-|

14:15 arohner: where are you trying it?

14:16 solussd: MikeDev, I think you want 'apply'

14:16 arohner: something in your environment could be ignoring/ dropping stderr

14:16 dulanov: ,(.toString *out*)

14:16 clojurebot: ""

14:16 solussd: (apply (fn [z y x] x) ["a" "b" "c"])

14:16 dulanov: ,(class*out*)

14:16 clojurebot: java.lang.Exception: Unable to resolve symbol: class*out* in this context

14:16 solussd: ,(apply (fn [z y x] x) ["a" "b" "c"])

14:16 clojurebot: "c"

14:17 arohner: stupid keyboard shortcuts

14:17 solussd: or you could just pass the vec as args:

14:17 arohner: I hate that emacs shortcuts typed into another other program does bad stuff

14:17 * into any other program

14:17 solussd: ,((fn [z y x] x) "a" "b" "c")

14:17 clojurebot: "c"

14:18 dulanov: ,((fn [_ _ x] x "a" "b" "c")

14:18 clojurebot: EOF while reading

14:18 dulanov: ,((fn [_ _ x] x) "a" "b" "c")

14:18 clojurebot: "c"

14:18 the-kenny: arohner: I really miss paredit in almost every other program... I keep forgetting to close braces

14:18 solussd: paredit is a pain though if you want to rearrange things...

14:19 dulanov: ,(#(%3) "a" "b" "c")

14:19 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

14:19 arohner: the-kenny: I'd be happy with ctrl-N, ctrl-P, ctrl-W not doing destructive things or popping up dialog boxes

14:19 the-kenny: solussd: "Rearrange"?

14:19 dulanov: ,(#('%3) "a" "b" "c")

14:19 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: Symbol

14:19 arohner: or leaving chat rooms...

14:20 dulanov: #() is not the same as fn

14:20 solussd: the-kenny: in emacs, using paredit always balances your parens, If I want to kill the end of a line (with closing parens) and maybe yank it somewhere else, it seems to get in the way.

14:21 Chousuke: solussd: use C-k to kill s-exps instead :/

14:21 solussd: the-kenny: but I only used it for maybe an hour before getting frustrated with it, so what do i know...

14:21 the-kenny: solussd: hm.. I understand what you mean

14:21 MikeDev: hey I fed a bad thing to closurebot how do I cancel it

14:21 now it just hangs for me

14:21 Chousuke: solussd: it makes no sense to delete everything to the end of the line if it breaks the s-exp structure. :)

14:21 the-kenny: But I like it for lisp-development. As Chousuke said, it will yank the sexp instead

14:22 MikeDev: nevermind, it' thinkgs

14:22 solussd: Chousuke: i'm sure I'd learn to work with it if I gave it enough of a chance. It would probably just spoil me though. :)

14:22 Chousuke: solussd: yeah, it does :P

14:22 the-kenny: It always keep the sexp-tree valid :)

14:22 Chousuke: sometimes you can end up with mismatching parens though :/

14:23 but then it's not too difficult to force emacs to insert them

14:26 the-kenny: agh...

14:26 * the-kenny just commited his twitter-password to a git repository

14:26 solussd: which git repository?

14:27 Chousuke: the-kenny: just delete the commit :)

14:27 the-kenny: Chousuke: ..or change the password ;)

14:27 Chousuke: well, whichever.

14:27 the-kenny: I think I already committed it with the initial commit... It's easier to change it

14:28 Chousuke: heh

14:28 you could also use git's history filtering features!

14:29 I like how nothing is sacred in git :P

14:29 the-kenny: I could also shoot myself in the foot :p

14:29 Chousuke: you can change anything at any time and it's not git's problem if that breaks things.

14:39 MikeDev: how do you cast a string to a char sequence?

14:39 cark: ,(seq "blah")

14:39 clojurebot: (\b \l \a \h)

14:39 MikeDev: ty

14:41 JAS415: the-kenny needs to use oauth :-P

14:42 the-kenny: JAS415: hm.. Maybe I'll have a look at oauth ;) But I have to refactor some files before that

14:44 eno__: how do you get the key of a map with max value?

14:44 e.g. {:three 3 :five 5 :four 4}, I want to get :five

14:51 j3ff86: eno, i have a function that does that, let me get it

14:53 (apply max-key second (indexed coll))))

14:53 eno__: j3ff86: thx

14:54 j3ff86: (apply max-key second (indexed coll))

14:56 actually i dont know if it works for symbols

14:56 eno__: not quite

14:58 ,(let [m {:three 3 :five 5 :four 4}] (apply max-key #(val (second %)) (indexed m)))

14:58 clojurebot: [1 [:five 5]]

14:58 eno__: getting close

15:00 ,(let [m {:three 3 :five 5 :four 4}] (key (second (apply max-key #(val (second %)) (indexed m))))

15:00 clojurebot: EOF while reading

15:01 eno__: ,(let [m {:three 3 :five 5 :four 4}] (key (second (apply max-key #(val (second %)) (indexed m)))))

15:01 clojurebot: :five

15:10 MikeDev: What is :blah all about?

15:11 Chousuke: it's a keyword

15:11 a symbol which evaluates to itself.

15:12 hmm

15:12 ,(map identical? [:foo 'bar] [:foo 'bar])

15:12 clojurebot: (true false)

15:12 MikeDev: Hey keyword, why dont you go evaluate yourself?

15:12 JAS415: the-kenny: i used this when i did oauth in clojure: http://code.google.com/p/oauth-signpost/

15:14 the-kenny: JAS415: I'll bookmark this. Thanks :)

15:15 ska2342: Chousuke: (identical 'bar 'bar) is false, because quote creates a new symbol every time.

15:15 ..identical?..

15:16 Chousuke: ska2342: yeah

15:17 ska2342: Chousuke: do you have any idea, how to access a symbol later again? E.g. to retrieve metadata associated with that sym?

15:18 chouser: the reader creates a new symbol every time, whether it's quoted or not

15:18 StartsWithK: ,(let [m {:three 3 :five 4 :four 4}] (-> m seq (apply max-key second) first))

15:18 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap$Seq cannot be cast to clojure.lang.IFn

15:18 StartsWithK: ,(let [m {:three 3 :five 4 :four 4}] (->> m seq (apply max-key second) first))

15:18 clojurebot: :four

15:18 StartsWithK: ups

15:19 chouser: ,(apply = ((juxt first second) '(:foo :foo)))

15:19 clojurebot: true

15:19 chouser: ,(apply = ((juxt first second) '(foo foo)))

15:19 clojurebot: true

15:19 chouser: ,(apply identical? ((juxt first second) '(foo foo)))

15:19 clojurebot: false

15:19 chouser: ,(apply identical? ((juxt first second) '(:foo :foo)))

15:19 clojurebot: true

15:20 ska2342: chouser: I already tried to get an answer to this from the groups, but w/o success. If I create a symbol and add metadata to it, how can I access the metadata of /that symbol/ later (not a copy of it attached to a Var)?

15:23 MikeDev: what is string concat?

15:23 ,(. "a" "b")

15:23 clojurebot: java.lang.IllegalArgumentException: Malformed member expression

15:23 MikeDev: ,(+ "a" "b")

15:23 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

15:24 eno: ,(str "abc" "def")

15:24 clojurebot: "abcdef"

15:24 MikeDev: ,(str "a" "b")

15:24 clojurebot: "ab"

15:24 MikeDev: k

15:24 ska2342: ,(str "first" "second")

15:24 clojurebot: "firstsecond"

15:26 ekontsevoy: http://clojure.org/libraries says "There are many libraries for Clojure that complement what is in the Clojure core" and then goes a long list of clojure.contrib.* pacakges, but where's a reference for aforementioned "Clojure Core"? Or should I use verbose Java SE for everything?

15:27 dulanov: http://richhickey.github.com/clojure/

15:27 ?

15:27 API section

15:28 ekontsevoy: Oh! Thanks

15:29 ska23421: chouser: is my question concerning symbols and metadata too stupid? Am I missing something easy and important?

15:31 hiredman: ,(meta (with-meta 'foo {:bar 1}))

15:31 clojurebot: {:bar 1}

15:31 hiredman: ,(identical? 'foo 'foo)

15:31 clojurebot: false

15:32 ska23421: hiredman: and how would you access the metadata of 'foo later?

15:32 hiredman: keep 'foo around

15:32 (def a 'foo)

15:33 (let [a 'foo])

15:33 etc

15:34 if that doesn't work for your, then your data isn't a good fit for metadata

15:34 ska23421: hiredman: actually I don't need that functionality. Just trying to grok metadata attached to symbols

15:36 hiredman: symbols are not interned, so a 'foo somewhere and a 'foo somewhere else in code don't yield the same object

15:37 ska23421: hiredman: OK. What happens to the metadata of (def #^{:context "Symbol"} my-symbol "What ever value")

15:37 Is only copied once from the symbol 'my-symbol to the Var with that name or is it still hanging around and accessible somehow?

15:38 hiredman: it is only copied if you use def

15:38 MikeDev: how to comment a line?

15:38 /

15:39 ///

15:39 hiredman: ;

15:39 the-kenny: ;

15:39 MikeDev: k

15:39 hiredman: ,;comment

15:39 clojurebot: EOF while reading

15:39 ska23421: hiredman: consider (def #^{:c "sym"} mysym #^{:c "val"} [1 2 3])

15:40 {:c "sym"} is nowhere to be found later, or?

15:40 hiredman: you don't retain a reference to mysym, so the object is lost a long with it's metadata

15:40 but def copies the metadata to the var named by mysym

15:41 ska23421: hiredman: ^mysym --> {:c "val"}. No copy here.

15:41 hiredman: that is not the var

15:41 #'mysym is the var

15:42 mysym is resolved to the three element vector

15:42 which has the metadat {:c "val"}

15:42 ,+

15:42 clojurebot: #<core$_PLUS___4745 clojure.core$_PLUS___4745@120c359>

15:42 hiredman: vs.

15:42 ,#'+

15:42 clojurebot: #'clojure.core/+

15:42 ska23421: hiredman: hang on, need some REPLing :-)

15:43 hiredman: ,(meta +)

15:43 clojurebot: nil

15:43 hiredman: ,(meta #'+)

15:43 clojurebot: are you kidding me?

15:44 * MikeDev slaps clojurebot

15:44 clojurebot: {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 654, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$fn__4742 clojure.core$fn__4742@552a98>, :doc "Returns the sum of nums. (+) returns 0."}

15:44 You will not become skynet

15:44 the-kenny: clojurebot: No, clojurebot will become skynet

15:44 clojurebot: clojurebot will become skynet

15:45 the-kenny: :)

15:48 interferon: is there a function that checks to see i a sequence contains an object, e.g. (contains [1 2 3] 2) => true

15:48 hiredman: ,(.contains [1 2 3] 2)

15:48 clojurebot: true

15:49 hiredman: ,(some #{2} [1 2 3])

15:49 clojurebot: 2

15:49 interferon: doesn't work on sets

15:49 ah some is better

15:49 hiredman: uh

15:49 are you sure?

15:49 chouser: (#{:a :b :c} :b)

15:49 hiredman: ,(.contains #{1 2} 2)

15:49 clojurebot: true

15:49 chouser: ,(#{:a :b :c} :b)

15:49 clojurebot: :b

15:50 interferon: :)

15:50 hiredman: clojure's collections are all java Collections and .contains is a java Collection method

15:51 ska23421: wow, this almost answers my questions concerning contains? for lists in the group. Good day today: to long standing questions seem to go away. Thanks

15:52 (I still think contains? should do something on lists other than returning false all the time)

15:53 hiredman: lists don't have keys, so a list won't have the key you are looking for

15:53 slyrus_: liebke: is it your intent that folks using incanter should be using the bundled clojure and clojure-contrib?

15:53 interferon: i find the use of sets as functions a little confusing, so it's good to know that contains? is a function

15:54 ska23421: hiredman: contains? even works on strings and arrays

15:54 ,(contains? [1 2 3] 3)

15:55 clojurebot: false

15:55 ska23421: It is a confusing function, isn't it?

15:57 the-kenny: It is

15:57 interferon: ,(contains? '(1 2) 1)

15:57 clojurebot: false

15:58 the-kenny: ,(doc contains?)

15:58 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."

15:58 interferon: that is an offensive function

15:58 ska23421: interferon: it will *always* return false if fed a list

15:59 ,(contains? "hello" \e)

15:59 clojurebot: false

15:59 ska23421: ,(contains? "hello" 2)

15:59 clojurebot: true

16:00 ska23421: OK, in line with docs. Confusing nevertheless. And just nothing implemented for lists.

16:01 hiredman: the majority of your "lists" are lazy sequences regardless

16:01 which means there would have to be a non-lazy linear time search

16:02 MikeDev: http://pastie.org/private/5shvcyia8dnzowg7qwldw

16:02 I have no idea what that error even is

16:03 hiredman: and your code is unreadble

16:03 ~style

16:03 clojurebot: style is http://paste.lisp.org/display/81021

16:03 danlarkin: oh god

16:03 ska23421: hiredman: I agree that a linear non-lazy search would be neccessary if really searching for an element == the key. The index-bases lookup would be O(1) for lists, so at least that would be possible.

16:03 danlarkin: hurts my eyeballs!

16:04 hiredman: MikeDev: and you didn't paste the exception (as far as I can tell) so no one can help you

16:04 MikeDev: http://pastie.org/private/gpd3vq1xhl8de9holniagw

16:04 oh sorry

16:04 hiredman: and camelcase has got to go

16:05 arohner: any clojuresql people online?

16:05 hiredman: foo-bar vs fooBar

16:05 arohner: the clojureql wiki link is broken

16:06 MikeDev: I dont use camelcase

16:06 so np

16:07 Chousuke: What's that HeadingResultsToTable called then? :/

16:07 should be heading-results-to-table

16:07 hiredman: or heading-results->table

16:08 MikeDev: http://pastie.org/private/dyr2o1fg0ncjvklbacvaxw

16:08 Try that

16:08 It's got the exception and code

16:08 Chousuke: also you should learn out of the habit of putting the closing parens on their own lines.

16:08 no-one does that.

16:08 MikeDev: It's not camelcase

16:08 and no thanks

16:08 Chousuke: so your code will just look different from everyone else's

16:09 MikeDev: camelCase

16:09 MyCase

16:09 danlarkin: aaaaand gross

16:09 Chousuke: YourCase is just as bad :P

16:09 hiredman: so you don't want other people to be able to read your code and help you?

16:09 MikeDev: no, camelCase doesnt scale

16:09 hiredman:

16:09 danlarkin: troll alert!

16:09 MikeDev: I can use all_lower, FirstLetter, and ALL_CAPS

16:10 hiredman: all-lower

16:10 Chousuke: Clojure has a few exceptions to the foo-bar style though

16:10 namely, most java stuff

16:10 but it seems it's also okay to name protocols as FooProtocol

16:11 ska2342: MikeDev: you probably use the case to denote something? Scope, type?

16:11 MikeDev: well, in object oriented langs, yes

16:11 hiredman: ~def slurp*

16:11 ska2342: MikeDev: which Clojure is not

16:11 Chousuke: anyway, you won't see that style used in anything but newbie code.

16:11 so you shouldn't use it either :)

16:12 MikeDev: But I always use FirstLetter with functions

16:13 hiredman: MikeDev: you are passing slurp* nil

16:13 cark: are you not able to adapt to language conventions ?

16:13 when in rome act as a roman

16:13 MikeDev: I may have to to get paid

16:13 Chousuke: MikeDev: You'll learn out of that habit if you keep using clojure though.

16:13 MikeDev: hiredman, thx

16:13 o i c

16:13 hiredman: MikeDev: in the future, if you need help, please consider the poor brain of the person who has to read your code

16:13 MikeDev: yeah I gotta catch that

16:14 Chousuke: MikeDev: you also indent way too much. Two spaces is just fine for lisp

16:14 hiredman: instead of being a jerk and saying "this is how I write it!"

16:15 Chousuke: lisp code tends to nest quite a lot so if you use excessive indentation it's going to look awful

16:15 MikeDev: well i use tab. cant u change it to be = to 2 spaces?

16:15 patrkris: MikeDev: and you don't have to worry about having a lot of end-parens on one line if you have a decent editor

16:16 technomancy: well you could make everyone who reads your code change their tab stops, or you could just do it right in the first place.

16:16 hiredman: rainbow parens!

16:16 Chousuke: MikeDev: 2 spaces is pretty much universal accross all lisp dialects.

16:16 MikeDev: it's not like with C or Java where everyone has their own indentation preference.

16:16 across*

16:17 ska2342: I never indent my code. Emacs does :-) C-M-q

16:32 mee: any vim users? how do you automatically format your code? is there a standalone code formatter like perltidy for clojure?

16:33 hiredman: that is an excellent qquestion to which I have no answer

16:33 mee: searching turned up this, which is hilarious (read the contents of the Command(s)) http://www.flickr.com/photos/manjilab/4097992719/

16:34 hiredman:

16:35 Chousuke: :P

16:48 LauJensen: Evening gents. I'm trying to call a C lib via clojure-jna and documentation is a little scarce. I believe the function takes an argument of the by BSTR and returns a Long. How do I call passing a BSTR?

16:53 technomancy: mee: hah; nice

16:57 MikeDev: is there a good example of exception catching?

16:59 the-kenny: MikeDev: It's pretty straightforward if you know the syntax: http://clojure.org/special_forms#toc12

17:02 MikeDev: (catch classname name expr*)

17:03 the-kenny: Inside a (try), yes.

17:03 MikeDev: what are classname and name

17:05 Chousuke: MikeDev: NullPointerException somename

17:05 the name is arbitrary. it's used to refer to the exception itself

17:06 the-kenny: lisppaste8: url

17:06 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

17:06 MikeDev: how did you get NullPointerException?

17:06 lisppaste8: the-kenny pasted "try-catch-example" at http://paste.lisp.org/display/91665

17:06 the-kenny: (Bad indent, but there's an example)

17:07 (the whole thing is sent to an agent, so [] is there to set the new state of the agent)

17:08 prhlava: Are questions about 1.1-alpha considered here or I should wait for the release?

17:09 MikeDev: if they consider my questions, they'll probably consider yours

17:09 the-kenny: prhlava: Just ask ;)

17:09 prhlava: :-) OK

17:09 I have a simple "skeleton" application which uses http://www.gridgain.com/ - free cloud platform - Clojure 1.0 works, 1.1 - does not - class not found. No other change, but switched clojure version

17:10 all points to clojure.lang.RT

17:10 (the gridgain uses remote class loader and the app fails only when more than 1 node is started)

17:12 michaeljaaka: why the contrib APi was taken from clojure.org?

17:12 it was very usefull

17:12 now again it is hard to find the doc

17:13 and link under API was replaced from old clojure.org/api

17:17 prhlava: The application works with clojure 1.0 on multiple nodes - no problem. With clojure 1.1 - the remote node fails to load a clojure class: "core_init".

17:19 (back in 5 minutes)

17:20 MikeDev: thx all. im tired

17:26 prhlava: hmm, otoh, it is quite possible that gridgain class loader does something not quit right :-(

17:26 what is the main function of clojure.lang.RT?

17:31 technomancy: clojure.lang.RT does basically everything

17:31 RT stands for Runtime

17:32 prhlava: technomancy: :-)

17:33 Chousuke: prhlava: it implements core functions in Java for performance/bootstrapping reasons as far as I can tell.

17:34 prhlava: I am just looking at the RT, it is failing at: at clojure.lang.RT.doInit(RT.java:406), that line does load("clojure/core").

17:35 Chousuke: prhlava: is the code AOT-compiled?

17:35 prhlava: if it's AOT-compiled for 1.0, it probably won't work with 1.1

17:37 prhlava: Chousuke: yes, it is AOT compiled (and I did AOT re-compile with 1.1)

17:37 (before running with 1.1)

17:37 Chousuke: hmm :/

17:42 leafw: anybody knows of a java-only persistent list with structural sharing?

17:42 being stuck in java world with a clojure view can get hard

17:44 arohner: leafw: clojure.lang.PersistentList?

17:45 or do you mean without loading clojure.jar?

17:45 leafw: arohner: I'd use it, but I suspect it may disappear in future clojure releases

17:45 arohner: why is that?

17:45 leafw: and it depends on a lot of cthe clojure.jar

17:45 arohner: clojure-in-clojure project.

17:45 Chousuke: leafw: type everything as IPersistentCollection then

17:45 or whatever interface there is

17:46 those most likely will stay

17:46 arohner: right. the implementation might change, but I'd be very surprised if rhickey dropped java interop with a persistent list

17:46 leafw: Chousuke: ok, so then I should just copy the whole class and freeze it in time

17:46 and use the clojure.jar for the interfaces only

17:47 arohner: why do you need to copy it?

17:47 leafw: is that a horrible idea? I kind of think that it is. I wish for a proper package like java.util.concurrent.* but for persistent collections

17:48 arohner: clojure's list implements j.u.list and j.u.collection

17:48 LauJensen: Evening gents. I'm trying to call a C lib via clojure-jna and documentation is a little scarce. I believe the function takes an argument of the by BSTR and returns a Long. How do I call passing a BSTR?

17:48 arohner: run (ancestors (class (list 1 2)))

17:49 leafw: arohner: I know, I know

17:49 arohner: LauJensen: what is BSTR? byte string?

17:50 LauJensen: I don't know, I've never come across it in Java

17:50 arohner: LauJensen: http://markmail.org/message/ypuginjtwdvqc6do#query:java%20JNA%20bstr+page:1+mid:mpoiqq36yxdnbgy2+state:results

17:51 LauJensen: arohner, that looks like the stuff, thanks a lot

17:51 'night all

17:52 leafw: by the way the IPersistentList .containsAll(Collection col) function is ... weird: returns col.isEmpty()

18:01 prhlava: Thank you all, and good night...

18:06 arohner: lisppaste8: url

18:06 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

18:07 arohner pasted "untitled" at http://paste.lisp.org/display/91668

18:07 arohner: any ideas why that's blowing up?

18:09 oh right, the arities are different

18:10 that's a little confusing

18:10 clojurebot: a is t

18:10 ataggart: just started playing with protocols about 15 mins ago

18:11 Chousuke: hm

18:12 arohner: it'd be nice if there was a convention or something for that

18:12 like _

18:13 Chousuke: there was a lot of discussion about whether there should be an explicit "this"

18:15 arohner: I just want the arity on the protocol and deftype to match

18:15 ataggart: ah just firgured out what you're talking about

18:15 yeah that's a bit weird

18:16 perhaps it could be solved with a better warning?

18:17 Chousuke: I think things ended up so that 'this' is explicit, but can be left out, in which case you have no way to refer to it.

18:23 ataggart: ok, I'm confused. What was the arity problem above?

18:25 arohner: if you define a protocol method with an arity of (method [dispatch-type foo bar]), then when making a deftype implement the protocol, the arity must be (method [foo bar])

18:25 s/arity/signature/

18:27 is there a clean, generic way to update a nested map and then return the root of the tree?

18:27 ataggart: update-in

18:28 arohner: yeah, but my leaf node is a set rather than a map

18:28 ataggart: just have the fn return a modified set

18:29 arohner: nm, I was reading it wrong

18:29 that might do what I want

18:29 _ato: (update-in {...} [:foo :bar] conj thing-to-add-to-set)

18:29 arohner: perfect. thanks

18:29 ataggart: ah and I see my confusion with defprotocol. I thought the symbol for the instance was specified in the deftype implementation.

18:30 seems weird to only have it specified in the defprotocol.

18:30 Chousuke: it can be specified in deftype as well

18:30 or hm

18:31 ataggart: does that mean if I have a deftype that reifies multiple protocols, there could be multiple symbols referencing the instance object?

18:31 Chousuke: I'm not sure how the new syntax works, anymore :P

18:32 ah, right. (deftype Foo [a b c] :as thisname (blah [] ...))

18:32 arohner: and using :as doesn't change the method signatures, right?

18:33 Chousuke: correct

18:35 ataggart: so then why did that code not work? both the arglists have the same arity

18:36 clearly I'm not grokking this yet

18:36 arohner: why did my pasted code not work?

18:36 ataggart: ya

18:36 arohner: because my deftype implementation needed one fewer argument

18:37 ataggart: yeah, I'm just trying to figure out why that's the case. All of the examples on the wiki use the same number of args

18:38 Chousuke: same hm?

18:38 ataggart: (defprotocol P

18:38 (foo [x])

18:38 (bar-me ([x] [x y])))

18:38 (deftype Foo [a b c] [P]

18:38 (foo [x] a)

18:38 (bar-me [x] b)

18:38 (bar-me [x y] (+ c y)))

18:38 Chousuke: that's not right.

18:38 that's out of date

18:38 ataggart: http://www.assembla.com/wiki/show/clojure/Protocols

18:38 arohner: that example is out of date. Try that in the repl

18:38 ataggart: ahh k

18:39 Chousuke: look at the datatype lpage.

18:40 ataggart: time for (doc defprototype)

18:41 erm defprotocol

18:47 the-kenny: technomancy: Is there a nice way to use defprotocol etc. with leiningen?

18:48 ataggart: I'm sure Rich has a good reason for it, but that defprotocol and a called method have a different number of args from the deftype impl is odd.

18:48 e.g., http://paste.lisp.org/display/91669

18:48 technomancy: the-kenny: sure; just use the clojure version number from the "new" branch

18:49 I haven't done it myself, but that branch is being built regularly on build.clojure.org, so there shouldn't be any tricks necessary

18:51 the-kenny: technomancy: hm.. what's the version number?

18:51 Or: Where can I find it?

18:54 _ato: doesn't look like it's actually being put in the snapshots directory though: http://build.clojure.org/snapshots/org/clojure/clojure/

18:57 the-kenny: _ato: hm :(

19:00 Any idea why not?

19:02 ataggart: the project is configured to run ant jar

19:03 instead of ant nightly-build

19:03 hence no uploading

19:03 compare http://build.clojure.org/job/clojure/40/console with http://build.clojure.org/job/clojure%20%28new%29/35/console

19:07 the-kenny: hm

19:20 ataggart: it's a simple config change, just need rights to do so.

19:22 konr1: I'm moving from vi to emacs - is there a slime tutorial you guys recommend me watching/reading?

19:23 And are CL-focused slime tutorials applicable to Clojure?

19:24 the-kenny: konr1: Yes, they are

19:24 konr1: Slime isn't very complicated

19:26 j3ff86: is there a limit to how big a sequence can be in clojure?

19:26 the-kenny: j3ff86: the java heap-space ;)

19:26 j3ff86: ah

19:26 the-kenny: I don't think there's another limit

19:27 But if you're working with long sequences, you maybe want a lazy-sequence

19:27 j3ff86: good point

20:07 technomancy: konr1: the slime manual is pretty thorough

20:07 a few features haven't been ported to clojure yet, but most of it is solid

20:10 * the-kenny misses the super-debugger from common lisp :(

20:27 mtm_: technomancy: just ran 'lein self-install' on a fresh Snow Leopard box, it installed fine. When I try 'lein help new' or lein new foo' I get an trace that says "Exception in thread "main" java.io.FileNotFoundException: project.clj (No such file or directory)"

20:27 any ideas?

20:28 Chousuke: try creating an empty project.clj?

20:29 mtm_: hmm, that blowed up real good with "Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/new__init.class or leiningen/new.clj on classpath:"

20:29 maybe a buggy lein script?

20:29 I'll dig further

20:30 _ato: mtm_: "lein new" doesn't exist in 0.5.0. It's coming in 1.0.0

20:30 mtm_: ah, I was going from the readme

20:30 silly me :)

20:31 ataggart: what's the "right" way to organize tests if we want to get lein to run them (which I assume it can, haven't delved too deeply yet)

20:31 toups: Hi #clojure. I notice there is a kind of impedane mismatch between the way swank-clojure-project expects things to be set up and my desire to maintain some general libraries which I use in many differeny projects. Is there a community standard way of handling this?

20:33 somnium: toups: put symlinks in ./lib ?

20:33 _ato: technomancy: what do you think of setting the default github branch to stable for Leiningen (github project -> admin -> default branch)? That way the main page will show the README from the stable branch. I think mtm_ is the third person I've seen run into problems due to the README not matching what self-install installs.

20:33 toups: somnium: simple as they, eh?

20:33 that, I mean

20:33 somnium: toups: it works for me

20:34 toups: I just like to check to see if everyone is doing the same thing before I reinvent the wheel

20:34 _ato: ataggart: just put a bunch of .clj files in project/test/ that use clojure.test and define some tests with (deftest)

20:34 ataggart: you can see how I do it here: http://github.com/ato/clojars-web/blob/master/test/clojars/test/utils.clj

20:34 ataggart: so you split them out from the code being tested?

20:35 hmm, looks like it could work either way

20:35 _ato: yeah. well Leiningen's just going to go through every namespace under project/test, load it and eval (run-tests) in it

20:36 so you could just symlink your sources in there if you mix deftests into your implementation files

20:36 I assume that would work

20:38 ataggart: cool

20:43 mtm_: _ato: all is well now; I've got the latest leiningen built and working. thanks for the help

20:44 _ato: :-)

20:50 tolstoy: Is there a way to get the name of the namespace your functions running in?

20:53 _ato: ,*ns*

20:53 clojurebot: #<Namespace sandbox>

20:53 tolstoy: Ah, cool. Still trying to learn how to learn where things like *ns* are documented.

20:54 konr1: Has anyone any idea on how clojure-swank handles the classpath? I just installed the whole thing on emacs using ELPA, and after starting slime with "m-x slime", swank complains that it couldn't find test.clj on the classpath

20:56 _ato: ,(name (ns-name *ns*))

20:56 clojurebot: "sandbox"

20:56 _ato: tolstoy: ^ you might need that if you want it as a string

20:57 tolstoy: _ato: Thanks. Mostly just for println/debugging or whatever.

21:00 hjiang: It seems I need to add ~/.m2/repository to CLASSPATH in my shell config. Is that the correct way? I didn't see it in the installation notes.

21:01 sorry, the question was for Leiningen

21:02 _ato: hjiang: you shouldn't need to, the bin/lein script should set the classpath for you.

21:02 hjiang: is it not working?

21:03 hjiang: _ato: lein new testp

21:03 Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/new__init.class or leiningen/new.clj on classpath:

21:03 _ato: yeah, seems the path isn't setup properly.

21:04 _ato: hjiang: I think you're having exactly the same problem mtm_ just had. "lein new" doesn't exist in lein 0.5.0

21:05 hjiang: oh, I see. I'll try the latest then. Thanks!

21:06 tolstoy: Hm. *ns* seems bound to clojure.core when I run my app. Interesting.

21:07 chouser: tolstoy: would you bring that up on the google group

21:07 tolstoy: I don't think it's intentional, and we might be able to fix it before 1.1

21:07 tolstoy: Ah, really? Hm Okay.

21:13 I think *ns* is bound to the name space of the initial function being called, and even if you call functions in other names spaces, which print out *ns*, you get the original value.

21:13 I'm not sure that's wrong.

21:15 All I'm really looking for is something like class.getName(). Something analogous to that.

21:15 _ato: tolstoy: ah yeah, that's current. If you want the namespace that function is defined in you might need to do it with a macro

21:16 tolstoy: Okay. It's not that big of a deal, fortunately. ;)

21:16 _ato: this might work: (defmacro current-ns [] *ns*)

21:18 so then you can do something like (println "I'm in" (current-ns))

21:18 tolstoy: _ato: Yeah, that's closer.

21:18 _ato: because its a macro *ns* is evaluated at compile-time so *ns* should be set to whatever file the macro is being expanded in

21:19 tolstoy: Yes, exactly.

21:21 technomancy: _ato: I think it should be less of a problem post-1.0 since our main launch stuff won't be changing much

21:22 _ato: technomancy: good, and I noticed you've put in a task not found error, which is less befuddling than the stacktrace 0.5.0 throws up

21:38 mee: what's the difference between (advantages of?) (> foo 0) and (pos? 0). Just sugar?

21:38 err (pos? foo)

21:39 Chousuke: I guess pos? is a bit faster

21:39 mee: oh, return values are different

21:40 it's very cool that the documentation links to the implementation, even if I can't read it all very well

21:41 Chousuke: heh

21:41 that's a recent improvement.

22:04 technomancy: is there some trick to calling clojure.main/repl and getting standard in hooked up correctly?

22:04 java -cp clojure-1.1.0-alpha-SNAPSHOT.jar clojure.main -e "(clojure.main/repl)" # <= does not cut it

22:05 JAS415: hmm

22:05 what are you trying to do?

22:06 mee: java -cp .../clojure.jar clojure.lang.Repl "$@" ?

22:06 is the command in clojure-repl, which seems to work

22:06 JAS415: yeah mine has jline.ConsoleRunner in there too

22:06 technomancy: yep, I'm just wondering if there's a way to call it from inside clojure.main -e

22:07 JAS415: i would guess that you would have to connect it to the tty or whatever

22:09 maybe try /legacy_repl

22:12 hmm

22:12 nope

22:14 hmm

22:14 it looks like that command prints one repl

22:14 neat

22:23 ah

22:24 technomancy: got a little closer with this... java -cp clojure.jar clojure.main -e "(clojure.lang.Repl/main (make-array String 0))"

22:24 still not quite

22:30 hmm

22:30 looks like the stuff you need to do it isn't externalized

22:30 ataggart: use clojure.lang.Script if you want to pass it a clj file

22:31 as for eval'ing a string from the commandline, I don't know

22:31 JAS415: i think he's trying to start a repl by evaling the string

22:31 ataggart: why?

22:32 what's wrong with: java -cp clojure.jar clojure.lang.Repl

22:32 (besides missing the convenience jars)

22:33 JAS415: i have no idea :-P

22:33 ataggart: k

22:33 JAS415: you can also do java -cp clojure.jar clojure.main

22:34 ataggart: my clj script still works thankfully. no-args and it starts the repl, otherwise it runs a file, etc.

22:34 JAS415: i'm just intrigued now as to why it doesn't loop when you try to call main directly

22:40 ataggart: anyone know of a simple way to return a modified version of a deftype'd instance, akin to how assoc would work on structs?

22:51 somnium: ataggart: you can use conj if you include IPersistentMap in interfaces

22:51 ataggart: otherwise seems necessary to implement Associative atm

22:51 ataggart: aha!

22:52 I had read that part of the wiki, but it didn't sink in

22:56 technomancy: ataggart: I'm wanting to start the repl from within a "java" ant task so I can set the classpath in Clojure

22:56 since ant sets up a subclassloader for you

22:57 ataggart: gotcha

22:59 JAS415: woahh

23:00 hm

23:01 so you want to start the ant task in java, run the repl in the middle, and finish the ant task?

23:03 could you start the repl in the beginning and call ant from clojure in like another thread and then call back to the prompt?

23:03 (I clearly don't know how ant works)

23:05 technomancy: no, the repl needs to be loaded from the subclassloader so it will have the calculated classpath

23:06 JAS415: darn

23:06 ataggart: why not stick the calculated classpath into the java task itself?

23:09 ah, unless you're using clojure to calculate it

23:09 technomancy: yeah, that's right

23:10 JAS415: haha

23:10 could you use sys.exec to run clojure

23:13 technomancy: actually... it looks like it's the ant task that's screwing up *in*. bugger.

23:55 ngoc: Hi, is it possible to use more than 1 infinite seq like this?

23:55 (def l100

23:55 (for [a (iterate inc 1)

23:55 b (iterate inc 1)

23:55 :when (= (+ a b) 100)]

23:55 [a b]))

23:55 (take 2 l100)

23:55 technomancy: ngoc: map accepts mutiple seqs in parallel

23:56 if you use for it treats one of them as an "inner seq" or some such

23:57 ngoc: Can you show me how to fix the code using map?

23:58 tomoj: b

23:58 oops.\

23:58 technomancy: ngoc: something like this: (map (fn [a b] [...]) (iterate inc 1) (iterate inc 1))

Logging service provided by n01se.net