#clojure log - May 13 2009

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

0:45 thearthur: hello all

0:46 I have'nt updated clojure since the lasy seq changes

0:46 its about time no?

0:46 what do i need to change in me source?

0:52 hiredman: http://clojure.org/lazier towards the middle is a reference

1:22 cads: I have a function that takes a struct-map, 'updates' some of its elements. one of the structure's parts is a list of substructures, and that makes writing bindings in that kind of function a little tricky

1:22 I feel like I could do better with it

1:23 what do you guys think? http://paste.lisp.org/display/80121

1:27 thearthur: anyone here know how to get a stack dump from Enclojure?

2:18 duck11231: please tell me someone here has a working build process with maven

2:18 clojurebot: build is working

2:20 Lau_of_DK: hmm, I didnt realize that anybody still used maven

2:26 duck11231: I've been trying to get it to work for me, and I'm starting a new project, and I want to try to get it up and running from the start

2:26 right now I have the clojure plugin working, but I can't get my src path working right

2:27 Lau_of_DK: Im sorry I cant help you - Cemerick spent the better part of 2� hours teaching me ant, so now Im sticking with that since its become an investment :)

2:31 duck11231: right now I use git submodules to pull in new versions of all the dependencies and a ant script to call out to the other ant scripts

2:32 it's becoming a hassle as I wanted to include clj-doc and it involved creating 3 new submodules

2:34 tWip: Lau_of_DK: what do you mean "still used maven"?

2:34 I'm using it all the time.

2:35 Lau_of_DK: Ok - so thats 1 :)

2:35 duck11231: are you using it for clojure?

2:35 tWip: well webjure uses it

2:36 duck11231: I agree with technomancy's sentiment that maven would be a lot cooler with a clojure wrapper around it.

2:36 tWip: do you mean just replacing pom.xml with some s-expressions?

2:37 duck11231: maybe, you could probably do other abstractions

2:37 it would be clojure data

2:37 tWip: there isn't really that much to maven, just have the project model and run builds

2:37 duck11231: I'm just getting started, and already my pom.xml is a monster

2:38 tWip: though having the project model as s-expressions and implementing maven plugins (MOJOs) in clojure would be cool

2:38 duck11231: but I'm trying to pull in all these dependencies too

2:38 mojos could be easily written in clojure, I was thinking about that

2:40 tWip: mostly I like maven because it automatically pulls dependencies from the net and has convention over configuration approach

2:40 duck11231: see, webjure just compiles the java, right? I want to compile my clojure namespace into a war

2:41 tWip: yes, it was mainly developed before AOT, I'll need to look in to compiling the clj as well

2:41 I think there's some clojure compiler plugin

2:41 duck11231: I can't quite figure out where to put my clj fils so they will be compiled by the plugin

2:42 tWip: possibly under src/main/clojure

2:42 if it follows conventions

2:42 duck11231: that's where I originally put it, then I tried src/main/java still no go

2:43 clojurebot: clojure-maven-plugin

2:43 clojurebot: clojure is the bestest programming language available.

2:43 duck11231: clojurebot: clojure-maven-plugin is http://github.com/talios/clojure-maven-plugin

2:43 clojurebot: In Ordnung

2:43 tWip: another thing about maven is that the documentation is so bad it's not even funny

2:44 every time you want to do something new, your best option is to just google for some blog entries of people who have done it before

2:44 the docs will not help

2:44 duck11231: It's not even out, and I'm already waiting for the sequel to programming clojure

2:45 I've seen just about all the public documentation about compiling clojure src files to classes with Maven at this point

2:46 of course, I haven't greped the irc logs

6:02 AWizzArd: I have a string S and a hashmap HM. In HM there is a key K for which (= K S) ==> true, but (identical? K S) ==> false. How can I get K from HM by using S?

6:03 Cark: hum that should work

6:03 AWizzArd: Example: HM = {"abc" 1, "xyz" 2}. Now a user creates S = (str "a" "b" "c"). How can I do (get-key S HM) ==> "abc" <-- the one from the HM, not S.

6:04 What I am looking for is the function "get-key", if it exists

6:05 Cark: hum so you don't cvare that the value can be found with a not identical string ?

6:06 how about interning all the strings before using these as key

6:06 jdz: doesn't (get HM "abc") work?

6:06 Cark: yes it works

6:06 AWizzArd: that returns me the 1

6:06 but I want the "abc" string that is the key inside HM

6:07 Cark: ,(doc keys)

6:07 clojurebot: "([map]); Returns a sequence of the map's keys."

6:07 AWizzArd: ,(let [x (str "abc"), y (str "a" "b" "c")] [(identical? x y) x y])

6:07 clojurebot: [false "abc" "abc"]

6:07 AWizzArd: if now x is the key in HM, then I want to use y to read x out of HM

6:08 Cark: what you really want is the dictionary entry

6:08 you may need to drop to java land

6:08 (class {:a 1})

6:08 ,(class {:a 1})

6:08 clojurebot: clojure.lang.PersistentArrayMap

6:08 Cark: ~def clojure.lang.PersistentArrayMap

6:08 AWizzArd: Cark: yes, I could iterate over the 20 million entries in my map, but I hoped that there is a O(1) way to get the original key out of the hashmap.

6:09 Cark: ~def clojure.lang.IPersitentMap

6:09 AWizzArd: or O(log32 n) as it is for Clojure

6:10 Cark: you need to get to the MapEntry from the key ...

6:10 ,(.entryAt {"blah" 1})

6:10 clojurebot: java.lang.IllegalArgumentException: No matching field found: entryAt for class clojure.lang.PersistentArrayMap

6:11 Cark: hum

6:11 AWizzArd: ah good, that works for me

6:11 jdz: AWizzArd: find

6:11 AWizzArd: ,(.entryAt {"blah" 1} "blah")

6:11 clojurebot: ["blah" 1]

6:11 AWizzArd: ,(doc find)

6:11 clojurebot: "([map key]); Returns the map entry for key, or nil if key not present."

6:11 Cark: ahyes !

6:12 AWizzArd: good good, thanks you two

6:14 Cark: 20 millions entries, how much memory does that use =)

6:29 AWizzArd: Cark: currently I don't have the 20 mio entries in there, but will have

6:31 Cark: AWizzArd : you might want to check the memory consumption, clojure is in no way frugal about it

7:17 yason: Hmmm, what's the naming-idiom for helper functions on top-level?

7:19 cemerick: yason: I use fn-name*

7:20 yason: with the asterisk on the right side only?

7:21 like (defn fn-dolookup* [x] ...)? Can this be observed in Clojure or Clojure/contrib sources as well?

7:22 Chousuke: the foo* naming convention is mostly for macro driver functions

7:22 cemerick: yeah. *name* is generally used only for vars you expect users to bind on.

7:22 Chousuke: normal helpers are named like any other function.

7:23 __mac: Also, you probably want defn- so you don't "leak" your helpers :)

7:23 Chousuke: you can (defn-) them though, so they're private.

7:23 cemerick: huh, I wasn't aware of that distinction re: macro drivers

7:23 yason: Chousuke: I'd like them to stand out a bit

7:23 hmmm, there's indeed (defn- ...)

7:24 hey that looks good enough by itself

7:24 Chousuke: I think the need for foo* for macros is because you can't use private functions in macros (unless the macro is only used privately as well)

7:24 clojurebot: for is not a loop

7:24 Chousuke: :P

7:24 cemerick: Chousuke: foo* has definitely been used for more than just macro helpers http://www.cliki.net/Naming%20conventions

7:24 Chousuke: so the "foo*" convention is a way of saying "yes, the expansion is this, but you are not supposed to use these functions directly"

7:25 cemerick: (obviously, that's a CL page, but foo* is used in scheme codebases I've worked with as well to name helper fns *shrug*

7:25 Chousuke: cemerick: well, yes, but the most common use is in macros.

7:26 yason: Chousuke: foo* plays nicely with macros since you probably want to define the macro helper functions to begin with the macro name for consistency

7:27 __mac: If you just want helper functions, not macro drivers, you can make them private and name them... whatever. Or if you don't mind some "uglyness" you can wrap a defn in a let, make your helper functions in the let and close over them with the defn function(s).

7:28 Chousuke: yason: well, that, and the helper function often does most of the work; it's just wrapped in a macro to control argument evaluation, or for other purposes

7:28 yason: __mac: I'll settle with (defn-) and try to use the same prefix as the front-end functions too. And wrapping (defn) inside (let) is too ugly for me :)

7:29 Chousuke: yes, the helpers are part of the macro definition itself IMHO

7:29 conceptually

7:32 AWizzArd: What performance/space advantages do sorted-maps have over ordinary hashmaps?

7:33 Chousuke: I don't know if they do, but you can iterate over them in key order.

7:34 hash-maps only give you undefined order :)

7:35 __mac: There is no way to find out the size of an object in java right? It's probably implementation defined and not defined in the language spec?

7:36 AWizzArd: __mac: the question is what the size of an object would be

7:36 __mac: yeah, like sizeof in C/C++

7:36 the whole object, not just the members

7:37 Datatypes have defined sizes so you can sort of get a feel for it by looking at the members but that's not all there is to an object

7:37 AWizzArd: in collections you store references to objects. Should one follow those references and count the size of their objects as well, until one hits atomic stuff that doesn't refer any further?

7:38 tWip: serialize to byte[] and use that length? ...I don't know if serialized size reflects the in-memory size though

7:38 AWizzArd: when we have {"abc" "123", "xzy" "456"} then it is a hashmap that stores 4 references

7:39 in principle it could look like {#7ea1 #1290 #bb21 #fc38}

7:39 on a 64-bit system we have 4 pointers, each 8 bytes in that hashmap

7:41 but if no other objects points to those strings, is it not then fair to say that their size should also be counted when calculating the size of the hashmap?

7:44 __mac: Well the rules for size of containers could be defined as following pointers and getting size of each contained object but that's not the issue really, the issue is the hidden stuff in each object, the java bookkeeping

7:47 I'm mostly curious if it's possible to have that kind of fine grained control over memory consumption in java. I once implemented a cache in C++ with an upper memory bound by using some sizeof and template magic so that I knew how large each object was that was in the cache. That way the upper bound could be respected.

7:49 tWip: it probably doesn't. Depends on what serializer you use as well :)

7:50 Also that seems rather inefficient and clumsy

7:50 tWip: I was thinking about the Java serialization, I think it's defined

7:50 __mac: you mean like objectoutputstream?

7:50 tWip: yes

7:50 __mac: because there are others as well, like xml output and all sorts of strange beasts

7:51 At least I think so, haven't looked at it in a while

7:52 tWip: seems googling around provides some ways, but getting the total amount of free memory and running gc manually would not cut it at least in multithreaded server environments

7:54 eee: ~logs

7:54 clojurebot: logs is http://clojure-log.n01se.net/

7:54 tWip: also there's getObjectSize in Instrumentation

7:55 __mac: Like I said I'm just curious, not trying to solve any problem right now. My particular use case for the C++ code was as a cache for a game with seamless loading of resources (no loading screens, seamless world). The idea was that you set an upper bound for the cache and load all resources through it and let the cache use a least recently used policy to toss out old resources when it hit the memory cap.

7:56 I suppose you could do that in Java by catching the exception generated when you exhaust the heap :)

7:57 But I think that's unreliable because the jvm might be too low on memory to work properly if you are really unlucky

7:58 yason: __mac: I know next to nothing about Java itself but sounds like the answer depends on what would you try to achieve :)

7:58 AWizzArd: __mac: you could use jvisualvm maybe?

7:58 __mac: What is that?

7:59 Oh ok profiler tool

7:59 AWizzArd: A profiler that comes with Java 6 Update 8 (or 10, don't know)

7:59 yason: __mac: if the items are big enough you can just use estimated object sizes which would create a not-so-tight bound

7:59 AWizzArd: https://visualvm.dev.java.net/

8:00 __mac: yason: yeah that's probably a good enough solution, it just bugs be a little that I can't know exactly in an easy way :P

8:01 tWip: that's the price we pay :)

8:01 __mac: But in the case of meda resources like images and sound pcm data and the like it's usually stored in ByteBuffers or arrays anyway of which you will know the exact size of the data content and the rest is hopefully negligable

8:02 unlink: Is there any way to create a Java class when not compiling to disk?

8:02 __mac: Thanks for the discussion all, I have to get some work done now ;)

8:04 yason: __mac: heh, high-level languages are not too good at that :)

8:04 __mac: yason: what, getting work done? :D

8:05 *at what

8:09 yason: __mac: allowing you to know exactly :)

8:09 (in an easy wasy:))

8:10 __mac: Yeah I got that, was just that the last thing I typed before your reply was that I had to get some work done ;)

8:12 gnuvince: Hi

8:12 unlink: hi

8:44 AWizzArd: unlink: did you try gen-class?

8:44 unlink: AWizzArd: the whole fn is guarded by (when *compile-files* )

9:07 Is there a nicer way to do ~' inside a syntax quote, or do I need to do: http://dpaste.com/43672/

9:07 (I'm avoiding autogensym like bit#, since I don't need gensym functionality and it makes the expanded macro harder to read)

9:08 Chouser: I think that's what's required.

9:09 unlink: ok

9:10 Maybe it would make sense to have a 1-character shorthand for ~'.

9:10 Am I missing anything obvious in that macro implementation which would make it less terrible?

9:10 Chouser: I doubt that'll happen. Intentional name capture like that is rare, and people generally want it called out pretty explicitly.

9:11 actually, even ther -- what happens if parts includes the symbol 'tree ?

9:12 unlink: It won't work, parts can only be :data, :left or :right.

9:13 AWizzArd: gensym would be the clean way anyway

9:13 unlink: Rather, a sequence containing only those keywords.

9:14 There's no need to guarantee uniqueness via gensym, though, since they are already guaranteed to be unique.

9:16 And there's no need for the extra ugliness in http://dpaste.com/43676/

9:31 AWizzArd: unlink: in my opinion it does not add extra ugliness. If you are the only developer in a hobby project it doesn't matter.

9:32 But in teams (especially when doing professional work) a code review should only allow well documented code. And gensyms do that.

9:32 unlink: I fail to see the connection.

9:32 AWizzArd: np

10:04 marklar: ,(read-string "(foo)(bar)")

10:04 clojurebot: (foo)

10:04 marklar: how come it is dropping bar?

10:05 Chouser: 'read' reads a single form

10:05 marklar: I'm guessing its because each list is considered 'one object' to be read, but I'm at a loss on how to read the others

10:05 Chouser: it only returns one thing, so that's all it can do

10:06 marklar: Chouser: ah, ok... how would one read the rest?

10:06 Chouser: ,(read-string (str "[" "(foo)(bar)" "]"))

10:06 clojurebot: [(foo) (bar)]

10:06 marklar: Chouser: thanks!

10:06 Chouser: or something

10:06 stuartsierra: or read in a loop

10:06 marklar: stuartsierra: thats what I wanted to do, but how do you get the 'rest' of the string?

10:06 Chouser: the "normal" way is to use 'read' rather than 'read-string' -- then it will consume enough of the text stream for one form, and leave the stream ready to read the next one

10:07 stuartsierra: marklar: open a StringReader

10:08 ,(let [r (PushbackReader. (StringReader. "(foo) (bar)")] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur))))

10:08 clojurebot: Unmatched delimiter: ]

10:08 stuartsierra: ,(let [r (PushbackReader. (StringReader. "(foo) (bar)"))] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur))))

10:10 ,)

10:10 clojurebot: Unmatched delimiter: )

10:10 stuartsierra: ,(let [r (PushbackReader. (StringReader. "(foo) (bar)"))] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur)))))

10:10 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: PushbackReader

10:10 stuartsierra: ,(let [r (java.io.PushbackReader. (java.io.StringReader. "(foo) (bar)"))] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur)))))

10:10 clojurebot: (foo) (bar)

10:21 AWizzArd: btw, a NullWriter would be interesting for duck-streams - everything one writes to it gets forwarded to /dev/null

10:21 stuartsierra: Hm. /dev/null is not platform-independent.

10:22 marklar: sorry had to run and take care of something

10:22 stuartsierra: But a NullWriter proxy would be easy to right.

10:22 write.

10:22 marklar: thanks for the tips, I'll look into read and StringReader

10:22 clojurebot: for is not a loop

10:23 AWizzArd: stuartsierra: right, under Windows it is called "NUL". But I was also thinking more of a proxy

10:23 that would be platform-independent straight away

10:23 stuartsierra: Commons IO has a NullWriter: http://tinyurl.com/ogn9go

10:23 AWizzArd: yes, I know

10:23 stuartsierra: ok

11:14 scottj: what did you point it to? I have a shortcut that runs xulrunner and passes the conkeror application.ini, but when I select that shortcut it just looks for the exe inside and uses only that

11:14 (sorry wrong chan)

13:08 hiredman: interesting

14:01 achim_p: hi all! anybody else on java 1.6.0_07

14:02 ... on os-x experiencing awfully long startup times?

14:02 (like: a minute)

14:03 kotarak: 1.6.0_03-p3 works fine here.

14:09 achim_p: it's weird. it only happens the first time i start the JVM after rebooting. it doesn't give any output when started with -verbose, it just hangs for a minute and then continues. it even ignores ctrl-c ...

14:10 twism: can we have clojurebot on twitter evalute expressions?

14:10 with the new @replies we wont be spamming followers

14:19 hiredman: twism: try it

14:26 hmmm

14:27 twism: hiredman: would have to do it this weekend

14:27 hiredman: anyway, I have some plans for rewriting the output side of clojurebot to make it easy to have the same functionality on irc, twitter, and xmpp

14:27 rhickey: did sdb work for anyone?

14:27 hiredman: twism: I mean tweet at it

14:27 twism: ah

14:27 hiredman: @clojurebot (+ 1 2)

14:28 I had it working at one point

14:28 ieure: But... Why?

14:28 technomancy: hiredman: what's his XMPP handle?

14:29 hiredman: doesn't have one yet

14:29 technomancy: oh gotcha

14:29 hiredman: I imagine it will be clojurebot@thelastcitadel.com

14:30 twism: clojurebot didnt answer me back... jerk im unfollowing him

14:31 or her

14:31 hiredman: give it ten minutes

14:32 or so, I throttle twitter responses unintelligently

14:32 twism: ah ok

14:33 hiredman: it also may not be working :P

14:33 I just sort of knocked it together before I decided the output handling needed a rewrite

14:33 grzm: I'm wondering if there's a less verbose way of saying "true if any of the elements of this vector match a given regular expression:

14:34 (some #(not (= () (re-seq #"a" %))) a)

14:34 where a is the vector, and #"a" is the match

14:34 technomancy: grzm: if regexes were callable there would. =)

14:34 grzm: er, pattern

14:34 hiredman: grzm: use re-find

14:34 ,re-find

14:34 clojurebot: #<core$re_find__4549 clojure.core$re_find__4549@64bbf1>

14:35 technomancy: (seq (filter my-regex my-vector))

14:35 hiredman: ,(re-find #"a" "aaa")

14:35 clojurebot: "a"

14:35 technomancy: as long as you're OK with "true-ish" instead of true

14:35 hiredman: ,(re-find #"a" "bbb")

14:35 clojurebot: nil

14:35 hiredman: you can nil pun with re-find

14:35 grzm: truish is find

14:35 fine

14:35 technomancy, hiredman: thanks :)

14:36 technomancy: grzm: mine doesn't work. =)

14:36 (yet, at least... there's talk of making regexes callable)

14:37 grzm: technomancy: no, but you gave me food for thought, and that's half the battle!

14:37 technomancy: imho that kind of conciseness is a great case for callable regexes

14:38 but I don't interact with many java APIs that use Patterns, so I'm biased

14:40 grzm: hiredman: what I'm actually looking at is something like this:

14:40 (re-find #"a" ["alpha" "beta" "gamma"])

14:40 (which throws an error)

14:41 ,(re-find #"a" ["alpha" "beta" "gamma"])

14:41 clojurebot: java.lang.ClassCastException

14:41 grzm: thank you, clojurebot

14:41 hiredman: ,(re-find #"a" (seq ["alpha" "beta" "gamma"])))

14:41 clojurebot: java.lang.ClassCastException

14:41 hiredman: oh

14:41 Right

14:41 dun

14:41 re-find takes a string

14:41 kotarak: ,(map #(re-find #"a" %) ["alpha" "beta"])

14:41 clojurebot: ("a" "a")

14:41 technomancy: ,(let [r (fn [pattern] (fn [s] (re-find pattern s)))]

14:41 stuartsierra: ,(map #(re-find #"a" %) ["alpha" "beta" "gamma"])

14:41 technomancy: ((r #"o hai") "o hai everyone"))

14:42 clojurebot: EOF while reading

14:42 ("a" "a" "a")

14:42 hiredman: ,(filter #(re-find #"a" %) ["alpha" "beta" "gamma"])

14:42 clojurebot: ("alpha" "beta" "gamma")

14:42 technomancy: ,(let [r (fn [pattern] (fn [s] (re-find pattern s)))] ((r #"o hai") "o hai everyone"))

14:42 clojurebot: "o hai"

14:42 technomancy: hacky syntax sugar

14:42 grzm: wow

14:43 hiredman: ,(class #"")

14:43 clojurebot: java.util.regex.Pattern

14:43 grzm: wonders if erc has syntax highlighting

14:44 technomancy: grzm: oooh... that's a good idea.

14:51 twism: hiredman: gotcha

14:52 well... make sure to tweet if it ever comes back online

15:11 hiredman: danlarkin: clojure-json seems to be puking on twitters maintenance message json

15:11 danlarkin: ohword?

15:11 hiredman: "{\"request\":NULL,\"error\":\"Twitter is down for maintenance. It will return in about an hour.\"}"

15:11 input to decode-from-str

15:11 danlarkin: ah I bet I know why

15:11 hiredman: java.lang.RuntimeException: java.lang.Exception: EOF while reading (NO_SOURCE_FILE:0)

15:12 stuartsierra: capital "NULL"?

15:12 danlarkin: yes

15:13 stuartsierra: Doesn't validate!

15:13 danlarkin: yeah capital NULL is invalid json

15:13 hiredman: poor twitter

15:14 well, poor me, rich twitter

15:14 stuartsierra: Well, that's it, we can't have a Clojure twitter client now. :)

15:14 danlarkin: I'll get a fix in for this when I can, hiredman

15:14 clojurebot: for is not used enough

15:14 hiredman: danlarkin: no rush

15:15 I think I am using a pretty old clojure-json to begin with

15:15 danlarkin: well I got the error locally too

15:15 so it's still a problem

15:16 technomancy: well it's not too serious of a problem since you wouldn't be able to use it anyway while Twitter is down for maintenance. =)

15:19 replaca: danlarkin: interesting question: can javascript read that string correctly (since we know that's the "real" def of JSON)?

15:20 dysinger: having some trouble with file-seq

15:20 runs out of memory

15:20 stuartsierra: rplaca: Rhino won't parse it

15:20 dysinger: (file-seq (File. "somedir/with/2Gs/of/files"))

15:20 *boom* as steve jobs would say

15:20 replaca: stuartsierra: we know who the real CL folks are! :-)

15:21 stuhood: ~def file-seq

15:21 stuartsierra: replaca: yep

15:21 dysinger: if you're typing that at the REPL, it's trying to print a seq of a million or so files.

15:22 dysinger: true

15:22 stuartsierra: shouldn't be a problem if it's used lazily

15:22 dysinger: using def fixes it.

15:22 stuartsierra: yes

15:23 dysinger: or (take 1000

15:23 stuartsierra: might still run out of memory if you def it and then consume the whole sequence.

15:23 dysinger: y

15:23 I had that problem 1st

15:24 stuartsierra: Try: (defn my-file-seq [] (file-seq ...)) Then use (my-file-seq) wherever you need it.

15:24 That way you never hold on to the head of the sequence, so it's all lazy.

15:25 dysinger: somewhere we are holding on to the head methinks

15:28 Cark: at the repl you hole the head in *1

15:28 hold

15:44 replaca: hmmm, to me it looks like clojure-json is almost 20x faster that c.c.json.write

15:44 That doesn't seem right based on what I know about the code

15:50 My test is the contrib autodoc JSON index

16:29 technomancy: is there a function for checking to see if a map is a subset of another map?

16:30 sd: is clojure and scala competing?

16:31 dnolen: no

16:31 sd: articles on the net seem to imply they are competing

16:31 technomancy: not intentionally anyway

16:31 sd: well not intentionally

16:31 but dont they solve similar/the same kind of problems ?

16:31 kinda like python vs ruby

16:31 dnolen: no

16:31 beyond general programming problems.

16:32 sd: well concurrency on the jvm

16:32 technomancy: they have similarities, but the target audiences are pretty different.

16:32 sd: really ? what are the target audiences of each?

16:32 technomancy: scala only appeals to people who think making up a new syntax is reasonable. =)

16:32 sd: hehe

16:33 seriously though, what are the different audiences? :)

16:33 dnolen: sd: if you come from a dynamic programming language you'll like Lisp

16:33 if you really like static typing, you'll like Scala

16:33 technomancy: sd: scala is for people who don't mind Java the Language.

16:33 sd: which language is more functional?

16:34 Chousuke: functional in the paradigm sense? :P

16:34 probably clojure.

16:34 though I don't know Scala, so I can't say for sure.

16:34 dnolen: sd: they are both very functional in design.

16:34 they both allow you step outside

16:34 replaca: but scala "looks" more functional in some ways

16:34 dnolen: Scala allows OO

16:34 danlarkin: replaca: well I did put effort into making it fast :)

16:34 arohner_: technomancy: (some #{subset} (vals supermap))

16:35 dnolen: Clojure allows stepping outside via Java.

16:35 replaca: in the sense of looking like haskell

16:35 technomancy: arohner_: thanks

16:35 arohner_: np

16:35 replaca: danlarkin: :-) I'm wondering if it's not just type tags

16:36 danlarkin: replaca: use (set! *warn-on-reflection* true) and find out

16:36 replaca: danlarkin: I was doing some tests of the pretty printer version vs. the regular version in both cases

16:36 danlarkin: yeah, I hadn't yet gotten motivated to hack stuart's code :-)

16:37 danlarkin: replaca: if/when you do lemme know :)

16:37 replaca: danlarkin: will do. I'm more interested in undestanding the difference between the base case and the pretty case

16:38 technomancy: arohner_: actually that doesn't work

16:38 ,((fn [sub parent] (every? #(= (sub %) (parent %)) (keys sub))) {1 2} {1 2 3 4 5 6})

16:38 clojurebot: true

16:38 danlarkin: replaca: in clojure-json/master?

16:38 arohner_: hrm, that worked in my limited setup

16:38 replaca: danlarkin: it looks like 8:1 ish for clojure-json and 4:1 ish for c.c.json.write

16:38 arohner_: (def subset {:a 1, :z 26})

16:38 sd: how do i do lazy evaluation in ruby?

16:38 replaca: danlarkin: in both

16:38 arohner_: (def supermap {:b 5, :x subset})

16:39 technomancy: sd: hey, are you sebastien from NY?

16:39 arohner_: (some #{subset} (vals supermap))

16:39 {:a 1, :z 26}

16:39 (some #{10} (vals supermap))

16:39 nil

16:39 Chousuke: sd: does ruby even support lazy evaluation?

16:39 arohner_: Chousuke: no, unless you count using proc/lambda to hack it

16:40 sd: Chouser: not unless you use proc/lambda to hack it

16:40 but it's quite ugly

16:40 technomancy: sd: you can do get some laziness with Hash.new

16:40 sd: oops

16:40 technomancy: sd: fib = Hash.new{ |h, n| n < 2 ? h[n] = n : h[n] = h[n - 1] + h[n - 2] }

16:40 sd: i meant clojure!

16:40 technomancy: hehe

16:40 sd: how do i do lazy evaluation in CLOJURE* sorry

16:40 hehe

16:40 technomancy: sd: many core functions are lazy, like map and for

16:40 replaca: danlarkin: more generally I'm trying to understand how to do a more reasonable overhead version of pretty dispatch so it makes sense for use with all kinds of structured data

16:41 Chousuke: evaluation is not lazy in clojure I guess, but you can have lazy sequences. And macros can control evaluation, so they can be lazy that way

16:44 danlarkin: replaca: yes, that makes sense. I was thinking about it a little the other day after we spoke, didn't come up with a better way during my brief think.

16:47 replaca: danlarkin: yeah, it's only partially optimized and in the general case of pretty printing small chunks of code/data it does ok, but it's not fast enough for using it to provide data in a high-volume web service or something

16:47 lisppaste8: scottj pasted "choose-one" at http://paste.lisp.org/display/80164

16:48 scottj: I'm trying to create a function that takes a collection of items (e.g. strings) and presents a window where the user can click one and the function will return the value of the item that was selected.

16:49 In the paste above you can see that I have it displaying a JPanel and JList, but I don't know how to setup a ListSelectionListener or whatever so that when an item in the list is clicked it returns that item

16:50 anyone here know swing and willing to help?

17:08 duncanm: how do i specify the constructor if i'm using the PROXY form to write an anonymous class?

17:09 ahhh

17:41 lisppaste8: scottj annotated #80164 "untitled" at http://paste.lisp.org/display/80164#1

17:44 arohner_: you can do map destructuring in fn arguments, right?

17:46 I have map destructuring working with a let, but I'm having trouble translating that into fn arguments

17:46 dnolen: it's exactly the same in fn arguments

17:47 ,((fn [{x :x y :y :as z}] [x y z]) {:x 1 :y 2})

17:47 clojurebot: [1 2 {:x 1, :y 2}]

17:53 arohner_: oh, I didn't realize you could put a vector before the arguments vector

17:55 stuhood: arohner_: he's not: the first vector is the arguments vector, the second is the body of the function

17:55 cads: hey are there lisp syntax highlighters that I can adapt to clojure to make a colorful repl for the command line?

17:57 arohner_: ah, I think I get it.

18:02 unlink: ha. I used clojure on my last final exam ever.

18:02 technomancy: so it turns out renaming 2GB small of files takes a long time.

18:03 unlink: I wrote the following function (in pencil): (defn fold-links [urls] (reduce (fn [acc [src dst]] (assoc acc dst (conj (get acc dst #{}) src))) {} urls))

18:07 achim_p: hmm, does anyone know of a good place to ask java questions? most of the forums i found seem to be kids discussing their school projects/homework ...

18:08 unlink: ##java is no good?

18:08 cp2: #java ?

18:09 scottj: achim_p: maybe stackoverflow.com

18:12 achim_p: unlink, cp2: i'm a bit of an IRC noob - these aren't channels on freenode, are they?

18:12 unlink: achim_p: yes, /join ##java

18:12 achim_p: scottj: thanks, that looks good

18:12 unlink: the ## means unofficial

18:12 (on freenode)

18:15 achim_p: unlink: okay, thanks! they didn't show up in the channels listing somehow

18:15 unlink: Don't depend on those.

18:19 ,(let [a 1] (eval 'a))

18:19 clojurebot: DENIED

18:19 unlink: ,"wtf?

18:19 clojurebot: EOF while reading string

18:19 duncanm: how do i get the this pointer inside the PROXY form?

18:19 unlink: ,(eval "hello")

18:19 clojurebot: DENIED

18:20 unlink: so sad

18:20 Cark: duncanm : it's available as "this" or "self" i don't remember

18:21 Each method fn takes an additional implicit

18:21 first arg, which is bound to 'this

18:32 technomancy: what's the cheapest way to see if a string matches a regex?

18:32 I'm using re-find, but I only need a true/false check

18:53 grzm: technomancy: i'll do it for a dollar: if you find cheaper, I'll match *cough* their price

18:55 dreish: ,(.matches (re-matcher #"foo" "foo"))

18:55 ,(.matches (re-matcher #"foo" "ffoo"))

18:55 hiredman: true

18:55 dreish: hiredman: quick, in your head, (apply * (range 1 100))

18:55 hiredman: 55?

18:55 dreish: lol

18:58 technomancy: grzm: that's a good price.

19:05 grzm: I'm transforming some sets of sql results to be used in some charts. the columns common to the result sets will each be charted in their own graph (for comparison). I'm having a hard time imagining how to do this without resorting to multiple passes over the result sets. Here's what's working so far: http://paste.lisp.org/display/80168

19:05 any ideas?

19:14 lisppaste8: izittm pasted "slime-apropos for clojure - Evaluation aborted." at http://paste.lisp.org/display/80176

19:15 Cark: grzm : using reduce ?

19:16 izittm: in the above paste: i'm trying M-x slime-apropos

19:16 however, anything i enter just gets me to Evaluation aborted

19:16 any ideas what could be wrong?

19:16 grzm: it seemed to me that there should be a way using reduce, but my skills are novice level at best. are you thinking i'd need to use binding as well to destructure the rows?

19:18 replaca: hiredman: did clojurebot just reblast twitter? I was confused about what was going on in my tweetdeck

19:19 cp2: he is attacking you

19:19 skynet incoming

19:20 technomancy: izittm: I don't think swank-clojure implements that functionality unfortunately

19:24 hiredman: replaca: sorry

19:25 (thats a yes)

19:27 izittm: tehcnomancy: :(

19:27 achim_p: grzm: i don't believe there's much to be gained by using reduce here. you'll even lose laziness

19:28 izittm: so how do you generally find docs?

19:29 technomancy: izittm: you can use find-doc from the repl; it's not that inconvenient

19:29 sure a first-class emacs command would be better, but it works

19:29 hiredman: crap

19:29 how did that happen again

19:29 (flooded twitter again)

19:30 :(

19:33 izittm: technomancy: thanks, i'll check it out!

19:33 replaca: hiredman: no worries. We're all friends here.

19:33 hiredman: I think clojurebot's full functionality should be available over twitter now

19:33 hmm

19:33 or not

19:34 ok, fixed

19:34 someone try a doc lookup

19:38 eyeris: How can I lookup, in Clojure, what methods a Java object contains?

19:38 technomancy: eyeris: show, in contrib's repl-utils

19:39 hiredman: ,(map #(.getName %) (.getMethods String))

19:39 clojurebot: ("hashCode" "compareTo" "compareTo" "indexOf" "indexOf" "indexOf" "indexOf" "equals" "toString" "length" "isEmpty" "charAt" "codePointAt" "codePointBefore" "codePointCount" "offsetByCodePoints" "getChars" "getBytes" "getBytes" "getBytes" "getBytes" "contentEquals" "contentEquals" "equalsIgnoreCase" "compareToIgnoreCase" "regionMatches" "regionMatches" "startsWith" "startsWith" "endsWith" "lastIndexOf" "lastIndexOf" "lastI

19:45 hiredman: clojurebot: are you broken?

19:45 clojurebot: Pardon?

19:45 hiredman: ~latest

19:45 clojurebot: latest is 1367

19:45 hiredman: I guess not

20:20 eyeris: How do I source a file from the repl?

20:21 technomancy: eyeris: ideally it would be on the classpath and you could call require

20:21 otherwise use load-file

20:22 eyeris: Thanks

20:25 Is there a way to import all classes in a namespace, similar to java's import blah.*?

20:26 I know it's not good practice, but it would be useful in the repl.

20:31 lazy1: eyeris: (import '[java.util.*])

20:31 eyeris: Why is the vector quoted?

20:32 * eyeris is a lisp-newb

20:32 * lazy1 is a clojure-newb

20:32 eyeris: I am used to (ns (:import [java.util Date]))

20:33 lazy1: My guess is that the vector is quoted since java.util is not imported yet. So you give a quoted name

20:33 Otherwise clojure will try to resolve java.util and will fail

20:36 cipher: ~*ns*

20:36 clojurebot: Gabh mo leithsc�al?

20:37 cipher: ~(refer 'hiredman.clojurebot)

20:37 clojurebot: Excuse me?

20:37 cipher: neat

20:38 dreish: ,(.matches (re-matcher #"foo" "foo"))

20:38 clojurebot: true

20:38 dreish: ,(.matches (re-matcher #"foo" "fooo"))

20:38 clojurebot: false

20:42 eyeris: Thanks for the tip lazy1

21:30 Edgar1: hello

21:31 is there any complete tutorial document for learning Clojure Language?

21:32 :-\ to me, I see that the reference stuff in the clojure.org page it's kind of hard to understand and read

21:33 cp2: http://en.wikibooks.org/wiki/Learning_Clojure

21:33 perhaps this?

21:33 also http://en.wikibooks.org/wiki/Clojure_Programming

21:33 theres a boot coming out too

21:33 (like a real book)

21:39 Edgar1: do you have in mind a kind of clojure rails?

21:41 eee: hi

21:41 Edgar1: hello

21:52 jmaness: does anyone know if clojure-http-client supports https? looking through the code on github, it doesn't appear so yet, but i wanted to make sure.

21:54 eee: i'm clueless about web stuff

21:54 what's the web?

21:54 :)

21:55 haven't messed with it, that is

22:00 cp2: jmaness: my guess is no, but if it allows you to specify the socket to use then you could

22:00 jmaness: cp2: i'll try it out, and if it doesn't work, i can always use Apache HttpClient.

22:00 cp2: http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLSocket.html

22:00 etc

22:29 danlarkin: jmaness: it should?

22:30 although I donno, never tried, so maybe it doesn't

22:35 jmaness: danlarkin: i found that one of the comments in the resourcefully.clj references https://www.google.com/accounts/LoginAuth, so that gives me hope

22:36 eee: so this allows you to programatically log in to an https site?

22:36 that's what you're looking for?

22:36 and then scrape the contents?

22:38 jmaness: i think so, but I haven't yet tried it. i'm still getting used to git

Logging service provided by n01se.net