#clojure logs

2009-05-13

00:45thearthurhello all
00:46thearthurI have'nt updated clojure since the lasy seq changes
00:46thearthurits about time no?
00:46thearthurwhat do i need to change in me source?
00:52hiredmanhttp://clojure.org/lazier towards the middle is a reference
01:22cadsI 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
01:22cadsI feel like I could do better with it
01:23cadswhat do you guys think? http://paste.lisp.org/display/80121
01:27thearthuranyone here know how to get a stack dump from Enclojure?
02:18duck11231please tell me someone here has a working build process with maven
02:18clojurebotbuild is working
02:20Lau_of_DKhmm, I didnt realize that anybody still used maven
02:26duck11231I'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
02:26duck11231right now I have the clojure plugin working, but I can't get my src path working right
02:27Lau_of_DKIm 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 :)
02:31duck11231right 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
02:32duck11231it's becoming a hassle as I wanted to include clj-doc and it involved creating 3 new submodules
02:34tWipLau_of_DK: what do you mean "still used maven"?
02:34tWipI'm using it all the time.
02:35Lau_of_DKOk - so thats 1 :)
02:35duck11231are you using it for clojure?
02:35tWipwell webjure uses it
02:36duck11231I agree with technomancy's sentiment that maven would be a lot cooler with a clojure wrapper around it.
02:36tWipdo you mean just replacing pom.xml with some s-expressions?
02:37duck11231maybe, you could probably do other abstractions
02:37duck11231it would be clojure data
02:37tWipthere isn't really that much to maven, just have the project model and run builds
02:37duck11231I'm just getting started, and already my pom.xml is a monster
02:38tWipthough having the project model as s-expressions and implementing maven plugins (MOJOs) in clojure would be cool
02:38duck11231but I'm trying to pull in all these dependencies too
02:38duck11231mojos could be easily written in clojure, I was thinking about that
02:40tWipmostly I like maven because it automatically pulls dependencies from the net and has convention over configuration approach
02:40duck11231see, webjure just compiles the java, right? I want to compile my clojure namespace into a war
02:41tWipyes, it was mainly developed before AOT, I'll need to look in to compiling the clj as well
02:41tWipI think there's some clojure compiler plugin
02:41duck11231I can't quite figure out where to put my clj fils so they will be compiled by the plugin
02:42tWippossibly under src/main/clojure
02:42tWipif it follows conventions
02:42duck11231that's where I originally put it, then I tried src/main/java still no go
02:43duck11231clojurebot: clojure-maven-plugin
02:43clojurebotclojure is the bestest programming language available.
02:43duck11231clojurebot: clojure-maven-plugin is http://github.com/talios/clojure-maven-plugin
02:43clojurebotIn Ordnung
02:43tWipanother thing about maven is that the documentation is so bad it's not even funny
02:44tWipevery 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
02:44tWipthe docs will not help
02:44duck11231It's not even out, and I'm already waiting for the sequel to programming clojure
02:45duck11231I've seen just about all the public documentation about compiling clojure src files to classes with Maven at this point
02:46duck11231of course, I haven't greped the irc logs
06:02AWizzArdI 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?
06:03Carkhum that should work
06:03AWizzArdExample: 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.
06:04AWizzArdWhat I am looking for is the function "get-key", if it exists
06:05Carkhum so you don't cvare that the value can be found with a not identical string ?
06:06Carkhow about interning all the strings before using these as key
06:06jdzdoesn't (get HM "abc") work?
06:06Carkyes it works
06:06AWizzArdthat returns me the 1
06:06AWizzArdbut I want the "abc" string that is the key inside HM
06:07Cark,(doc keys)
06:07clojurebot"([map]); Returns a sequence of the map's keys."
06:07AWizzArd,(let [x (str "abc"), y (str "a" "b" "c")] [(identical? x y) x y])
06:07clojurebot[false "abc" "abc"]
06:07AWizzArdif now x is the key in HM, then I want to use y to read x out of HM
06:08Carkwhat you really want is the dictionary entry
06:08Carkyou may need to drop to java land
06:08Cark(class {:a 1})
06:08Cark,(class {:a 1})
06:08clojurebotclojure.lang.PersistentArrayMap
06:08Cark~def clojure.lang.PersistentArrayMap
06:08AWizzArdCark: 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.
06:09Cark~def clojure.lang.IPersitentMap
06:09AWizzArdor O(log32 n) as it is for Clojure
06:10Carkyou need to get to the MapEntry from the key ...
06:10Cark,(.entryAt {"blah" 1})
06:10clojurebotjava.lang.IllegalArgumentException: No matching field found: entryAt for class clojure.lang.PersistentArrayMap
06:11Carkhum
06:11AWizzArdah good, that works for me
06:11jdzAWizzArd: find
06:11AWizzArd,(.entryAt {"blah" 1} "blah")
06:11clojurebot["blah" 1]
06:11AWizzArd,(doc find)
06:11clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
06:11Carkahyes !
06:12AWizzArdgood good, thanks you two
06:14Cark20 millions entries, how much memory does that use =)
06:29AWizzArdCark: currently I don't have the 20 mio entries in there, but will have
06:31CarkAWizzArd : you might want to check the memory consumption, clojure is in no way frugal about it
07:17yasonHmmm, what's the naming-idiom for helper functions on top-level?
07:19cemerickyason: I use fn-name*
07:20yasonwith the asterisk on the right side only?
07:21yasonlike (defn fn-dolookup* [x] ...)? Can this be observed in Clojure or Clojure/contrib sources as well?
07:22Chousukethe foo* naming convention is mostly for macro driver functions
07:22cemerickyeah. *name* is generally used only for vars you expect users to bind on.
07:22Chousukenormal helpers are named like any other function.
07:23__macAlso, you probably want defn- so you don't "leak" your helpers :)
07:23Chousukeyou can (defn-) them though, so they're private.
07:23cemerickhuh, I wasn't aware of that distinction re: macro drivers
07:23yasonChousuke: I'd like them to stand out a bit
07:23yasonhmmm, there's indeed (defn- ...)
07:24yasonhey that looks good enough by itself
07:24ChousukeI 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)
07:24clojurebotfor is not a loop
07:24Chousuke:P
07:24cemerickChousuke: foo* has definitely been used for more than just macro helpers http://www.cliki.net/Naming%20conventions
07:24Chousukeso the "foo*" convention is a way of saying "yes, the expansion is this, but you are not supposed to use these functions directly"
07:25cemerick(obviously, that's a CL page, but foo* is used in scheme codebases I've worked with as well to name helper fns *shrug*
07:25Chousukecemerick: well, yes, but the most common use is in macros.
07:26yasonChousuke: foo* plays nicely with macros since you probably want to define the macro helper functions to begin with the macro name for consistency
07:27__macIf 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).
07:28Chousukeyason: 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
07:28yason__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 :)
07:29yasonChousuke: yes, the helpers are part of the macro definition itself IMHO
07:29yasonconceptually
07:32AWizzArdWhat performance/space advantages do sorted-maps have over ordinary hashmaps?
07:33ChousukeI don't know if they do, but you can iterate over them in key order.
07:34Chousukehash-maps only give you undefined order :)
07:35__macThere 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?
07:36AWizzArd__mac: the question is what the size of an object would be
07:36__macyeah, like sizeof in C/C++
07:36__macthe whole object, not just the members
07:37__macDatatypes 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
07:37AWizzArdin 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?
07:38tWipserialize to byte[] and use that length? ...I don't know if serialized size reflects the in-memory size though
07:38AWizzArdwhen we have {"abc" "123", "xzy" "456"} then it is a hashmap that stores 4 references
07:39AWizzArdin principle it could look like {#7ea1 #1290 #bb21 #fc38}
07:39AWizzArdon a 64-bit system we have 4 pointers, each 8 bytes in that hashmap
07:41AWizzArdbut 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?
07:44__macWell 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
07:47__macI'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.
07:49__mactWip: it probably doesn't. Depends on what serializer you use as well :)
07:50__macAlso that seems rather inefficient and clumsy
07:50tWipI was thinking about the Java serialization, I think it's defined
07:50__macyou mean like objectoutputstream?
07:50tWipyes
07:50__macbecause there are others as well, like xml output and all sorts of strange beasts
07:51__macAt least I think so, haven't looked at it in a while
07:52tWipseems 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
07:54eee~logs
07:54clojurebotlogs is http://clojure-log.n01se.net/
07:54tWipalso there's getObjectSize in Instrumentation
07:55__macLike 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.
07:56__macI suppose you could do that in Java by catching the exception generated when you exhaust the heap :)
07:57__macBut I think that's unreliable because the jvm might be too low on memory to work properly if you are really unlucky
07:58yason__mac: I know next to nothing about Java itself but sounds like the answer depends on what would you try to achieve :)
07:58AWizzArd__mac: you could use jvisualvm maybe?
07:58__macWhat is that?
07:59__macOh ok profiler tool
07:59AWizzArdA profiler that comes with Java 6 Update 8 (or 10, don't know)
07:59yason__mac: if the items are big enough you can just use estimated object sizes which would create a not-so-tight bound
07:59AWizzArdhttps://visualvm.dev.java.net/
08:00__macyason: 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
08:01tWipthat's the price we pay :)
08:01__macBut 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
08:02unlinkIs there any way to create a Java class when not compiling to disk?
08:02__macThanks for the discussion all, I have to get some work done now ;)
08:04yason__mac: heh, high-level languages are not too good at that :)
08:04__macyason: what, getting work done? :D
08:05__mac*at what
08:09yason__mac: allowing you to know exactly :)
08:09yason(in an easy wasy:))
08:10__macYeah I got that, was just that the last thing I typed before your reply was that I had to get some work done ;)
08:12gnuvinceHi
08:12unlinkhi
08:44AWizzArdunlink: did you try gen-class?
08:44unlinkAWizzArd: the whole fn is guarded by (when *compile-files* )
09:07unlinkIs there a nicer way to do ~' inside a syntax quote, or do I need to do: http://dpaste.com/43672/
09:07unlink(I'm avoiding autogensym like bit#, since I don't need gensym functionality and it makes the expanded macro harder to read)
09:08ChouserI think that's what's required.
09:09unlinkok
09:10unlinkMaybe it would make sense to have a 1-character shorthand for ~'.
09:10unlinkAm I missing anything obvious in that macro implementation which would make it less terrible?
09:10ChouserI doubt that'll happen. Intentional name capture like that is rare, and people generally want it called out pretty explicitly.
09:11Chouseractually, even ther -- what happens if parts includes the symbol 'tree ?
09:12unlinkIt won't work, parts can only be :data, :left or :right.
09:13AWizzArdgensym would be the clean way anyway
09:13unlinkRather, a sequence containing only those keywords.
09:14unlinkThere's no need to guarantee uniqueness via gensym, though, since they are already guaranteed to be unique.
09:16unlinkAnd there's no need for the extra ugliness in http://dpaste.com/43676/
09:31AWizzArdunlink: in my opinion it does not add extra ugliness. If you are the only developer in a hobby project it doesn't matter.
09:32AWizzArdBut in teams (especially when doing professional work) a code review should only allow well documented code. And gensyms do that.
09:32unlinkI fail to see the connection.
09:32AWizzArdnp
10:04marklar,(read-string "(foo)(bar)")
10:04clojurebot(foo)
10:04marklarhow come it is dropping bar?
10:05Chouser'read' reads a single form
10:05marklarI'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:05Chouserit only returns one thing, so that's all it can do
10:06marklarChouser: ah, ok... how would one read the rest?
10:06Chouser,(read-string (str "[" "(foo)(bar)" "]"))
10:06clojurebot[(foo) (bar)]
10:06marklarChouser: thanks!
10:06Chouseror something
10:06stuartsierraor read in a loop
10:06marklarstuartsierra: thats what I wanted to do, but how do you get the 'rest' of the string?
10:06Chouserthe "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:07stuartsierramarklar: open a StringReader
10:08stuartsierra,(let [r (PushbackReader. (StringReader. "(foo) (bar)")] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur))))
10:08clojurebotUnmatched delimiter: ]
10:08stuartsierra ,(let [r (PushbackReader. (StringReader. "(foo) (bar)"))] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur))))
10:10stuartsierra,)
10:10clojurebotUnmatched delimiter: )
10:10stuartsierra,(let [r (PushbackReader. (StringReader. "(foo) (bar)"))] (loop [] (let [x (read r false :eof)] (when-not (= :eof x) (prn x) (recur)))))
10:10clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: PushbackReader
10:10stuartsierra,(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:10clojurebot(foo) (bar)
10:21AWizzArdbtw, a NullWriter would be interesting for duck-streams - everything one writes to it gets forwarded to /dev/null
10:21stuartsierraHm. /dev/null is not platform-independent.
10:22marklarsorry had to run and take care of something
10:22stuartsierraBut a NullWriter proxy would be easy to right.
10:22stuartsierrawrite.
10:22marklarthanks for the tips, I'll look into read and StringReader
10:22clojurebotfor is not a loop
10:23AWizzArdstuartsierra: right, under Windows it is called "NUL". But I was also thinking more of a proxy
10:23AWizzArdthat would be platform-independent straight away
10:23stuartsierraCommons IO has a NullWriter: http://tinyurl.com/ogn9go
10:23AWizzArdyes, I know
10:23stuartsierraok
11:14scottjwhat 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:14scottj(sorry wrong chan)
13:08hiredmaninteresting
14:01achim_phi all! anybody else on java 1.6.0_07
14:02achim_p... on os-x experiencing awfully long startup times?
14:02achim_p(like: a minute)
14:03kotarak1.6.0_03-p3 works fine here.
14:09achim_pit'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:10twismcan we have clojurebot on twitter evalute expressions?
14:10twismwith the new @replies we wont be spamming followers
14:19hiredmantwism: try it
14:26hiredmanhmmm
14:27twismhiredman: would have to do it this weekend
14:27hiredmananyway, 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:27rhickeydid sdb work for anyone?
14:27hiredmantwism: I mean tweet at it
14:27twismah
14:27hiredman@clojurebot (+ 1 2)
14:28hiredmanI had it working at one point
14:28ieureBut... Why?
14:28technomancyhiredman: what's his XMPP handle?
14:29hiredmandoesn't have one yet
14:29technomancyoh gotcha
14:29hiredmanI imagine it will be clojurebot@thelastcitadel.com
14:30twismclojurebot didnt answer me back... jerk im unfollowing him
14:31twismor her
14:31hiredmangive it ten minutes
14:32hiredmanor so, I throttle twitter responses unintelligently
14:32twismah ok
14:33hiredmanit also may not be working :P
14:33hiredmanI just sort of knocked it together before I decided the output handling needed a rewrite
14:33grzmI'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:34grzm(some #(not (= () (re-seq #"a" %))) a)
14:34grzmwhere a is the vector, and #"a" is the match
14:34technomancygrzm: if regexes were callable there would. =)
14:34grzmer, pattern
14:34hiredmangrzm: use re-find
14:34hiredman,re-find
14:34clojurebot#<core$re_find__4549 clojure.core$re_find__4549@64bbf1>
14:35technomancy(seq (filter my-regex my-vector))
14:35hiredman,(re-find #"a" "aaa")
14:35clojurebot"a"
14:35technomancyas long as you're OK with "true-ish" instead of true
14:35hiredman,(re-find #"a" "bbb")
14:35clojurebotnil
14:35hiredmanyou can nil pun with re-find
14:35grzmtruish is find
14:35grzmfine
14:35grzmtechnomancy, hiredman: thanks :)
14:36technomancygrzm: mine doesn't work. =)
14:36technomancy(yet, at least... there's talk of making regexes callable)
14:37grzmtechnomancy: no, but you gave me food for thought, and that's half the battle!
14:37technomancyimho that kind of conciseness is a great case for callable regexes
14:38technomancybut I don't interact with many java APIs that use Patterns, so I'm biased
14:40grzmhiredman: what I'm actually looking at is something like this:
14:40grzm(re-find #"a" ["alpha" "beta" "gamma"])
14:40grzm(which throws an error)
14:41grzm,(re-find #"a" ["alpha" "beta" "gamma"])
14:41clojurebotjava.lang.ClassCastException
14:41grzmthank you, clojurebot
14:41hiredman,(re-find #"a" (seq ["alpha" "beta" "gamma"])))
14:41clojurebotjava.lang.ClassCastException
14:41hiredmanoh
14:41hiredmanRight
14:41hiredmandun
14:41hiredmanre-find takes a string
14:41kotarak,(map #(re-find #"a" %) ["alpha" "beta"])
14:41clojurebot("a" "a")
14:41technomancy,(let [r (fn [pattern] (fn [s] (re-find pattern s)))]
14:41stuartsierra,(map #(re-find #"a" %) ["alpha" "beta" "gamma"])
14:41technomancy ((r #"o hai") "o hai everyone"))
14:42clojurebotEOF while reading
14:42clojurebot("a" "a" "a")
14:42hiredman,(filter #(re-find #"a" %) ["alpha" "beta" "gamma"])
14:42clojurebot("alpha" "beta" "gamma")
14:42technomancy,(let [r (fn [pattern] (fn [s] (re-find pattern s)))] ((r #"o hai") "o hai everyone"))
14:42clojurebot"o hai"
14:42technomancyhacky syntax sugar
14:42grzmwow
14:43hiredman,(class #"")
14:43clojurebotjava.util.regex.Pattern
14:43grzmwonders if erc has syntax highlighting
14:44technomancygrzm: oooh... that's a good idea.
14:51twismhiredman: gotcha
14:52twismwell... make sure to tweet if it ever comes back online
15:11hiredmandanlarkin: clojure-json seems to be puking on twitters maintenance message json
15:11danlarkinohword?
15:11hiredman"{\"request\":NULL,\"error\":\"Twitter is down for maintenance. It will return in about an hour.\"}"
15:11hiredmaninput to decode-from-str
15:11danlarkinah I bet I know why
15:11hiredmanjava.lang.RuntimeException: java.lang.Exception: EOF while reading (NO_SOURCE_FILE:0)
15:12stuartsierracapital "NULL"?
15:12danlarkinyes
15:13stuartsierraDoesn't validate!
15:13danlarkinyeah capital NULL is invalid json
15:13hiredmanpoor twitter
15:14hiredmanwell, poor me, rich twitter
15:14stuartsierraWell, that's it, we can't have a Clojure twitter client now. :)
15:14danlarkinI'll get a fix in for this when I can, hiredman
15:14clojurebotfor is not used enough
15:14hiredmandanlarkin: no rush
15:15hiredmanI think I am using a pretty old clojure-json to begin with
15:15danlarkinwell I got the error locally too
15:15danlarkinso it's still a problem
15:16technomancywell 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:19replacadanlarkin: interesting question: can javascript read that string correctly (since we know that's the "real" def of JSON)?
15:20dysingerhaving some trouble with file-seq
15:20dysingerruns out of memory
15:20stuartsierrarplaca: Rhino won't parse it
15:20dysinger(file-seq (File. "somedir/with/2Gs/of/files"))
15:20dysinger*boom* as steve jobs would say
15:20replacastuartsierra: we know who the real CL folks are! :-)
15:21stuhood~def file-seq
15:21stuartsierrareplaca: yep
15:21stuartsierradysinger: if you're typing that at the REPL, it's trying to print a seq of a million or so files.
15:22dysingertrue
15:22stuartsierrashouldn't be a problem if it's used lazily
15:22dysingerusing def fixes it.
15:22stuartsierrayes
15:23dysingeror (take 1000
15:23stuartsierramight still run out of memory if you def it and then consume the whole sequence.
15:23dysingery
15:23dysingerI had that problem 1st
15:24stuartsierraTry: (defn my-file-seq [] (file-seq ...)) Then use (my-file-seq) wherever you need it.
15:24stuartsierraThat way you never hold on to the head of the sequence, so it's all lazy.
15:25dysingersomewhere we are holding on to the head methinks
15:28Carkat the repl you hole the head in *1
15:28Carkhold
15:44replacahmmm, to me it looks like clojure-json is almost 20x faster that c.c.json.write
15:44replacaThat doesn't seem right based on what I know about the code
15:50replacaMy test is the contrib autodoc JSON index
16:29technomancyis there a function for checking to see if a map is a subset of another map?
16:30sdis clojure and scala competing?
16:31dnolenno
16:31sdarticles on the net seem to imply they are competing
16:31technomancynot intentionally anyway
16:31sdwell not intentionally
16:31sdbut dont they solve similar/the same kind of problems ?
16:31sdkinda like python vs ruby
16:31dnolenno
16:31dnolenbeyond general programming problems.
16:32sdwell concurrency on the jvm
16:32technomancythey have similarities, but the target audiences are pretty different.
16:32sdreally ? what are the target audiences of each?
16:32technomancyscala only appeals to people who think making up a new syntax is reasonable. =)
16:32sdhehe
16:33sdseriously though, what are the different audiences? :)
16:33dnolensd: if you come from a dynamic programming language you'll like Lisp
16:33dnolenif you really like static typing, you'll like Scala
16:33technomancysd: scala is for people who don't mind Java the Language.
16:33sdwhich language is more functional?
16:34Chousukefunctional in the paradigm sense? :P
16:34Chousukeprobably clojure.
16:34Chousukethough I don't know Scala, so I can't say for sure.
16:34dnolensd: they are both very functional in design.
16:34dnolenthey both allow you step outside
16:34replacabut scala "looks" more functional in some ways
16:34dnolenScala allows OO
16:34danlarkinreplaca: well I did put effort into making it fast :)
16:34arohner_technomancy: (some #{subset} (vals supermap))
16:35dnolenClojure allows stepping outside via Java.
16:35replacain the sense of looking like haskell
16:35technomancyarohner_: thanks
16:35arohner_np
16:35replacadanlarkin: :-) I'm wondering if it's not just type tags
16:36danlarkinreplaca: use (set! *warn-on-reflection* true) and find out
16:36replacadanlarkin: I was doing some tests of the pretty printer version vs. the regular version in both cases
16:36replacadanlarkin: yeah, I hadn't yet gotten motivated to hack stuart's code :-)
16:37danlarkinreplaca: if/when you do lemme know :)
16:37replacadanlarkin: will do. I'm more interested in undestanding the difference between the base case and the pretty case
16:38technomancyarohner_: actually that doesn't work
16:38technomancy,((fn [sub parent] (every? #(= (sub %) (parent %)) (keys sub))) {1 2} {1 2 3 4 5 6})
16:38clojurebottrue
16:38danlarkinreplaca: in clojure-json/master?
16:38arohner_hrm, that worked in my limited setup
16:38replacadanlarkin: it looks like 8:1 ish for clojure-json and 4:1 ish for c.c.json.write
16:38arohner_ (def subset {:a 1, :z 26})
16:38sdhow do i do lazy evaluation in ruby?
16:38replacadanlarkin: in both
16:38arohner_ (def supermap {:b 5, :x subset})
16:39technomancysd: hey, are you sebastien from NY?
16:39arohner_(some #{subset} (vals supermap))
16:39arohner_{:a 1, :z 26}
16:39arohner_(some #{10} (vals supermap))
16:39arohner_nil
16:39Chousukesd: does ruby even support lazy evaluation?
16:39arohner_Chousuke: no, unless you count using proc/lambda to hack it
16:40sdChouser: not unless you use proc/lambda to hack it
16:40sdbut it's quite ugly
16:40technomancysd: you can do get some laziness with Hash.new
16:40sdoops
16:40technomancysd: fib = Hash.new{ |h, n| n < 2 ? h[n] = n : h[n] = h[n - 1] + h[n - 2] }
16:40sdi meant clojure!
16:40technomancyhehe
16:40sdhow do i do lazy evaluation in CLOJURE* sorry
16:40sdhehe
16:40technomancysd: many core functions are lazy, like map and for
16:40replacadanlarkin: 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:41Chousukeevaluation 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:44danlarkinreplaca: 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:47replacadanlarkin: 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:47lisppaste8scottj pasted "choose-one" at http://paste.lisp.org/display/80164
16:48scottjI'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:49scottjIn 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:50scottjanyone here know swing and willing to help?
17:08duncanmhow do i specify the constructor if i'm using the PROXY form to write an anonymous class?
17:09duncanmahhh
17:41lisppaste8scottj annotated #80164 "untitled" at http://paste.lisp.org/display/80164#1
17:44arohner_you can do map destructuring in fn arguments, right?
17:46arohner_I have map destructuring working with a let, but I'm having trouble translating that into fn arguments
17:46dnolenit's exactly the same in fn arguments
17:47dnolen,((fn [{x :x y :y :as z}] [x y z]) {:x 1 :y 2})
17:47clojurebot[1 2 {:x 1, :y 2}]
17:53arohner_oh, I didn't realize you could put a vector before the arguments vector
17:55stuhoodarohner_: he's not: the first vector is the arguments vector, the second is the body of the function
17:55cadshey are there lisp syntax highlighters that I can adapt to clojure to make a colorful repl for the command line?
17:57arohner_ah, I think I get it.
18:02unlinkha. I used clojure on my last final exam ever.
18:02technomancyso it turns out renaming 2GB small of files takes a long time.
18:03unlinkI 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:07achim_phmm, 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:08unlink##java is no good?
18:08cp2#java ?
18:09scottjachim_p: maybe stackoverflow.com
18:12achim_punlink, cp2: i'm a bit of an IRC noob - these aren't channels on freenode, are they?
18:12unlinkachim_p: yes, /join ##java
18:12achim_pscottj: thanks, that looks good
18:12unlinkthe ## means unofficial
18:12unlink(on freenode)
18:15achim_punlink: okay, thanks! they didn't show up in the channels listing somehow
18:15unlinkDon't depend on those.
18:19unlink,(let [a 1] (eval 'a))
18:19clojurebotDENIED
18:19unlink,"wtf?
18:19clojurebotEOF while reading string
18:19duncanmhow do i get the this pointer inside the PROXY form?
18:19unlink,(eval "hello")
18:19clojurebotDENIED
18:20unlinkso sad
18:20Carkduncanm : it's available as "this" or "self" i don't remember
18:21Cark Each method fn takes an additional implicit
18:21Cark first arg, which is bound to 'this
18:32technomancywhat's the cheapest way to see if a string matches a regex?
18:32technomancyI'm using re-find, but I only need a true/false check
18:53grzmtechnomancy: i'll do it for a dollar: if you find cheaper, I'll match *cough* their price
18:55dreish,(.matches (re-matcher #"foo" "foo"))
18:55dreish,(.matches (re-matcher #"foo" "ffoo"))
18:55hiredmantrue
18:55dreishhiredman: quick, in your head, (apply * (range 1 100))
18:55hiredman55?
18:55dreishlol
18:58technomancygrzm: that's a good price.
19:05grzmI'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:05grzmany ideas?
19:14lisppaste8izittm pasted "slime-apropos for clojure - Evaluation aborted." at http://paste.lisp.org/display/80176
19:15Carkgrzm : using reduce ?
19:16izittmin the above paste: i'm trying M-x slime-apropos
19:16izittmhowever, anything i enter just gets me to Evaluation aborted
19:16izittmany ideas what could be wrong?
19:16grzmit 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:18replacahiredman: did clojurebot just reblast twitter? I was confused about what was going on in my tweetdeck
19:19cp2he is attacking you
19:19cp2skynet incoming
19:20technomancyizittm: I don't think swank-clojure implements that functionality unfortunately
19:24hiredmanreplaca: sorry
19:25hiredman(thats a yes)
19:27izittmtehcnomancy: :(
19:27achim_pgrzm: i don't believe there's much to be gained by using reduce here. you'll even lose laziness
19:28izittmso how do you generally find docs?
19:29technomancyizittm: you can use find-doc from the repl; it's not that inconvenient
19:29technomancysure a first-class emacs command would be better, but it works
19:29hiredmancrap
19:29hiredmanhow did that happen again
19:29hiredman(flooded twitter again)
19:30hiredman:(
19:33izittmtechnomancy: thanks, i'll check it out!
19:33replacahiredman: no worries. We're all friends here.
19:33hiredmanI think clojurebot's full functionality should be available over twitter now
19:33hiredmanhmm
19:33hiredmanor not
19:34hiredmanok, fixed
19:34hiredmansomeone try a doc lookup
19:38eyerisHow can I lookup, in Clojure, what methods a Java object contains?
19:38technomancyeyeris: show, in contrib's repl-utils
19:39hiredman,(map #(.getName %) (.getMethods String))
19:39clojurebot("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:45hiredmanclojurebot: are you broken?
19:45clojurebotPardon?
19:45hiredman~latest
19:45clojurebotlatest is 1367
19:45hiredmanI guess not
20:20eyerisHow do I source a file from the repl?
20:21technomancyeyeris: ideally it would be on the classpath and you could call require
20:21technomancyotherwise use load-file
20:22eyerisThanks
20:25eyerisIs there a way to import all classes in a namespace, similar to java's import blah.*?
20:26eyerisI know it's not good practice, but it would be useful in the repl.
20:31lazy1eyeris: (import '[java.util.*])
20:31eyerisWhy is the vector quoted?
20:32eyerisI am used to (ns (:import [java.util Date]))
20:33lazy1My guess is that the vector is quoted since java.util is not imported yet. So you give a quoted name
20:33lazy1Otherwise clojure will try to resolve java.util and will fail
20:36cipher~*ns*
20:36clojurebotGabh mo leithsc�al?
20:37cipher~(refer 'hiredman.clojurebot)
20:37clojurebotExcuse me?
20:37cipherneat
20:38dreish,(.matches (re-matcher #"foo" "foo"))
20:38clojurebottrue
20:38dreish,(.matches (re-matcher #"foo" "fooo"))
20:38clojurebotfalse
20:42eyerisThanks for the tip lazy1
21:30Edgar1hello
21:31Edgar1is there any complete tutorial document for learning Clojure Language?
21:32Edgar1:-\ to me, I see that the reference stuff in the clojure.org page it's kind of hard to understand and read
21:33cp2http://en.wikibooks.org/wiki/Learning_Clojure
21:33cp2perhaps this?
21:33cp2also http://en.wikibooks.org/wiki/Clojure_Programming
21:33cp2theres a boot coming out too
21:33cp2(like a real book)
21:39Edgar1do you have in mind a kind of clojure rails?
21:41eeehi
21:41Edgar1hello
21:52jmanessdoes 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:54eeei'm clueless about web stuff
21:54eeewhat's the web?
21:54eee:)
21:55eeehaven't messed with it, that is
22:00cp2jmaness: my guess is no, but if it allows you to specify the socket to use then you could
22:00jmanesscp2: i'll try it out, and if it doesn't work, i can always use Apache HttpClient.
22:00cp2http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLSocket.html
22:00cp2etc
22:29danlarkinjmaness: it should?
22:30danlarkinalthough I donno, never tried, so maybe it doesn't
22:35jmanessdanlarkin: i found that one of the comments in the resourcefully.clj references https://www.google.com/accounts/LoginAuth, so that gives me hope
22:36eeeso this allows you to programatically log in to an https site?
22:36eeethat's what you're looking for?
22:36eeeand then scrape the contents?
22:38jmanessi think so, but I haven't yet tried it. i'm still getting used to git