#clojure logs

2009-07-22

00:44ataggartwhat's the best way to get something added to clojure-contrib? assembla? clojure-dev group?
00:46arohner_ataggart: yes, join assembla & clojure dev
00:46ataggartI have, just wondering what I do with this file thats on my machine
00:46arohner_ataggart: are you making a new thing, or patching an existing component?
00:46ataggartnew thing
00:46arohner_ataggart: fork the github project, and commit your change to your fork
00:47ataggartk thx
00:47arohner_then you'll need to get your change from your fork into the trunk. I'm not sure about the process there
00:48ataggartyeah, I haven't really grokked git yet
00:49arohner_I'm familiar with the mechanics of git, I'm not sure about the clojure process for getting your change from your fork to the trunk
00:52ataggartit looks like I just need to create a patch and send it up via assembla (http://clojure.org/patches)
00:58replacaataggart: contributions to coontrib should be discussed in the google group first (though contributors do ometimes sneak them in)
00:58ataggartso just attach the code to the thread?
01:00replacawell, I'd discuss the idea first more than the code (though you can attach the code, too)
01:01replacafolks tend to be more interested in the capability and the api than the actual implementation
01:01ataggartwell I've now "applied" to join the clojure-dev group
01:02replacaif it seems to have consensus in the google group that "it's a good thing" to have in contrib, then open an assembla ticket and attach the patch
01:02ataggartk
01:02replacaataggart: feature discussion should be in the general clojure group
01:02replacanot in dev
01:02ataggartah ok
01:03replacadev is more for mechanics and details of how things are getting done
01:03replaca(though it might be interesting to be part of)
01:03replacaalso, have you done a CA?
01:03ataggartyep
01:03replacathen that's all!
01:05AnniepooI'm creating a structure with some anonymous functions that are callbacks for a popup menu.
01:05AnniepooSome of them need the event and some don't
01:07Anniepoosuppose I have #(some-menu-callback) and #(another-callback %)
01:07Anniepoothe first doesn't need the event
01:07Anniepoonow, if I have the callback in callback-fn and try to invoke it with
01:08Anniepoo(callback fn the-event)
01:08Anniepooit freeks on the first one
01:08replacatry (fn [_} some-menu-callback)
01:08replacatry (fn [_] some-menu-callback)
01:09Anniepooah, thanks
01:09Anniepoo8cD
01:09replacaotherwise it thinks it has the wrong number of args
01:09Anniepooyup
01:10Anniepooy'all are wonderful, this is a really helpful community
01:10replacanp
01:11lisppaste8ataggart pasted "contrib logging" at http://paste.lisp.org/display/83982
01:21Knekkhmm, populating a large array is so slow...
01:21ataggartwhat's "large"?
01:21Knekk,(* 512 512 16)
01:21clojurebot4194304
01:21ataggartmhmm... large
01:22replacaataggart: logging looks nice (no writing code to the specific mechanism). coouple of typos in the ns comment (log and send-log are macros, not funcs) and you mispelled "their"
01:23ataggartheh, just saw the typo.
01:23ataggartand I wasn't sure what the convention was regarding discussing a function/macro
01:23ataggartupdating my local version now
01:24ataggartthanks for looking at it
01:24replacawell, in this case it's important that it's a macro and probably should be emphasized. In other contexts it's probably OK to be more casual about it
01:25replacanp -> this looks valuable to me for helping make sure we have code interop
01:26replacaheterogenous logging expectations is always a headache for mixing java libs
01:27Knekkany ideas on how to speed up performance with large datasets?
01:28ataggartparallelize?
01:28Knekknope
01:30hiredmanperformance of what?
01:30Knekkpopulating a large array of structs
01:32hiredmanwhy did parallelizing fail?
01:33KnekkI didn't try it. I was joking.
01:33Knekkhiredman: threads? agents?
01:34hiredmancreate a threadpoolexecutor, generate thunks to init ranges of the array, feed them to the executor
01:34hiredmanor use agents
01:35Knekkok, I'll try that tomorrow, thanks.
01:35ataggartis pmap appropriate for this?
01:35_mstor pcalls?
01:37hiredmanpcalls maybe
01:37Knekkthey are lazy/semi-lazy, and I need a persistent, fully-instantiated array
01:37hiredman~def pcalls
01:37hiredmanI don't believe pcalls is lazy
01:38Knekkreturns a lazy seq
01:38hiredman,(doc pcalls)
01:38clojurebot"([& fns]); Executes the no-arg fns in parallel, returning a lazy sequence of their values"
01:38hiredmanthe seq is lazy because the fns might take longer then others
01:39hiredmanclojurebot: you are broken
01:39clojurebotI don't understand.
01:39lushenis there a split function besides (.split)
01:39hiredmanlushen: I'd check str-utils in contrib
01:40lushenit is returning me a Ljava.lang.String that might be causing bugs
01:40lushenok thanks
01:40hiredmanlushen: I doubt it
01:40hiredmanseq knows how to make seqs from arrays
01:40hiredmanand most sequence functions call seq on their args
01:40clojurebotfunctions are maps
01:40hiredman(first (.split "foo bar" " "))
01:41hiredman,(first (.split "foo bar" " "))
01:41clojurebot"foo"
01:41ataggartre-split in str-utils may be what you want
01:41hiredman,(.split "foo bar" " ")
01:41clojurebot#<String[] [Ljava.lang.String;@c7c56a>
01:41hiredman.split takes a regex
01:41hiredman,(.split "foo bar" "\\s")
01:41clojurebot#<String[] [Ljava.lang.String;@ac8e62>
01:41hiredman,(first (.split "foo bar" "\\s"))
01:41clojurebot"foo"
01:42hiredmanit just takes the regex as a string because java does not have regex literals
01:43lushenokay let me try to explain what i'm going for
01:43lushenI've got a bunch of flatkeys like "a/b/c"
01:43lusheni'm feeding the split array into update-in
01:44hiredmanuh
01:44hiredmanno
01:44hiredmanupdate-in takes a map or maybe a vector
01:44lushen(update-in output (.split "a/b/c" "/") (fn [x y] y) "hahahahaha")
01:45hiredman,(doc update-in)
01:45clojurebot"([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."
01:45hiredmanyou are missing a lot of things
01:45hiredmanand things are out of order
01:45hiredmanetc
01:45hiredman,(update-in {:foo 1} [:foo] + 5)
01:45clojurebot{:foo 6}
01:46hiredman,(update-in {:foo {:bar 1}} [:foo :bar] + 5)
01:46clojurebot{:foo {:bar 6}}
01:47Knekkpcalls doesn't really make it faster on my laptop
01:48hiredman*shrug*
01:48hiredmanlarge array initialization could just be slow
01:48lushendoes it defeat the point of using update-in to parse a flathash if i have to feed the function a nested map in the first place?
01:48hiredmanlushen: you don't need to feed it a nested map
01:49hiredmanas my first example demoed
01:50hiredmanah
01:50hiredmanok
01:50hiredmanI understand you update-in line now
01:50hiredmanyour
01:50hiredman,(vec (.split "foo/bar" "/"))
01:50clojurebot["foo" "bar"]
01:50lushenah!
01:50hiredmanupdate-in takes a vector as it's second arg
01:51hiredmana java array is not a vector
01:52_mst,(assoc-in {} (.split "a/b/c" "/") "hahahahaha")
01:52clojurebot{"a" {"b" {"c" "hahahahaha"}}}
01:52_mstassoc-in might save the trouble of that extra (fn ...) too
01:53lushenbut that might overwrite the existing?
01:53lushenthanks let me try these out
01:54_mstyep, it will replace anything that was already in your map at that key
02:12lusheni have run into another problem: http://pastie.org/554637
02:12lushenthe two functions are mutually referrent
02:13lushendo i have to nest the shorter one in the longer one?
02:13replacalushen: no, just use declare
02:14replaca(delare foo) (defn bar [] (foo)) (defn foo [] 7)
02:14replaca(bar) => 7
02:14lushenthnx
02:14replacanp
02:35lushen(i am new to functional programming) : how do I make something like [ 0 0 "something" 0 ]
02:36hiredman,[0 0 "something" 0]
02:36clojurebot[0 0 "something" 0]
02:37hiredmanpretty simple, no?
02:37lushenfor instance if i have the structure [3 "something"] i want to get [0 0 0 "something"]
02:38hiredman,([3 "something"] 1)
02:38clojurebot"something"
02:38hiredman,(assoc [0 0 0 0] 3 ([3 "something"] 1))
02:38clojurebot[0 0 0 "something"]
02:39lushenthank you
02:40lushenis there something like (vector 0 4) -> [0 0 0 0] ?
02:41hiredman(vec (range 4))
02:42hiredman,(vec (range 4))
02:42clojurebot[0 1 2 3]
02:42hiredman,(vec (repeat 0 4))
02:42clojurebot[]
02:42hiredman,(vec (repeat 4 0))
02:42clojurebot[0 0 0 0]
02:42hiredman,(vector 0 0 0 0)
02:42clojurebot[0 0 0 0]
03:01hiredman,((comp vec (partial apply repeat) reverse list) 0 4)
03:01clojurebot[0 0 0 0]
03:12Fossihi
03:16lushenhi
04:45gulagong__,(prn "good morning")
04:45clojurebot"good morning"
06:03Jomyoot,(/ 0 0)
06:03clojurebotjava.lang.ArithmeticException: Divide by zero
06:30Lau_of_DK,(loop [] (recur))
06:30clojurebotExecution Timed Out
07:47hamzahi, i packed my application in to a jar i need to load an image inside the jar. how can i convert URL imgURL = getClass().getResource(imgName); to clojure?
08:23kylesmithhamza: (.. YourClass getClass getResource imgName) should work
08:47Chousukeisn't the getClass redundant?
08:57durka42,(.getClass YourClass)
08:57clojurebotjava.lang.Exception: Unable to resolve symbol: YourClass in this context
08:57durka42,(.getClass String)
08:57clojurebotjava.lang.Class
08:58durka42,String
08:58clojurebotjava.lang.String
08:58JomyootHOw do I append an element to end of list
08:58Jomyootopposite of cons
08:58Jomyoot(1 2 3) + 4 = (1 2 3 4)
08:58Jomyootwhat's the function name?
08:59gnuvince,(append [1 2 3] [4])
08:59clojurebotjava.lang.Exception: Unable to resolve symbol: append in this context
08:59gnuvinceerr
08:59gnuvinceconcat?
08:59cark,(concat [1 2 3] [4])
08:59clojurebot(1 2 3 4)
08:59gnuvince,concat
08:59clojurebot#<core$concat__3872 clojure.core$concat__3872@14412b0>
09:00gnuvinceToo many languages, too many words.
09:00Jomyootin a non lazy way
09:00Jomyooti want to construct a new seq entirely
09:00Jomyootconcat is lazy
09:00carkJomyoot : if you need to append to the back of the list, a list might not be the proper data structure
09:01ChousukeJomyoot: appending to the end of a list is O(n)
09:01Chousukehm
09:01cark,(-> [] (conj 1) (conj 2) (conj 3))
09:01clojurebot[1 2 3]
09:01carkand that's not lazy
09:03ChousukeI suppose if clojure had finger trees you could have an efficient deque
09:05carkdoes it need to be a finger tree ?
09:05carkwe have a persistent queue already
09:10hamzai have compiled my application and i can run it using java package.main but if i put it in a jar and try to run it java -jar i get java.lang.ExceptionInInitializerError caused by null pointer exception. my -main ony contains a println line
09:33Jomyoot,(let [x 1] (let [x 2] (println x)))
09:33clojurebot2
09:59Jomyooti would never understand macro
10:04Fossiit'll grow on you
10:42rzoomhaving some trouble with format
10:42rzoomanyone have an example?
10:43rzoomuser=> (format "blah to %1$s sir!" "rob")
10:43rzoomjava.lang.Exception: Unable to resolve symbol: in this context (NO_SOURCE_FILE:0)
10:43rzoom"blah to rob sir!"
10:45rzoomusing %s instead of %1$s gives the same result
10:49Chouser,(format "blah to %1$s sir!" "rob")
10:49clojurebot"blah to rob sir!"
10:49Chouserrzoom: there's something wrong with your environment, I think.
10:50Chouseryou, it returns the correct result after reporting an exception!?
10:50Chousers/you, //
11:02rzoomChouser: yeah, pretty strange eh?
11:03Chousercan you paste the whole stack trace somewhere?
11:04rzoomthis is really weird. when i re-type it, it works
11:05Chousermaybe you've got a weird unicode space in there somewhere
11:05rzoomthere must be a hidden character in there
11:05rzoomyah
11:06rzoomthanks for the help, though.
11:47gkoWhat's the best way to convert a list of bytes to a Java array of bytes?
11:47Chouserinto-array
11:47gkonot list of bytes, list of numbers
11:47gkoOK, I'll try.
11:47Chouserinto bytes or Bytes?
11:48gkobytes
11:48Chouser,(into-array Byte/TYPE (map byte [1 2 3 4 5]))
11:48clojurebot#<byte[] [B@af908f>
11:49gkowas so simple :)
11:50Fossi,(meta meta)
11:50clojurebotnil
11:50Fossihow am i supposed to get the metadata of a function?
11:51gko,(meta #^meta)
11:51clojurebotUnmatched delimiter: )
11:51Chousermost functions have no metadata
11:51gko^#^meta
11:51gko,^#^meta
11:51clojurebotEOF while reading
11:51Chouservars do, though
11:51gko,#^meta
11:51clojurebotEOF while reading
11:51gko,^#meta
11:51clojurebotNo dispatch macro for: m
11:51gkogrr
11:51Chouser,(meta (var meta))
11:51clojurebot{:ns #<Namespace clojure.core>, :name meta, :file "clojure/core.clj", :line 158, :arglists ([obj]), :doc "Returns the metadata of obj, returns nil if there is no metadata."}
11:52Chouser, ^ #' meta
11:52clojurebot{:ns #<Namespace clojure.core>, :name meta, :file "clojure/core.clj", :line 158, :arglists ([obj]), :doc "Returns the metadata of obj, returns nil if there is no metadata."}
11:53Fossiah, ok
11:56Fossiand the metadata of namespaces?
11:57Chouser,^(the-ns 'clojure.core)
11:57clojurebot{:doc "Fundamental library of the Clojure language"}
11:57Fossiah, cool
11:58Chousergetting is pretty much always just ^ but the problem is more often getting at the object that has the metadata
12:02Fossiworks with clojure.core, but not with my namespace
12:02Fossilooks like ns does something differently
12:02Chouseryou're sure you have metadata on it?
12:04Fossihm. this is getting interesting
12:19cemerickhrm, I might just use lucene as a key-value datastore *evil grin*
12:20stuartsierracemerick: I've done it. It works up to about 10GB.
12:22cemerickyeah, I've used it as the single store for metadata (as opposed to having sqlite or whatever off to the side), but I've always had source material available for reindexing if necessary...
12:22stuartsierraYes, that's necessary.
12:22cemerickstuartsierra: at which point the merges kill you?
12:23stuartsierraThe merges kill you, and the index is more likely to get corrupted when it gets that big.
12:24stuartsierraNow I've got only searchable fields in the index, and HTML content stashed on a filesystem.
12:24technomancypretty rough around the edges, but the concept is sound
12:24technomancynot that I condone using it as a key/value store!
12:25stuartsierraSomeone was telling me about Cassandra last night at Philly Lambda.
12:28technomancyyeah, it's not like there's a shortage of key-value stores out there
12:29cemerickthere's no clear winner for cross-platform, embedded usage as far as I can tell (unless you're happy with a copyleft license)...but we covered this yesterday :-)
12:36gdeHow do I check that an argument is a character?
12:36drewrI think I like it but I'm having a time fitting my data into it
12:36drewr,(char? \d)
12:36clojurebotjava.lang.Exception: Unable to resolve symbol: char? in this context
12:36drewrdoh
12:36drewr,(instance? Character d)
12:36clojurebotjava.lang.Exception: Unable to resolve symbol: d in this context
12:36drewr,(instance? Character \d)
12:36clojurebottrue
12:37gdeThanks!
12:37cemerickhuh, I thought there was a char?
12:37gdethere is a string?
12:37cemerickyes, definitely
12:37drewri wish we had some notation for fns
12:37Chouserno, but there is a 'str' and a 'string?'!
12:38cemerickdrewr: I remember thinking that the data model looked overly complicated (at least for what we need)
12:39gdeis there a way of doing (instance? Character d) without using any Java?
12:39drewrcemerick: i don't think it's *overly* complicated, but it is more so than hbase
12:40carkgde : yes you can define a character? predicate and use it =)
12:40cemerickdrewr: heh, well, we thought HBase was overly complicated too :-)
12:40cemerickcouch is more our speed.
12:41drewrcemerick: if couch didn't fall over after 10K records we would probably still be exploring it
12:41drewrit's probably improved by now
12:41stuartsierraI'm still trying to find a good answer to the question, "What do I do with the output of a Hadoop job to make the records accessible on the web?"
12:41cemerickdrewr: when was that happening? We haven't had any such issues, FWIW.
12:42cemerick(not that we're beating it up particularly badly atm, but we've got a lot more than 10K records)
12:42drewrit was last year; it was bad enough that it turned me off at the time
12:42drewri should probably look again
12:42Chousergde: Not quite sure what you mean. You just want to avoid using the name of a Java class, or something else?
12:42gdechouse: yes I wanted the code to be platform independent.
12:43drewrgde: java is platform independent
12:43ChousukeAre you going to run the code on ClojureCLR or something?
12:43Chousukein that case, you will need to define some functions twice.
12:44Chouser#ifndef ClojureCLR (defn char? [x] (instance? Character x)) #endif
12:44gdei have some code that doesn't use any Java directly and i'd like to keep it that way
12:44rhickeyissue/patch welcome for char?
12:45Chousukeheh :P
12:45gdethanks, Chouser!
12:45drewrgotta put that CA to use!
12:46gde"char?" would be very nice
12:46technomancynext week in the Seattle Functional languages meeting, if anyone else is interested.
12:46ChousukeSome reader conditional could be useful for writing portable clojure if ClojureCLR gains support :P
12:47technomancy*next week is
12:47hlshipdoes anyone have a handy example of adding meta data?
12:48hlshipThat is, I have a (defview) macro that creates a function, but I want to add some extra meta-data to the defined function.
12:48Chousukewith-meta should help you
12:48hlshipI keep getting lost between the meta-data on the name and the meta-data on the function itself.
12:48Chousukefunctions don't support metadata, do they?
12:48Chouserhlship: you macro expands to 'defn' or something else?
12:49stuartsierrahlship: one thing to remember: "def" and all its variants copy metadata on the name to metadata on the Var being defined.
12:49hlshipExpands to defn currently, but could be (def ~fn-name (fn [] ...)) if it should
12:49hlshipthat's where I keep getting lost ...
12:50Chouser(defmacro m [] `(defn foo {:my :meta} []))
12:50technomancyhlship: there's some examples of using def to add docstrings before defn is defined in core.clj
12:50Chouserdefn supports a map of metadata after the fn name.
12:50technomancyor that
12:50hlshipGood options!
12:51hlshipThat last one is probably the easiest one for me .. let me give that a try. Thanks as always!
12:53technomancyyou should probably read through core.clj anyway; it's very instructive.
12:54hlshipI have been reading it, core.clj, yes ... but the (def) stuff is very complicated/bootstrapped.
12:54Chousukeor you could do (defmacro defview [& fn-stuff] `(alter-meta! merge {:meta 'stuff} (defn ~@fn-stuff)))
12:54Chousukeso that users could supply their own metadata map with defview as well.'
12:55jbondesonwe need a "Stump Chouser" irc game. winner gets a kewpie doll.
12:55Chousukealso, hm
12:55Chousukemy alter-meta! call is apparently wrong :)
12:55Chousukeshould have the (defn...) part as its first argument instead of last.
12:57Chouserand alter-meta! returns the metadata map instead of the var. def's traditionally return var's, though I don't know if anybody ever uses that
12:57stuartsierraclojure.test/with-test uses it!
12:58Chouserwell, there you go then.
12:58Chouser:-)
13:00yasonre
13:09ChousukeChouser: hm :/
13:11Chousukeso there's no way to just stick some additional metadata on the var returned without using let :(
13:11Chousersure -- both def and defn transfer meta from the name to the var
13:12hlshipturns out it was super easy
13:12hlshipthanks again for the help
13:12hlshipjust needed that little nudge
13:13Chousera little harder to write a macro that puts meta on a def
13:14Chouser(defmacro m [] `(def ~(with-meta 'foo {:my :meta}) "val"))
13:18gkoFor sockets, do you just use reuse Java API + duck_streams?
13:20technomancygko: there's a server-socket library in contrib
13:21gkotechnomancy: for clients?
13:21technomancyyeah, you probably want the Java API + duck-streams
13:24gkook
14:04gkoSo, to read a response: (duck/to-array-byte (.getInputStream s)) ?
14:07stuartsierrathat should work
14:08stuartsierrait's to-byte-array
14:08gkoright
14:09gkobut it's blocking...
14:13hiredmanuh
14:13hiredmanwhy wouldn't it?
14:13hiredman,(doc to-byte-array)
14:13clojurebot"clojure.contrib.duck-streams/to-byte-array;[[arg]]; Converts argument into a Java byte array. Argument may be a String, File, InputStream, or Reader. If the argument is already a byte array, returns it."
14:14hiredmanarrays cannot be lazy
14:14hiredmanso it has to read until the end of the input stream, then construct the byte array
14:14hiredmanpossibly it could return a promise
14:14Chousernot sure if duck-streams are designed with sockets in mind
14:24Chouserok, anybody with JNI experience here?
14:25hserusi have worked on it long back
14:25ChouserI'm using swig on C++ code, and my .so builds and loads ok.
14:25hserusok..
14:38stuartsierraChouser: yes, duck-streams was not designed with sockets in mind.
14:39stuartsierrahiredman's right, to-byte-array has to read to the end of the input stream before it returns anything.
14:39gkook
14:41Chouserhserus: sorry, got called away.
14:41hserusChouser: np
14:41Chouserok, so (System/loadLibrary "my_lib") rns without error
14:41Chouserruns
14:42ChouserBut when I try to create a object, I get an error: (my.lib.Foo. "tmp)
14:42Chouserjava.lang.UnsatisfiedLinkError: my.libJNI.new_Foo(Ljava/lang/String;)J
14:43hserusi guess you've verified that the library is in the path?
14:43Chouserwell, it loads
14:44Chouserif it's not in the path, if fails at loadLibrary
14:46Chousermy.libJNI is a Java class generated by swig, and loads ok too -- I can use reflection to see all its methods
14:46gkoFor socket, something like this:
14:46gko(defmethod copy [SocketInputStream OutputStream] [input output]
14:46gko (let [buffer (make-array Byte/TYPE *buffer-size*)]
14:46gko (loop []
14:46gko (let [size (.read input buffer)]
14:46gko (if (and (pos? size) (> (.available input) 0))
14:46gko (do (.write output buffer 0 size)
14:46gko (recur))
14:46gko (if (and (pos? size) (= (.available input) 0))
14:46gko (.write output buffer 0 size)
14:46gko nil))))))
14:46hserusare the related libraries in path too?
14:47Chouserhserus: yes, I was having problems with that too, but all those failures are when I load the lib.
14:47Chousernow that all the deps are in the path, loadLibrary is working. That's also the step where the swig docs seem to expect UnsatisfiedLinkError's
14:48Chouserso I'm confused as to how I'm getting UnsatisfiedLinkError when trying to construct
14:49Chouserand with no error message, just a Java method signature
14:49Chouserjava.lang.UnsatisfiedLinkError: my.libJNI.new_Foo(Ljava/lang/String;)J
14:50hserusi have no idea.. do you know what the class does?
14:50Chouserthe Foo C++ class? I've got the source to it, so I can look at that. You think that may reveal the problem?
14:51Chouserit seems unlikely it's getting as far as calling the constructor
14:51hserusprobably, it might be using another dependency which isn't available in path
14:57hserusChouser: any luck?
15:11Chouserhserus: I'm trying to add a simple static method to the C++ and see if I can get that working.
15:12hserusok
16:24rhickeyanyone looking to contrib towards the forkjoin stuff - let me know if you want to try to implement pvmap-index or pvreduce-index, which are passed fns taking index and val
16:25rhickeyalso interested in any performance feedback on the par branch
16:31rhickeyesp if you have > 4 cores
16:33technomancywhere would be a good place to read up on forkjoin?
16:33rhickeyhttp://gee.cs.oswego.edu/dl/concurrency-interest/index.html
16:34technomancythanks
16:34rhickeybut I hope to hide the complexity from people, using pvmap/pvreduce requires no forkjoin knowledge
16:35drewrfj seems to me like mapreduce with threads instead of computers
16:50arohner_is there a way to just go run a fn in a separate thread, using the agent thread pool?
16:50arohner_I don't have an agent, and I don't care about the return value
16:50rhickey,(doc future)
16:50clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
16:50arohner_but I would like to be able to use i.e. await
16:51arohner_rhickey: thanks
17:04rhickeylisppaste8: url
17:04lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:05lisppaste8rhickey pasted "pvmap rocks!" at http://paste.lisp.org/display/84027
17:06rhickeyquad-core perf ^^
17:06Chousukenice. :)
17:07rhickeygame-changing
17:07arohner_wow
17:10ChousukeAre you going to merge the namespace with clojure.parallel?
17:10Chousukepar is not a very good name. :P
17:10rhickeyclojure.parallel is going to be deprecated from the looks of this, I just didn't want to deal with that right now
17:11Chousukeright.
17:11ChousukeI wonder if anyone was using it anyway.
17:12rhickeythe beautiful thing about this is it's persistent data structure -> persistent data structure
17:12rhickeypvmap returns a regular Clojure vector
17:13Chousukeheh, yeah.
17:14ChousukeThough it's also fun that even in the linear case, ArrrayList is not that much faster :P
17:15rhickeydepending on the gc patterns, there were some runs where linear (vec (map ... is just Elapsed time: 82.551 msecs, I used a more typical number
17:16drewrany issue with converting pmap to pvmap?
17:17rhickeydrewr: pmap works on any seq, pvmap only takes vectors
17:17drewrahh
17:18rhickeyparallelizing a seq has limits, e.g. the per-item work must be substantial
17:19rhickeyalso pmap is semi-lazy, pvmap computes a full result
17:19rhickeynote this pvmap call is just for inc, a tiny per-item job
17:19drewryeah
17:20rzoomwonder how long the pmap version would take
17:20rhickeypmap inc is a losing proposition, many times slower than map
17:20rzoomah
17:20rzoommakes sense
17:20rhickeypmap is for big per-item work
17:21rhickeywhere it is still quite handy, being lazy and all
17:21arohner_rhickey: would it be possible to make a fast pvfilter?
17:21rhickeyI'll be able to do similar ops for maps and sets
17:22rhickeyarohner_: pvfilter is a little trickier, I've been thinking about it
17:23Chousersparse vectors?
17:23Chousukehmm
17:23rhickeymaps can be used as sparse vectors
17:23Chousukehow do I specify the classpath for ant for building with jsr166y?
17:23rhickeyChousuke: that's built into the par branch
17:24rhickeyjust put jsr166y.jar into your Clojure base dir
17:24rhickeyi.e. next to build.xml
17:25Chousukenow it complains about the class version... I guess ant is using 1.5?
17:26rhickeyChousuke: you have to set up Java 6, what OS?
17:26ChousukeOS X 10.5.7, java is 1.6.0_15 (developer preview. Has escape analysis and I want to see if it has any effect :P)
17:27rhickeyant won't see that unless you do:
17:27rhickeyexport JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
17:27ChousukeI see.
17:28rhickeyJava Preferences panel is not enough
17:28Chousukehmm :/
17:29Chousukenow I get "cannot find symbol" for ((ForkJoinPool)pooledExecutor).setAsyncMode(true); ... I wonder if I have the right version of the jsr jar.
17:29rhickeyuse: http://cloud.github.com/downloads/richhickey/clojure/jsr166y.jar
17:31rhickeyChouser: were you saying the results of pvfilter should be a sparse vector?
17:31Chouserrhickey: must musing
17:32Chouserrhickey: dunno if you'd want the old vector's indexes intact, or if you'd want new non-sparse indexes.
17:32Chousukerhickey: that worked.
17:32Chouserthe latter, I suppose, but not sure how that could be done in parallel.
17:33rhickeyparallel map and set merges etc are pretty exciting
17:33rhickeypmmap
17:33rhickeyhrm
17:39Chousukerhickey: I'm not seeing as amazing results as you are. I think memory might be a bottleneck for me instead of CPU :/
17:40ChousukeI have a dualcore processor
17:41Chousukeit's still faster than ArrayList, though :)
17:42Chousukehm
17:43ChousukeI enabled escape analysis, and it causes some rather inconsistent results for (time (def v1 (vec (map inc v))))
17:45Chousukewithout escape analysis, I got speeds ranging from 550ms to 670ms now it's giving me 550-1200ms, with one 221ms result and one 1337ms :P
17:47Chousukearray map case goes 200-400ms, and pvmap 50(!) to 1400ms (again, !) (more often around 240ms though)
17:48mebaran151is there a library function to turn a bunch of nested key value lists into a hash?
17:48Chouser,(apply hash-map [[:a 1] [:b 2]])
17:48clojurebot{[:a 1] [:b 2]}
17:48Chouserheh
17:48Chousukehmm
17:48Chouser,(into {} [[:a 1] [:b 2]])
17:48clojurebot{:b 2, :a 1}
17:49Chousukeperformance is really weird with escape analysis :/
17:50Chousukein general it looks like it improves things though. unless you get unlucky.
17:53mebaran151doesn't work with nesting though
17:53mebaran151as in [:a [:b 1]] {a {b 1}}
17:57arohner_does stuart sierra hang out here?
18:07Chousukemebaran151: http://gist.github.com/152325 something like this?
18:08mebaran151I think I tried something like that
18:30cemerickarohner_: saw him earlier today *shrug*
20:10krumholt__i have a function i want to use on all elements of a seq. normally i would use map, but the function takes two arguments x and y. and i want the second argument to be the result of the last function evaluation. how can i do that?
20:11ieurekrumholt__, reduce.
20:14krumholt__ieure, perfect thanks
20:38ataggartis there a fucntion to see if there is a currently running transaction?
20:46cemerickataggart: (clojure.lang.LockingTransaction/isRunning)
20:52hiredman(alter (ref 1) inc) and see if there is an exception?
20:54ataggarthiredman: ugly solutions are verboten
20:54ataggartcemerick: thanks
21:13arohner_I'm trying to write a version of test-ns that runs the tests in parallel. These are functional tests that can take 30-60s
21:13arohner_I have
21:13arohner_(dorun (map deref (map #(future (%)) (filter #(:test (meta %)) (vals (ns-interns ns)))))))
21:13arohner_that's not faster than the current test-ns. am I doing anything stupid?
21:14ykphuahwhy a new lisp instead of taking from CL/scheme/ELisp?
21:15arohner_ykphuah: http://clojure.org/rationale
21:23ykphuaharohner_: hmm, I wanted to integrate emacs/elisp with the JVM, but using clojure means I need to learn another LISP.
21:23ykphuahso I can't really call clojure's functions from elisp.
21:24arohner_I guess so
21:34yangsxI'm wondering whether it's possible to map over a function that takes a rest argument.
21:34yangsx (defn a [x & y]...)
21:35arohneryangsx: yes, it is
21:35yangsxlike: (map #(a x %) coll)
21:35yangsxaroher: ?
21:35yangsxarohner: ?
21:35arohneryangsx: it is possible
21:35arohnerthat code looks good
21:37arohnera will get called once for every item in coll, with two arguments, x and an item
21:37yangsxarohner: no, not exactly what I want. The coll is a sequence of sequnce, and I want something like `(a x ~@%)
21:38yangsxsequences*
21:38arohnertry
21:38arohner(map #(apply a x %) coll)
21:38arohnerassuming coll looks like [ [1 2 3] [4 5 6] [7 8 9]]
21:40yangsxI see, thanks arohner. I forgot apply.
21:52Anniepooon this page, http://bc.tech.coop/blog/081029.html
21:52Anniepoothe last green on black code section shows an ns definition with (:use (my.lib this that))
21:52Anniepoois this correct?
21:57Anniepoothis also appears in the clojure API docs
21:57Anniepoo(:use (my.lib this that))
22:28Mark_Addlemani have a list: ([1235 ([0 17])] [1236 ([0 15] [16 8])]) and i want to transform it to ([1235 0 17] [1236 0 15] [1236 16 8]). i'm having all sorts of trouble thinking about this in the right way.
22:54ChouserMark_Addleman: break it down -- each second-level vector stands along, right?
22:54Chouserthen build it back up.
22:57Chouser(def x '([1235 ([0 17])] [1236 ([0 15] [16 8])]))
22:57Chouser(let [[p c] (second x)] (map #(cons p %) c))
23:00Chouser(let [[p c] (second x)] (map #(vec (cons p %)) c))
23:01Chouser(mapcat (fn [[p c]] (vec (map #(vec (cons p %)) c))) x)