#clojure logs

2009-02-15

00:00WizardofWestmarcalready tried type hinting I assume?
00:00gnuvince_WizardofWestmarc: it's everywhere.
00:01gnuvince_I can process about a thousand files in less than four minutes, but I'd be really happy if I could bring that number down some more.
00:01WizardofWestmarcwhat sort of processing?
00:01gnuvince_http://github.com/gnuvince/clj-starcraft/tree/master
00:02gnuvince_unpacking and decoding Starcraft replay files.
00:02WizardofWestmarcah ha
00:02WizardofWestmarchow complicated is the sc files? I know at their core it's about time and commands entered by the players
00:04gnuvince_The format is a rather simple one, but it's packed, and that's a mess to unpack. Fortunately, a gentleman already wrote an unpacker in Java :)
00:04gnuvince_The rest is basically just reading bytes and associating actions to players
00:05ayrnieugnuvince - where do you get starcraft save files, to test on?
00:05gnuvince_ayrnieu: http://www.teamliquid.net/replay/
00:05ayrnieuoh. 'starcraft replay files'.
00:05WizardofWestmarcwas gonna say, there are probably 10s to 100s of thousands of replay files on the 'net
00:06gnuvince_yeah
00:06WizardofWestmarcare you gathering statisticial info from them or purely a case of "this is cool!"?
00:07gnuvince_WizardofWestmarc: there is a tool for Windows called "bwchart" that gives you information and stats on the games you played
00:07gnuvince_How many units were produced, your actions-per-minute rate, etc.
00:07WizardofWestmarcright
00:07gnuvince_But it's Windows only and requires an installation of Brood War
00:07WizardofWestmarcah ha, ties into the player in windows
00:08WizardofWestmarcerr in the game
00:08gnuvince_I would like to make a mini clone that would be cross platform and have no dependencies on Brood War itself.
00:08WizardofWestmarc...which is just the engine >_>
00:08WizardofWestmarcmakes sense
00:08gnuvince_The real goal is to teach me some Clojure and Java.
00:08WizardofWestmarcwell of course
00:08WizardofWestmarcdoesn't mean it can't have other uses as well ;-)
00:08gnuvince_But the side effect is nice enough to keep me going.
00:08gnuvince_Of crouse
00:08gnuvince_course*
00:09WizardofWestmarcI just wish the lib someone in here pointed me to had decent documentation (a java lib not a clojure one)
00:09WizardofWestmarcit looks interesting for what I'm messing with, but I can't find good docs, a few "ok" blog posts but that's it (openNLP if you're wondering)
00:09gnuvince_Well, time to head to bed
00:10gnuvince_Good night gents'
00:10WizardofWestmarclater \m/
03:22Lau_of_DKTop of the morning gents
03:23RaynesGood morning old chap. ;)
03:23Lau_of_DKMr. Raynes - What a pleasant surprise :)
03:24Raynes:p
03:32tkadluboMorning, hope the weather is good wherever you live. I want to filter a define a lazy sequence by filtering another lazy sequence. Can I consume beginning of the generated sequence in the filtering predicate?
03:32Lau_of_DKI think so, but can you paste an example?
03:32tkadluboArrr, s/want to filter a/want to/
03:36tkadluboI mean specifically Erastotenes' sieve. Something like (def primes (filter prime? (range 2 limit))) where prime? predicate uses primes sequence.
03:36Lau_of_DKYes that would return a lazy seq
03:37tkadluboThat's good. Thanks.
03:37Lau_of_DKnp
03:37Lau_of_DK,(filter even? (range 2 10))
03:37clojurebot(2 4 6 8)
03:37Lau_of_DKIf youre in emacs, you can do that directly in the REPL - Dunno how comfortable you are with the IDE yet :)
05:07teAnyone know anyone hiring clojure programmers?
05:12Lau_of_DKAnyone seen this before? java.lang.NoClassDefFoundError: clojure/lang/AFunction (iwish.clj:0)
05:12Lau_of_DK [Thrown class clojure.lang.Compiler$CompilerException]
05:20teHow hard would it be to implement something like TryRuby in clojure
05:21Lau_of_DKAsk Chouser, he already did it: http://clojurescript.n01se.net/repl/
05:26RaynesIt seems that when it comes to writing something in Clojure, all you do is think about it and it's done.
05:26RaynesIt's magically.
05:26Raynesmagical*
05:26RaynesNow, why in the hell didn't God write the universe in LISP. :|
05:27vha4god?
05:27vha4lisp?
05:38Raynes,(interleave (take 10 (iterate inc 1)) (repeat 3))
05:38clojurebot(1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3)
05:39RaynesWhat happens if you make an infinite sequence. Clojurebot stops that right? >_>
05:45Lau_of_DK,(println (iterate inc 0))
05:45clojurebotjava.lang.OutOfMemoryError: Java heap space
05:45Lau_of_DK,(loop [] (recur))
05:45clojurebotExecution Timed Out
05:45Lau_of_DKYea he seems to be pretty robust
05:45Raynes:|
05:50tkadluboMaybe garbage collector tuning methods weren't sandboxed away...
06:19angolhi! Is anyone here? Is there a downloadable documentation? I like programming outside the house/office. hence no internet connection? any help would be appreciated.
06:23RaynesThere should be. :|
06:29Lau_of_DKWhen Clojure boorks because it says ClassNotFound clojure.lang.AFunction - whats the problem ?
06:30cgrandLau_of_DK: did you try to clean and rebuild clojure?
06:31Lau_of_DKThats actually what caused the problem - I was trying to get some interactive Compojure development going, but technomancys .el files didnt work, they gave some other obscure error whenever I tried to require something, so I updated, and now this @ cgrand
06:32cgrandat which point did you get that exception (before getting to the REPL?)
06:35Lau_of_DKjava -cp $classpath clojure.lang.Script app/boot.clj
06:35Lau_of_DK
06:35Lau_of_DKThe script defines the cp and then fires that
06:36Lau_of_DKhttp://github.com/technomancy/concourse/blob/51afbc7b94692407cec98de24ae76b91a86d730a/app/boot.clj
06:36Lau_of_DKBoot looks alot like that
06:36leafwangol: Stuart Halloway is about to publish a book on clojure. Also, you may use 'wget' on a shell as a spider, to download the entire clojure.org website. In addition, you have built-in the (doc <name>) and (find-doc "<name>") functions.
06:45Lau_of_DKIve found a jar that works now, how can I check its revision ?
06:45orerois it just me or read-line is broken? I tried it interactively and it complains that LineNumberingPushbackReader cannot be cast to BufferedReader. what gives?
06:46Lau_of_DKorero: You tried it from slime?
06:47oreroLau_of_DK: I use clojure-mode. same thing as far as the repl goes.
06:47Lau_of_DKNot quite, inferior-lisp doesnt redirect *in* and *out*, but slime does
06:47oreroLau_of_DK: then what *in* and *out* point to in the inferior-lisp?
06:48orerobesides, if read-line doesn't work, why does read work?
06:49Lau_of_DK(doc read)
06:49clojurebotReads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* .; arglists ([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?])
06:49Lau_of_DK(doc read-line)
06:49clojurebotReads the next line from stream that is the current value of *in* .; arglists ([])
06:50Lau_of_DKI cant say for sure
06:50oreroI can't remember for sure, but I think some weeks ago read-line worked for me, so unless I'm confused....
06:51Raynesorero: If you are using Stu's version of Clojure included with the sample code, read-line is broken.
06:51RaynesI had that same problem a week ago.
06:52oreroRaynes, is it something new or ongoing?
06:52oreroI got the latest trunk.
06:52RaynesI don't know. I know it's broken, that's all I know. I mentioned it but no one answered so I just reverted back to the release version.
06:53RaynesMaybe someone should bring this to Rich's attention?
06:53oreroRaynes, in release it works?
06:53RaynesYes.
06:53RaynesPerfectly.
06:54oreroRaynes, ok thanks. now that I know it's not me, I'll look into it. I thought it was just me doing something really stupid.
06:54RaynesNo problem.
06:55oreroLau_of_DK: didn't you write ClojureQL?
06:55Lau_of_DKI did, together with Kotarak
06:56oreroLau_of_DK: I've just started looking into it. looks great. does it work with sqlite?
06:56leafwanybody can recall the webpage of the nice lib for pretty-printing clojure exceptions?
06:56Lau_of_DKorero: Up until now, we've ensured that everything worked with MySql, Postgresql and SQLite, without the user doing anything specific to make that happend, although from this point forward, I think we'll focus mostly on MySql, Post and Derby
06:57Lau_of_DKThe code however, will be very easy to modify, so if you want to do something specific for SQLite, you can do it and just send me the patch
06:58oreroLau_of_DK: ok. too bad you won't include sqlite. it's a sweet db.
06:59Lau_of_DKIts a toy primarily, derby takes the same principle a step further and has backing from the apache-foundation, so I think its a good move
06:59Raynes,(list [2 3 4])
06:59clojurebot([2 3 4])
06:59Lau_of_DKIm not saying though, that we wont have support for SQLite - You can do almost everything in SQLite as it is, Im just saying extending from here will come mostly through patches from good folk like yourself
06:59Raynes,(set '(1 2 3))
06:59clojurebot#{1 2 3}
07:00RaynesOh thats neat.
07:01oreroLau_of_DK: I haven't tried Derby yet. I've been using sqlite for quite some time because it was so simple and easy and was good for my needs.
07:02Raynes(doc str)
07:02clojurebotWith no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args.; arglists ([] [x] [x & ys])
07:02Lau_of_DKorero: And Derby is basically the same, simple, easy and local. Its just more extended in terms of features, and as I recall its being developed upon quite heavily by Apache F.
07:02Raynes,(str #{\n \o})
07:02clojurebot"#{\\n \\o}"
07:03Raynes,(apply (str #{\n \o}))
07:03clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
07:03Raynes(doc apply)
07:03clojurebotApplies fn f to the argument list formed by prepending args to argseq.; arglists ([f args* argseq])
07:03oreroLau_of_DK: I'll go take a look at it now. does clojureql works with it in the current version?
07:03Lau_of_DKRaynes: Could you please install Emacs and use the local repl? :)
07:03Lau_of_DKorero: Yes, both SQLite and Derby
07:03Lau_of_DKand Mysql and Postgresql, and in principle Oracle, though I havent tested
07:03oreroLau_of_DK: great
07:04RaynesI have the REPL in netbeans open, I'm sorry, didn't realize using Clojurebot was not allowed in here ;).
07:04Lau_of_DKIf you didnt know you didnt know :)
07:05RaynesSomeone should put up a Clojurebot in a dedicated channel.
07:06Lau_of_DKRaynes: Why? I have IRC in the right side buffer, and a Repl in the left side buffer... No need
07:06RaynesThen why have Clojurebot here?
07:06Lau_of_DKHe's good for letting us keep up with the svn log, and for clearing up point in discussions
07:06RaynesScratch that, all my suggestions have been disregarded so far, this one shall be no different. Forget it.
07:07Lau_of_DKLike, when you discuss for the 10.th time wether apply is lazy or not
07:07Lau_of_DK(doc apply)
07:07clojurebotApplies fn f to the argument list formed by prepending args to argseq.; arglists ([f args* argseq])
07:07Lau_of_DKOh Raynes, did I hurt your feelings? I didnt mean to
07:07Lau_of_DKAnd if its any comfort, I think all my suggestions have been disregarded as well :)
07:08RaynesSomebody should at the very least write a list of rules for this channel.
07:08RaynesAnd no, you didn't hurt my feelings.
07:13Lau_of_DKYou can write a list of rules if you want :)
07:13Lau_of_DKI dont really see the point though
07:14RaynesI do. So people would know the rules before breaking the invisible ones.
07:14Lau_of_DKWhen I ask you to cool it with clojurebot, thats not a rule, its just me asking you nicely
07:15RaynesIt should be a rule, spamming with bots is one of the reasons why people make dedicated channels for bots, while still keeping them in the main channel.
07:16RaynesPeople who want to use the bots extensively are diverted to the bot's channel.
07:16RaynesBut it doesn't really matter. This isn't my channel, and that isn't my bot :p
07:17RaynesAlso, I'm sorry if I come off too strong sometimes, when it sounds like I'm trying to be mean I'm really not.
07:18Lau_of_DKNo I didnt take it that way at all
07:23angolthanks leafw
07:23leafwyou guys sound like you have nothing else to do :)
07:24Lau_of_DKleafw: Thats not true - I have lots of interactive Compojure development to do - but I cant get it working!!
07:25Raynesleafw: I should be reading. But I can't seem to force myself to do it. I'm on teh sequences chapter.
07:26leafwRaynes: on Stuart's book? I loved it. I thought I knew clojure, but I learned quite a few things on every page corner.
07:26RaynesYup.
07:27RaynesIt's the first book I haven't just pirated in over a year.
07:27RaynesWell worth the money.
07:27leafwI couldn't sent my last reviews, the deadline was the 6th ... oh well, it stands quite nice as it is.
07:38Lau_of_DKIn compojure, if I want a table with width: 100%, how do I output that?
07:43Lau_of_DKI get no love
07:45orerowe love you Lau. we just don't know. ;-)
07:48Lau_of_DK phew - that makes it all better :)
07:54Lau_of_DKMan...
07:55Lau_of_DKAfter some 5 hours I finally get interactive compojure development working...
07:55RaynesSuccess.
07:55Lau_of_DKTurns out clojure.jar and clojure-contrib.jar have to be the same revision due to some change in "includes" something...
08:02Lau_of_DK(html [:table {:width "100%"} [:tr [:td "Hi there"]]])
08:02Lau_of_DKAnd thats how its done
08:03Lau_of_DKMan, I thought compojure was hard, but once I got Emacs involved, it became a kids game
08:03Lau_of_DK(sponsored by the Gnu foundation)
09:25tashafaquestion...
09:26tashafaany1 knows whats the easiest way to get a functions arguments as a seq (without using [& rest])?
09:35ChousukeWhat do you mean? :/
09:36tkadlubotashafa: And what's wrong with [& rest]?
09:36Chousukeyou mean have the args separate as well as in a seq?
09:36Chousukemap destructuring probably.
09:36Chousukethough I can *never* remember how that works...
09:38blbrownhope this come out right. Can I reference a function that hasn't been defined yet...in another namespace. E.g. if I am in the same namespace. (ns a1 (def abc)) ...where abc is defined in a2. (ns a2 (defn abc []) ... a2 is implemented after a1 is
09:38blbrownI tried and I get this error. aused by: java.lang.Exception: Name conflict, can't def *styled-text* because namespace: octane.toolkit.octane_main_window refers to:#'octane.toolkit.public_objects/*styled-text*
09:41blbrownChousuke, see what I am saying?
09:42tashafatkadlubo: I want to make sure the function can only recieve a certain number of arguments
09:43Chousukeblbrown: octane_main_window :uses public_objects, right?
09:44Chousukeblbrown: also: use hyphens in your namespace names instead of underscores. stylistic convention :)
09:44blbrownChousuke yea, it is a cyclic dependcy thing I am trying to bypass
09:44Chousukehmm
09:44Chousukecan't you use require instead?
09:44blbrownChousuke, yea, I normally try to avoid underscores of the filenames because I work with older operating systems
09:44Chousukeand namespace-qualify the names.
09:45blbrownlet me try that
09:46blbrownI am not keeping all lisp code conventions. The lisp gods will just have to be mad at me
09:46Chousukeas long as you stay away from camelcase
09:47blbrownhehe
09:59pilkarn(not (empty? playlist)) == playlist ?
10:02Chousukepilkarn: nah.
10:02Chousukepilkarn: you playlist could be [], which is empty, but still "true"
10:02pilkarnah maybe thats why i had used that not empty?
10:03Chousukemight be..
10:03Chousukeif your playlist were a seq, though, then it being empty would mean it's nil
10:04Chousukeso you could test for (if (seq playlist)) where seq ensures it's a sequence
10:17aperotteIn trying to write a class for clojure, I ran up against a Java issue. If anyone has any insight, please help :). I have an Object[] array that I want to contain arrays of different types (could be primitive or objects). How do I access the elements of the nested array. It seems that the usual [][] notation doesn't deal well with this.
10:20Chousukehm /:
10:20Chousukeit should work just fine in Java
10:21aperotteI get a compile error that says array required, but java.lang.Object found
10:21aperotteI'll run a few more tests to make sure that's actually the problem.
10:36Lau_of_DKHi all
10:38aperotteHi Lau_of_DK
10:39pilkarndeos Java allow arrays of arrays with different types?
10:39pilkarnhihi lau
10:40aperottePilkarn: I can create it, by first creating an Object[]
10:40aperottethen filling it with arrays of various types
10:41aperotteI just can't get access to the elements once it's been filled (at least not in a convenient way)
10:43pilkarnah ofc using object as type
10:44pilkarnpost the code?
10:44pilkarnclojurebot: paste?
10:44clojurebotlisppaste8, url
10:44lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
10:44cp2aperotte arrays are objects in java so you should have no problem storing them in an Object[], however when you access you will need to cast
10:45aperotteahh ... that's what I was afraid of
10:46aperotteI wanted the code to be ignorant of the type of array inside ...
10:47lisppaste8aperotte pasted "heterogeneous arrays" at http://paste.lisp.org/display/75516
10:47cp2oh
10:47cp2i see what you mean
10:48cp2uhmm
10:48Lau_of_DKclojurebot: seen technomancy?
10:48clojurebottechnomancy was last seen quiting IRC, 2304 minutes ago
10:48cp2i suppose you could do ((Object[]) Outer[0])[0]
10:48cp2although it might cry from trying to cast a primitive array to an object array
10:49aperotteexactly
10:49aperotteit's important to me to be able to have primitive arrays
10:50cp2well, java has autoboxing for primitive types, so using arrays of Integer and such should work
10:50cp2but then again i dont know what you are trying to use it for
10:51aperottesorry, I'm trying to write an n-dimensional array class
10:51aperotteso it's important to be able to have unboxed primitive arrays
10:51cp2ah, i see
10:54aperottehmm ... maybe it will work if I use one of the "collections" instead of the outer array
10:56lisppaste8sd pasted "compiling arraytets" at http://paste.lisp.org/display/75518
10:56pilkarnim no Java expert(dont know it very well) but ^^ compile,s isnt that how you need to do?
10:57pilkarnhmm o that prints 1
10:57pilkarnoh it should
10:57aperotteI think the problem is that the 1 it prints is a boxed 1 instead of a primitive one
10:58pilkarnbut if you want an array of arrays you have do declare object[][] not object[] ?
10:58pilkarnor isnt that necessary
10:58pilkarnor i guess ut shouldnt be since object means of any right?
10:59cp2aperotte: try System.out.println(Outer[0][0].getClass().getName());
10:59cp2to see if its boxed
11:00cp2acutally, that might print out java.lang.Integer either way
11:00pilkarndude it is when you index it
11:01tashafalet me phrase this differently...
11:01pilkarni think you cant do [i][i] unless it is statically proved to be an array
11:02blbrownwhen you do :import with namespace, can you qualify the java import
11:02blbrownE.g. (java.awt [Color :as AWTColor])
11:02tashafais there a way to get the arguments of a current function (preferbly in a seq)?
11:03blbrowntashafa, have you looked at 'doc' not entirely what you want, but you might be able to look at the source for 'doc'
11:06gnuvince_electricity--
11:07aperottepilkarn: I think you're right, I'll have to try another approach.
11:07aperottecp2: it prints java.lang.Integer, but says the variable cannot be dereferenced if it's a primitive
11:07aperottewhich seems to make sense
11:08blbrownclojure + jfreechart + swt = the awesome
11:08tashafahmm this is not about documentation although i've looked there
11:10tashafaI have a function that takes 2 arguments, I want to be able to get thes 2 arguments in a seq without expicilty using (defn function [val1 val2] (let [values [val1 val2] ...
11:10tashafasurely theres a better way to do this...
11:11tashafa:edit explicity using the let keyword
11:12tashafa:edit expicitly
11:12tashafacant type today
11:13tashafaexplicitly*
11:13gnuvince_,((fn [[x1 x2 :as xs]] [x1 x2 xs]) 3 4)
11:13clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1576$fn
11:13gnuvince_,((fn [[x1 x2 :as xs]] [x1 x2 xs]) [3 4])
11:13clojurebot[3 4 [3 4]]
11:14tashafathanks!
11:14gnuvince_,((fn [& [x1 x2 :as xs]] [x1 x2 xs]) 3 4)
11:14clojurebot[3 4 (3 4)]
11:14gnuvince_,((fn [& [x1 x2 :as xs]] [x1 x2 xs]) 3 4 5)
11:14clojurebot[3 4 (3 4 5)]
11:18tashafagnuvince_: hmm... but how would you ensure that fn only allowed for 2 arguments (i.e. throws illegalargument excpetion when fn arguements != 2)
11:19tashafathanks again
11:19tashafa,((fn [[x1 x2 :as xs]] [x1 x2 xs]) [3 4 5])
11:19clojurebot[3 4 [3 4 5]]
11:25gnuvince_tashafa: that's what I'm trying to figure out.
11:26gnuvince_I'm unsure that you can do that.
11:28tashafaah...its cool, your solution is close enough. I'm going to have to implement some kind of check somewhere else in the code. thanks!
11:31gnuvince_tashafa: I think it's more trouble than just having [x1 x2] personally
12:09pilkarndoesnt compile show any errors when it fails?
12:16gnuvince_Anyone know what the deal is with that wubbie person on the mailing lists?
12:21pilkarnwhats it he synatx for requrie for not renaming?
12:21pilkarn(:require (progs.mp3player [utils :as utils]))
12:21pilkarn(:require (progs.mp3player.utils)) doesnt work and not (:require (progs.mp3player [utils]))
12:21blbrowngnuvince, there is a mailing list, hehe? you talking about the clojure/google group or a mailing list
12:26gnuvince_blbrown: The google group.
12:54pilkarn(:require (progs.mp3player.utils)) doesnt work and not (:require (progs.mp3player [utils]))
12:54pilkarn(:require (progs.mp3player [utils :as utils]))
12:54pilkarnhow do you require normally without renaming?
12:56Chousuke(:require progs.mp3player.utils) or (:require progs.mp3player utils) iirc
12:56Chousukeoops, missing a set of parens from the latter :/
13:13slashus2Say I have a ref to a list of agents, what is the best way to alter the list of agents to add another agent?
13:13durka42in a transaction, you can use conj
13:14slashus2Okay, thank you.
13:14durka42adding to a list sounds like it might be a job for commute, although if order matters you would need alter
13:16slashus2I am trying to do something similar to the ant colony simulation that Rich Hickey showed in the concurrency presentation. I want to be able to add and destroy organisms (agents) on demand.
13:16slashus2Using a ref to a list or vector of agents may not be the best way.
13:23slashus2(dosync (alter a-few-refs conj ref)) just as an example, does not work.
13:23slashus2a-few-refs is a vector of refs right now.
13:23slashus2The error is that a PersistentVector cannot be cast to a Ref
13:25ayrnieu,(let [(ref afr (list (ref 0) (ref 1) (ref 2)))] (dosync (alter afr conj (ref -1))) (map #(inc @%) @afr))
13:25clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
13:25ayrnieu,(let [afr (ref (list (ref 0) (ref 1) (ref 2)))] (dosync (alter afr conj (ref -1))) (map #(inc @%) @afr))
13:25clojurebot(0 1 2 3)
13:25ayrnieuWFM.
13:26slashus2Okay, I figured it out, thank you.
13:27slashus2One thing I didn't really take away from the talk, was the difference between send and send-off
13:28ayrnieusend uses a fixed-size thread pool, send-off uses an exandable pool.
13:29ayrnieuagents are emphermeral: they only represent a thread when they're running in a function that someone has sent to them.
13:31slashus2In practice, I can keep using send-off to increase the amount of agents?
13:31ayrnieuthe number of concurrently active agents, you mean.
13:32Chouseryou can keep using send-off on more agents to increase the number of threads running
13:32ayrnieucreating an agent is just (agent 0) -- this doesn't task a thread pool.
13:32Chouserthough as the agents complete, they free up threads such that further send-offs can reuse them
13:33slashus2When using send, I would not be able to keeping using send?
13:33ayrnieuso if you really wanted, you could create a hundred threads by firing off agents that just sleep for a few seconds.
13:34ayrnieuthe only difference between send and send-off is that send will not create a new thread if one is not available. The agent just won't run until one becomes available.
13:35ayrnieu(also, the pool is fixed in size. Maybe you can increase it to some application-sensible size through Java.)
13:35slashus2OOOh so I can keep using send, but no more threads will be created than the amount that I first used send with?
13:35ayrnieusend's pool is determined by the number of processors (cores?) you have.
13:35slashus2Oh that is really neat.
13:36slashus2Send-off just creates as many threads as agents that you send it, but send uses the number of threads equal to the amount of cores that you have?
13:37ayrnieuso, send-off creates a new thread if one isn't available.
13:37ayrnieus/so/no/.
13:37ayrnieuit's still a thread *pool*, it still tries to reuse them.
13:38slashus2One isn't available includes when a thread is sleeping?
13:38ayrnieuand send's pool is not equal to the amount of cores that you have, it is determined by that amount. I think it's Processors+1.
13:40ayrnieuI assume that sleeping threads are considered unavailable; I don't know if they are.
13:43slashus2In the ant colony simulation, when using send-off, it creates 49 threads for ants, because there are 49 agents. Those agents run until the program closes. So in that case, when using send-off on another agent, it would increase to 50 threads?
13:44slashus2The reason I ask this, is because it doesn't seem to be working.
13:46slashus2I am trying to do this mid simulation. I "modify" the list of ant agents by adding a new agent. I then send off that agent to behave(an agent function), but the ant does not seem to be behaving.
13:47ayrnieuwhat do you mean, those agents run until the program closes? You mean that you call send-off once for each agent and never have to do this again because the agent is still in that function?
13:48slashus2(dorun (map #(send-off % behave) ants)) <-- this is called once where the beginning population of ants is created.
13:49slashus2Scenario: I create another agent and use send-off to the behave function.
13:50slashus2If I deref the agent, it seems to be moving. It must be a problem with the animation. So the problem isn't with my understanding of the agent system.
13:50ayrnieuso behave contains something like (send-off *agent* ...) , to loop?
13:51slashus2yes
13:52slashus2The original simulation is working. The other ants are behaving, and apparently so are these new ants.
13:52slashus2The animation system isn't picking up on the new ants.
13:52ayrnieumaybe your animator hang on to its original deref of your agent list?
13:53ayrnieualso, why don't you drop the list and just add-watcher an animator agent?
13:54slashus2I will look into that.
14:01slashus2Okay, this doesn't make sense. The ant is being drawn on the screen as a little line, when dereferencing the agent that represents that ant, it seems to be changing position, but the ant is not moving in the animation.
14:06Chousukeslashus2: does the redraw function know about your ant? or was drawing it part of behave? :/
14:08slashus2The redraw function does draw the little ant.
14:09slashus2Chousuke: The code I am working with is http://clojure.googlegroups.com/web/ants.clj
14:09slashus2I am just experimenting to learn.
14:09pilkarndo you mark impure functions with ! ? I find it helpful for debugging
14:21slashus2Chousuke: The only difference is at the bottom I am doing (def ants-ref (ref ants)) so that I am able to alter the list of ant agents.
14:21Chousukeah, it does not work like that!
14:22slashus2As soon as I do (dosync (alter ants-ref conj (create-ant [20 20] (rand-int 8))))
14:22slashus2It paints the ant on the screen.
14:22Chousukeslashus2: you can't alter the ants list like that; the *only* thing you can alter is what the ref points to
14:22Chousukeyou can't actually mutate anything
14:22slashus2Chousuke: the ants-ref points to a list of agents.
14:22Chousukeso the original ants list never changes
14:22slashus2It does indeed change the ants list
14:23slashus2Try it. While the program is running do the transaction I just did within the live repl.
14:23slashus2IF you look at ants, the new agent is added.
14:24slashus2On the animation, the new ant will be painted.
14:24Chousukeif you do (def ants [...]), then you *can't* change the list that ants is.
14:24slashus2...
14:24Chousukeyou're seeing something else.
14:24slashus2How is the new ant painted onto the animation then?
14:26Chousukecreate-ant adds it into the world
14:26Chousukebut that's not the ants list :)
14:26slashus2oh..
14:28slashus2How would you do what I am wanting to do.
14:28slashus2?
14:28slashus2It is hard to wrap my programming style around immutability.
14:29Chousukeyou'll need to call (send-off behave your-new-ant) before it'll start moving I think
14:29Chousukewith your-new-ant being whatever the create-ant returns
14:30slashus2So I don't really need to add it to ants.
14:30Chousukethat's right
14:30slashus2*head explodes*
14:30Chousukethere's no way you could do it, really :)
14:30Chousukethe ant list is just a helper datastructure for the (dorun (map #(send-off % behave) ants))
14:31Chousukehm, and that made me realise I had swapped the arguments to send-off :P
14:31Chousukethe ant of course comes first :)
14:31slashus2yey, it worked.
14:31slashus2question is now... how will I kill that ant?
14:32slashus2Just make the thread stop running under a certain condition?
14:32durka42set a flag somewhere and have the ants check it before recursing
14:32Chousukeants.clj does not seem to allow killing individual ants.
14:32slashus2right
14:32durka42hmm, you could set it in the doomed ant's metadata
14:33Chousukeor just its state
14:33Chousukeit's a map, isn't it?
14:33slashus2set it in the ant agent data?
14:33slashus2:dead
14:33Chousukewhen there's the (if running ...) check before it (when-not (:mustdie @*agent*))
14:34silkarnwhy does compile silently fail?
14:34Chousukethen you can kill an ant by doing (send-off ant assoc :mustdie true)
14:34Chousukebecause it won't send behave to itself again
14:35slashus2Chousuke: Why must I send-off again? Won't the thread stop once I don't call (send-off *agent* #'behave) again?
14:35Chousukeyou send that assoc from outside
14:35Chousukeie. from the repl
14:36Chousukeyou just need to add to behave a check for it.
14:36slashus2That meta-data can also be set from within the agent as well.
14:36slashus2agent function I mean.
14:36Chousukewhich agent function? :)
14:36slashus2behave
14:36Chousukehow could you set that data from there?
14:37Chousukeit runs automatically.
14:37Chousukeyou'd have to have a timeout or something
14:37AWizzArdclojurebot: max people
14:37clojurebotmax people is 149
14:37Chousukeit's possible, but I thought you wanted to kill them manually :)
14:37slashus2can you not alter agents from within behave?
14:38Chousukeslashus2: you can only send-off new actions
14:38Chousukethe return value of an action becomes the ant's new state
14:38slashus2To alter agents you have to use send-off?
14:38Chousukeor send, but yes
14:39slashus2So it happens within a transaction; sort of like (alter)?
14:39Chousukeslashus2: you can of course do (send-off *agent* assoc :mustdie true) from inside behave, but why would you do that? :)
14:39Chousukeslashus2: nah; sends are just queued
14:40slashus2Chousuke: If you send off on an agent that already exists, it executes the action on it?
14:40Chousukeyeah, after all previously queued actions or running actions have finished
14:41silkarnI have a problem, if I def something that is passed to a function that def defs the symbol of the passed thing not the thing it self right?
14:41Chousukesilkarn: behave runs "forever" because it sends off itself to the agent that received the behave action.
14:42Chousukeer, slashus2
14:42silkarnso I have to sue refs if i want mutability inside clojure?
14:42Chousukeyou have refs, agents and atoms
14:43Chousukelet's assume you have an ant running in the behave send-off loop
14:43gnuvince_I just saw Rich's post about first/more/rest. What do you guys think of keeping first and rest as is and having the function "tail" return possibly-empty-collection-of-the-remaining-elements?
14:44slashus2Chousuke: When I use send-off, does the function behave take the deref of the agent as an argument? behave takes [loc], which seems to be the deref of the agent?
14:45Chousukeyes.
14:45Chousukenow, you modify the behave function so that it has this: (when-not (:must-die @*agent*) (send-off *agent* #'behave))
14:46Chousukethen you can at any time kill an ant you have a reference to by doing (send-off myant assoc :must-die true)
14:46slashus2That is why I was a little confused when you did (send-off *agent* assoc :mustdie true). How do you know that the deref of agent isn't going to be used as an argument in that case?
14:46Chousukethat will cause myant's state to change so that (:must-die @myant) will return true
14:46Chousukeand the behave loop will end
14:47slashus2I understand that, but the seemingly inconsistent behavior confuses me.
14:47Chousukeslashus2: no, it's not inconsistent
14:47Chousukeslashus2: the first argument of assoc will still be the deref of the agent: a map
14:47Chousukebut that's what we want.
14:48slashus2The deref of agent will be something like [10 20]
14:48Chousuke,(assoc {:food 1} :mustdie true)
14:48clojurebot{:mustdie true, :food 1}
14:48Chousukehmm
14:48Chousukewell that's a problem :(
14:48ChousukeI assumed it was a map
14:48slashus2It isn't a map.
14:48slashus2It is a vector
14:49slashus2with [x y]
14:49silkarnfor an mp3player, what makes more sense, refs, agents or atoms?
14:49Chousukeslashus2: that makes the case more problematic
14:50Chousukeslashus2: since now you can only kill ants by their location
14:50Chousukeand I think that might have race conditions :/
14:50Chousukeor hm
14:50Chousukenot really
14:50durka42silkarn: what sort of state are you storing?
14:51silkarndurka42: state of the mp3player, i need some gloabl state to keep track of the current player-thread, playlsit etc
14:52durka42i would say probably refs, but it depends
14:52silkarni used a lot of defs first but it is ugly so I am refectoring
14:52durka42because you do need synchronization
14:52durka42if you use refs any modifications must be done in transactions
14:52Chousukesilkarn: I don't think it's very easy to kill individual ants in ants.clj without significant changes.
14:53Chousukesilkarn: if behave took a map it'd be easy, but since it's a vector...
14:53durka42Chousuke: watch that tab completion
14:53Chousukegah
14:53Chousukeslashus2: :P
14:53Chousukesilkarn: you're confusing!
14:54slashus2I could modify the behave function to take another argument, a map, and change the create-ant function to create an agent with another argument, a map.
14:54slashus2Do that difficult?
14:54slashus2Not*
14:55slashus2Of course, the (send-off my-ant assoc :dienow true) won't work because the deref of my-ant will have 2 arguments.
14:56slashus2Unless I added {:x 20 :y 20 :dienow false} as the only argument in the agent?
14:57slashus2That would work.
14:57ayrnieurather than have a :dienow , you could (send-off my-ant #(do % nil))
14:59slashus2That would expand to (do [20 20] nil) ?
14:59slashus2Causing the ant to lose its sense of location, but still leaving a dead body on the screen.
15:00ayrnieusure. The point is to throw away the single required argument, and to return nil.
15:00ayrnieuyou could also (fn [_] nil)
15:05pilkarnso im elss confusing now
15:25slashus2In an agent function, is the current agent modified to whatever the agent function returns?
15:25Chouseryes
15:25slashus2yey I get it.
15:25Chouser:-)
15:27rhickeysurprisingly, people are favoring optimal names on the more/rest/next question: http://groups.google.com/group/clojure/browse_frm/thread/88d9fdb5bcad36a
15:28rhickeymaybe they don't have much code to port?
15:28rhickey;)
15:29pilkarnwhat happens when compile runs? it does static analysis and doesnt say what happens?
15:29pilkarnit just silently fails it seems
15:29MarkVolkmannMental block here ... Why would I want to use commute instead of alter to change the value of a Ref? What's the benefit of reapplying the update functions invoked by commute when the transaction commits?
15:30gnuvince_commute should be done for operations where order doesn't matter
15:30rhickeyMarkVolkmann: let's say every transaction needs to update a jobs-completed counter when it's done...
15:31gnuvince_if you have two threads that need to add 1 to a counter, it doesn't matter if thread1 does it before thread2, the counter will be 2 afterwards.
15:31rhickeyif you use alter the jobs will have to serialize
15:31rhickeywhen they don't actually care what the resulting counter value is
15:33MarkVolkmannAh ... "jobs will have to serialize". I haven't run across that before.
15:34rhickeyMarkVolkmann: but that's strictly an optimization - if you are unsure use alter
15:34gnuvince_serialize in the sense "run one after another"
15:34MarkVolkmannWhat is it that causes a transaction to retry? Is it that a transaction attempts to change the value of a Ref that has been changed by another transaction since the current transaction started?
15:35BrackiIs anybody using gorilla for Vim?
15:36cp2just a minor question -- whats the "eta" on full laziness being in the main branch?
15:36MarkVolkmannI couldn't get Gorilla installed properly and gave up for now. I using VimClojure instead. I think Meikel is making improvements to Gorilla that will make it easier to install soon.
15:36rhickeyMarkVolkman: yes
15:36pilkarnwhat happens when compile runs? it does static analysis and doesnt say what happens?
15:36pilkarnit seems to compile fine but then when i run it ha sno main
15:36mattreplrhickey: that's the good part about having a community of CL expatriates and early adopters in general, a dislike of legacy for its own sake
15:38gnuvince_I agree that the time to get things right is not in 2-3 years when a lot more people depend on Clojure.
15:38hircushi all
15:39hircushas there been any recent Clojure/SLIME regression? I had a working set-up on Linux, but on OS X, I could get a basic slime+clojure repl working but there's no tab-completion of forms
15:39ayrnieumattrepl - bitter but superficial comments about CL do not make an expatriot.
15:39hircuse.g. (defn foo TAB
15:39Chouserhm, someone want to digg or reddit my blog post before it becomes obsolete? ;-)
15:41gnuvince_hircus: do you have the "normal" SLIME REPL with user> or do you have the inferior-lisp's user=> prompt?
15:41hircusgnuinferior lisp
15:41mattreplayrnieu: or more general, not all that dislike aspects of CL and use Clojure are expatriots
15:41ayrnieuhircus - does ESC-Tab complete it?
15:41hircusgnuvince_: inferior lisp.
15:42hircusayrnieu: "No tags table loaded; try M-x visit-tags-table
15:42ayrnieumattrepl - in which case, their legacy aversion is meaningless.
15:42gnuvince_hircus: something changed in slime recently with regards to the repl. In your .emacs, you need: (require 'slime) (slime-setup) (require 'slime-repl) (slime-repl-init)
15:42mattreplmasochistic?
15:42hircusmy SLIME knowledge is limited to getting it to work with SBCL and Clojure
15:42hircusaha. let me just try that
15:42durka42hmm, it was already in /r/lisp, but not /r/clojure
15:42gnuvince_(make sure that slime/contrib is in your load path)
15:43hircus*doh* I think I did something like that on my Linux machine a few days ago. something about it not loading the full repl by default anymore?
15:43gnuvince_Yeah
15:43lisppaste8gnuvince pasted "slime config" at http://paste.lisp.org/display/75533
15:43gnuvince_This is my configuration
15:44ayrnieuI have (slime-setup '(slime-fancy slime-asdf)) , and needed the slime-fancy to get the cool stuff.
15:44hircusgnuvince_, ayrnieu got it fixed now. thanks.
15:44gnuvince_hircus: happy to help
15:44gnuvince_ayrnieu: what's in slime-fancy?
15:45ayrnieugnuvince - slime-repl , for one.
15:45gnuvince_ah
15:45gnuvince_nice
15:45hircusdoes slime-asdf does anything for Clojure, or is it more for when using Common Lisp?
15:45ayrnieuhircus - it's for CL.
15:46hircusah ok
15:46hircusthanks, you two
15:50gnuvince_ayrnieu: does slime-interrupt work for you?
15:53ayrnieugnuvince - I haven't set clojure up with slime.
15:58BrackiAh I've made Gorilla work for me. The problem was to explicitly set maplocalleader. I had assumed it would be the same setting as localleader.
16:01gnuvince_ayrnieu: ok
16:10durka42Bracki: a fellow gorilla user!
16:26BrackiHm I seem to miss something. How do I import/refer/use clojure contrib?
16:26durka42you use particular libraries from it
16:26AWizzArdBracki: you don't import it, but you require it
16:26durka42(use 'clojure.contrib.math)
16:27AWizzArdBracki: (require '[clojure.contrib.duck-streams :as ds])
16:28AWizzArd(line-seq (ds/reader "https://www.microsoft.com/&quot;))
16:34blbrowndid clojure get some kind of award from a software magazine. I thought I read that somewhere
16:35BrackiDoes this channel have a pastebin?
16:36blbrownBracki http://paste.lisp.org/new/lisp I am sure lisp paste would work fine
16:36durka42~paste
16:36clojurebotlisppaste8, url
16:36lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:36durka42blbrown: your link will announce in #lisp
16:37lisppaste8bracki pasted "untitled" at http://paste.lisp.org/display/75539
16:37BrackiSo what's going on wrong there. I'm trying to use contrib.test_is
16:38durka42test-is, not test_is
16:38durka42hmm, it works when i do (use 'clojure.contrib.test-is)
16:39Brackihm, same problem.
16:39Brackiyou just copy/pasted into the repl?
16:40durka42(require '[clojure.contrib [test-is :as test-is]])
16:40durka42then test-is/is
16:40durka42or use works
16:44pilkarn(defn fac [n] (reduce #(* %1 %2) (range 1 (inc n)))) , does that build the list lazily or is it first created O(n) then reduced over O(n) ?
16:44durka42reduce should be lazy
16:45Brackidurka42: that works.
16:45durka42and i think range is too
16:45rhickeydurka42: range is lazy, reduce is always eager - it reduces its args to a single result
16:45Brackiwhat does "works" do?
16:45durka42i meant, or use works
16:45durka42,use
16:45clojurebot#<core$use__4964 clojure.core$use__4964@5084c6>
16:46durka42oh, right, of course
16:47Brackiah.
16:50pilkarnid i have (fun btn f) where f is a function that takes several args and fun is a function. if i dont want f to be evaluated directly but later when btn is prsed, then i wrap the whole f call in # ? (fun btn #(f x y z)) ?
16:58Chousukepilkarn: f is not called if you just pass it as an argument
16:58Chousukepilkarn: the notation #(f 1 2 3) is just a literal function that calls f with the arguments 1, 2 and 3
16:59Chousuke#(f) is equivalent to f
16:59Chousukeor well
16:59Chousukeactually, nto
16:59Chousukeonly if f takes no arguments :)
17:05BrackiHow do I split a list in two lists?
17:07hiredman,(doc split-with)
17:07clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
17:07ayrnieuthat depends on what relationship you want the two lists to have to the list.
17:08Brackiin half, split a list of integers in the "middle".
17:09blbrownChouser, were you telling me about the O'Reilly algorithms books? I got it, don't know how I should approach it
17:10ayrnieu,(split-at 2 [1 2 3 4 5])
17:10clojurebot[(1 2) (3 4 5)]
17:11blbrown,(split-at "," ["klsdklfjslkdjflksjdlf, kljsldfjslkdjflksd"])
17:11clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
17:11blbrown,(split-at '," ["klsdklfjslkdjflksjdlf, kljsldfjslkdjflksd"])
17:12clojurebotEval-in-box threw an exception:EOF while reading string
17:12blbrown,(split-at ',' ["klsdklfjslkdjflksjdlf, kljsldfjslkdjflksd"])
17:12clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$split-at
17:12ayrnieu,(doc split-at0
17:12pilkarnhmm cant clojrue import mutually? ie ns/file X imports function from Y and Y imports a function from X ? I use declare somehow?
17:12clojurebotEval-in-box threw an exception:EOF while reading
17:12ayrnieu,(doc split-at)
17:12clojurebot"([n coll]); Returns a vector of [(take n coll) (drop n coll)]"
17:14ayrnieu,(map str (split-with #(= % \,) "klsdklfjslkdjflksjdlf, kljsldfjslkdjflksd"))
17:14clojurebot("" "(\\k \\l \\s \\d \\k \\l \\f \\j \\s \\l \\k \\d \\j \\f \\l \\k \\s \\j \\d \\l \\f \\, \\space \\k \\l \\j \\s \\l \\d \\f \\j \\s \\l \\k \\d \\j \\f \\l \\k \\s \\d)")
17:14hiredmanblbrown: there are several things wrong with what you were trying
17:14ayrnieuthat's actually better than ("clojure.core$take_while__3672$fn__3674@c4bf9ef" "clojure.core$drop_while__3696$fn__3702@c4bf9ef") , a buggy return from my build.
17:14hiredmana charater in clojure is preceded by a \
17:14blbrownhiredman, I was just messing around
17:14pilkarnhmm cant clojrue import mutually? ie ns/file X imports function from Y and Y imports a function from X ? I use declare somehow?
17:14ayrnieupilkarn - no.
17:15hiredman\,
17:15hiredmannot ','
17:15BrackiSo how do I get the length of a list?
17:15blbrownit is count
17:15blbrownI think most people are used to 'len' or 'length'
17:15blbrown,(count [1 2 3])
17:15clojurebot3
17:16pilkarnayrnieu: no what?
17:16ayrnieupilkarn - the answer to your questions are "no".
17:16pilkarnlen would ahve been better but whatever
17:16pilkarnand count could then have been (count 1 [1 2 3 1]) -> 2
17:17pilkarnayrnieu: and there is no solution to that?
17:18blbrown,(def length count)
17:18clojurebotDENIED
17:18hiredman,(split-with #(= % \,) "klsdklfjslkdjflksjdl, kljsldfjslkdjflksd")
17:18clojurebot[nil (\k \l \s \d \k \l \f \j \s \l \k \d \j \f \l \k \s \j \d \l \, \space \k \l \j \s \l \d \f \j \s \l \k \d \j \f \l \k \s \d)]
17:18blbrownpilkarn, that is what I do...shrug
17:18Bracki,(doc /)
17:18clojurebot"([x] [x y] [x y & more]); If no denominators are supplied, returns 1/numerator, else returns numerator divided by all of the denominators."
17:18ayrnieupilkarn - sure. You could not do that. You could separate these functions out into their own namespace. You could put the mutually-dependent modules in the same namespace. You could look into clojure's guts and propose a declaration. You could patch the namespace after load instead of doing it through 'use'.
17:19BrackiCan somebody explain that to me? I want division without remainder, no floats or anything.
17:19hiredman,(int \,)
17:19clojurebot44
17:19hiredman,(split-with #(= (int %) 44) "klsdklfjslkdjflksjdl, kljsldfjslkdjflksd")
17:19clojurebot[nil (\k \l \s \d \k \l \f \j \s \l \k \d \j \f \l \k \s \j \d \l \, \space \k \l \j \s \l \d \f \j \s \l \k \d \j \f \l \k \s \d)]
17:19ayrnieu,(unchecked-divide 7 3)
17:19clojurebot2
17:21pilkarnhow much work would a mp3-decoder be?
17:21Chousukein clojure? :/
17:21hiredmanpilkarn: just use a java mp3lib
17:22hiredman,(split-with #(not= (int %) 44) "klsdklfjslkdjflksjdl, kljsldfjslkdjflksd")
17:22clojurebot[(\k \l \s \d \k \l \f \j \s \l \k \d \j \f \l \k \s \j \d \l) (\, \space \k \l \j \s \l \d \f \j \s \l \k \d \j \f \l \k \s \d)]
17:23hiredman,(map (partial apply str) (split-with #(not= (int %) 44) "klsdklfjslkdjflksjdl, kljsldfjslkdjflksd"))
17:23clojurebot("klsdklfjslkdjflksjdl" ", kljsldfjslkdjflksd")
17:23Brackiwhat yields index of item in list?
17:24hiredmanlists are not index
17:24ayrnieu,(.indexOf "hello" "l")
17:24clojurebot2
17:25hiredmanindexed
17:25ayrnieu(.indexOf [1 2 3 4 5] 4)
17:25hiredmanif you want an indexed data structure use a vector
17:26BrackiOk, what I actually wanted to do is solve some of these to get me going with clojure. http://codekata.pragprog.com/2007/01/kata_two_karate.html
17:26ayrnieu,(.indexOf '(a b c d e) 'c)
17:26clojurebot2
17:27hiredmanBracki: hit up project euler and start working through it with clojure
17:28hiredmanayrnieu: of course, but it has to walk the list
17:28hiredmanwait
17:28hiredmanactually for vectors it would too
17:28hiredmannm
17:29BrackiAlright, thats exactly what I was looking for.
17:31BrackiBut same problem. What's modulo in clojure?
17:32hiredman,(doc mod)
17:32clojurebot"([num div]); modulus of num and div."
17:32BrackiDoes that come from contrib?
17:32BrackiCause it's not listed on the api page.
17:32ayrnieu,`mod
17:32clojurebotclojure.core/mod
17:33ayrnieu,[(mod -1 3) (rem -1 3)]
17:33clojurebot[2 -1]
17:33lenst,(meta #'mod)
17:33clojurebot{:ns #<Namespace clojure.core>, :name mod, :file "core.clj", :line 1864, :arglists ([num div]), :doc "modulus of num and div."}
17:33Brackihttp://clojure.org/api#mod -> no result.
17:36hiredmanand?
17:36ayrnieu,(.contains (keys (ns-publics 'clojure.core)) 'mod)
17:37clojurebottrue
17:37BrackiThat means that my version of clojure doesn't have it as well, cos i'm usisng the latest "official" relase.
17:37hiredmanBracki: type mod into the repl
17:37BrackiGorilla=> (.contains (keys (ns-publics 'clojure.core)) 'mod)
17:37Brackifalse
17:38hiredmanwhat release are you using?
17:38BrackiJust wrote that, the latest from google code, 2008/12/17.
17:39hiredmanno kidding
17:39hiredman*shrug*
17:40ayrnieu,(map :name (filter #(and (:doc %) (.contains (:doc %) "mod")) (map meta (vals (ns-publics 'clojure.core)))))
17:40clojurebot(derive with-precision ensure require underive mod)
17:40hiredman~def mod
17:41ayrnieuprobably goatse.
17:41BrackiThx. See here http://code.google.com/p/clojure/source/browse/branches/20081217/src/clj/clojure/core.clj no mod
17:42hiredmanactually it is the definition of mod
17:42hiredmanBracki: yeah, we established that you have no mod
17:43ChouserBracki: but 'rem' is close
17:43hiredmanbut there is the def of mod, you can copy and paste it
17:43Chouser,(rem 7 5)
17:43clojurebot2
17:43ayrnieu,(map #(.getName %) (all-ns))
17:43clojurebot(clojure.set hiredman.sandbox hiredman.clojurebot.seenx hiredman.clojurebot.dice hiredman.clojurebot.sb org.danlarkin.json.decoder user hiredman.clojurebot.google clojure.main org.danlarkin.json clojure.core hiredman.clojurebot.translate org.danlarkin.json.encoder clojure.zip sandbox hiredman.clojurebot hiredman.clojurebot.forget hiredman.utilities hiredman.clojurebot.core clojure.xml hiredman.clojurebot.svn hiredman.pque
17:49pilkarnman my mp3player is around 250-300 lines of code, written in clojure completely but a lot of java-wrapping. doe sit sound reasonable? just making a simple player was basically no code at all but making laylists, stop next play etc and makign sure evrything works added so much code
17:50hiredman~translate to sp the plains in spain in the rain
17:50hiredmanhuh
17:50BrackiRegarding the project euler thingy, how do I filter a list twice, or rather combine the result of two filter passes to a new list?
17:51pilkarnyes an mp3-decoder in Clojure. I already am using mlayer and it is ok but lacks some features. im mostly interesting un learning basic signal processing, and it seems like a fun project that would teach me a lot.
17:51ayrnieuBracki, that depends on what relationship you want the combined list to have to the two lists.
17:52ayrnieu,(filter #(zero? (mod % 3)) (filter #(zero? (mod % 13)) (range 200)))
17:52clojurebot(0 39 78 117 156 195)
17:53ayrnieu,(filter #(and (zero? (mod % 3) (mod % 21))) (range 400))
17:53clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$fn
17:53BrackiYeah but I want to OR the filters not AND them.
17:53Chousukejust use or then
17:53ayrnieu,(filter #(and (zero? (mod % 3)) (zero? (mod % 21))) (range 400))
17:53clojurebot(0 21 42 63 84 105 126 147 168 189 210 231 252 273 294 315 336 357 378 399)
17:54Chousukeyou can't separate the lists that way though
17:56pilkarnyes an mp3-decoder in Clojure. I already am using mlayer and it is ok but lacks some features. im mostly interesting un learning basic signal processing, and it seems like a fun project that would teach me a lot.
17:56pilkarnhow can you compose filter and filter?
17:56ayrnieu,(meta (var compose))
17:56clojurebotjava.lang.Exception: Unable to resolve var: compose in this context
17:57blbrownIf I define this structure. Is this an PersisentArrayMap or StructMap. I thought it would be a 'struct' map: { :tag :af, :attrs {:timestamp "Feb 14 06:02:17 2009", :id 1 }
17:57blbrown{ :tag :af, :attrs {:timestamp "Feb 14 06:02:17 2009", :id 1 } }
17:57pilkarn, (def ff (comp filter filter))
17:57clojurebotDENIED
17:57ayrnieu,(doc comp) ;; bleh, I won't replace the doc with "DON'T USE THIS YOU EVIL ESCAPEE FROM HASKELL"
17:57clojurebot"([& fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
17:57pilkarn(ff #(< % 15) #(> % 10) (range 20))
17:58pilkarn, (let [ff (comp filter filter)] (ff #(< % 15) #(> % 10) (range 20)))
17:58clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$filter
17:58hiredmancomposing filter like that will not work
17:58hiredmanfilter takes more than one argument
17:58hiredmanbut (like all functions) only returns one
17:59pilkarnso you can only compsoe functions with arity 1?
17:59pilkarnso compose is good in haskell because all fucntions are currried?
17:59pilkarnbut not in clojure?
17:59ayrnieuwhy do you ask "you can only?" like that? comp is just a clojure function.
17:59hiredmanyes
17:59Chousuke(filter #(or (> 10 %) (< 2 %)) [1 2 3 4 5 12 70 100])
17:59Chousuke,(filter #(or (> 10 %) (< 2 %)) [1 2 3 4 5 12 70 100])
17:59clojurebot(1 2 3 4 5 12 70 100)
18:00Chousukehm
18:00Chousukewell that wasn't very useful :(
18:00Chousuke,(filter #(or (< 10 %) (> 2 %)) [1 2 3 4 5 12 70 100])
18:00clojurebot(1 12 70 100)
18:00BrackiHow do I unpack a list?
18:00pilkarncan i get the arity of a function at runtime?
18:00ayrnieuBracki - that depends on what you mean why 'unpack'.
18:00hiredmanif you want to do a lot of composing you have to uncurry functions by hand
18:01Chousukepilkarn: :arglists in metadata
18:01hiredmanBracki: unpack?
18:01Chousuke,(:arglists ^#'filter)
18:01clojurebot([pred coll])
18:01Brackithe sum of the list by passing a list to: (+ '(1 2 3))
18:01hiredmanChousuke: that only works are functions stored in vars
18:01ayrnieu,(:arglists (meta (fn [_] 1)))
18:01clojurebotnil
18:01hiredmanBracki: apply
18:01Chousuketrue
18:01pilkarnand that metadata is gened automatically?
18:02Chousukepilkarn: it exists for defn'd functions
18:02hiredmanpilkarn: there is no way to get arity information from an arbitrary function
18:03pilkarnwhy does reduce give arity 2? (reduce + coll) ok but (reduce #(+ %1 %2 3) 0 coll) -> arity 3
18:03ayrnieu,(doc reduce)
18:03hiredmanuh
18:03clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the r
18:03hiredman,(:arglists ^#'reduce)
18:03clojurebot([f coll] [f val coll])
18:04hiredman^- two arg lists
18:07ayrnieuIf you want to produce code as fantastic and worthless as the Haskell community has trained itself to do with that language's horrifically maldesiged^W^Wfeatures, then you'll have to do a bit of work to make this possible. And Clojure still won't have the piles of syntax sugar to give the result a veneer of acceptability.
18:07hiredman*cough*
18:08pilkarnhow can I do (convert-to-vector java-LinkedList) ?
18:08hiredman(doc vec)
18:08clojurebotCreates a new vector containing the contents of coll.; arglists ([coll])
18:08hiredmancoll in the docs means Collection
18:09hiredman,(doc instanceof?)
18:09clojurebotjava.lang.Exception: Unable to resolve var: instanceof? in this context
18:09hiredman,(doc instanceof)
18:09clojurebotjava.lang.Exception: Unable to resolve var: instanceof in this context
18:09ayrnieubut if this is a Java linked list and not a clojure PersistentList, you can get an iterator from it and then use iterator-seq
18:10ayrnieu,(map :name (filter #(and (:doc %) (.contains (:doc %) "instance")) (map meta (vals (ns-publics 'clojure.core)))))
18:10clojurebot(re-pattern instance? init-proxy re-matcher read .. seque memfn accessor class? construct-proxy get-proxy-class struct-map proxy-mappings update-proxy proxy struct gen-class make-array)
18:11hiredman,(instance? (java.util.LinkedList.) java.util.Collection)
18:11clojurebotjava.lang.ClassCastException: java.util.LinkedList cannot be cast to java.lang.Class
18:11durka42,(find-doc "instance")
18:11clojurebot------------------------- clojure.main/repl ([& options]) Generic, reusable, read-eval-print loop. Reads from *in* and writes to *out*. *in* must either be an instance of LineNumberingPushbackReader or duplicate its behavior of both supporting .unread and collapsing CR, LF, and CRLF into a single \newline. Options are sequential keyword-value pairs. Available options and their defaults: - :init, function o
18:11durka42oh, i forgot that prints out the doc and not just the names
18:11hiredman,(vec (java.util.LinkedList.))
18:11clojurebot[]
18:12hiredman,(vec (java.util.LinkedList. 1))
18:12clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Collection
18:12hiredman,(vec (java.util.LinkedList. [1 2 3 4]))
18:12clojurebot[1 2 3 4]
18:12hiredmanyay java.util.Collection!
18:14cp2can somebody tell me the equivalent of say, int.class ?
18:14hiredman,(java.util.Collections/shuffle (java.util.LinkedList. [1 2 3 4]))
18:14clojurebotnil
18:14hiredmanugh
18:14cp2actually, nevermind
18:14ayrnieu,[(class 1) Integer/TYPE]
18:14clojurebot[java.lang.Integer int]
18:14cp2i just realised that what i asked isnt relevant to my problem
18:15cp2well, it is, but in a different way
18:17hiredman1d2
18:17clojurebot2
18:17pilkarn(LinkedList. (make-array Integer (count [1 2 3]))) -> java.lang.ClassCastException: [Ljava.lang.Integer; cannot be cast to java.util.Collection (NO_SOURCE_FILE:0)
18:17pilkarn, why?
18:17clojurebotjava.lang.Exception: Unable to resolve symbol: why? in this context
18:17hiredman,(doc make-array)
18:17clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
18:17pilkarnayrnieu: why is haskell code so worthless? i find it extremely elegant, clojure inspired rhickey a lot I think.
18:18hiredmanpilkarn: a java array is not a Collection
18:18durka42,(use 'clojure.contrib.lazy-seqs) (random-permutation [1 2 3 4])
18:18clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/lazy_seqs__init.class or clojure/contrib/lazy_seqs.clj on classpath:
18:20hiredmanclojure's datastructures are Collections, so they can be passed to LinkedList directly
18:20hiredman,(java.util.LinkedList. [1 2 3 4])
18:20clojurebot#<LinkedList [1, 2, 3, 4]>
18:22pilkarnclojurebot: contrib?
18:22clojurebotcontrib is http://code.google.com/p/clojure-contrib/
18:22pilkarni want to shuffle a vector
18:23hiredman,(doto (java.util.LinkedList. [1 2 3 4]) java.util.Collections/shuffle)
18:23clojurebot#<LinkedList [1, 3, 2, 4]>
18:24hiredman,(vec (doto (java.util.LinkedList. (range 10)) java.util.Collections/shuffle))
18:24clojurebot[4 5 3 9 8 1 2 0 6 7]
18:24hiredman,(vec (doto (java.util.LinkedList. (range 10)) java.util.Collections/shuffle))
18:24clojurebot[3 9 0 7 2 4 6 8 1 5]
18:25Chousuke,(java.util.Collections/shuffle [1 2 3])
18:25clojurebotjava.lang.UnsupportedOperationException
18:25Chousukehee
18:29BrackiIn the REPL how do I reuse the last returned value?
18:30durka42*1
18:30durka42*2, *3
18:30pilkarnthanks
18:31pilkarnayrnieu: you still didnt answer whats so bad about haskell?
18:31pilkarnand roughly how much code is an mp3decoder? anyone know? 500 loc, 3000?
18:33Chousukepilkarn: that's a useless question
18:33Chousukepilkarn: it depends too much on the language, the features wanted, skill and even just coding style.
18:33pilkarnyes but there is a bound anyhow
18:33Chousukeanyway, I don
18:34ChousukeI don't think Clojure is suitable for an mp3 decoder
18:34ChousukeIf I were to write one I'm quite sure I'd use C
18:35zakwilsonI've done some simple image processing in Clojure. I think an MP3 decoder is feasable.
18:35hiredmanpoor stuart
18:36durka42"When faced with this, apply the following method: try the simplest possible thing, and if it doesn't satisfy you, try the next simplest thing."
18:36durka42i like it
18:38hiredmanpilkarn: I suggest you go write a mp3 decoder then you will have an empiracally arrived at number for the loc needed to implement a mp3 decoder
18:39hiredmanno need for guessing games
18:39pilkarnno i just asked, perhas soemone had done one and then they could say my C mp3 decoder was 2000loc or my java decoder was 1000loc and then id have a slight idea
18:40hiredmanmp3 decoding is not a piece of code people write much these days, it is a librarythey consume
18:41hiredmanit is 2009, I would hope we can call mp3 decoding a "solved problem"
18:44pilkarnsure but one might be interested in learning about signal processing
18:44pilkarnand unfortuneately jlaye sucks even though it is a "solved problem"
18:47hiredmanif you are intrested in learning about signal processing, why not just write the thing?
19:16pilkarnif i start a new process do all refs need to be passed to that then while if i use a new thread those threads share the refs?
19:20Chouserpilkarn: threads all share the same memory, so all the same globals are available whether they are refs, vars, file handles, buffers, whatever.
19:21Chouserto communicate with a different process you'll need to use some kind of IPC mechanism -- sockets, "shared memory" objects, environment variables, etc.
19:30blbrownI think RIch is too smart to write the documentation
19:31blbrown...meaning, I can't understand what he is saying
19:33durka42where?
19:34AWizzArdbtw, did the idea (def [x y z] [10 :hello {:a 1, :b 2}]) already die or is there a chance that we can get this? :)
19:35blbrowndurka42, http://clojure.org/runtime_polymorphism
19:38AWizzArd,(doc future)
19:38clojurebot"([& 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."
19:39AWizzArd,(time @(future))
19:39clojurebot"Elapsed time: 1.058 msecs"
19:40MarkVolkmannIs there a function that detects whether a symbol is defined?
19:41MarkVolkmannI want to base an action on that. If I don't check, I get an exception that says "Unable to resolve symbol".
19:41technomancyMarkVolkmann: find-var?
19:42MarkVolkmannThat must be in a contrib library.
19:42technomancynope; it's in clojure.core
19:42MarkVolkmannAh ... I thought it had a question mark on the end.
19:42technomancyoh; heh
19:42AWizzArdMarkVolkmann: resolve
19:45pilkarnwhat i the alternative to polling?
19:45technomancyis it possible to make custom data types that are callable like functions the way maps and vectors are?
19:45technomancyI'd like to be able to do something like ((date 2008 2 28) :month) => 2
19:46technomancybut I suspect that might need to dip into Java
19:46pilkarnif date creates a hashmap it is guess
19:46technomancyI'd like it to be a new data type, but I can do that if there's no other way
19:46pilkarnput data in a namespace
19:47hiredmanclojurebot: multimethods?
19:47clojurebotmultimethods seperate the 20% from the 80%
19:48technomancyhiredman: often times the intent behind your clojurebot invocations are not always clear. are you trying to say that I could implement call-able data types with multimethods?
19:50hiredmantechnomancy: ah, no, I was reacting to blbrown, 15 minutes ago
19:50pilkarnlol
19:50MarkVolkmannIs there an idiom for insuring that some code in a .clj file is only run the first time that file is loaded?
19:51hiredman(doc defonce)
19:51clojurebotdefs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated; arglists ([name expr])
19:51pilkarn, (do (defn make-date [y m d] {:year y :month m :day d}) ((make-date 2008 12 02) :month))
19:51clojurebotDENIED
19:51pilkarndenyn youself biatch
19:51pilkarn, deny youself biatch
19:51clojurebotjava.lang.Exception: Unable to resolve symbol: deny in this context
19:52MarkVolkmannWon't defonce just define something once? I want to execute a chunk on code just once. In particular, I want to start a thread only the first time this source file is loaded.
19:52technomancyMarkVolkmann: runonce is defined in lancet, might be helpful.
19:53hiredmanMarkVolkmann: according to the docstring, the expr is not evaled if a root binding already exists
19:53Chouser(defonce mythread (Thread. #(...))) should do it.
19:53Chouseryeah, like hiredman said.
19:53MarkVolkmannThanks!
19:53hiredman(defonce q (do some stuff here))
19:56xooxWhat is the proper way to filter on the children of a node that has been selected by filtering? "(xml-> (xml1->" is giving me heap errors.
19:56lisppaste8sd pasted "date namespace" at http://paste.lisp.org/display/75559
19:58pilkarn^technomancy: ^^ but perhaps you know that approach already, just giving an exmaple of how I would do. namespaces + hashmaps + multimethods does most/all things I need from objectorientation
19:58pilkarnoh he left
19:59pilkarnthe more i program in clojure the more objectorientation just feels like obfuscation. it complicates my code rather than simplifie sit.
20:05hiredman~translate to de the plains in spain in the rain
20:05clojurebotdie Ebenen in Spanien im Regen
20:05hiredmanhmmm
20:12blbrowngerman>?
20:13Chouserxoox: can you paste an example that demonstrates the problem?
20:14xooxChouser: Yes, give me two minutes.
20:18lisppaste8xoox pasted "xml-zip filtering" at http://paste.lisp.org/display/75560
20:20xooxChouser: ^
20:23blbrownhttp://img253.imageshack.us/img253/8665/screenshot3sk9.png more on my clojure app, monitor garbage collection statistics
20:26Chouserxoox: fetch-dom ?
20:27xooxChouser: Sorry, it is essentially (xml-zip (xml/parse url)). I will update the paste.
20:27lisppaste8xoox annotated #75560 with "fetch-dom" at http://paste.lisp.org/display/75560#1
20:28pilkarn~translate to de scheisskopf
20:28clojurebotscheisskopf
20:28pilkarn~translate to de Ich bin geil
20:28clojurebotIch bin geil
20:28blbrown~translate nein
20:28pilkarn~translate to de I am awesome
20:28clojurebotIch bin genial
20:28hiredman ~translate from de scheisskopf
20:28Chouserxoox: sorry, gotta go for a minute. I'll be back soon.
20:28pilkarn~translate to eng Ich bin geil
20:28blbrown~translate to eng dogs
20:28hiredman~translate from de scheisskopf
20:28clojurebotscheiss kopf
20:29xooxChouser: I'll be around for about an hour an a half. Thanks in advance for any pointers.
20:29pilkarn~translate do de hired man
20:29blbrownhiredman, are you do some kind of REST request to babelfish or something
20:29hiredmanblbrown: google translate
20:29blbrownah
20:29hiredmanman
20:30hiredmantranslate needs a lot of polish, it throws a lot of exceptions
20:30xoox~translate to de Mehr licht.
20:30clojurebotMehr Licht.
20:30xoox~translate from de Mehr licht.
20:30clojurebotMore light.
20:30blbrown~translate from de Nein
20:30clojurebotNo
20:31blbrown~translate to de beer
20:31clojurebotBier
20:31blbrown~translate to de I like cats
20:31clojurebotIch mag Katzen
20:31blbrown~translate to de I like Java
20:31clojurebotIch mag Java
20:31blbrown~translate to de I like clojure
20:31clojurebotIch mag clojure
20:32xoox~translate from de Alles Gescheite ist schon gedacht worden. Man muss nur versuchen, es noch einmal zu denken.
20:32clojurebotEverything is quite intelligent thought. You just have to try once again to think.
20:33blbrownxoox, really needs a text to speech wav output. Then we can hear what is printed. I'm just saying, if you want feature complete hehe
20:40Chouserxoox: I think it's just returning a really large object. Printing it at my repl just spews tons of text.
20:41Chouserbut if I do (def matches (xml-> (xml1-> ...))), that works ok, though of course its lazy
20:42ChouserBut then I can say (node (last matches)) and get a sane result rather quickly.
20:47xooxChouser: Okay thanks. I guess I was just being misled and assuming an error caused by trying to print the object was a problem with the code.
20:49Chouseryou're quite welcome. I'm very much aware that the use of neither clojure.zip nor zip-filter is particularly objvious, and there's essentially no documentation on the concepts behind either.
20:49ChouserI keep meaning to write some kind of tutorial or something, but I haven't gotten around to it yet.
20:51xooxChouser: By the way, is that the "correct" way to search only one branch of the tree? Find the element and then filter on its descendants?
20:52ChouserOff the top of my head, that's the only way I can think of.
20:53AWizzArdbtw, did the idea (def [x y z] [10 :hello {:a 1, :b 2}]) already die or is there a chance that we can get this? :)
20:53Chousereach iteration of each filter step only has access to the one loc -- its starting point.
20:54ChouserIn order to examine the whole set of matching locs in order to do something like pick the first one, then you have to step outside the xml-> expression. I think.
20:54Chouserthough if there's only one branch that matches up to that point there's no harm at all in putting the remaining filter expressions in the same xml->
20:55ChouserAWizzArd: I don't think anyone ever approached Rich with that idea.
20:57AWizzArdI thought you did.
20:57AWizzArdsome months ago
20:58AWizzArdanyway... n8 n8
21:58MarkVolkmannI assumed that conj always added to the end of vectors, but it seems I was wrong.
21:58Chouser?
21:58danlarkinbzzzt
21:58MarkVolkmannWhat's the best way to create a new vector with an item added to the end of an existing one.
21:58MarkVolkmannAre you saying conj always does that?
21:58danlarkinconh
21:58danlarkinconj, sorry
21:59Chouserconj on a vector adds to the right-hand side
21:59Chouserconj on a list adds to the left
21:59MarkVolkmannHmm, I'll recheck my code to see why I thought it wasn't doing that.
21:59ayrnieu(map #(conj % 1) [[-1 1] (2 3)])
21:59ayrnieu,(map #(conj % 1) [[-1 1] (2 3)])
21:59clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
22:00ayrnieuoh, it swallowed the quote. Stupid apple keyboard.
22:01MarkVolkmannIt's some weird multithreading timing issue.
22:02hiredmanlets see some example code
22:02MarkVolkmannI'll gladly paste it if you want, but I don't want to burden everyone. I think I can describe the situation.
22:03MarkVolkmannI'm making two calls to a function in succession.
22:03MarkVolkmannThe function starts a transaction and adds the string argument to a vector that is the value of an atom.
22:03MarkVolkmannThey sometimes get added in the reverse order of my calls.
22:04hiredmanlets see some code
22:04MarkVolkmannThe combination of dosync and swap! may be adding some uncertainty about the order in which the strings get conj'ed to the vector.
22:04MarkVolkmannDoes that sound plausible?
22:04MarkVolkmannI'll paste the code.
22:05hiredmanlisppaste8: url?
22:05lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:05Chouserif you care about the order, you should not use 'swap!' in a transaction
22:06lisppaste8mvolkmann pasted "logger.clj" at http://paste.lisp.org/display/75563
22:07lisppaste8mvolkmann annotated #75563 with "client code" at http://paste.lisp.org/display/75563#1
22:07MarkVolkmannSo the first paste is logger.clj which provides a log function.
22:07MarkVolkmannThe purpose is to allow multithreaded code to do printlns that won't get intermingled.
22:08Chouserbesides order, a 'swap!' in a transaction could be retried -- you could get the same thing added multiple times.
22:08MarkVolkmannFor example, I don't want one thread to log "The sky is blue", another to log "The grass is green" and see the output "The sky The is grass is blue green"
22:09MarkVolkmannThe client code just calls log with any number of arguments which are concatenated to form a message.
22:09hiredmanswap! should not be in a transaction
22:09MarkVolkmannOh, I thought it had to be in a transaction.
22:10Chouserno
22:10hiredmanI think in this case you would be better off with a ref anyway
22:10Chouserbut I think you need a transaction, in order to avoid a race condition with the empty check, etc.
22:10MarkVolkmannI started with that, but changed to an atom since I'm only coordinating change to a single value.
22:10Chouser...which means a ref
22:11MarkVolkmannOh, right! I knew that, but forgot.
22:11MarkVolkmannOkay, I'll rework it to use a ref.
22:11MarkVolkmannThanks for the advice!
22:18gnuvince_Hello
22:18Chousergnuvince_: hi
22:19gnuvince_How's it going, Chouser?
22:20Chouserpretty well, thanks. and you?
22:21gnuvince_Not bad at all. My project is going forth nicely.
22:24gnuvince_~seen ayrnieu
22:24clojurebotayrnieu was last seen in #clojure, 23 minutes ago saying: oh, it swallowed the quote. Stupid apple keyboard.
22:25ayrnieu?
22:36gnuvince_ayrnieu: I had a problem with slime-fancy, I fixed it by selectively enabling the contrib modules I wanted.
22:36ayrnieuoh well.
22:38gnuvince_But it was in the REPL, and I recall you saying you didn't use it with Clojure.