#clojure logs

2009-09-17

00:01hiredmanlooks like sort of a homebrew implementation of yield
00:02hiredmanwell, no
00:02hiredmanI think I need definitely need more context
00:02albinoaren't they just calling wait() on whatever the object is in a syncryonized fashion?
00:02jamespOk can't find an example. It's basically:
00:03hiredmanjamesp: pastebin!
00:03jamespYea, I sec
00:03hiredmanalbino: but if they create a new object before every .wait, then how can anyone call notify
00:03lisppaste8_mst pasted "wait/notify" at http://paste.lisp.org/display/87214
00:04hiredman_mst: sshh
00:04_mstevilness, sorry :)
00:04hiredmanwe want to write it better
00:05hiredmanwhatever api this is should most likely be using a FutureTask or some such instead of whatever weird wait/notify scheme they have
02:19BercilakA couple days ago I was in here asking about doctests for clojure
02:19BercilakThere didn't seem to be anything obviously wrong with the idea, so I coded up an implemention
02:19Bercilakhttp://groups.google.com/group/clojure/browse_frm/thread/7fd233ca0beffb1b#
02:20BercilakI'd love it if you folks could take a look and give me feedback
04:18lowlycoderhas no one in the world writtttten a facebook app in clojure?
04:21LauJensenI hope not
04:23lowlycoderwhy not?
04:23Fossilowlycoder: there are some facebook apps on appengine, but i guess none of them in clojure
04:23LauJensenI feel it would be very much like taking a diamond and using it to clean your toilet
04:23lowlycoderi'm not convined clojure is ready for primetime until i see facebook apps in clojure
04:23Fossithorough?
04:24arbschtlowlycoder: why don't you write one? :)
04:24LauJensenlowlycoder: haha
04:24LauJensenclojurebot: primetime is <lowlycoder> i'm not convined clojure is ready for primetime until i see facebook apps in clojure
04:24clojurebotc'est bon!
04:25lowlycodererr; you need to pay me royalties
04:26lowlycoderi actually think clojure/flash can be a very powerful combo
04:26LauJensenFLASH?!
04:26LauJensenOh my
04:27lowlycoderit sounds like we're not twins separated at birth
04:27LauJensenlowlycoder: Please read this: http://en.wikipedia.org/wiki/Computer_programming, once you're done I'll take you to the next step
04:28LauJensen(that was a joke)
04:29lowlycoderthe papervision3d engine is actualllllly pretty cool
04:29lowlycoderi'd be interested to see a vw powered with papervision3d and clojure
05:14Fossiis there a macro in contrib that switches/reverses a functions arguments?
05:17avitalHello friends (and Chouser). Is there a simple way to write a version of merge that takes one argument which is a collection instead of multiple arguments? So that I could do something like (merge1 [{:a 3 :b 4} {:c 5}]) and get {:a 3 :b 4 :c 5}?
05:17Chousukeapply merge
05:17Chousuke:)
05:18avitalChousuke are you also Chouser?
05:18Chousuke,(apply merge [{:a 3 :b 4} {:c 5}])
05:18clojurebot{:c 5, :a 3, :b 4}
05:18avitalThanks :)
05:18Chousukeno.
05:18avital,(apply merge #{{:a 3 :b 4} {:c 5}})
05:18clojurebot{:b 4, :a 3, :c 5}
05:18avitalcool
05:19Chousuke(doc apply)
05:19clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
05:19Chousukevery useful :)
05:20avitalyes it is!
05:34G0SUBhas anyone used StringTemplate here?
06:16G0SUBhow can I convert a relative pathname to an absolute pathname?
06:17G0SUBST expects the absoulte pathname, but I don't want to hardcode it.
06:25ChousukeG0SUB: the java.util.File class can do that.
06:26G0SUBChousuke: any link to the docs?
06:31Chousukehttp://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html ? :)
06:31Chousukeoh, it was io
06:32vyWhy does (class (.getBytes "as")) prints out "[B"?
06:32G0SUBChousuke: :)
06:32Chousukevy: [B is the class of a primitive byte array
06:32Chousukevy: or that's what the JVM calls it, anyway
06:34vyI was expecting something akin to "#<byte [B@37a04c>".
06:35vyUmm... Nevermind.
06:35Chousuke,(.getBytes "as")
06:35clojurebot#<byte[] [B@86d597>
06:35Chousukelike that? :)
06:59LauJensenI have an agent who is calling himself on a regular interval. For the task at hand this is bad, he should rather respond to an event than poll - like wait/notifyAll - Any takes on how to implement that idiomatically?
07:15arbschtLauJensen: how about updating a reference which has a watcher?
07:15LauJensenwatcher.... Thats might be what I was looking for :)
07:17LauJensenarbscht: Thanks, that looks good, I'll dig in
07:36LauJensenuser> (add-watcher tst :send-off (agent 0) #(javax.swing.JOptionPane/showMessageDialog nil "triggered"))
07:37LauJensenI define tst as an atom with an int value, and after this expression I swap! inc on it, making it 3, but I never get a pop-up, why is that ?
07:39hamzahey guys, i am using Clojure 1.1.0-alpha-SNAPSHOT but select function is not avaible?
07:40LauJensenhamza: select-keys is
07:40LauJensenarbscht: Any clue on that watcher?
07:40hamzado i have to upgrade for select?
07:43LauJensenI imagine so, since its in the API spec
07:46hamza,(doc select)
07:46clojurebot"clojure.contrib.datalog.database/select;[[db rn pt]]; finds all matching tuples to the partial tuple (pt) in the relation named (rn)"
07:48arbschtLauJensen: does the agent have errors?
07:48arbschtLauJensen: the action-fn should take more arguments
07:49hamzathe thing is i can not reference any of the set function union select rename do i have to import them?
07:49LauJensenarbscht: tried that also
07:50LauJensenhmm
07:50LauJensenI had add-watch/add-watcher a little mixed up arbscht :)
07:50LauJensen2 not 4 args
07:52jdz,(doc clojure.set/select)
07:52clojurebot"([pred xset]); Returns a set of the elements for which pred is true"
07:52jdzi think clojure.set is not used by default
07:52Fossiexcellent. just what i was looking for a few days ago
07:52hamzathx that worked.
08:25hamzain a dosync block i need to some operations before setting a ref is safe to assume that the will not change until i exit the dosync block?
08:27Chouserthe value of the ref seen within the transaction will not change.
08:28hamzakk, so any other write to the ref will be blocked until i am done?
08:28Chousukeno.
08:28Chousukeyour transaction will just retry
08:30hamzakk, everthing starts over and i do everything again with fresh data?
08:30Chousukepretty much
08:30Chousukethat's why you should not have side-effects in transactions
08:31hamzawhat i am trying to do is i am going to create a serial number than check if it is already used using a set. i don't want to assing same serial twice.
08:32ChousukeI think in that case you could just use an atom /:
08:32Chousukeusing (swap! atom inc) to increment the counter
08:33Chousukeyou don't even need a transaction :)
08:33hamza kk, thx i'll look at atoms
08:34Chousuke(doc swap!
08:34clojurebotEOF while reading
08:34Chousuke(doc swap!)
08:34clojurebot"([atom f] [atom f x] [atom f x y] [atom f x y & args]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."
08:34Chouserbut transactions compose in a way that atoms do not. If you're using refs elsewhere in related parts of the code, you might want a ref and transaction for this.
08:35hamzai didn't know about atom's so pretty much ref's every where.
08:36Chousukeyou should keep the number of atoms and refs small though.
08:37Chousukeeg. if you need a global map of values that might vary, start with a single ref containing the entire map instead of a map containig refs :)
08:37Chousukeeven if the values could change independently of each other.
08:37Chousukethe fewer refs you have, the simpler your code will be :P
08:39hamzakk,
08:39lisppaste8crios pasted "untitled" at http://paste.lisp.org/display/87223
08:41crioshello
08:41criosjust as my first clojure program, I was trying to emulate this java code: http://paste.lisp.org/display/87223
08:42criosa simple "ping" "pong" program
08:42crioswhere two threads write alternating strings, waiting each other
08:43lisppaste8crios pasted "untitled" at http://paste.lisp.org/display/87224
08:44criosthis is my "clojure" version, of cource not working: http://paste.lisp.org/display/87224
08:44criosI'm trying to understand what would be an idiomatic clojure way of doing something of similar
08:46criosI should use really the locking macro?
08:48adityohello
08:48adityoanyone done XML parsing with Clojure
08:49Chouseradityo: sure, there are namescapes clojure.xml and clojure.contrib.lazy-xml
08:52adityoi am using clojure.xml/parse and it returns a tree like map of tags, attrs and content, my question is how do i parse it?
08:52adityoonce i am down to the first level of content it is a vector which is again a map of tag...
08:53Chouseradityo: that *is* parsed. what do you want to do with it?
08:53Chouserif you want to query it, you might like clojure.contrib.zip-filter
08:54adityoChouser: yeah its parsed, sorry. i want to get to the value of something nested
08:54Chousercrios: perhaps more idiomatic clojure would be to have to agents (instead of threads) telling each other to proceed.
08:54hamzamay be that will help http://stackoverflow.com/questions/1194044/clojure-xml-parsing
08:55crioshaving two agents? so with a "await-for" the other agent?
08:56Chousercrios: well, with agents you'd mostly likely just let them go idle in between
08:56Chousercrios: it's hard to know the best clojure idiom when the task isn't accomplishing much.
08:57adityoChouser: wow zip-filter is the cool, but why call is zip-filter :)
08:58Chouseradityo: it filters zippers. zippers are built by clojure.zip over any kind of nested structure (nested vectors, xml, etc.)
08:59criosChouser: the task should be having two threads which alternativamente print a string. Each thread prints always the same string :)
08:59Chousercrios: but why two threads? if you use two agents, it's possible only one thread would be used in the end. Is that acceptible?
09:07criosChouser: yes for this example should be acceptable. I'll try it.
09:08criosnow I'm just studying Clojure, no "ping pong" business yet :)
09:12criosAnyway, if I really wanted handle a thread pool in clojure, I should use the locking macro, monitor-enter etc?
09:12Chousercrios: that's really low-level stuff -- I haven't needed any of it yet in clojure.
09:15lisppaste8Chouser annotated #87224 "a bit like ping-pong, but using agents" at http://paste.lisp.org/display/87224#1
09:17Chousercrios: so there's a somewhat idiomatic example of something. Not sure if it's enough like your two-thread java ping-pong example to be useful or not.
09:18Chousernote there's no need for locking. Also the agent that's waiting to be triggered isn't monopolizing a thread.
09:23somniummacro-fu question: how to convert the arguments to a macro to a seq of symbols? ie (my-macro foo bar baz) #=> '('foo 'bar 'baz)
09:24Chousersomnium: the args to my-macro in that example should be symbols already
09:25Chousukesomnium: hm, you don't usually want '('foo 'bar 'zonk)
09:25Chousuke,'('foo 'bar)
09:25clojurebot((quote foo) (quote bar))
09:25criosChouser: yes it seems mono-thread. I'll study it carefully, thank you. If I well remember, any action on an agent is done by an internal ad-hoc thread. When using send-off, you don't "waste" an internal thread for blocking operation
09:25Chousuke,'(foo bar) ; foo and bar are symbols
09:26clojurebot(foo bar)
09:26Chousercrios: yes, you're right. When I added the Thread/sleep I should have changed to send-off
09:26somniumChousuke: probably I'm not getting something simpler then, what I want to do is take the args as symbols, see if they're defined, if not convert them to strings and process
09:28Chousukeyou can't do that with a macro I think :/
09:28somnium... yeah kind of trying to emulate reader macros
09:28somniumtrying to write a wrapper for js library
09:28Chousukereader macros don't check whether stuff is defined :/
09:29Chousukeit's just a simple code -> other code transformation
09:30Chouser(defmacro mymac [& syms] `(for [sym# '~syms] (or (resolve sym#) (str sym#))))
09:30Chouser(mymac map foo inc bar) ==> (#'clojure.core/map "foo" #'clojure.core/inc "bar")
09:30somniummygod how do you guys learn this stuff
09:31somniumthats exactly what Ive been trying to do :)) thanks
09:31Chousukeit's not that difficult once you get it :P
09:31Chousukethe trick is to know what a macro produces and how the compiler handles whatever it produces :)
09:32Chousukea macro is just like a normal function except for two things: 1) it's arguments are NOT evaluated and 2) it's return value is evaluated by the compiler
09:32Chousersomnium: Chousuke's right -- simply dedicate every waking moment to asking and answering questions on this channel, and 12 to 18 months later you'll be an expert! :-)
09:32Chousukeits*
09:32Chousuke:P
09:33ChouserChousuke: :-)
09:33Chousukehmm, 2) is not exactly correct. :/
09:34Chousuke2) its return value replaces the macro invocation in the code approximately at compile time :P
09:35somniumsound advice I suppose :-)
09:35somniumif you called (my macro foo (bar baz) zonk) how does (bar baz) get handled by the reader at macro expand time?
09:36Chousersomnium: the reader produces the list of two symbols: (bar baz)
09:37Chousersomnium: the compiler resolves my-macro, sees it's a macro call, and passes three args to my-macro
09:37somnium(It took me months to get the hang of ruby meta-programming, which seems really overly complicated, though I haven't gotten the hang of this yet)
09:37Chouserarg 1, the symbol foo; arg 2, the list of two symbols (bar baz), etc.
09:37somniumok, I think I get it, will have to spend some time with macroexpand for it to make sense
09:37somniumreally make sense
09:38lisppaste8crios annotated #87224 "untitled" at http://paste.lisp.org/display/87224#2
09:38Chouserone way to think about the difference between ruby (and python) "meta programming" and lisp macros is to think about when each operate.
09:39criosChouser: really each agent is using an its own thread, for a total of two threads. So your example should be operationally equivalent to the mine written in Java. Great!
09:39crios(I've added the print of the thread name)
09:40Chousermacros run very early -- some vars may be defined, locals are not. args that might eventually become anonymous fns aren't yet -- all the args are just symbols and groups of symbols.
09:40Chousercontrast with, say, python decerators, which run *after* their targets have been fully processed into function objects which you can then examine, wrap, etc.
09:41Chousercrios: there's no promise that those agents will get different threads, or that a1 will get the same thread each time.
09:41criosah ok
09:43somniumChouser: will defs and defns that come earlier in the file than the defmacro be available within the macro code?
09:43Chousersomnium: yes
09:43somniumok
09:44Chousersomnium: that's actually the key difference in my mind between read "lisp macros" and the weak macro languages provided via preprocessors for languages like C and, if I understand correctly, Haskell.
09:45Chousersomnium: lisp allows you to build up the language and utilities available to your macros
09:45Chousukein most languages macros are just a text transformation
09:46Chousukeclojure macros are *data structure* transformations
09:46avitalHi. Is there a function that returns a string representation of the name of a function or symbol in general? So that I could do something like (fn-name map) should return "map". (str map) returns something like "clojure.core$map__3815@5a83b00f". Bleh.
09:46ChouserChousuke: yes, but I don't actually think that's so terribly important.
09:47ChousukeChouser: processing text is much more difficult than processing data structures.
09:47Chousukebecause text is, well, unstructured :P
09:48ChouserChousuke: yes, but with the ability to write functions that are then available to your macros, you could have what amounts to readers and printers, and abstract away most or all of that extra difficulty
09:49ChousukeChouser: and in the end your macros would work with data structures, reducing to lisp macros :)
09:49ChouserI'm not saying that's desirable (though it would actually give you added power) I'm just saying that's not what sets lisp macros apart, AFAIU
09:49somniumhmm, if thats true why are sexps such a big deal for macro systems?
09:49ChousukeChouser: if you abstract away the reader and the printer you get lisp macros :P
09:50Chousukesomnium: sexps are just a convenient way to represent the data structure as text; they don't actually matter to the macros.
09:50ChouserChousuke: not quite, but yes very close
09:50avitalOk I figured it out - since we're within a macro we can use ~'
09:51Chousukesomnium: you could have your lisp *text* as XML and process it with a macro normally, because by the time the macro sees it it's not XML any more (the reader has read it and transformed it into data structures, which are the actual code)
09:51somniumfor the record now that I'm accustomed to them I like lisp syntax (as was foretold), but I always thought (perhaps incorrectly) the lisp macro system was the primary argument for getting accustomed to the syntax
09:52Chousukesomnium: well, the syntax is the simplest possible representation for the data structures.
09:52Chousukesomnium: and it allows things like syntax-quote to work naturally
09:53ChouserI actually built a working macro system for JavaScript. It can be done, but it's much clumsier.
09:53Chousukeif the textual syntax didn't correspond to the actual code, it would be much more difficult to write macros
09:54Chouserit's already often difficult to write macros in lisp, where the syntax is very much staying out of your way. And syntax complexities and things get ugly fast.
09:55Chousersomnium: in practice, almost every language that has macros as powerful as lisp also has a lisp-like syntax. So in that sense,you're right.
09:56Chousukethat said, lists aren't the only way to have homoiconicity. there's a language that uses maps instead of lists :)
09:56Chousukehttp://will.thimbleby.net/misc/
09:56somniumI guess you need access to the source ast too, or the source text at least
09:56clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
09:58Chousersomnium: right. http://blog.n01se.net/?p=9
10:00somniumit looks cool, is it fast enough to run in a browser?
10:00Chouserbut that was the last installment. I got JaM working enough to prove to myself that (a) it was possible and (b) it was really hard to get right.
10:01Chousersomnium: generally, yes. Its speed depends mainly on how much code there is to process -- once you get to running the code of course the macros are all done.
10:02Chouseryou could potentially do this work on the server or even at build time and send only the resulting JS.
10:02jdztalking about macros and syntax: http://users.rcn.com/david-moon/PLOT/index.html
10:02Chouserhuh. that was only 3 years ago. seems so much longer.
10:02somniumlisp has more dialects than chinese it seems
10:05triyoHow would I go about converting a struct map into a non-struct map?
10:05jdzinto?
10:06jdzand why do you use struct-maps in the first place if you want to do things like that?
10:06Chousuketriyo: you don't need to
10:09triyoI am trying to store my sql query result that is a struct in my memcached server...however I get that the Object is not serializable which is weird as I ran:
10:09triyo,(ancestors clojure.lang.PersistentStructMap)
10:09clojurebot#{java.lang.Iterable clojure.lang.Seqable clojure.lang.APersistentMap clojure.lang.IMeta clojure.lang.IFn clojure.lang.IObj java.lang.Object clojure.lang.Associative clojure.lang.IPersistentMap clojure.lang.Obj java.util.concurrent.Callable java.lang.Runnable java.util.Map :clojure.contrib.generic/any java.io.Serializable clojure.lang.Counted clojure.lang.IPersistentCollection clojure.lang.AFn}
10:14somniumChouser: I get a clojure.lang.PeristentList cannot be cast to clojure.lang.Symbol when I try your example with a list as an argument...
10:15Chousersomnium: yeah, 'resolve' wants a symbol
10:16Chouserok, I take back what I said about Template Haskell. Its macros are written in Haskell, and you can build up a library to use in your macro definitions.
10:16triyojdz: struct map into normal map. If i try to store a normal map into memcached server it all work fine. If I try to store a struct, memcached throws an exception stating that Object is not serializable.
10:16somniumis it necessary to catch those exceptions?
10:16jdz,(doc into)
10:16clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
10:16jdztriyo: that's what i meant...
10:16Chousersomnium: depends on what you're trying to do, I suppose. Do you want to allow the user to pass in lists?
10:17achimtriyo: could it be the contents of the struct map? for instance, PersistentLists, Conses and LazySeqs don't implement Serializable
10:17Chousercode that uses a Haskell macro has to use special $() syntax at the call site. I think this is the only drawback on the user side.
10:18triyojdz: I am trying to store result of the with-query-results of clojure.contrib.sql which seems to return a struct.
10:18Chouserwriting macros looks dramatically more difficult because of the strict type system, complex syntax, etc. And yet the full power is there I believe.
10:18jdztriyo: try (into (hash-map) <your-struct-map>)
10:19somniumI think so, there might be alternatives, right now I'm just trying to something like ($ #foo :click (fun ($ #bar :hide))) and get ("$('#foo').click(function() { $('bar').hide()});"
10:20triyoChousuke: you right, I saw that PersistentStructMap implements serializable. But I still then can't exaplain why it works for a simple map and not a struct.
10:21somniumI did something similiar with functions but having to quote things made it kind of ugly
10:22Chouserthe reader doesn't like #foo
10:22somniumhmm
10:22somniummaybe keywords are better then, that's what I ended up doing for tokens to become strings
10:22Chouseryou could certainly process any literal keywords, but let everything else through unchanged
10:23Chouseruse 'keyword?' instead of 'resolve'
10:23somniumI want to setup a list of json rpcs functions at the beginning of the file and then be able to plug those into 'components' in the templates, so I need some way to resolve between js-tokens and server-side tokens...
10:24somniummaybe I should follow the rules and make it all work with functions first
10:24Chousersomnium: that's likely to make your life easier. :-)
10:25triyoachim: initially I though it might be one of the types. But when I tried same keys and values in a simple map instead of a struct it worked.
10:27triyojdz: into did the trick
10:27triyothx
10:29triyoNow that is really strange. Is this a bug? I saw the #174 that was related to Keyword with similar problem. Keyword didn't implement Serializable though but PersistentStructMap does. hmm
11:07icylisperhttp://icylisper.blogspot.com/2009/09/bootstrapping-lisp-environment.html . kindly comment :)
11:10Chousukelooks neat
11:11icylisperChousuke: basically i found it quite useful for CL, thought would extend it to clojure apps.
11:12icylisperthe value add is the attach/deatchtty and be able to embed swank in clojure apps
11:13ChousukeI'm content with my clojure setup so I'm not going to test that thing but maybe someone else will
11:14icylisperChousuke: :)
11:29kunleyHi!
11:30kunleyIs there anything in Clojure which resembles the CL's conditions aka restartable exceptions?
11:31Chouserkunley: you might be interested in clojure.contrib.error-kit
11:34kunleyChouser: yeah looks interesting :)
11:45kunleyChouser: Looking at the examples, I'm impressed. Looks like exactly what I needed.
11:46criosChouser: about http://paste.lisp.org/display/87224#1,
11:47criosmsg is the return value of each task invokation?
11:53Chousercrios: the value returned by an agent task becomes the new value of the agent
11:55criosthe last 'msg' evaluation becomes the new agent value, correct?
11:55crios(fn task [msg cnt x y] (prn msg) (when (pos? cnt) (Thread/sleep 1000) (println (. (Thread/currentThread) getName )) (send-off y task (dec cnt) y x)) msg)
11:57criosChouser: so that a1 will always print :ping and a2 print :pong
11:57Chouserright.
11:57crioswow, thank you
11:58Chouserwhich actually raises an point about the design of this thing. Since the entire difference between on agent and the other is the value that's getting passed in each time, and because send-off's from an agent task don't actually happen until the task is done, you only really need one agent.
12:01criosChouser: yes, you are correct
12:01lisppaste8Chouser annotated #87224 "single-agent ping pong" at http://paste.lisp.org/display/87224#3
12:03Chousukethere's also *agent* which could be used instead of agt in that example
12:04lisppaste8Chouser annotated #87224 "single-agent ping-pong without 'let'" at http://paste.lisp.org/display/87224#4
12:05crios*agent* ^
12:05crios?
12:05Chouser*agent* is dynamically bound inside and agent task to the currently-running agent.
12:06criosok
12:07criosmuch more readable than the java version!
12:07crioscompliments!
12:10criostime to go
12:10criosbye
12:40slavaI'm at rich hickey's keynote
12:41slava'yo rich, I'm gonna let you finish, but parrot is one of the best VMs ever!'
12:42hiredman:D
12:43drewrhaha
12:50futuranonslava: well played
13:12slavapoor rich, people are asking dumb questions
13:13hiredmanwhy do you tease so
13:13Chouserbecause teasing is more fun that transcribing dumb questions?
13:14hiredmanhttp://twitter.com/al3x/statuses/4057515252
13:14hiredmanhttp://grailspodcast.com/blog/list
13:22replaca__Check out Alex's notes on the summit wiki: http://wiki.jvmlangsummit.com/Keynote_-_Hickey
13:25hiredmanhttp://www.youtube.com/watch?v=zRTx1oGG_1Y&amp;feature=channel_page
13:26stuartsierrahiredman: do you know if video of the complete talk will be online later?
13:26hiredmanI don't
13:26stuartsierraok
13:26slavaI think so
13:27hiredmanI hope all the talks are put online
13:29slavayeah they will be
14:56licoresse...
16:09spuzHi, I'm struggling to get started with clojure, if I load a .clj file into ClojureBox for example, how do I run it?
16:11futuranonspuz: Ctrl+c, Ctrl+k
16:11futuranonIf by load, you mean you have it open
16:12futuranonspuz: I would google "slime cheatsheet"
16:12spuzfuturanon: thanks
16:13futuranonspuz: this also may come in handy depending on your background: http://bc.tech.coop/blog/081209.html
16:14futuranonspuz: and of you have no idea what it means; bookmark it for later ;)
16:14futuranonif you*
16:14spuzheh I will :)
16:30rafsoakenhi there, my question is if one can in foll. expression avoid the duplicated (- a 2)? -->(for [a (range 10) :when (= (* (- a 2) 6) 18)] (- a 2))
16:33Chouserrafsoaken: 'for' allows a :let clause
16:34rafsoakenChouser: ah great, thx!
16:35rafsoakentrue overlooked it in the api
16:37Chouseryeah, not included in the example. easy to miss.
16:48LauJensenLadies and gents, I've looked at the STM vs Actors and actually found a bug in the O'Reilley solution to the Sleeping Barber problem, comments are as always encouraged and appreciated: http://www.dzone.com/links/scala_vs_clojure_round_2_concurrency.html
16:57_mstmaybe a minor thing, but isn't IO from within a dosync discouraged?
16:57hiredmanyes
16:57hiredmanside effects inside a transaction are a bad idea
16:57Chouser_mst: yes, since it can retry. best to pump io through an agent to keep it from retrying and to keep it cleanly serialized.
16:58hiredmanall io (file access, db access, other kinds of mutation) are a bad idea
16:58hiredmanshould be all side effects
16:58LauJensenAgreed :)
17:11LauJensenAnd if you're not busy and like the post feel free to vote - #Scala isn't hesitating :)
17:56grosourshi
19:37wtetzneris there a way to get the arity or arities of a function?
19:43dnolen`wtetzner you can look at the metadata of a functions.
19:43dnolen`,(:arglist ^#'reduce)
19:43clojurebotnil
19:43dnolen`,^#'reduce
19:44clojurebot{:ns #<Namespace clojure.core>, :name reduce, :file "clojure/core.clj", :line 598, :arglists ([f coll] [f val coll]), :doc "f should be a function of 2 arguments. If val is not supplied,\n returns the result of applying f to the first 2 items in coll, then\n applying f to that result and the 3rd item, etc. If coll contains no\n items, f must accept no arguments as well, and reduce returns the\n result of calling f with no
19:44dnolen`,(:arglists ^#'reduce)
19:44clojurebot([f coll] [f val coll])
19:44dnolen`,(first (:arglists ^#'reduce))
19:44clojurebot[f coll]
19:44wtetznerdnolen`: thanks
19:52wtetzner,(count (first (:arglists ^#'reduce)))
19:52clojurebot2
20:00Chouseror you can use reflection to look at the invoke methods available
20:06wtetznerChouser: yeah, i think that's the only way to do it for anonymous methods
20:33dthomasIs there a nice method to get a sequence of values from a map given a sequence of keys? I was thinking maybe get-in or select-keys but they have different purposes. (Not that it's hard to just use map, get, and an anonymous fn.)
20:42dnolen`,(select-keys {:foo 0 :bar 1 :baz 2} [:foo :bar])
20:42clojurebot{:bar 1, :foo 0}
20:43dnolen`dthomas: ^
20:45dthomasdnolen`: Oh, yeah, and then just (vals) that? And it's no big deal to "throw away" the result since it's efficient and shares with the map you selected out of?
20:45dnolen`dthomas: on caveat is that order isn't guaranteed here.
20:45dnolen`one
20:46dthomasdnolen`: Another good point; ordering is important in my case.
20:47dnolen`dthomas fortunatey trivial to write because maps can be used as fns.
20:47dnolen`(defn get-keys [amap keyseq] (map amap keyseq))
20:47Guest64829Forgive my slight bit of noise, but I'm testing this out. IRC newbie alert!
20:48dnolen`dthomas: isn't clojure nice ;)
20:48dthomasdnolen`: Duh! I forgot that maps are callable like that. Thanks for all the tips.
20:48dnolen`np
20:49dthomasI always remember (:foo bar) but never (bar :foo).
20:50wtetzner__actually you might as well just use (map amap keyseq) instead of defining get-keys, since it's shorter than using (get-keys amap keyseq)
20:51dthomasI was also pleased to learn that (let [[head & tail] nil]) works and leaves both head and tail at nil. I don't know why I expected that to be a problem in the first place.
20:52dthomas(Well, it doesn't _leave_ them at nil, it binds them to nil.)
20:52dnolen`wtetzner: heh, true enough.
21:58jhawk28has anyone used incanter on very large datasets?
22:02JAS415Alfred North Whitehead quotes, sweet
23:31JAS415is it possible to do a sorted set that takes a comparator?
23:41JAS415hmm
23:41JAS415looks like someone already made the patch it just never got included
23:41JAS415http://code.google.com/p/clojure/issues/detail?id=76
23:41interferoni want to use JAX-RS, which requires annotated classes and methods
23:42interferondoes clojure support this?