#clojure logs

2008-12-25

02:10Lau_of_DKGood morning gents
03:51Lau_of_DKHey heey :)
04:56bOR_merry christmas everyone. I've a design question:
04:58bOR_I've a model in which human hosts are refs in a vector. One of the key/vals in these host-refs should contain information about the infections that the host carries.
04:59bOR_each infection has some properties: a sequence, a mutation rate etc.. so I've made a struct for infections.
04:59bOR_what is a convenient way to collect a number of infections inside the :inf value of the host?
04:59bOR_let :inf contain a vector of refs?
05:31hoeckbOR_: mhh, maybe a set wrapped in a ref?
05:33bOR_set would be somewhat useless though. ah.
05:34bOR_good point. I need to give an identifier to each type of virus, so that you don't get infected with 10 different clones of hiv.
05:35bOR_I've now just made th e host a ref, and have :infections be a [], in which ts.
05:35bOR_ts = structs
05:35bOR_don't seem to need a ref in ref there.
05:36bOR_although I wonder how easy it is to ' change' to swap in/out elements of the vector.
05:37bOR_I'll try some things and see what problems I run into.
10:38Lau_of_DKGood afternoon gents
12:28Chousukehmm
12:28Chousukemy clojurebotv2 seems to be working (at least somehow)
13:44Lau_of_DKGood evening gents
14:13gnuvinceAre Java arrays arranged contiguously in memory?
14:15Lau_of_DKyes
14:15gnuvinceThank you
14:15Lau_of_DKnps
14:15gnuvinceMerry Christmas (if it applies) by the way :)
14:16Lau_of_DKIt doesnt, but I appreciate the thought
14:33Lau_of_DKgnuvince: Im sorry about the confusion. The Java standard actually leaves it up to the host to arrange it in memory, although TYPICALLY it will be in consecutive blocks
14:35gnuvinceok
14:36Lau_of_DKhttp://www.brpreiss.com/books/opus5/html/page82.html
14:37chrisnI have a java swing threading question
14:37chrisnIs there a thread pool set up for you?
14:38chrisnBasically I want file loading to happen offline
14:38chrisnin my swing app.
14:38chrisnIt doesn't seem that agents are a good fit...
14:44Lau_of_DKchrisn: I dont really understand your question. Regarding a pool, Java itself has some type of Queue system, dont know why agents wouldnt do that trick though
14:44chrisnIts ok, I don't understand it either :).
14:44Lau_of_DK:)
14:45chrisnOK, I have a graphics system. I want to load files offline and put up dummy objects, images, shaders, etc while loading the data from the fs.
14:45chrisn1. GL calls can't happen from arbitrary threads, so the result has to be applied to gl state in the render thread
14:45chrisnWhile a file is loading, more entities may request actions take with the result of the file loading process
14:46chrisnI did this in C using a thread pool and continuations.
14:46chrisnI am trying to figure out where agents make sense.
14:46chrisnThe thing is, the result of the load isn't a change to a datastructure.
14:46chrisnIt is just a chain of more function calls
14:47chrisnThat have to happen in the rendering thread
14:47Lau_of_DKYou could dispatch agents to fetch the info from the files and have them feed their state back to some global ref, which you clear out like a log and then update GL with the progress?
14:47chrisnYep, something like that
14:47chrisnIt seems a bit of a perversion of the agent model somehow
14:47Lau_of_DKI wouldnt say so
14:47chrisnBut I don't want to create my own thread pool...
14:48chrisnWell, here is another thing. Where in the clojure documentation does it state how many threads are in the agent thread pool?
14:48chrisnThese actions are going to be IO-blocked, not CPU blocked and thus I want more threads than processors.
14:49chrisnprobably 2x or more
14:49Lau_of_DKAgents can automatically find out when it doesnt make sense to launch anymore, as I understand them
14:49Chouserchrisn: that's exactly the purpose of 'send-off' (vs. 'send')
14:49chrisnHow many threads are in the clojure thread pool?
14:50Chouserchrisn: there are two send pools for agents, one for 'send' and one for 'send-off'
14:50chrisnsh
14:50chrisnah
14:50chrisnthat helps, thanks Chouser.
14:50Chouser'send' currently uses 2+cpus, I think. 'send-off's pool grows as needed.
14:51chrisnoh, spectacular
14:51Chouser(doc send-off)
14:51chrisnDispatch a potentially blocking action to an agent. Returns the
14:51chrisn agent immediately. Subsequently, in a separate thread, the state of
14:51chrisn the agent will be set to the value of:
14:51chrisnIt doesn't state anything about grows as needed
14:51chrisnI was looking at the docs, Chouser.
14:52ChouserI was referring to the "potentially blocking" phrase.
14:54chrisnHell of a lot to infer from one phrase.
14:55Chouserwell, the "grows as needed" detail is from reading the code. No offense intended.
15:00chrisnyeah, I decided to read the code because that detail is an odd one and I have the time... Merry Christmas! Thanks for you help.
15:00Lau_of_DKHey Chris
15:00chrisnyo
15:00Lau_of_DK:)
15:00chrisndo I know you?
15:00Lau_of_DKI dont think so
15:00chrisnk
15:00ChouserI'm also Chris to some.
15:01chrisnoh, that will make things easier... :).
15:01Lau_of_DKhehe
15:02Lau_of_DKChris is an old Nordic name which means "Dumb as a rock"
15:03chrisnhaha!
15:03chrisnfinal public static ExecutorService pooledExecutor =
15:03chrisn 28 Executors.newFixedThreadPool(2 + Runtime.getRuntime().availableProcessors());
15:03chrisnthe pooled executor is one of those
15:03Lau_of_DKChouser: come on, give me a break, that was a joke :)
16:26Lau_of_DKI have this file, where if I load it using load-file, I get an error "Unable to resolve symbol: g in line 0
16:26Lau_of_DKIf I manually evaluate line 0, it works fine
16:27Lau_of_DKw00t?
16:34hoeckLau_of_DK: then there is somewhere a "g" on a single line somewhere in the file
16:34hoeckline numbering somehow doesn't work in this case
16:37Lau_of_DKI didnt check the whole file to be honest, just the first 50 lines or so
16:37Lau_of_DKAnd no G's
16:38hoecki just inserted an "f" on a blank line in some clj file and tried to load-file it
16:38hoeckand i got the same error
16:38Lau_of_DKk
16:38Lau_of_DKThat might have been it
16:38Lau_of_DKI git-reverted out of it
16:43Lau_of_DKhoeck: Almost too funny, at line 51 there was a little g hiding behind closing ))))))))
16:43Lau_of_DK:) Is this line-counting bug reported?
16:47hoeckdon't know, guess not
16:48hoeckeg.: a (g) on an empty line is reported correctly
16:51Lau_of_DKBut it says (filename:0) which leads me to believe that the error is on line 0
16:53Chousukeline numbering should start with 1
16:55hoeckChousuke: Dijkstra would not like that :)
16:56Lau_of_DKI agree
16:56Chousukehmm.
16:56hoeckbut it starts at 1 in clojure zero just means no-line
16:56ChousukeI don't see a reason to start line-numbering from 0
16:56Lau_of_DK0 isnt anything, its void
16:56Chousuke0 lines means no lines.
16:56hoeckmee neither
16:56hoeckme
16:57Lau_of_DKhoeck: do you mean: me me me ?
16:57hoeckfunny, columns start at zero (at least in emacs) but lines at 1
16:57Chousukeand I finally got my restructured version of clojurebot working as well as the old one
16:57Lau_of_DKthats true
16:58Lau_of_DKhoeck: but if you dont like it, you can always customize
16:59hoeckI just stumbled over this anomaly, and I don't really care, it doesn't make sense though
17:15Chousukehm
17:17Chousukehiredman: I got my reworked version of clojurebot working... I think
17:17hoeckclojurebot: botsnack
17:17clojurebotthanks; that was delicious. (nom nom nom)
17:17ChousukeI didn't test with the security manager enabled yet
17:17hiredmanwith a permissive policy file the security manager should not make a difference
17:17Chousukebut most of my work didn't touch the sandbox code
17:18ChousukeI pushed v2 into my master branch: http://github.com/Chousuke/clojurebot/tree/master
17:18hiredmanhmmm
17:18Chousukeyou can't directly merge your master with that, since they're not really related
17:24Chousukealso you can't really run two completely separate bot instances at the same time as they share the same brain.
17:26Chousukekind of like a hivemind :P
17:27hiredmanI dislike using binding there at the bottom for *bot* and what not, because it makes those variables unavailble at the repl
17:27hiredmaner
17:28hiredmanthose vars
17:28Chousukewhere?
17:29hiredmanclojurebot core?
17:29hiredmanI am not looking at it right now, this is just what I remember from looking at it last night
17:29Chousukeah, well
17:30Chousukethe new stuff looks *completely* different
17:30Chousukehere's how you boot it up http://github.com/Chousuke/clojurebot/tree/master/hiredman/clojurebot.clj
17:32Chousukethe run-clojurebot macro could probably do without the & body argument; that's a remnant from some earlier stuff :/
17:34Chousukeyou could just (def mybot (start-clojurebot bot-attrs)) and then just call the functions with mybot as the argument.
17:34Chousukerun-clojurebot*
17:35hiredmannice
17:35hiredmanI have a clojurebotv2 branch, but how do I pull stuff from your v2 branch?
17:37Chousukegit checkout clojurebotv2; git pull chousuke master
17:40Chousukeif you try the pull in your master branch you will get errors. git reset --hard will get you back where you started :)
18:01dthomasWhen using Clojure from SLIME, is it normal to have exceptions like RuntimeException: RuntimeException: RuntimeException: TheRealException? I find I have to keep hitting "Throw cause of this exception" until I get to TheRealException (and then work my way back out to the REPL).
18:01dthomasThis is the first time I remember seeing this behavior. I wonder if it's something new that's been introduced, or if it's due to hitting an exception down within a nested lazy seq or something.
18:02hiredmanI've seen it a few times on the vanilla repl
18:02dthomasOK, so not a SLIME thing. That makes me feel a little better.
18:02hiredmandon't remember the details
19:29hiredman,(pow 10 14)
19:29clojurebotjava.lang.Exception: Unable to resolve symbol: pow in this context (NO_SOURCE_FILE:0)
19:29hiredman,(.pow 10 14)
19:29clojurebotjava.lang.IllegalArgumentException: No matching method found: pow for class java.lang.Integer (NO_SOURCE_FILE:0)
19:34nagnalshow would clojure be for scientific computing? like fft, big matrix manipulation etc?
19:34nagnalsi want osmething that is good for both rapid prototyping and execution speed :)
19:35Chousernagnals: I think those are broadly the same desires as Clojure's author.
19:36Chouser,(.pow 10M 14)
19:36clojurebot100000000000000
19:37Chouser,(Math/pow 10 14)
19:37clojurebot1.0E14
19:38hiredmanheh
19:38hiredmanduh
19:39hiredmanclojurebot: hiredman?
19:39clojurebothiredman is slightly retarded
19:39chrisn(def testvar 5)
19:40chrisn,(def testvar 5)
19:40clojurebotDENIED
19:40chrisn,(println "screw off")
19:40clojurebotscrew off
19:41chrisn,(name *ns*)
19:41clojurebotjava.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0)
19:41hiredman,(identity *ns*)
19:41clojurebotfoo
19:42chrisn,::bar
19:42chrisn,(keyword "foo" "bar")
19:42clojurebot:foo/bar
19:43chrisn(author "clojurebot")
19:43chrisn,(authot "clojurebot")
19:43clojurebotjava.lang.Exception: Unable to resolve symbol: authot in this context (NO_SOURCE_FILE:0)
19:44chrisn,(author "clojurebot")
19:44clojurebotjava.lang.Exception: Unable to resolve symbol: author in this context (NO_SOURCE_FILE:0)
19:44chrisn(range 100)
19:44chrisn,(range 100)
19:44clojurebot(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99)
19:44chrisnhmmm
19:44chrisnthat could get ugle
19:44chrisnlike my typing
19:45chrisn,(let [a 5] a)
19:45clojurebot5
19:45chrisn,(agent {})
19:45clojurebotclojure.lang.Agent@4be2cc
19:46chrisn,(fn [] 5)
19:46clojurebotfoo$eval__439$fn__441@1697b67
19:46chrisn,(*1)
19:46clojurebotjava.lang.IllegalStateException: Var clojure.core/*1 is unbound. (NO_SOURCE_FILE:0)
20:27zakwilsonclojurebot: svn?
20:27clojurebotsvn is https://clojure.svn.sourceforge.net/svnroot/clojure/
20:29hiredmanerm
20:29hiredmanthat is not right
20:29hiredmansvn is http://clojure.googlecode.com/svn/trunk/
20:29hiredmanclojurebot: svn is http://clojure.googlecode.com/svn/trunk/
20:29clojurebotOk.
20:32zakwilsonI think I told it that once.
21:14RadioApeShotAnyone want to rap about lazy lists with a newb?
21:14RadioApeShotsequences, really
21:15Chouserwe could try
21:15RadioApeShotWell
21:15RadioApeShotHere is the thing.
21:16RadioApeShotI have a non-lazy function called, perhaps unclearly, square-zip
21:16RadioApeShotsquare-zip takes two sequences and returns all possible pairs of elements
21:16Chouserok
21:16RadioApeShotI'd like to implement this so that it returns a lazy sequence of all possible pairs
21:16RadioApeShotBut I am not sure the best way to go about doing so with clojure
21:17Chouserdo you want to approach this as a learning experience, or should I tell you the built-in macro that'll do it for you?
21:17RadioApeShotLearning experience
21:18RadioApeShotI just opened boot.clj to look at the iterate implementation
21:18Chouserusually the easiest way to build a lazy seq is to use combinations of functions that already produce lazy seqs.
21:18Chouserchief among them is 'map'
21:18RadioApeShotHm
21:19RadioApeShotSo I could use a pair of maps in this case
21:19RadioApeShotAnd I would get a lazy seq for free.
21:19RadioApeShotBut the sequence would not be flat
21:19RadioApeShotI have a flatten but I am not sure if it preserves laziness
21:20Chousertake a look at 'mapcat'
21:20RadioApeShotOk
21:20Chouserhm, its docs don't make claims of laziness
21:21Chouserbut looking at the source, it appears to produce a (at least mostly) lazy seq.
21:22RadioApeShotLaziness
21:22RadioApeShotI am also poking around with Haskell these days
21:22Chouserah
21:22RadioApeShotBut I don't seem to have a feel for using it idiomatically
21:22RadioApeShotBut at least there things are (maybe?) less ambiguous.
21:23RadioApeShotmapcat should flatten my list for me, though, it looks like.
21:23RadioApeShotI guess the thing to do is implement square-zip and apply it to two lazy sequences
21:23RadioApeShotIf it does not preserve the laziness, then it will go on forever.
21:24Chouserwell, there are levels of laziness.
21:24RadioApeShotHow do you mean
21:24ChouserI'm certain mapcat will not eagerly consume the entire sequence.
21:24Chouserbut I'm not 100% it will never take any more of the input sequence than theoretically necessary.
21:26RadioApeShotThat should be sufficient for my purposes... I think.
21:27Chouser(take 1 foo), for example (if I recall correctly), used to call 'rest' on 'foo' even though it shouldn't have to do that unless you took 2 instead of 1.
21:28RadioApeShotThe idea I have is that a lazy sequence can let you use a map to do a calculation on a list of things without iterating 2*n times.
21:28RadioApeShotDoes that make any sense?
21:28RadioApeShotif you (map f (f-that-produces-lazy-seq data)) then you only pass once, rather than twice
21:29RadioApeShotBecause the work of calculating the sequence is delayed until it is used in f
21:31chrisnDoes that assume that f doesn't need the entire sequence?
21:32Chouser(map f sq) does indeed only traverse sq once
21:32ChouserI'm quite sure what else you're saying
21:33chrisnNo matter what, the lazy was is going to use a lot less memory and thus probably be a lot faster for large values of n
21:34RadioApeShotI guess reverse cannot be lazy
21:34RadioApeShotAt least not in a sane way?
21:35Chouserreverse is not lazy
21:35Chouserbut it's very rarely needed in Clojure
21:35RadioApeShotYes
21:35RadioApeShotI don't really need it here.
21:45chrisnWhat is the macro, btw?
21:46Chouser'for'
22:28chrisnoh man for is a lot more powerful than I thought
22:30Chouser:-)