#clojure logs

2009-06-12

00:00polarbizzlerthat will do the trick thanks
00:00polarbizzleri was searching for some examples like on that link forever
00:44Drakesonwhat is the inverse of interleave?
00:46Chouser__take-nth
00:46Chouser__or partition with destructuring
00:54Drakesonthanks
01:17dufflebunkI'm looking at the online api docs for if-let, "(if-let bindings then)" and then it says "If test is true, ..." but there's no "test" in the syntax... just "bindings" and "then".
01:17dufflebunkShould it be (if-let test bindings then) ?
01:17dnolenthe binding is the test
01:18dnolen,(if-let [x nil] true false)
01:18clojurebotfalse
01:18dnolen,(if-let [x 1] true false)
01:18clojurebottrue
01:18dufflebunkAh, ok
01:19dufflebunkthanks
01:19dnolennp
01:21dufflebunkso that's what the "binding-form test" part meant.
02:53cgrandeleftherios: I'm here
03:09eevar2yay, clojure on github
03:12opqdonutproxy can't define new methods?
03:12hiredmannope
03:15opqdonutwhy :/
03:16hiredmanuse gen-interface + proxy
03:18opqdonutgah, i'll just return a map of functions
03:19frodefis there no way to get cond with implicit progns?
03:19frodefI mean, how do I do multiple exprs in a cond clause?
03:19hiredmanyou mean do
03:20hiredmanand no
03:20frodefjhiredman: progn is "do" in clojure?
03:20hiredmanyou coud just a multimethod instead
03:20hiredmanuse a
03:20hiredmanfrodef: I think so
03:21hiredmannever used progn or whatever language it is from
03:21frodefright, it's the same.
03:21frodefthanks.
04:45frodefI'm trying to write a swing viewer for my model. What's the good way to keep the model state?
04:46jdz_a ref?
04:46frodefcan/should I do like the java-people and create a class that keeps its state in members?
04:46jdz_or an atom?
04:46jdz_a map (or struct-map) then?
04:47frodefjdz: ok, I'll look at those. thanks.
04:48jdzmaybe you want a map in a ref/atom
05:18Chousukefrodef: usually you'll want something immutable wrapped in a reference type.
05:18Chousukea single ref wrapping a map if usually a good starting point
05:26opqdonutwhat could cause clojure.lang.Compiler.LOADER to be unbound?
05:27opqdonutguess I should be creating my own DynamicLoader
05:29opqdonutthat did the trick
06:57opqdonutis there an easy way to access class members by string names
06:58mccraigu want to access a field or call a method ?
06:58mccraigof an instance of a java class ?
07:00mccraigopqdonut: http://gist.github.com/128577
07:00opqdonutfield
07:00opqdonutof an instance
07:00mccraigshows how u can access a field, even a private one
07:00mccraigtaking the example of an Agent's state
07:00opqdonutheh, terrible
07:01frodefmaps are immutable also, right?
07:01mccraig'course, the SecurityManager has to be configured lax to permit access to private fields
07:02jdzfrodef: yes
07:03opqdonutwell i don't need private fields :)
07:03mccraigskip the setAccessible call then, and ur away
07:04eevar2__,(doc bean)
07:04clojurebot"([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties."
07:04eevar2__^^ opqdonut
07:05opqdonutmccraig: yah
07:05opqdonuteevar2__: ?
07:07eevar2__may or may not do what you need ;)
07:07opqdonutwell, it does not
07:07opqdonutmccraig: http://paste.lisp.org/display/81759
07:07mccraigeevar2__: JavaBean properties only include fields which have a corresponding java get...() method
07:08eevar2__hmm.. and i see he asked for class members, guess bean may not be appropriate for that
07:19mccraigopqdonut: does set! not work for u, since it's public fields ?
07:41opqdonutmccraig: i need to set! by string name
07:41opqdonutbut gtg ->
07:55adityonewbie question: how do i read from standard input?
07:57achimadityo: read-line, for example
07:58adityoachim: thanks
07:58achimadityo: in is the standard input, a java Reader, you can call java methods on it if you need anything special
07:58frodefany hints on how to best do an event queue between two threads?
08:02cemerickfrodef: easiest way is to put a persistent queue in a ref, and access it from your threads inside transactions
08:03frodefcemerick: can I do a blocking read that way?
08:03Chouserfrodef: I'd look at java.util.concurrent.BlockingQueue
08:06adityoachim: cool
08:10Chousukehttp://www.making-the-web.com/misc/sites-you-visit/nojs/ :/
08:12ChousukeApparently, it's possible to for a site to sniff your history by abusing CSS and iframes. I wonder if that's even fixable
08:22asbjxrnI'd call it guess, and not sniff.
08:23asbjxrnSince it relies on showing a link and detecing if the browser displays it as visited or not.
08:23asbjxrnBut still..
09:48cemerickis the github repo now "official"? I see people tweeting about it, but haven't seen an announcement from rhickey
09:48Chousercemerick: I haven't seen an announcement either.
09:49ChouserIt's not clear to me yet if github or assembla will host the official primary repo.
09:50cemerickI *thought* the decision was to use github for the SCM, tools on assembla, but yeah, it's unclear.
09:50cemerickThere's a lot of watchers on the github repo already. Word travels fast. :-)
09:50Chouser:-)
09:50Chousukeit doesn't really matter who hosts the main repo anyway ;P
09:51cemerickyeah, same here
09:51Chousukeyou can just clone it to your favourite git service anyway
09:51duck1123is there a fn to convert '(:a "a" :b "b" :c "c") to {:a "a" :b "b" :c "c"}
09:51ChouserChousuke: depends on how much lag time you're willing to accept between a rhickey push and your own pull.
09:51Chousukeduck1123: apply hash-map
09:51ChousukeChouser: well, yeah
09:52Chousukegithub is a bit slow sometimes :/
09:52Chousukebut faster than SVN at google code :P
09:52cemerickwell, a different clone from svn would have different sha1s, so that could get tricky if you start basing on a repo that isn't blessed.
09:53ChouserChousuke: no, my point is if rhickey pushes to assembla, I'm not willing to always wait for a nightly poll that transfers it to github. Or whatever. I want my local copy to poll from where he pushes.
09:54ChouserIn fact, if I could pull directly from his working copy, that'd be neat. :-)
09:54ChousukeChouser: right.
09:54Chousukeheh
09:54ChousukeChouser: I think assembla+git works so that github actually does the hosting and assembla just provides some tools on top of that.
09:55rysI think that's what most people are looking for at the end of the day (to be able to clone rhickey's repo directly and pull from it, so there's no indirection)
09:55Chousukegit can have multiple remotes, so you could pull from several places.
09:56Chouser"I don’t think it would be wise to use github mode and integrated git together, even if they allow it."
09:56ChouserI'm not sure exactly what that means, but I'm willing to wait for final conclusions/announcements.
09:56ChousukeI could have my own public clojure-fork on gitorious or something and then people could have a mainline remote and a chousuke-public remote if they're interested :P
09:56rhickeyI've decided not to use assembla's built-int git, but to have it point to github
09:57Chouserah, so no mirroring
09:57rhickeyI'm actively working out the detils, just got IntelliJ all happy with the github version of Clojure
09:58rhickeyChouser: right, assembla doesn't like to have 2 vcs options enabled, go I'm going with the github support
09:58waltersi wonder if google is still paying some guy to try to make svn better
09:59Chousukerhickey: is your git repo already public on github?
09:59rysI _think_ they're directly working on git (TortoiseGit in particular), if memory serves, so I'd bet on seeing git support at googlecode at some point
10:00ChouserChousuke: people are twittering about it.
10:00rhickeyhttp://github.com/richhickey/clojure/tree
10:00rhickeyno pushes yet
10:00Chousukegithub's search didn't find that. :/
10:01Chousukeis clojure-contrib going to move too if this is successful?
10:02rhickeyChousuke: yes
10:02Chousukegreat.
10:02rhickeystill working out how to organize it - seems like a good time to make the ports (ClojureCLR and ClojureScript) stand alone
10:03rhickeyI've come to really dislike gcode's issue system, but need to find a way to port issues over to assembla
10:04Chousukegit has submodule support so you could have the contrib master repo contain those, but perhaps it's not worth the added complexity
10:04ChousukeI still don't know how to use git submodules very well :/
10:04Chousukeeasier to just clone things separately
10:04duck1123they should be moved to clojure-extras or something IMO
10:04ChouserI doubt it'd be worth anything like that. Java's classpath allows sufficient namespace integration.
10:04Chousukebut, heh, I just cloned your repo. took about 5 seconds. :P
10:05ChouserI'll be happy for clojurescript to have less visibility. :-P
10:06rhickeyI could use help devising and implementing plans for all of this, now that I think I know where we are going
10:06duck1123is it usable yet? It looked interesting, but I couldn't figure out how to use it. (not that I really tried)
10:07Chousukerhickey: do you think there's any way to automate moving issues to assembla? :/
10:07Chouserduck1123: it's pretty out of date now. It was in decent shape, nearly usable before the "lazier" changes, but I haven't kept it synced.
10:08Chouserduck1123: I'm not really interested it putting much more effort into it at least until clojure-in-clojure.
10:08rhickeyChousuke: there is this on the assembla side: https://www.assembla.com/wiki/show/breakoutdocs/Ticket_REST_API
10:08adityoquit/
10:08duck1123Chouser: I had to write some JQuery recently, and I kept wanting to write in clojure
10:08Chouserduck1123: :-)
10:09rhickeygoogle is notoriously bad about data export
10:10Chousukerhickey: hmm, right.
10:11rhickeyhttp://code.google.com/p/support/issues/detail?id=1689
10:12rhickeyhttp://code.google.com/p/support/issues/detail?id=148
10:15Chouser"we are *actively* working on this right now" (50 minutes ago) -- nice
10:37Drakesondo we have a function similar to this: (defn de-interleave [n coll] (map #(take-nth n %) (take n (iterate next coll)))) ?
10:37Drakesone.g. (de-interleave 2 [1 2 3 4 5 6]) -> ((1 3 5) (2 4 6))
10:42cgrand,(apply map vector (partition 2 [1 2 3 4 5 6]))
10:42clojurebot([1 3 5] [2 4 6])
10:43cgrand(not lazy)
10:47DrakesonIs there a lazy version of (apply map vector coll) ? I would call it transpose.
10:47Drakeson(transpose [[1 2 3][4 5 6][7 8 9]]) -> [[1 4 7][2 5 8][3 6 9]]
10:52duck1123Does anyone know of any good search engine like sites (other than google) where I can input a class and get the javadoc for it? Preferably with a search plugin.
10:54DrakesonI would appreciate an interface to such in slime (via C-c I)
10:56duck1123I have an javadoc emacs plugin, but I never use it much
10:56duck1123I had to add all the javadoc sources, and it was kinda buggy
11:00cemerickduck1123: yahoo used to have a great javadoc search feature, though they pulled it last wee (don't know why)
11:00duck1123I found javadoconline.com, but I'm not sure if I really care for it yet
11:01cemerickI'd love to have something like http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html for javadoc
11:06hiredman~jdoc String
11:06hiredmanhttp://www.docjar.com/ has decent javadoc coverage
11:08duck1123hiredman: thanks, I'll give that one a try
11:14j-dotduck1123: if you have the Google Toolbar installed, there is a custom search button here: http://www.javac.info/jdk_search.xml
11:16duck1123j-dot: I don't. I use the firefox omnisearch plugin. (makes the address bar behave like chrome)
11:17j-dotcool, for anyone else who's interested, the write-up and link to install it is here: http://gafter.blogspot.com/2009/03/jdk-api-search-in-google-toolbar.html
11:19duck1123i think i just need to start using the emacs plugin i had again
11:43ChousukeI think Mark Volkmann's clojure article should perhaps be featured on clojure.org. It seems great for people looking for an introduction into Clojure.
11:44ChousukeAppears to be much better organised and up to date than the wiki pages :P
11:48drewrduck1123: The Clojure Search does a pretty good job: http://is.gd/ZUZ8/BufferedReader
11:49hiredmanit would be neat if github did pubsub so I could just have clojurebot subscribe
11:50duck1123hiredman: agreed
11:50hiredmanof course then I would need to figure out pubsub
11:50duck1123is clojurebot on xmpp yet?
11:50hiredmannope
11:51duck1123I've been meaning to work on a clojure library for igniterealtime's xmpp library when I get around to it
11:52hiredmanI've started a few times
11:53duck1123is anyone else here currently using clj-record?
11:54duck1123currently, (get-record 7) throws an exception if that id doesn't exist. Personally, I think it should return nil. Any opinions?
11:55cp2hrm
11:55cp2well, it depends on how you are using it i suppose
11:56cp2'nil' could be a perfectly legal value in your application
11:56duck1123the record will always be a map though
11:56duck1123so in this case nil is an illegal value
11:57cp2yeah, then in that case
11:57cp2i would prefer it returning nil
11:57cp2because you can just do (if-let [record (get-record 7)] ...
11:58duck1123that's exactly how i've been using it in my fork
12:02hiredmanugh
12:03hiredmangit shas are not as nice as svn revisions
12:03Chousukeheh :P
12:04hiredman~latest
12:04clojurebotlatest is 1382
12:05Chousukerevision numbers only make sense locally to a branch. In that respect, hg does it right.
12:05hiredmanhow is that even going to work?
12:05hiredmanjust hold the date of the last check in?
12:05Chouserhiredman: ooh, I like that idea
12:05Chousukeor the commit message.
12:07duck1123first line only
12:08Chousercommit message is the "normal" git way I think, but when we have a single official repo, timestamp would give a nice sense of whether you're up to date or not
12:08Chousukethe problem is, when doing commits, git actually records the date.
12:09Chousukebut that's no guarantee of when the commit will appear in the mainline
12:09Chousukeyou could have it in the private repo for half a year, and then when you finally merge, you will have half-year-old commits at the top of the log :)
12:09Chouserwouldn't the merge get a new timestamp?
12:10Chousukethe merge commit does but the actual commits being merged are separate.
12:11ChousukeI can't remember whether the merge commit ends up at the "top" or not :/
12:11Chousukehmm, seems like it does.
12:12hiredmanI get two dates from the github api
12:12hiredman:committed_date and authored_date
12:12Chousukemaybe committed_date means "pushed_date" instead :/
12:15hiredmanugh
12:16hiredmanthe dates from github have a single colon in the timezone specifier that prevents SimpleDateFormat from parsing them
12:18duck1123I wish SimpleDateFormat could work with xsd:dateTime
12:19duck1123it's so annoying to have to write custom code for that. (or use jodatime)
12:19hiredman(.replaceAll datestring "([+-])(\\d\\d):(\\d\\d)" "$1$2$3")
12:20hiredmanso horrible
12:22doug_Is there an easy way of making a hash-set from a coll? I resorted to this: (defn hash-set-from [coll] (reduce #(conj %1 (keyword %2)) (hash-set) coll))
12:23hiredmanthere are several
12:23hiredman,(apply hash-set '(1 2 3))
12:23clojurebot#{1 2 3}
12:24hiredman,(into (hash-set) '(1 2 3))
12:24clojurebot#{1 2 3}
12:24dnolen,(set [1 2 3 4 5])
12:24clojurebot#{1 2 3 4 5}
12:24hiredman,(class {})
12:24clojurebotclojure.lang.PersistentArrayMap
12:24hiredman,(class #{})
12:24clojurebotclojure.lang.PersistentHashSet
12:24dnolenset takes a collection and produces a hash-set
12:25doug_thanks very much for hash-set tips.
12:27Chousukehmm.
12:30Chousuke,(apply hash-set [1 2 3 4 5])
12:30clojurebot#{1 2 3 4 5}
12:30Chousuke:)
12:30Chousukeoh, it was up there.
12:31Chousukemissed it ;/
12:40duck1123is there a version of find-doc that just returns the symbols?
12:41duck1123I can often figure out what I'm looking for just by seeing the name
12:43Chousukeduck1123: unfortunately not :/
12:46marklarlisppaste8: paste?
12:46marklarclojurebot: paste?
12:46clojurebotlisppaste8, url
12:46lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:46lisppaste8marklar pasted "Show-doc" at http://paste.lisp.org/display/81772
12:47marklarduck1123: not exactly what you were looking for, but it may help. Wish I could remember who wrote it
12:47marklarthickey: Thanks again :)
12:47thickeynp :)
12:49duck1123that actually looks more useful than what I was asking for
12:49stuartsierraAndroid Scripting Environment! http://tinyurl.com/ku2gj5
12:49thickeydoes anyone know more about the Clojure Object Explorer that was shown at the Bay Area Clojure Meetup?
12:49marklarstuartsierra: whoa, thats cool
12:51technomancythickey: that'd be replaca's project
12:52technomancythickey: http://github.com/tomfaulhaber/clj-explorer/tree/master
12:52thickeytechnomancy: thanks
13:26replacathickey: yeah, I know a little about it :-)
13:27replacathickey: anything I can tell you besides the pointer technomancy sent you? It's still very young.
13:28thickeyreplaca: i don't have any questions at the moment. i just wanted to see it in action
13:29cp2shutup.lua
13:29cp2hehe
13:30replacathickey: cool. You can just grab it and play. But there's no doc yet
13:31replacathe interesting things are that you can click on the text and it expands or contracts stuff
13:31replacaand you can change the pretty print dispatch function so that you can have it operate on XML, json or what ever
13:32thickeyreplaca: cool stuff. thanks
13:32replacathickey: enjoy, and keep an eye on it cause I'll be making it "more real" as we go along
13:49rhickeyname solicitation time again: single-assignment, block until available dataflow variables create with ___, assign with ___, deref with deref/@
13:50rhickeydataflow, flow, flow1, ivar
13:56cemericka little more context is probably necessary :-)
13:57cemerickis this being bolted into refs, or is it something else entirely?
13:58Chouserthis isn't future?
13:58Chousermore like a single-item BlockingQueue?
13:59rhickeyit's a lot like an Oz dataflow var, without any unification bits. It's like a future but the source isn't determined at creation time - someone must come along and write to it, any readers arriving prior to that will block, all release with value once written, subsequent readers will always see that value, subsequent write throws
13:59hiredmanooo
14:00rhickeyso, not like a queue in that there are multiple readers of the one value
14:00Chouseroh, multiple readers for a single value ... right.
14:00cemerickhrm, interesting.
14:01hiredmanworm
14:01cemerickpersonally, I'd keep away from the flow-related names, which generally are associated with cells impls and constraint propagation in general (in my experience)
14:01Chouserfuture could be built on it
14:01hiredmanhttp://en.wikipedia.org/wiki/Write_Once_Read_Many
14:03lisppaste8rhickey pasted "flows" at http://paste.lisp.org/display/81776
14:03Chouser(let [x (dam)] (release! x 5))
14:03rhickeycemerick: right, I'm not happy with flow and dataflow, people use them for very different things
14:05rhickeywas ivar in Haskell
14:05rhickeyIVar
14:06rhickeybut var already has implications
14:06Chouserit's a blocking bucket
14:07rhickeyhow appealing
14:07Chouserhehe
14:07Chousera cork
14:08Chouserhey, I implemented this using a wather
14:08Chouserwatcher
14:09Chouseron an IRef. ...an atom in my case.
14:09rhickeywhat prevented subsequent assignment?
14:10cemerickgap? e.g. once filled, hard (impossible) to fill again
14:10Chouserhm, I guess more accurately I could have used this. Instead I wrote await-iref
14:10rhickeyhttp://en.wikipedia.org/wiki/Futures_and_promises
14:11rhickeyaccording to that, 'promise' fits
14:12Chouserhttp://paste.lisp.org/display/81237#2 -- await-iref
14:12cemerickrhickey: of course, scheme's promises are clojure's delays
14:13rhickeyright, it's a mess
14:13rhickeysame thing called promise, ivar, dataflow var
14:13cemerickthe latter are nearly meaningless to me :-)
14:13cemericklatter two...
14:14Chouserand just as bad, promise and var mean other things in other places
14:14rhickeybut promise was a bad name for what Clojure calls delay, IMO, and fits this well
14:15lisppaste8rhickey annotated #81237 "flow/promise" at http://paste.lisp.org/display/81237#3
14:15Chouserinteresting that it's got a constructor that creates a new identity, but takes no args.
14:16rhickeythus the promise notion
14:16rhickeysomeone else is going to complete the construction
14:17dnolencurious are there particularly good use cases for dataflow vars, never used anything like them before.
14:17Chouserwhat does the I in Haskell's IVar stand for?
14:17rhickeyimmutable
14:17Chouserahhh
14:18rhickeyfrom Id I-vars
14:18cemerickactually, hiredman mentioned 'worm', which doesn't seem so bad (accurate and unambiguous, anyway)
14:19rhickeyI'm not putting a worm in my language
14:19technomancyspit/slurp is bad enough, eh? =)
14:19rhickeyvar1 once
14:20hiredmanI like promise
14:20cemerick+1 promise, compared to the other options
14:21Chouseris this really the only thing we're ever going to want to promise?
14:21Chouserthat's also a word that's used somewhat coloquially when talking about the api.
14:22Chouserhash-maps return integer keys in order, but that's not a promise.
14:22Chouseron the other hand, it's not nearly as bad as the two meanings of map, so maybe we're ok.
14:22rhickeypvar
14:22Chouservar-once
14:23rhickeysince if you are reading another thread better be writing
14:23rhickey:)
14:24ChouserI don't like the re-use of "var" (in my last suggestiong either)
14:25Chousermaybe "var" can be renamed. :-)
14:25replacaspeaking of futures and pvars, is there any way to tell if a future has a value other than waiting for it? I'd liek to be able to look at the value if it's there but go off and do something else if it's not ready yet
14:25replaca*LIKE
14:26Chouser(.isDone f)
14:26rhickeyreplaca: future-done? will go in with this checkin
14:27rhickeyright now setting the promise/pvar/whatever is a fn call, but I'd like to encapsulate that, maybe if we name that we'll get some clues
14:28cemerickjail/capture?
14:28rhickey(put pv 42)
14:28hiredmanisn't pvar that parallel var thing?
14:28hiredmanah, pvalues
14:30Chouseryou deliver on a promise, don't you?
14:30hiredmanooo
14:31Chouseror fulfill
14:32Chouserpromise-val, deliver-val!
14:32Chouser:-/
14:33rhickey(def p (put))
14:33rhickey(put p 42)
14:34ChouserI like the namespace conservation, but that might be a tad confusing.
14:34rhickeyI wish it had a more meaningful connection to put options, where the noun/verd thing works
14:36Chouserthese won't allow validators?
14:36rhickeyno
14:36Chouserwhat about watchers. ;-)
14:37rhickeythese are supposed to be fairly primitive things
14:37rhickeythe first Clojure workflow constructs
14:40gnuvinceAre some of you going to participate in this year's ICFP contest?
14:41rhickeygnuvince: would be fun, don't know about my availability yet
14:53rhickeyvariable ?
14:54replacarhickey: oops, wandered off. Thanks!
14:55rhickey(def b (unbound))
14:55rhickey(bind b 42)
14:55rhickeybindable
14:55replacaChouser: I was just reading a post where you were railing against undocumented interfaces and now you're recommending one to me. :-)
14:57Chouserreplaca: :-) :-)
14:57hiredmanbind doesn't suggest blocking
14:57rhickeybind doesn't block
14:58Chouser(def b (will-bind)) (bind b 42)
14:58hiredmanfine
14:58rhickeypending
14:58Chouserhm!
14:58cemerickooh, I just thought of pending too :-)
14:58gnuvinceAnother ref type?
14:58Chouser(def b (pending)) (pend b 42) ?
14:59rhickeygnuvince: not really, in that refs are really for state, these are one-shots
14:59cemerick(def b (pending)) (complete b 42) ?
14:59zargon_hmm, whats the difference between :while / :when modifier in for loops?
14:59gnuvincerhickey: what's the use case scenario?
14:59hiredman:while is like take-while :when is like filter
14:59cemerickpending/deliver, pending/fulfill
15:00zargon_hiredman: thx
15:00cemerickrhickey: doesn't that guarantee confusion given binding (totally different concepts, but I guess that's my point)
15:00rhickeygnuvince: plenty, you can build whole workflow systems out of things like this - see Mozart/Oz
15:00rhickeycemerick: yes, just riffing
15:01ChouserI like pending -- seems more specific than promise
15:01Chouserprovide? put? fulfill?
15:01rhickeypending/fill
15:02replacarhickey: i like pending/fill!
15:02zargon_,(for [x (range 3) y (range 3) :while (< y x)] [x y])
15:02clojurebot([1 0] [2 0] [2 1])
15:03zargon_hmm, why is that? shouldn't that be empty?
15:03zargon_it should stop immediately in the first iteration ...?
15:04Chouser:while applies to the level of the loop it appears after
15:04zargon_ahhh!
15:04zargon_there's much more behind for than the docs suggest ...
15:05rhickeyChouser: no, while should be an abort as soon as false
15:05zargon_huh?
15:06Chouserit aborts y in that example, but not x
15:06rhickeyhrm
15:06rhickeyhow could one bail overall then?
15:07bhurtStupid question of the day: if I pass nil into a java function, does it become null?
15:07Chouserbhurt: yes, nil is null
15:07bhurtThanks.
15:09Chouserrhickey: well, you can put a :while on x as well, but of course you wouldn't be able to examine y there.
15:30rhickeyChouser: yeah, I guess that's how it's always been: http://groups.google.com/group/clojure/browse_frm/thread/34724b7b13b3e2ed/6f4ed88d53f12423?#6f4ed88d53f12423
15:31rhickeydo we need :bail ?
15:31ChouserI don't think I've needed it, but that's probably not saying much.
15:33grammati:break-if ?
15:37rhickeyvoid/fill ?
15:38Chouserheh
15:38Chouserpending/supply?
15:38Chouserpending/unpend?
15:38Chouserpending/depend?
15:39rhickeypending is not growing on me, I kept forgetting it, and it's not a noun, unless we start calling these things pendings - ick
15:42rhickeypromise/fill or promise/deliver work - lots of people misspell fulfill
15:42zargon_rhickey: would you mind to add a clarifying statement to the api docs on "for"?
15:43rhickeyzargon_: seems to need it
15:43zargon_thx
15:48rhickeypend/fill ?
15:48Chousernot bad. you're ok calling them "pends"?
15:49rhickeyI don;t know
15:49hiredmana pend is a hallway
15:49Chouserpromise/fill isn't too bad either
15:51grammatiI missed most of the conversation and don't really know what you're talking about, but... how about a "deferred"? (as in twisted)
15:51rhickeypendent
15:52rhickeyalso pendant
15:55wlrdefer/complete
15:55cemerickthat's not bad
15:56rhickeydefer syn/delay
15:56rhickeywe're not supplying the work at construction
15:57rhickeypending/pendent is the right notion
15:57cemericktrap/fill?
15:58j-dotpendent/settle?
15:59gnuvincesuspension/DISBELIEF! ?
15:59kefkaIf I'm doing lots (multi-MB) of binary I/O for IPC and mostly RPC, what resources (Clojure libraries, Java classes) are the fastest?
15:59cemerickgnuvince: :-D
15:59gnuvinceIf I understand correctly, we're looking for a noun/verb pair?
15:59rhickeygnuvince: constructor/setter
16:00gnuvinceI got all these stupid ieads :-/
16:00gnuvinceraincheck/cash-in
16:00gnuvincerhickey: you got a thesaurus handy?
16:01gnuvinceYou could look up synonyms for "suspension" or something like that
16:01rhickeydon't we all? http://thesaurus.reference.com/
16:01Chouserwait, are you on the *internet*!?!
16:01cemerickget out of the house! They're in the tubes!
16:02j-dotobligation/deliver, obligation/oblige?
16:02gnuvince,defer
16:02clojurebotjava.lang.Exception: Unable to resolve symbol: defer in this context
16:02grammatiunbound/bind
16:03gnuvinceoh wait, not a noun :-/
16:03Chouser,(doc delay)
16:03clojurebot"([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force), and will cache the result and return it on all subsequent force calls."
16:03kotarakthe eternal struggle for good names?
16:03gnuvincepostponement?
16:05kefkaNote on the above: can't use duck-streams (I don't think) because this is binary, not character data.
16:07rhickeyneed/fill
16:08rhickeyif our programs have needs they'll be that much closer to consciousness, AI here we come!
16:09hiredman~need
16:09clojurebotthe world <reply>what the world needs is more higher order functions
16:09gnuvincewe should have a wiki for those kind of things...
16:11rhickeydemand/supply - did someone say that/
16:11rhickey?
16:11wlrannounce/deliver
16:12hiredmandebit/credit
16:13gnuvince,promise
16:13clojurebotjava.lang.Exception: Unable to resolve symbol: promise in this context
16:14gnuvincepromise/deliver?
16:14gnuvincerhickey: the constructor will not actually fill in a value, that'll happen with the setter (once), right?
16:14rhickeygnuvince: right, it's a no-arg ctor
16:15gnuvincedig/fill?
16:15rhickeythus the preference for a noun that can also be used to refer to these constructs - that's why promise is good
16:16gnuvinceWhat I slightly dislike about promise is that I think I've seen it used in other languages to delay a value and force it later.
16:16gnuvinceThat might be in SICP
16:17rhickeypend[ing] is nice because it hints at the blocking that will occur of you read before filled
16:17gnuvincepending I liked
16:17gnuvinceBut you said it was growing on you :-/
16:18rhickeywasn't
16:18gnuvinceright
16:18gnuvincesorry
16:19kotarakimagine/realize
16:20rhickeyfirst word noun is best
16:23gnuvinceHow do you feel about "raincheck" for the constructor?
16:23rhickeynot too good
16:23rhickey:)
16:23gnuvinceNo problem :)
16:24gnuvinceJust surfing on thesaurus.com
16:25gnuvincepledge?
16:25rhickeypromise/deliver seems decent
16:26rhickeyof course. in langs where these are primitives it just looks like variable declaration and assignment :(
16:30Chouserinteresting that import is a macro
16:30Chouser...when require and use are not
16:30kotarakThis changed lately, no?
16:30Chouserkotarak: oh, perhaps you're right.
16:31Chouserindeed. import is a fn in 1.0
16:31Chouserkotarak: thanks
16:31rhickeyChouser: require and use should be, but there will be some breakage because they are called by Java host programs. Will need fn versions too, that take classLoader arg
16:32rhickeythis to enable use of caller's classloader
16:32Chouserok, that'll be nice.
16:36rzoomwhy does this work: (Float. ({:a "3"} :a))
16:36rzoomand not this: (float ({:a "3"} :a))
16:36Chouserrzoom: float is a simple type case.
16:37Chouserrzoom: (Float. x) call the object constructor
16:37rhickeylast call - any objections to promise/deliver?
16:37ChouserThe Float class has a constructor that takes a string.
16:37duncanmhow do i take the last 5 elements of a seq?
16:37duncanmthere's no TAKE-LAST
16:38rhickey,(doc butlast)
16:38clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
16:38kotarak(drop (- (count the-seq) 5) the-seq)
16:38rhickeyoh, 5
16:39kotarakBeware of (iterate inc 0)....
16:39hiredmanheh
16:39duncanmif drop takes a negative number, i guess that works too
16:40duncanmoh wait
16:40duncanmi get it
16:41duncanmit might be handy to have TAKE-LAST
16:41Chouserlast could take an optional count arg
16:42duncanmright
16:42kotarak(defn take-last [n s] (drop (max (- (count s) n) 0) s))
16:42rhickeyChouser's idea is best, add n arg to last
16:42Chouser(reverse (take 5 (reverse x)))
16:43hiredmanick
16:43rhickeyow!
16:43Chouser:-)
16:43hiredmanit seems like a lazy-seq and a N element ring buffer might be best
16:44Chousercan't be done lazily
16:44kotarakBecause it's not a stopping time.
16:45hiredmanoh
16:45hiredmanright
16:45hiredmanto put things in the buffer you would have to realize them, of course
16:47rhickeyoh no, canceled/cancelled - Futures use double L
16:48rzoomcan classes be passed as function arguments? e.g. (defn f [t v] (new t v)) to create an instance of type t, using v as the arg to the constructor.
16:48rzoomthis is not making clj happy
16:49Chouserrzoom: a class can be passed, but you cannot just call new on it then.
16:49Chouseryou'd need to call a method of the Class class, like (.newInstance t)
16:52Chouseror something like: (clojure.lang.Reflector/invokeConstructor Integer (to-array ["5"]))
16:54rzoomlooks like there is no way around that Reflector call, i guesss.
16:55Chouserthere are a couple techniques that might help, depending on your situation.
16:55ChouserSometimes I've been able to pass around a clojure fn that will construct the object, rather than the class itself.
16:56rzoombasically, i am just looking for a easy way to convert strings to various basic java types
16:56hiredmanerm
16:56hiredmaneasiest is read-string
16:57Chouserthat's even slower than the reflector call. :-)
16:57rzoomwell, taking a map as an arg
16:57Chouserbut nice and general.
16:57Chouserrzoom: a map of?
16:58rzoome.g. {:a "3.5", :b "7"} would like to be able to convert :a value to float, and :b value to int
16:58Chouserrzoom: how do you decide what type to convert to?
16:59rzoomi can hard-code that
16:59rzoomall :a's are going to be floats, all :b's ints, etc.
16:59Chouser{:a (Float. (:a mymap)), :b (Integer. (:b mymap))}
17:00rzoomso, i thought about a function to take a value and a type and return the converted value, then assoc new value
17:01hiredman(update-in map [:a] #(Float. %))
17:01hiredman,(-> {:a "3.5", :b "7"} (update-in [:a] #(Float. %)) (update-in [:b] #(Integer. %)))
17:01clojurebot{:a 3.5, :b 7}
17:01kotarakFloat. not problematic? I though there was some Float/parseFloat or something, which was preferred.
17:02rzoomhiredman: that is pretty good.
17:04kotarak(w/o in)
17:05Chouser,(into {} (for [[k v] {:a "3.5", :b "7"}] [k (({:a #(Float. %), :b #(Integer. %)} k) v)]))
17:05clojurebot{:b 7, :a 3.5}
17:06rzoomhmmmm. i guess that the best way to pass a class is just to do the Reflector call
17:06rzoomthe trouble being that there are a lot of keys, so being able to pass a list of keys to convert would be prettier.
17:07ChouserIf all you're using the class for is to construct it, I'd recommend looking at passing around clojure fns instead, as both hiredman and I demonstrated.
17:07hiredmanmake a multimethod
17:07rzoomyeah, that is probably a good idea, will go with fn passing.
17:07ChouserThat lets you use a static factory method instead, or constructor, or whatever. Plus it'll run faster that the reflector call.
17:07Chouserthan
17:09hiredmanyou can make a multimethod that dispatches on (fn [[a]] a) and map it over your map and then pour the resulting seq back into a map with into
17:16replacarhickey: so where do contrib commits go now? github, svn, please wait, or other?
17:16Chouserwhere 'last' is defined in core.clj, there's no math yet. 'dec' isn't defined.
17:18kotarakSo was git chosen?
17:21replacakotarak: seems like we're almost there, if not quite. Last I heard, it was all still "experimental"
17:22kotarakreplaca: well, I hoped for hg, but with hg-git it will hopefully work...
17:33replacakotarak: yeah, I didn't have much opinion, but I'm used to git so it's pretty good by me (one less thing to learn :-)). I've tried git on windows (a little) this week and it seems to be not too bad
17:35kotarakreplaca: I don't really care, I prefer hg mostly for philosophical reasons. I don't think there is much difference. hg or git don't buy each other much. And with hg-git by the github guys there's a bridge between the worlds. :)
17:36technomancykotarak: yeah, nice timing on that.
17:38bhurtHaving worked with both git and hg now, I think git is somewhat better for open source style development, but hg is better for a more centralized/corporate environment.
17:38bhurtI HATE HATE HATE bazaar.
18:09rhickeyfirst commit to github! http://github.com/richhickey/clojure/tree/master
18:11liebkewoot! I saw the tweet :)
18:11rhickeyjust need to coordinate the move for contrib - any contribbers on?
18:15rhickeyhrm, I can't admin the clojure-contrib on github until I've imported the repo? I'd like to add collaborators who could help with that...
18:16technomancyyou can create a blank repo and push to it after the fact.
18:16rhickeyI want to use their svn import, a one-time thing
18:16technomancyoh, server-side import, right. I don't know about that.
18:17rhickeyah, direct url works
18:23arohneris it possible to call apply on a java method?
18:23arohneri.e. (apply .foo instance args)?
18:24rhickeyarohner: no, Java methods are not proper functions
18:24kotarakarohner: http://paste.lisp.org/display/67182 by rhickey
18:25arohnerexcellent! thanks
18:27replacarhickey: my idea about how to freeze: just tell us to stop for a day or so. Stephen and Stuart S. have been the big committers the last week or so.
18:29replacabbl
19:37mrsolohttp://paste.lisp.org/display/81782 any better way to do this? I found out that assoc is the only way to retain original comparator for sortedhash
19:38Chousukemrsolo: wouldn't (into cur-result (...)) work?
19:39mrsolono
19:39mrsolowill it?
19:39mrsolohmm
19:39mrsololet me try
19:39mrsoloi was doing (into {}
19:40kotarakand (apply assoc cur-result ...), partial is not needed
19:42mrsolochousuke: oh yea it works thanks :-)
19:42mrsolokotarak: you right...nice to know
19:43kotarakalso nice idiom: (into (empty foo) ...)
19:43Chousukeyeah. preserves the type
19:44kotarakmrsolo: well you do it in your anon fn: (apply generate-tree (second x) more)
19:44mrsolohttp://paste.lisp.org/display/81783 alternative form,
19:45mrsolokotarak: ya my concept isn't that strong yet..need reiforcements :-)
19:45mrsolonice empty is very handy
19:58mrsoloack empty doesn't peserve comparator
19:59mrsolohttp://paste.lisp.org/display/81786
20:18Chousermrsolo: that's a sorted map?
20:19Chousersorted-map-by?
20:20Chousersure enough. probably counts as a bug.
20:22mrsoloya sorted map
20:51JAS4151I'm not sure how to word my question, but I made a 'stateful' generator in clojure using lazy sequences and atoms to calculate the Fibonacci sequence, (here http://paste.lisp.org/display/81789#1 ... the fib-seq function... don't execute int he repl as it will just go on forever and crash clojure... use with take-n or something), is there an easier way to do this in Clojure? I know that in Common Lisp I would use variable capture instead of usi
20:54stuhoodthere is a definitely an easier
20:54stuhoodway
20:56JAS4151cool
20:56stuhoodcheck out the functions "lazy-seq-fibo" and "fibo" from the Programming Clojure example code: http://github.com/stuarthalloway/programming-clojure/blob/cb0944e31490c0198a1ad2761b08a379fa73f480/examples/functional.clj
20:58JAS4151ok thanks, i'll look over these
21:00JAS4151ah so clojure works like erlang and you can match against number of arguments?
21:00JAS4151that's cool
21:04stuhoodyea... pretty handy
21:05stuhoodyou can also do destructuring in function arguments, which is similar to pattern matching, but not quite as powerful
21:10JAS4151i was reading about that, looks like it might be more useful than destructing-bind in common lisp
21:55Chouser__I cloned the clojure git repo, but it doesn't seem to have any branches in it. What did I do wrong?
21:57arbschtother than master, you mean?
21:59Chouser__yeah
21:59Chouser__I want 1.0 as well
21:59arbschttry git branch -a
21:59arbschtyou should be able to checkout 1.0 from origin
22:00Chouser__gah
22:00Chouser__yes, that did it, thanks.
22:00Chouser__I thought just "git branch" would show them all.
22:01arbschtthat shows local branches only
22:01arbschtmake a local tracking branch if you want to modify 1.0
22:01arbschtgit checkout -b clojure-1.0 origin/clojure-1.0
22:01Chouser__wow. Guess I need to read up more on git.
22:02Chouser__my git-svn habits aren't sufficient. :-)
22:02arbschtheh :)
22:49gstampIs there a function for replacing the nth element of a collection?
22:58gnuvince_(doc update-in)
22:58clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
22:58gnuvince_,(update-in [1,2,3] [0] inc)
22:58clojurebot[2 2 3]
22:58gnuvince_,(update-in [1,2,3] [0] (fn [] 17))
22:58clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--2656$fn
22:58gnuvince_,(update-in [1,2,3] [0] (fn [_] 17))
22:58clojurebot[17 2 3]
22:59gnuvince_Not terribly sexy I'm afraid
22:59gstampyeah... should do the job. i'll wrap the non sexyness in a method to hide it.
22:59gstampthanks
23:00gnuvince_happy to ablige
23:02cark,(assoc [0 1 2] 1 :a)
23:02clojurebot[0 :a 2]
23:06gstampthat's nicer. Neither seems to work for sequences though
23:06gstamplists rather
23:07carkrhikey doesn't like to provide core function doing the work in O(n)
23:07carkmaybe check seq-utils ?
23:08gstampi'll check it out
23:08hiredman,(let [a '(1 2 3)] (concat (take 1 a) [4] (drop 2 a)))
23:08clojurebot(1 4 3)
23:09carkthat's ugly too =P
23:10hiredmanit's lazy
23:11gstampi should probably just ensure I'm always working with a vector
23:11carkyes, use the right data structure for the job