#clojure logs

2009-12-10

00:00hiredmanmaybe the equiv of java blocks, whatever those are at the bytecode level
00:00alexykthe outer map is guaranteed to contain inner maps which have only one key-value pair
00:01alexykum, or not
00:03hiredman,(.replace #"\." "foo.bar" "/")
00:03clojurebotjava.lang.IllegalArgumentException: No matching method found: replace for class java.util.regex.Pattern
00:04twbrayHey, is there a Gary W. Johnson around here? He submitted a cool comment on my blog but I tried to get too cute and b0rked it.
00:04cp2,(.replaceAll "foo.bar" "\\." "/")
00:04clojurebot"foo/bar"
00:05hiredmancp2: I know
00:06hiredmanI just checking Pattern
00:07cp2i figured, but im just in such a helpful mood
00:07hiredman:)
00:07cp2well thats a lie, its more of im bored
00:09arohnerif I have a map, and I want to swap the keys and values, that's called the inverse, right?
00:09arohnermathematically speaking
00:10hiredman,(doc clojure.set/map-invert)
00:10clojurebot"([m]); Returns the map with the vals mapped to the keys."
00:10arohneroh, nice
00:10arohnerI searched for inverse, not invert
00:10arohnerthanks
00:10hiredmanweird that it's over in set
00:10hiredmanarohner: incremental search++
00:11arohnerincremental search on the API page?
00:11arohnerI just did (find-doc "inverse")
00:12hiredmanah
00:12hiredmanyeah, I was on the api page in firefox
00:12hiredmantyping incremental very slowly
00:12hiredmaner
00:13hiredmaninverse
00:14defncrap -- i accidentally committed all of my damn .jar files, is there any way to get rid of them in the current commit so i dont have to push them?
00:14arohnermake your changes, then git commit --amend
00:15arohnerit will squash the new commit into the old commit
00:15arohnerbut it's not a good idea to do that if you've already pushed
00:17defnwow wtf, .gitignore is not properly ignoring my .jar files
00:18defni have *.jar ..jar and lib/*.jar in .gitignore
00:18dakronehmm..is there a repository for misc clojure libraries anywhere?
00:18defngithub
00:18dakronebesides clojars, I mean something sort of like 'gem search <foo>'
00:19defnnah, nothing besides that that i'm aware of
00:19defnbut that's a cool idea
00:19dakroneI wrote a library and published it on clojars, but other than that is there anywhere else new libraries are announced?
00:19defndisclojure
00:19defntwitter #clojure
00:20dakroneokay, did that also
00:20defnas long as you're talking about it
00:20defnwhat's your library? :)
00:21dakronehttp://writequit.org/blog/?p=332
00:23hiredmangoto's and labels in a stack language is just weird
00:24cp2not to mention ugly
00:24cp2and potentially hazardous :)
00:25hiredmanI am adding stack comments so I can keep track of what is on there, this could get complicated
00:28defndakrone: cool
00:29defnim working on http://github.com/defn/cljex right now
00:30dakronedefn: looks very useful, looking forward to it
00:30defnnothing fancy, it's just going to be a simple compojure + markdown w/ pygments syntax hilighting
00:30cp2interesting
00:30defnno need to drag your feet, fork it and start writing examples :)
00:31dakroneheh
00:31defnlots of low hanging fruit yet :)
00:31dakronehave you thought about copying some of the examples from http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples ?
00:31defnyep, i talked to timothypratley1 about it
00:31defnthat's in the plan
00:32dakronecool, I find that very useful
00:32defneventually id like to make the examples tagged
00:32defnso you can click on something like "bit-twiddling" and get a list of all the forms that involve bit-* etc.
00:33defnit's really nice for new people to the language to have some sort of real world example of how to use a form, especially for non lispers
00:33dakroneyea, it'd be nice to have multiple examples for each API function, a simply one leading up to a more complex one
00:33defni found a lot of the terse API documentation where it says something like ([s idx coll]) to be daunting
00:34defnyeah exactly, i was thinking something along those lines, but i mean, as it stands right now, it's just a markdown document with syntax hilighting builtin
00:34defnso you can add whatever you want for the form, link to stuff, etc.
00:34technomancychouser: did I hear you decided on a title?
00:35defni just put up that example form as a rough guide to how they should in their most basic form be setup
00:42alexykhow do I turn a map, {:a {:b [1 2 3] :c [5 6]} :b {:c [7] :d [9 10]}} into a seq: [[[:a :b] [1 2 3]] [[:a :c] [5 6]] [[:b :c] [7]] [[:b :d] [9 10]]] ?
00:43alexyki.e. path to leaves becomes the first element of the tuple, leaf the second, the whole map unrolled into a seq
00:43hiredmanvery carefully
00:44alexykhiredman: what's the basic zipper function?
00:44somnium,(use 'clojure.walk)
00:44clojurebotnil
00:44hiredmanclojure.zip has the zipper stuff
00:45alexykhow do I see what's in clojure.zip or clojure.walk?
00:47replacaalexyk: look at the clojure API docs
00:47alexykkk
00:48replacayou might want to look at heut's "functional pearl" about zippers too, to see what they are cause the doc strings aren't too helpful.
00:49hiredmanyou can always take a look at the source
01:13replacawith the huet paper in hand, the source is really clear
01:16hiredmanif you can read haskell
01:16defnhey hiredman i think i asked this earlier maybe, but how do you get emacs to auto-indent on return in clojure-mode?
01:17technomancydefn: (define-key lisp-mode-shared-map (kbd "RET") 'reindent-then-newline-and-indent)
01:17technomancybonus: works in elisp, scheme, etc
01:17defnawesome, thanks
01:19technomancydefn: tempted to make that the default binding in clojure-mode actually
01:20defntechnomancy: that makes good sense to me
01:20technomancyit's unconventional, but there are times to break the mold. =)
01:21defnif anyone gets upset about it, politely remind them there are comments, and that they can comment that piece out
01:21defnbtw i think it was one of your repos that linked to the lisp style guide
01:22defni was going to ask you about compojure, specifically using html and html-tree
01:23replacahiredman: the huet paper is actually OCaml (which I don't know), but when I combined it with Rich's implementation it all seemed pretty clear
01:23defnin some cases you wind up with code like: [:html [:head [:title "foo"]] [:body [:h1 "bar"] [:p "Hello baz."]]]
01:23hiredmanreplaca: really, I could have sworn
01:23replacatechnomancy: I would vote yes to that
01:24defnwhat's weird is that we're representing this DSL with clojure, so it seems like indenting and treating closing ]'s as we would XHTML makes sense
01:24defnbut i wonder what the lisp style guide's view on such a thing would be
01:24technomancyreplaca: that makes three of us. done.
01:25replacathree stooges carry the day :-)
01:25technomancydefn: well in HTML it's more than a single char
01:25technomancyso grouping them together is hard to read
01:25replaca(or maybe three musketeers)
01:25technomancyplus there's no paredit for html
01:25technomancy(yet... I guess. (!))
01:25defnhaha you love your paredit
01:25replaca+1e9 for paredit
01:26technomancydefn: well, that is to say it's far easier to make your editor smart about parens than about closing XML tags
01:26defni was editing for awhile without paredit, i actually am kind of freaked out now when i get an automatic paren, or i have to type the close paren to move forward
01:26defntechnomancy: i think HTML5 will make it easier to do things like that
01:26defn(maybe)
01:27defnsome of the new tags seem like you'd be able to infer at which point it ought to close based on the structure of the document
01:27defn(assuming it's good valid html5)
01:27tomojthat's still harder than parens
01:27defnheh, no argument from me there
01:27defnjust thinking out loud
01:27tomojI don't like the indenting you get with that style html
01:28technomancyconsidering nxml is a full XML parser, I think someone will eventually implement it, but that's beside the point. =)
01:28tomoj[:html
01:28tomoj [:head
01:28tomoj [:title "Foo"]]]
01:28replacatomoj: that's how i'd do it
01:28tomojguess it's not so bad, but I'd prefer the two spaces you get with (
01:29defnwhat about
01:29defn [:title "Foo"]
01:29defn ]
01:29defn]
01:29replacadefn: ugh!
01:29technomancydefn: since each closing bracket is interchangable with another it's very different from closing XML
01:29defni cringe a little bit, but i also see that being a more manageable syntax for larger nested stretches
01:30meeam I the only one that thinks building html like this is a terrible idea? What happens when you need actually complicated html?
01:30defntechnomancy: that's a fair argument
01:30tomojmee: I don't like it much either
01:30defnbut at a certain point i think you hit a maximum # of ['s and ]'s where it becomes not just preferred, but advantageous to the way i demonstrated above
01:31defnadvantageous to use the way*
01:31replacamee: in general I prefer doing things with a templating engine (like enlive) that lets you write HTML directly and just inject the dynamic parts
01:31technomancydefn: you'll have to explain the advantages in more detail; I don't think anyone else is seeing it. =)
01:31replacabut I think that's a matter of taste
01:32defntechnomancy: let's assume you have a deeply nested structure of ['s and ]'s
01:32defnlet's say, a 150 line def x, which is some massive (html [:html...) structure
01:33defni think at a certain point, even with paredit, just the way you can scan chunks more efficiently if you have the lone ]'s to give you some sort of idea of where contexts switch at a glance
01:35replacadefn: you sound like a C guy basing python :-)
01:35replaca*bashin
01:35replaca*bashing
01:35defni guess i just believe that when it comes to HTML, as far as how ive always read and understood it, i always tended to see it as a sort of structure, like a real physical structure, rather than an abstract machine
01:37defni always sort of saw the levels as being like floating planes, one above another, floating on the same layer, etc. to me the sort of structure that XHTML always seemed pretty spot on
01:38defnbleh, the structure of XHTML always seemed spot on
01:39defni hate the <a></a> stuff, but for the thing it is describing, namely a web page, it always seemed like the right way to go, so i struggle a little bit with that decision in compojure
01:40tomojwell, no need to struggle
01:40tomojyou can write your html in html if you like :)
01:47somnium,(-> [:p "foo" :p] butlast vec)
01:47clojurebot[:p "foo"]
01:48somniumdefn: you could always write a macro that lets you close the tags :P
01:52alexykhow do you join two seqs?
01:52hiredmanclojurebot: how do you join two seqs?
01:52clojurebotYou will not become skynet
01:52hiredmanbah
01:52hiredmanclojurebot: how do I join two seqs?
01:52clojurebotwith style and grace
01:52hiredmanconcat
01:52hiredman,(concat [1] [2])
01:52clojurebot(1 2)
01:53alexykthx!
01:53defntomoj: sure i can, what im trying to explain and/or see if there is any sympathy for, is whether or not when writing code in any language that will in the end behave like a different language, it is acceptable to break convention for readability
01:53defnit seems like a fuzzy topic
01:54defnif it is acceptable*
01:54tomojI have no sympathy
01:55tomojbut I won't come arrest you
01:55defnin other words, does it make more sense to write html using clojure that looks like html, or should it look like clojure
01:56alexykbtw, here's the transform I needed: (reduce (fn [r0 [from repliers]] (concat r0 (reduce (fn [r1 [to dates]] (conj r1 [[from to] dates])) [] repliers))) [] {:a {:b [1 2 3], :c [5 6]}, :b {:c [7], :d [9 10]}})) => ([[:a :b] [1 2 3]] [[:a :c] [5 6]] [[:b :c] [7]] [[:b :d] [9 10]]); improvements welcome!
01:58alexykbtw compared to scala, almost gibberish. Scala looks like: coll.foldLeft(init)(fun)
01:58defn{:a {:b [1 2 3] :c [5 6]} :b {:c [7] :d [9 10]}} into a seq: [[[:a :b] [1 2 3]] [[:a :c] [5 6]] [[:b :c] [7]] [[:b :d] [9 10]]] was what you started with, yes?
01:59alexykI need that transform, yes
01:59tomojis it always two levels?
01:59alexyknested map with leaves into path and leaf tuple. always two levels, yes
02:00replacaalexyk: why can't you write it the same in Clojure? Can't you just write foldLeft?
02:00alexykreplaca: foldLeft is called reduce in Clojure
02:00defn:)
02:01defnclojure is missing the foldr iirc
02:01defnbut it's easy to write
02:02somniumalexyk: what is 'fun in your scala example?
02:02alexyksomnium: fun is the nested foldLeft. I'm just saying it's visually shifted into suffix positions and easier to parse. I had a bitch of a time with ))) [] in the middle
02:02alexykcounting blinkin' )'s
02:04replacaalexyk: that's right -> I'm tired and forgetting my haskell :-)
02:05replacaalexyk: yeah, I'd break up something that complex
02:05alexyknewlines are for babies
02:05replacawaah!
02:06alexykone-liners can be pasted into IRC easiy :)
02:06alexykthat's why we have sexps in the first place -- to avoid paste
02:09defnalexyk: did you think about using (get-in)?
02:09alexykdefn: first time hearing of it!
02:10defni think it might save you some space
02:10tomojalexyk: (apply concat (for [[k1 v1] m] (for [[k2 v2] v1] [[k1 k2] v2])))
02:10defn,(def k {:a {:b [1 2 3] :c [5 6]} :b {:c [7] :d [9 10]}}
02:10clojurebotEOF while reading
02:10defn,(def k {:a {:b [1 2 3] :c [5 6]} :b {:c [7] :d [9 10]}})
02:10clojurebotDENIED
02:10defndamn
02:11alexykclojurebot: why can't we def globals?
02:11clojurebothttp://clojure.org/rationale
02:11alexyk,ohshutup
02:11clojurebotjava.lang.Exception: Unable to resolve symbol: ohshutup in this context
02:11defn(get-in k [:a :b]) => [1 2 3]
02:12alexykdefn: looks like useful for random access, but for a whole sweep less efficient (descends all over)
02:13defnyeah, i thought it might work if you were always going like [:a :b] [:a c] [:b :c] [:b :d]
02:13alexyktomoj: what do I do with the (apply concat...) form above?
02:13defnerr rather, that's kind of a pattern i saw by using (get-in)
02:13defnwhich seemed curious
02:13tomojalexyk: (def alex [m] (apply concat ...))
02:13tomoj(alex {:a {:b ...]])
02:14alexykhmm...
02:15alexykyou mean defn. wow!
02:15tomojoh, yeah
02:15alexykPalm d'Or goes to tomoj! nice
02:16tomoj'course naming the variables sensibly might help its readability
02:16alexykyeah, clearer than the reduces
02:18defn(def alex [m] (apply concat (for [[k1 v1] m] (for [[k2 v2] v1] [[k1 k2] v2]))))
02:18defnis that what you're saying?
02:19alexykdefn: s/def/yournick/ :)
02:19defnoh the irony
02:19alexyksorry couldn't help it
02:19defndamn that is nice tomoj
02:19alexykbtw this is a graph transform, from adjacency lists to triples
02:19defnwhat are adjacency lists and triples?
02:19defn*(wikipedia articles graciously accepted)
02:20alexykgraph representations
02:20alexykhttp://en.wikipedia.org/wiki/Adjacency_list
02:20defnahhhh
02:21defnso that's where i was getting the a ajd b,c -- b ajd a,c -- c adj a,c
02:21defnc ajd a,b
02:22alexykyep. And for triples we just zip followers with head into pairs. If edges are labeled, then it's triples, with the edge weight.
02:23defnwhat is the edge weight?
02:24alexykit's any label on an edge. E.g. bandwidth, timestamp -- whatever your relationship represents in the graph by an edge, if it's quantitative.
02:24defnah ok
02:25alexykok, sleepy time... cya'll tmrw!
02:26ordnungswidrigaloha
02:32ordnungswidrigdoes anybody know of work on the topic of update of persistent data structures? especially for business models in pers. ds?
02:40tomojhuh?
02:40defncould you be more specific about "business models" and "update of persistent data structures"
02:41defn?
02:44adityo~max people
02:44clojurebotmax people is 240
02:44twbrayI hear persistent data structures were up on Wall St. today.
02:44adityoany links
02:48AndChat|most work i found is about simple ds like tries, hashtables etc. the update semantic for them is clear to me: you get a updated 'copy' of the hashtable.
02:51ordnungswidrigbrb: have to switch trains
02:54ordnungswidrigre
02:55ordnungswidrigif you model some business objects with persistent ds then the deep update of an object has no clear semantic to me.
02:57ordnungswidrigsay, you have customer->order->shippingaddress and you do an update on the address. what will the update return? a shippingadress, an order, a customer or a some reference to a 'world' object?
03:00somnium,(update-in {:a {:b {:c 1}}} [:a :b :c] inc)
03:00clojurebot{:a {:b {:c 2}}}
03:01somniumif its in a ref/atom/agent then its also persistent
03:02ordnungswidrigsomnium: so you basically treat the whole world as an opaque ds which is updated.
03:02ordnungswidrigi wonder how that can scale regard model size and concurrent modifiers
03:03cp2zzzz
03:04somniumnot the whole world, however you choose to make it discrete
03:06tomojif you have the whole world in a single reference type concurrent writers that might not really conflict with each other (i.e. they're working on separate unrelated parts of the world) will have to fight
03:19mcodik /quit
03:24ordnungswidrigre
03:25ordnungswidrigso, finished juggling with the clients
03:36tomoj`does this sound evil to you? a macro unhygienically defonce's a var holding an atom into the using namespace and each use of the macro swap!s the atom. later, another macro is called from the using namespace which takes the value of the atom and sends it off to the internets
03:36tomoj`sounds evil to me :(
03:38tomojnow that I say this out loud the solution is obvious.. just let the users pick what atom to use
03:38ordnungswidrigsomnium: still there?
03:42somniumordnungswidrig: pong
03:43ordnungswidrigsomnium: we left at the question what is the "scope" of an update in a persistent datastructur.
03:45somniumordnungswidrig: have you watched rich's talks on state and identity?
03:46ordnungswidrigsomnium: yes, and I think I understand it.
03:48ordnungswidrighowever in a business object model I find the concept of identify not clear for a business model. at last it is not unambigous.
03:50ordnungswidrigSay, you have customer1->order1->item and customer2->order2->item now what shall be semantic when I change item? Item has in a sense two identities which can be told apart by the path it it.
03:50ordnungswidrigs/it it/to it/
03:50hiredmanwhy does a customer contain an order?
03:50carkwouldn't your object reside in a database in a business setting ?
03:51ordnungswidrighiredman: just an example
03:51hiredmanwell, for example, stop nesting stuff
03:51ordnungswidrigcark: can be
03:51ordnungswidrighiredman: but the stuff in the world is nested, isn't it?
03:51hiredmannope
03:52ordnungswidrighiredman: so you would cut the graph and reference by an uri?
03:52hiredmansure
03:52carki used to think hard about this, but for real programs it never bit me
03:52hiredmanif you have ever looked at a customer order, they don't come with customers
03:52hiredmanthey come with customer ids
03:52hiredmanwhich is an account number
03:53hiredmana reference to a customer
03:53ordnungswidrighiredman: sure, so you say the scope of an update would be a single "entity"?
03:53hiredmanI really don't understand what the big deal is
03:54hiredmanI mean, the "scope" of an update is what it updates
03:54ordnungswidrigI see, so the modeling problem is to define the sope of the updates and make every scope identifiable by an URI
03:55hiredmanan "update" on an immutable object doesn't update anything
03:55hiredmansince an update implies change and immutable objects don't
03:55ordnungswidrigI know, tell it "derive"
03:56ordnungswidrigI was toying around with the ideas of persistent datastructures and business object modeling. I wonder how they would go togehter.
03:56somniumordnungswidrig: the modeling could just resemble a relational id
03:56hiredmanexactly
03:56somniumrelational db I mean
03:56hiredmanit's just like a db
03:56hiredmanhave you seen any of the papers on whats it called, functional relational programming
03:57carkthat all fine for business modeling, how about simulation modeling, when you want to have "objects" ?
03:57hiredmanhttp://lambda-the-ultimate.org/node/1446
03:57ordnungswidrigcark: that's a good point!
03:58ordnungswidrigcark: in simulations you'd expect to have a well defined "world state", wouldn't you?
03:58_atohmmm my naive Clojure atoms + hashmaps + pmap implementation of twbray's widefinder 2 performs roughly the same as WideFinder2d.scala on a quad core xeon with a several gb log file. Probably need a gruntier box to experience the gc hell he's talking about, we only seem to be losing 5-10% to the GC on the quad core. _mst adjusted it to use ConcurrentHashMap (which the Scala version uses) and it seems slightly faster than the Scala
03:58_atoversion
03:58carkright
03:58ordnungswidrighiredman: thanks for the link. I suppose this is what I was looking for
03:59twbray_ato: Have found a much better set of JVM options, things are improving. I shouldn't write when I'm discouraged.
03:59twbray_ato: post your code, I'll run it on the big data
03:59hiredmancark: you've seen ants.clj, yes?
03:59carkyes
04:00carkthough it has been a year at least
04:00hiredmanit's essentially oop - mutability
04:00hiredmanif I recall
04:00carkright, but it's very non-functional
04:00hiredmaneach ant object as map
04:00ordnungswidrigcark: assume we have a large model for a simulation, say a mmorpg. there will be a lot if stuff that can change
04:01_msttwbray: I'd be interested to know your jvm options. I don't think any of the JVM knobs we twiddle made a huge impact (right, _ato?)
04:01hiredmancark: the state updates are all functions, and the state is always an immutable value
04:01hiredmanthat is kind of the whole point
04:01carkthat's a matter of deciding at which granularity we cease being functional and start being statefull
04:01ordnungswidrighiredman: for a deep model, every update will lead to a now "root" state reference, right?
04:01_ato_mst: yeah, mark and sweep concurrent gc just slowed it down a bit
04:02twbray_mst: Will publish. Turned out I get better results by letting JVM choose its own GC strategy, just fiddling with -Xmx and -Xms.
04:02carkordnungswidrig : that's not the case in the ants simulation
04:02_mstah yeah, that's consistent with what we saw too
04:02defn,*feeling lucky*
04:02clojurebotjava.lang.Exception: Unable to resolve symbol: *feeling in this context
04:02ordnungswidrigcark: can we be function in the whole and still manage the hot "root" reference?
04:02_atotwbray: okay, I'll post it shortly, just gotta change the regexes back to match your data
04:02hiredmancark: I think ordnungswidrig would call ants a shallow model
04:02ordnungswidrighiredman: yes
04:02defn,*feeling-lucky*
04:02clojurebotjava.lang.Exception: Unable to resolve symbol: *feeling-lucky* in this context
04:02twbray_ato: Or if you'd rather, you can have an account on the big machine
04:03hiredmanclojurebot: click
04:03clojurebotPardon?
04:03hiredmanclojurebot: *click*
04:03clojurebotIt's greek to me.
04:03hiredmanhmmm
04:03carki'd be interested to see a deep purely functional model with errr tengential references
04:03hiredmanclojurebot: roulette
04:03clojurebotclick
04:03hiredmanclojurebot: roulette
04:03clojurebotclick
04:03hiredmanclojurebot: roulette
04:03clojurebotbang
04:03ordnungswidrigcark: tangential?
04:04carksay customer->orders->order->items->item and stock->items->item
04:04defnhow do you find out where (which namespace) a *blah* is defined?
04:04carkitems are in two places
04:04defn*feeling-lucky* appeared to me in my REPL and im curious where it came from
04:04carkhow to do this without a whole lot of code to ensure everything is in sync
04:04_atotwbray: that would make testing easier :)
04:04hiredmandefn: do `*feeling-luck*
04:05hiredman` fully qualifies symbols
04:05hiredman`+
04:05hiredman,`+
04:05twbray_ato: email me, tim dot bray at sun
04:05clojurebotclojure.core/+
04:05ordnungswidrigcark: yes, that's one the of issues that I see! you must define an update function to decide wheter to branch the identity of item or it must update all references to the updated item
04:05somniumcant you have a map of all customers, and a map of all items, and a map of all orders
04:05somniumeach has a primary key of some sort
04:05ordnungswidrigsomnium: that would be more like a loose model not what I consider a pure functional model
04:05somniumand you query it
04:05defn*feeling-lucky*/*feeling-lucky*
04:05defnthat's not very helpful, heh
04:06carkright, then you bneed to maintain keys
04:06ordnungswidrigsomnium: and you'd decide on the update boundaries in advance
04:06hiredmandefn: you made a namespace *feeling-lucky* and interned a var there
04:06defnyeah, i just cant figure out where *feeling-lucky* came from
04:07ordnungswidrigsomnium: who know wheter you must to keep the shipping address as a separate address instance with its own key, or wheter you better handle the shipping address as a component of the ordeR?
04:07somniumordnungswidrig: that is up to your model
04:07hiredmandefn: grep your code
04:07somniumsame question as when you design a database
04:08carkmy final thought on the subject was this : if i need to emulate a database with the whole key thing, then i should really use a database instead of rewriting this
04:08tomojyeah..
04:08hiredmansure
04:08tomojwe need the D in ACID anyway so...
04:08carkbut then i loose the nice properties of a purely functional model
04:08esjgood morning, House of Clojure.
04:09carkfor ionstance i'm back at using the mementop pattern for undo =)
04:09ordnungswidrigcark: not necesserily. if you can define a patch algebra on the update function then you can do undo/branch/merge in a distributed fashion, like darcs does
04:09hiredmancark: STM has ACI alreadying, just need that D
04:09ordnungswidrigcark: I was refering to the conclusion to use a rdb
04:10carkhiredman : but stm won't allow for easy undo
04:10carki mean with refs for each objects
04:10hiredmanusing datastore with gae I just shove stuff in and pop it out
04:10carkdatastore with gae ?
04:11hiredmangoogle appegine's object store thing
04:11ordnungswidrigto be honest, this was the beginning of my thoughts. How would one define a patch algebra on somewhat generic pure functional datastructures. And can one use them to build business object model and work on them in a DVCS style.
04:11hiredmanit is basically a bag store
04:12hiredmanyou store bags of properties that have a Kind but can have any key value fields
04:12carki see
04:12carkyou're using appengine with clojure ?
04:12hiredmanyou can run very simple queries against it
04:12hiredmansure
04:12hiredman(very small facebook apps)
04:13tomojwhat's the Kind for?
04:13hiredmanit's like a type tag
04:13tomojah, but everything's got it?
04:13hiredmanyeah
04:14hiredmanyou can query for all the entities of a Kind that have a field with key X set to value Y
04:14ordnungswidrighiredman: the entry on LTU about FRP link to ben moseley's frp page which somewhow morphed into an aikido dojo's website?!
04:14hiredmanordnungswidrig: wha?!
04:15ordnungswidrighttp://ben.moseley.name/frp/paper-v1_01.pdf
04:15ordnungswidrigbut I'd rather like to read the paper, atm.
04:16hiredmanthe problem frp is googling you get all the functional reactive stuff
04:16_atotwbray: here's what my version looks like: http://gist.github.com/253226
04:16tomojordnungswidrig: http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf
04:16ordnungswidrigre
04:17ordnungswidrigtomoj: thanks
04:17lpetityea, aikido rocks
04:18ordnungswidrigI see a strong statistical correlation between people doing aikido and functional programming
04:18lpetitoh really?
04:18hiredmanwell
04:18esjI'm one such
04:18ordnungswidriglpetit: just my personal impression.
04:18hiredmanI can image a strong correlation between aikido and functional reactive programming
04:19esjof course, I do both badly...
04:19ordnungswidrighiredman: *lol*
04:19lpetitI used to (for 6 years), but not quite now
04:19lpetitpresumably hiredman is more a tae kwondo fan ? :-)
04:20hiredmanI did tae kwondo for a year or two
04:20hiredmanI know a guy (not well) that ref'ed in the last olympics
04:21ordnungswidrighiredman: there are olympics in functional programming?
04:21hiredman:P
04:21hiredmantae kwon do
04:22hiredmanaikido does seem interesting, or krav maga
04:23ordnungswidrighiredman: I like aikido because it is in some way a pure concept
04:24hiredmanmmm
04:25TheBusbyhow do I call merge-with on a list like, ({5 a 6 b} {5 c 7 r} {8 d 9 e}) ?
04:25hiredmanthe sport aspect of tae kwon do bother me the second time I picked it up, because where I was training really emphasised it
04:25hiredmanTheBusby: apply
04:26ordnungswidrighiredman: aikido is more like ballroom dancing. you compete with the others but you don't really fight them.
04:27ordnungswidrigback to deep functional models and the problem of update scope...
04:27TheBusbyhiredman: thanks
04:32twbray_ato: You'll save a bit of time by doing all those (report) calls with send, they're single-threaded and some of the maps have tens of thousands of keys.
04:34lpetitone last word: aikido resembles functional programming, in that in order to really have results with it, you really have to "get it", and it takes more time than other martial arts where some visible side effects are there at the end of the first year.
04:35ordnungswidriglpetit: amen.
04:36_atotwbray: ah, cool. I think your logs are probably pretty different to what we were testing with, I'll probably need to tweak things a bit to suit. With ours the report phase was really fast
04:36twbray_ato: Well, 245M records :)
04:47piccolinoDoes clojure optimize away something like (if true (something)) to just (something)?
04:55tomojpiccolino: why?
04:55piccolinoI'm writing a macro, and I know the value of the boolean, and I want to know if I should double the length of my code by testing it and writing the output code twice, or if I can trust that clojure will simplify that code.
04:57tomojwell, I doubt clojure will simplify it
04:57tomojperhaps hotspot will
04:58piccolinoHm.
04:59tomojis this in the inner loop or something?
05:00tomojI would be surprised if an extra (if true ..) mattered at all for performance
05:00piccolinoYeah, maybe it matters, maybe it doesn't. I'd rather not do an if true every time if I can help it.
05:00piccolinoI'm just gonna leave it.
05:03hiredmanuh, you can have the macro emit one thing for true, and one for false
05:04hiredmanyou don't have to emit both in an if
05:04piccolinoI know, that's what I meant above.
05:05hiredmanok
05:59angermandoes anyone know how to tell emacs not to fontify the slime compilation? I'm getting "Fontifying *SLIME Compilation*... (regexps..." and that regexps takes quite some time ...
06:00tomojnever seen that :/
06:00angermanok, answereing my own queystion: (setq font-lock-verbose nil)
06:01angermanat least this way it's in the logs ;)
06:02angermantomoj: well it occured since I started using lein swank
06:02angermanwhen ever I send something from the buffer to the repl via C-c C-c or C-c C-e i get that line and the regepxs thing goes for nealy a whole screen with dots.
06:03tomojoh, haven't played with lein yet
06:03tomojI guess I probably should one of these days...
06:04angermanI'm really starting to like it. I only need to mod the lein binary to use -server and -Xmx512M ... I guess I'm doing to big problems on the repl ;)
06:05tomojyou run lein swank in your project and then M-x slime-connect?
06:05angermanexactly
06:05tomojthat sounds awesome
06:06tomojcurrently with swank-clojure-project every project is forced to act the same way
06:06somniumhow is it different than swank-clojure-project?
06:07tomojwell, I'm not sure that it is, but the fact that you're running it from within the project gives you at least the opportunity to customize per-project
06:08tomojalso, 'sudo -u ... lein swank'
06:08angermanyep it automatically sets the correct classpath according to project.clj etc.
06:08somniumhmm, I havent figured out how to put new branch in project.clj yet
06:08somniumclojure-new I mean
06:08tomojfor my project that needs to run as a different user I've been starting swank manually with some nasty code
06:09somniumah
06:09somniumthat will come in handy
06:11liwpdoes anyone have any elisp code that will allow you to start a lein project in slime from emacs? I.e. emacs does 'lein swank' for you
06:13angermanliwp: M-! lein swank?
06:14angermanyou might want to add & to the end
06:14liwpangerman: that won't work since I'm not in the right directory
06:14ordnungswidrigangerman: can't "lein swank" be used as inferior-lisp-command or like that in slime?
06:15liwpso you'd first have figure out the project root and then start lein swank in that dir
06:15liwpdid technomancy have some swank project elisp function?
06:15angermanmy elisp-fu isn't that good.
06:16angermanbut yes, best place would be to look around at technomancys website and github repo
06:17tomojthe swank project elisp function I know of and associate with technomancy is swank-clojure-project
06:18liwptomoj: yeah, I think that's the same thing. I've copied it to my .emacs and renamed it to clojure-project, but I think it's the same thing
06:18liwpit looks for pom.xml in the directory tree and uses that as the project root dir
06:19liwpI guess using lein would allow one to skip all the classpath setup stuff that swank-clojure-project does...
06:19tomojmine doesn't care about pom.xml
06:19liwpmaybe it's a different function after all
06:19tomojwell maybe it cares, but it still works without any xml
06:20liwpdoes it ask for the project root when you run it?
06:20tomojyep
06:20angermanI guess you would just have to go up the directory structure and look for project.clj
06:20tomojI'm thinking one could write a function which asks for a project root, sets default-directory to that, and then runs "lein swank" as an async process
06:21angermanhmm...
06:21liwptomoj: yep, something like that, but I'm not sure my elisp-fu is strong enough
06:21tomojmine neither
06:21somniumyou could copy-paste the frst few lines from swank-clojure-project to det started
06:22somniumhttp://www.gnu.org/software/emacs/elisp/html_node/Asynchronous-Processes.html then one of these?
06:23somnium(my elisp is horrible, but its just lisp after all)
06:23tomojI assume/hope that those functions respect default-directory
06:24somniumstart-process appears to
06:24tomojhow does lein avoid the terribly long jvm startup time?
06:46angermanhttp://gist.github.com/253288
06:46angermanelisp-fu
06:46angermanlol
06:47angermanpretty certain it's not perfect but could work.
06:47tomojhave you tried it?
06:48angermanyes.
06:48tomojcool
06:48tomojwill save for later when I learn lein
06:48angermanit seems I can start multiple different jvms on the same swank port
06:48liwpangerman: nice!
06:48angermanif you kill the *lein-swank* buffer, the process should die
06:50adityoi am trying to compile a file and i got the following error
06:50adityo error: java.lang.UnsupportedClassVersionError: Bad version number in .class file
06:50adityoseen this for the first time
06:51adityoany help?
06:51Chousukeit may be compiler for a newer version of Java?
06:51Chousukecompiled*
06:52adityoohh!! i just copied those files from my linux box and i am running it on a Mac now
06:54liwpadityo: the platform shouldn't matter, but the java version certainly will
06:54adityookie
06:55adityoi think i am running sun java 1.6 on my Ubuntu but here on the mac its 1.5
06:56liwpadityo: yeah, that way will break. Were you to copy files from the Mac (1.5) to linux (1.6) you should be fine
06:57adityoliwp: okie, so does the jvm check for java versions or something?
06:57liwpadityo: the class files have a version number in them that specifies which class file format the file is in and I think they upped that in 1.6 IIRC
06:58liwpadityo: the jvm versions are always backwards compatible so the 1.6 jvm will be able to read whatever the 1.5 version can read
06:59liwpthe class file version doesn't really have that much to do with the java version in the sense that a newer java version can also generate files in the older class file format, I think you might just lose some of the newer java features that way
07:00adityookie
07:05adityohave to keep this in mind when deploying to other machines
07:24angermanhow do I unbind a variable in the current ns?
07:25tomojangerman: ns-unmap ?
07:26angermanhmm lets see
07:27tomoj,(ns-unmap *ns* 'ns-unmap)
07:27clojurebotnil
07:27tomoj,(ns-unmap *ns* 'ns-unmap)
07:27clojurebotjava.lang.Exception: Unable to resolve symbol: ns-unmap in this context
07:27tomojoh shit
07:27tomojsorry hiredman, didn't think that would work :)
07:28angerman,(use '(clojure core))
07:28clojurebotnil
07:28angerman,(ns-unmap)
07:28clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$ns-unmap
07:28angerman:)
07:29tomojer, 'ns-unmap, 'use, 'refer, etc
07:29tomojwell, even so you could (clojure.core/use ..) :/
07:30tomojis there no way to stop people from ns-unmaping ?
07:30angerman(defn ns-unmap [ & args ] (println "nice try...")) ?
07:30tomojok, but clojurebot won't let us defn
07:31angermanprobably doing that (in-ns clojure.core)
07:31tomojI could sneak in here when no one's paying attention and ns-unmap 'map and 'for and whatever else
07:32tomojactually we can talk to clojurebot through jabber, I guess, so I don't even have to do it in here :O
07:32angermanthe question would be where clojure bot prevents the defining. on a clojure level or on a lower level
07:32tomoj,(defn foo [] )
07:32clojurebotDENIED
07:32tomojheh
07:32tomojclojurebot: <3
07:32clojurebot
07:32tomojaww
07:32angerman,(def *m* "no")
07:32clojurebotDENIED
07:33tomojfuck you clojurebot
07:33angerman~source def
07:33clojurebotTitim gan éirí ort.
07:37tomoj(refer 'clojure.core :only '(defn) :rename '{defn foobar})
07:37tomoj,(refer 'clojure.core :only '(defn) :rename '{defn foobar})
07:37clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$defn
07:37tomojwat
07:38tomojwhy does clojurebot think I tried to call defn?
07:38tomoj,(refer 'clojure.core :only '[defn] :rename '{defn foobar})
07:38clojurebotnil
07:39tomoj,(foobar baz [])
07:39clojurebotDENIED
07:39tomojdamn, smarter than I thought :)
07:39angerman[...]
07:41lpetit~source repl-caught
07:41clojurebotTitim gan éirí ort.
07:41tomoj,(ns-unmap *ns* 'foobar)
07:41clojurebotnil
07:42lpetit~source repl
07:47lpetit~source read
08:06carkwhat is a good, preferably free, ofuscator that will work with clojure AOT compiled jars ?
08:06cark*obfuscator
08:08cemerickcark: proguard has worked well for us
08:08carkthank you
08:10ordnungswidrigwhat charset is use in #clojure?
08:13ChousukeUTF-8, please :P
08:14ChousukeUsing anything else is just silly.
08:14Chousukethough most of the time it doesn't matter, since everyone speaks English.
08:19esjexcept clojurebot, when its gets frisky
08:34Chousuke,(update-in {:a 1} [:b] (fn [x] (print x) 3))
08:34clojurebot{:b 3, :a 1}
08:34clojurebotnil
09:50bjorkintoshis 'programming clojure' a good book?
09:53esjyes
09:55bjorkintoshis it the only decent guide available?
09:56esjits currently the only book, but there are others to be released soon
09:56chouserbjorkintosh: so far it's the only complete book available. lots of people get by (with various levels of success) with free online resources.
09:58bjorkintoshhow much do i need to know of java/jvm to take full advantage of it through clojure?
09:59ohpauleezbjorkintosh: http://java.ociweb.com/mark/clojure/article.html http://en.wikibooks.org/wiki/Clojure_Programming are both great
09:59chouserbjorkintosh: not much. basic knowledge of "normal" object-oriented concepts will take you a very long way.
10:00ohpauleezAfter reading the guides on the wikibooks link, and the article, I was able to make my way through developing comfortable and enjoyable in clojure
10:00bjorkintoshcool.
10:01ohpauleezbjorkintosh: You might want to bookmark the link to the Java docs online, in case you need some library
10:01ohpauleezbut that's all you need to really know about java
10:04bjorkintoshokay.
10:12Licenser_hrm I've a odd problem I use create-server to create a server, and pass messages to it via a Socket connection I opened - which is working fine, but no matter what I do the server won't send anything back to the client (or the client ignores it :/)
10:12Licenser_any obviouse things I could do wrong here?
10:14esjfirewall ?
10:15Licenser_Nah, the connection is established, meaning packets can flow forth and back
10:17esjperhaps Wireshark or such would help you determine whether the server or client is at fault.
10:18Licenser_A very good idea, sadly it seems very hard to capture local traffic under windows
10:20esjindeed, everything under Windows is hard.
10:21Licenser_I know it's not my OS of choice
10:22tomojhave you tried on a server you know will work?
10:22tomojwindows shouldn't be a problem I'd think
10:22tomojcertainly the windows java socket api should work fine
10:23Licenser_tomoj: hmm good idea, I'll see if I can telnet to the box
10:24Licenser_tomoj: :D okay the server isn't the problem it's the cleiunt
10:24Licenser_thanks!
10:25tomojI've never used create-server before
10:25tomojthe fn you pass is supposed to do whatever reading/writing to the input/output streams and then return when it's finished?
10:25Licenser_me neither
10:26Licenser_yap that is about it
10:26Licenser_and it works really great
10:26Licenser_I found the best way top parse incoming messages is to reduce over the line-seq from the input stream
10:26Licenser_that way the state of teh connection isn't really a state but a argument to the reduce function
10:27Licenser_once I'll get this wokring I'll write an article ;)
10:35chouserI can never remember. Is java.util.Timer good or bad?
10:35chouserI think it's bad, but I can't remember the good one's name.
10:38esjwhat is the approved technique for returning results out of a resource enclosing form like with-connection in clojure.contrib.sql ? I can successfully execute my query but I need to return it. I thought dorun / doseq would be it, but they return nil.
10:39chouserah, perhaps java.util.concurrent.Executors/newSingleThreadScheduledExecutor
10:39chouseresj: doall or vec
10:39esjchouser: magic, thanks.
10:40fliebelDoes anyone know how I can run a REPL in a Vim buffer with VimClojure?
10:43tomojfliebel: the fact that it's not obvious saddens me
10:44fliebeltomoj: VimClojure does not come with an awful lot of documentation…
10:44karmazillachouser: the reason Timer is bad is because the thread will die if an exception bubbles up
10:44chouserkarmazilla: ooh, ouch.
10:44tomojwhat I mean is, the fact the repl is not the central feature saddens me
10:46tomojI guess we already have a repl and so vimclojure doesn't need to provide one in a prominent way
10:46tomoj(I'm brainwashed by emacs :()
10:48chousertomoj: it's just a keystroke
10:48fliebeltomoj: Maybe the repl is just below the surface, but the fact that it does not open the moment vim starts makes I can't find it.
10:49chouserI don't use vimclojure's integration, but I'll see if I can find the keybinding.
10:49fliebelchouser: thanks, what are you using?
10:49chouserI just use a plain terminal repl with rlwrap around it.
10:50tomojso you edit your source files and then go into the repl and load them?
10:50chouserI'm hoping any inconvenience involved in that setup will be motivation to complete texture. Hasn't worked yet. :-/
10:51chousertomoj: that's one way, or I have window-manager-level keybindings to send form over with a couple keystrokes.
10:52chousernot beautiful, but also very straightforward. Nothing much there to break, even when using odd branches of clojure, or untested patches, etc. Things that seem likely to break more complex setups like slime.
10:52tomojthe form you're sending over is the code in your source file or some code that loads the source file?
10:53chouserthe code in my source file (or "scratch buffer")
10:53tomojah
10:53tomojthen you don't get line numbers on errors, though, right?
10:53fliebelchouser: I found it should be /sr, but I'm not sure how I'm supposed to enter that.
10:54chousertomoj: right, when done that way.
10:54tomojusing window-manager-level stuff sounds awesome to me, but as long as technomancy et al keep slime working.. :)
10:55esjfliebel: you've used VI before ? If not press <esc> first maybe ?
10:56chousertomoj: yeah, active support from People Who Know for your particular use cases makes a huge difference.
10:56fliebelI press escape, the \sr but I get all sorts of regex tings
10:56tomojI vaguely wish my window manager was in clojure :/
10:56esjfliebel: sorry never used it, so no other guesses
10:57chousertomoj: last time I tried emacs I got pretty far, pretty comfortable. But ended up ditching it because there were one or two vimmers working hard to make our development environment excellent in vim, and I just couldn't keep emacs up to snuff.
10:57fliebelesj: s seems some delete key, s it goes back to —insert-- when i do that
10:57tomojI wonder if I should give vim a shot.. I've never really tried it
10:57chouserfliebel: it can't be \sr ... hang on, still looking.
10:58chouserfliebel: you got vimclojure installed and nailgun running?
10:58fliebelchouser: yes
10:58fliebelchouser: at least I have syntaxt coloring and a terminal window saying NGServer started on 127.0.0.1, port 2113.
10:59chouserfliebel: you found the .vim/doc/clojure.txt help file? I don't know why it isn't found via :help
11:00karmazillaI have yet to figure out the keybindings part of vimclojure, but I'm guessing that maybe you are expected to configure them yourself in .vimrc?
11:00fliebelI was just about to search for it it…
11:01chousersorry, it can't be /sr it should be \sr but it's not working for me at the moment.
11:01fliebelchouser: the file is called clojure.txt
11:01chouserunless you remapped your localleader
11:03fliebelwhat is my localoader?
11:04chouseryour localleader is \ unless you remapped it
11:04fliebelok… then it should be \sr...
11:04chouserright.
11:05Licenser_anything I'm doing wrong here: (let [in (new BufferedReader (new InputStreamReader (.getInputStream socket)))]?
11:06fliebelso I go to normal mode by pressing escape, then I press \ … nothing then I press s and go back to —insert—
11:06chouserfliebel: if you get fed up with vimclojure, here's an alternate solution I've been meaning to try: http://agriffis.n01se.net/skel.hg/index.cgi/file/fe1c0bdb217b/vim/plugin/ScreenRepl.vim#l1
11:06angermanLicenser_: s/new (.[^ ])/\1./g ?
11:07angermanLicenser_: s/new ([^ ]+)/\1./g ?
11:07fliebelchouser: might try that… but I'd rather get vimclojure working first
11:08chouserfliebel: that's the behavior I's seeing for \sr as well. Which is what I'd expect if \sr weren't bound at all.
11:08ChousukeLicenser_: looks fine to me.
11:09Licenser_angerman, thanks
11:09Licenser_Chousuke: darn, I hoped I had an mistake :P
11:12ohpauleezjust out of curiosity, does anyone know of a project/package targeting distributed computing with clojure
11:13ohpauleezI'm currently working to port and enhance my autonomic lib, and have a loose wrapper tying enlive and htmlunit together on the back burner
11:13esjTerracotta is all i know, Paul Stadig posted on this on the google group today / yesterday
11:14ohpauleezthanks esj, I'll check it out
11:14ordnungswidrighi all
11:14esjdepending on what you are doing FlightCaster did a lot of batch stuff in Hadoop/Cascading and released lots of the code into Incanter... dunno how much, or if its what you're after.
11:14ohpauleezI figured terracotta was a good platform to do it, but I didn't know if someone was looking to make a distributed backend for parallel ops
11:15fliebelchouser: omnicompletion is not working for me as well, so it might be a nailgun issue.
11:15ohpauleezI'm looking more to make a new package that redefines pmap/preduce, etc, that has distibution under it. But I haven't thought through it yet
11:15ohpauleezjust was curious
11:16ohpauleezfliebel chouser: is vimclojure broken with the latest stuff for you?
11:16ordnungswidrigam i right that equality comparision on persistent datastructures makes no sense on the instance level? at last most of the time.
11:16tomojhuh?
11:16ordnungswidrigi mean equality based on identity
11:17chouserohpauleez: oh, I didn't even think about the version. Indeed, I'm trying to use it with 'new'.
11:17ordnungswidrigjava == vs. Object#equal
11:17tomojah
11:17tomojyes == is not right
11:17ohpauleezchouser: it works for me right now, but there have been times where I've had to rebuild vim clojure with new versions of clojure
11:17Chousukewell, if they're identical then they're equal
11:17tomoj,(identical? [1] [1])
11:17clojurebotfalse
11:18Chousukebut I think that's the first thing checked by equas anyway :P
11:18ordnungswidrigso if i want to tell one instace from another I need sth. acting as a natural key.
11:18chouserbut, I don't use vimclojure regularly, so I don't know when what might have broken.
11:18Chousuketomoj: I didn't say the reverse was true :)
11:18tomojI didn't say you did say, just respondin to ordnungswidrig
11:19tomojyou are right though, clearly if they're identical then they're equal
11:20ordnungswidrigif multiple orders would reference the 'same' shipping adress you'd need an address key to be able identif| a certain one...
11:23tomojregular equality won't work?
11:25Licenser_is there something like ===?
11:25ordnungswidrigtomoj: no, say order1 and order2 reference shipping adresses which are equals. now, you want to update order1 with a new shipping address
11:25Licenser_no there sems not to be
11:26Licenser_ordnungswidrig: wouldn't you change it by refferencing the order which you want to cahnge?
11:26ordnungswidriglicenser: hm, that is true.
11:26fliebelchouser: I got into the REPL!!!!! just after trying over and over to type \sr
11:26chouserwow
11:27ordnungswidrigopposire case: i want to change an item referenced by both orders.
11:27ordnungswidrigand the change should appear in both orders
11:28somniumordnungswidrig: you can alter the value pointed to by @address
11:28tomojso then either both orders are in a ref and we can modify them both atomically, or each order holds a ref/atom/etc to an item
11:28ordnungswidrig@address? that sounds scary, like peek and poke
11:29ordnungswidrigah i see, a ref
11:29fliebelchouser: I can even send functions for the buffer over to the repl!
11:29somniumin one case you alter the identity (address :a1 to :a2) in the other the value referenced by :a1
11:29ordnungswidrigyes by this you define the borders of indipendently updatable parts of you model, right?
11:29tomojif we alter the ref, both orders will "see" the change
11:31ordnungswidrigif i want to stay purely functional then I would have to make the adresses identifiable with a synthetic id.
11:31tomojif you want to stay purely functional you aren't going to make any money
11:32ordnungswidrigand do some ref bookkeeping to find all 'instances' with a certain id.
11:32esjtomoj: making money is a side effect ?
11:32tomojrather, side effects make money
11:32ordnungswidrigtomoj: because of me, or because of pure fp? galois does, e.g.
11:33somniumis that why haskell is sponsored by M$?
11:33ordnungswidrigand they're lazy, too!
11:33tomojgalois makes money?
11:34Licenser_Hmm is there any problem in calling line-seq on the InputStream of a socket? It should just wait untill the socket is closed and untill that is done spit out the lines when they come right?
11:34tomojhe's dead?
11:34the-kennyLicenser_: I think there's something for this in contrib (fill-queue)
11:35Licenser_the-kenny: thanks I'll read up on that
11:35ordnungswidrigif you see every update on your business model as a function, then you're in pure fp, right? haskell does it, as well as stm
11:35the-kennyLicenser_: It's basically a background-thread which fills a queue and you can remove items from that queue etc etc.
11:35Licenser_hmm but I don't think that is waht I'm looking at
11:36Licenser_I want it to be foreground at the moment, problem is that the line-seq does not block but just tosses up it arms and screams I'm empty!
11:36tomojmaybe I misunderstand what "pure fp" means
11:37tomojto me anything which is "pure fp" is totally useless
11:38ordnungswidrigi mean an update of a business model is a function that returns a new, updated instance of the model
11:38ordnungswidrigpure in a sense of no mutable state, no side effects
11:38Licenser_odd, very odd
11:39tomojI guess you do your side effects in between these updates?
11:39Licenser_reader (fron c.c.duc-streams refuses to open my socket too -.-
11:39ordnungswidrigtomoj: if they are necessary, yes.
11:40tomojcertainly they are necessary...
11:40tomojotherwise the program is useless
11:40ordnungswidrigtomoj: of course
11:41devlinsfLicenser: What version of contrib are you using
11:41Licenser_1.0.0
11:41devlinsfLicenser_: The duck streams upgrade is recent
11:41ordnungswidrigimagine that you hold your model in clojure maps and vectors. no vars, refs or agents. then every update on you model returns a new revision of your model.
11:41Licenser_ah okay
11:42devlinsfTry this (reader (.getOpenStream my-socket))
11:42ordnungswidrigi.e. update is a function update Model -> Params... -> Model
11:42tomojI don't understand why you eschew refs
11:43ordnungswidrigtomoej: academic research?
11:43tomojeh
11:43Licenser_does not know getOpenStream but with getInputStream works (as in no crash) but gives no results
11:44tomojI mean, even with refs, if the functions which update the refs are pure, can't we regard the whole thing as a function from total state to next total state?
11:44ordnungswidrigtomoj: i see the necessarity of refs to define the boundaries of a updates. ids for every independently updatable object should work, too
11:44somniumordnungswidrig: are you reducing across an infinite sequence of updates?
11:45Licenser_Do I miss something that is wrong with this: (map (fn [x] println "-" x "-") (line-seq (reader (.getInputStream socket))))
11:45somniumthen the global state is always an argument and a new global state is always returned
11:45tomojordnungswidrig: should work, but with concurrency?
11:45ordnungswidrigsomnium: nope, still thinking on making a patch algebra of the business model update functions and getting, undo/branch/merge for free
11:45somniumah
11:45ordnungswidrigtomoj: yes, that makes sense
11:45devlinsfLincenser_ :Yep. Map is lazy, println is a side effect
11:46ordnungswidrigtomoj: concurreny can be enabled by comapre-and-set or automativ merge
11:46devlinsfTry this (println (apply str (map #(str "-" % "-") ...)))
11:46ordnungswidrigtomoj: and manual conflict resolution
11:46tomojok
11:46devlinsfOr use doseq, not map
11:46tomojpersonally I don't want to do any manual conflict resolution
11:47tomojI'd rather let clojure's stm take care of the problem :)
11:47ordnungswidrigtomoj: in a eventual consitent world, this is an option.
11:47ordnungswidrigtomoj: stm does cas
11:47somniumyes, I like the 'someone else's problem' approach to reducing complexity
11:48Licenser_devlinsf: argh I think I know what is the problem, you're totally right
11:48devlinsfLicenser_: I've made that exact mistake before
11:48Licenser_what freaks me out so is that it works for the server o.O
11:49tomojordnungswidrig: I've concluded I really have no idea what you're talking about, good luck
11:49ordnungswidrigtomoj: if two user update the same customer record, you can either try to merge and (probably conflict) or do a CAS and ask thew loosing user whether to try again
11:51devlinsfLaziness can be a pain
11:51Licenser_devlinsf: yes :(
11:51Licenser_but thanks a lot!
11:51devlinsfN/p
11:51the-kennyAfter some hours running without problems, my code just crashed
11:52the-kennyWith a very very long stacktrace which didn't help
11:52Licenser_hmm hmmm
11:53jasappthe-kenny: what are you doing if you don't mind me asking?
11:53Licenser_ah I know why it's working on the server, reduce makes it execute ^^
11:53the-kennyjasapp: Something with twitter and youtube ;) Nothing very big yet
11:54jasappgotcha
11:54the-kennyjasapp: basically, I'm reading the stream of tweets continously and doing some data-crunching on the numbers.
11:54jasappcool
11:55jasappare you storing the tweets, or just tossing them?
11:55the-kennyjasapp: CouchDB.
11:55ordnungswidrigme wonders if one can predictinfluence pandemies with twitter like google does with search requests
11:55the-kennyjasapp: But I'm refactoring it at the moment.
11:55jasappinteresting
11:55ordnungswidrig...influenca...
11:56jasappI'm doing something similar with ebay and mongo
11:56the-kennyordnungswidrig: I'm sure it'll - at least when everyone uses geolocation
11:56defnthe-kenny: hehe, im doing something like that too
11:56the-kennydefn: You stole the idea of a friend of me! :p
11:56ordnungswidrigclojure seems to have a good standing in data mining...
11:56defnyou gave me some boilerplate for reading the firehose
11:57tomojthe-kenny: what are you using to interface with couchdb?
11:57defni didnt know about that new firehose thing
11:57the-kennydefn: I know ;) I'm just joking
11:57the-kennytomoj: clojure-couchdb with some modifications
11:57tomojah
11:57ordnungswidrigfirehose?
11:57defntwitter's constant stream of tweets
11:57defnyou just keep downloading tweets as they're posted
11:57jasappdon't you have to be special to get a firehose?
11:57defnin json format
11:57defnnope
11:58ordnungswidrigme forked the-kenny's clojure-couchdb and put some lucene it...
11:58the-kennytomoj: I think I'll drop the exception-throwing parts from my fork and use return-codes for error messages It starts to annoy me.
11:58ordnungswidrigthe-kenny: I'd appreciate dropping the exceptions
11:58the-kennyjasapp: You have to be special to get a stream of *all* tweets.
11:58defnyeah
11:59jasappahh, ok
11:59the-kennyjasapp: But you can define "filters" and get everything which passes them.
11:59ordnungswidrigthe-kenny: that'd be a rather big stream, right? do you have numbers?
11:59defni downloaded 1,000,000 tweets the other night
11:59the-kennyordnungswidrig: Not really. I'm reading everything with "http" in it.
11:59defnpretty fun to play with them
12:00jasappI've been saving iphone auctions
12:00the-kennyIt like 500kb/s or so.
12:00the-kennys/It/It's/
12:00defnthere are about 27million tweets per day
12:00the-kennyI'm not sure, but my macbook can even handle to resolve all these urls without using more than 6% of my processor
12:01dnolenthe-kenny: any opinion about clojure-couchdb over clutch? clutch seemed further along at one point...
12:01the-kennydnolen: Never tried clutch. I was searching for a simple interface without things like a custom view-server and such goodies
12:01esjhelp ! how does one pass arguments into java calls and multiple depths like: formatter.withZone(DateTimeZone.UTC).print(dt)
12:01ordnungswidrigthe-kenny: resolve? you mean un-tinyurl?
12:01the-kennyordnungswidrig: Yes
12:01esjexhausting the combinatorics here is getting me nowhere ;)
12:02the-kennyordnungswidrig: It's a 4 line function in clojure using java.net.HttpUrlConnection
12:02defnhehe try to do a permutation of i believe it's 9 integers
12:02devlinsf(. print (. withZone formatter DateTimeZone/UTC) dt)
12:02devlinsfesj: try that
12:03esjdevlinsf: much oblidged !
12:03ordnungswidrigdnolen: i liked clutch for not throwing exceptions. but i had to drop it because the db was passe along in a binding
12:03devlinsfEh, try this first
12:03the-kenny,(doc ..)
12:03clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
12:03devlinsf(class (. withZone formatter DateTimeZone/UTC))
12:03devlinsfthat should be a sanity check
12:03the-kennyesj: I think you want .. :)
12:03tomojordnungswidrig: would you rather pass the db/host in as the first param to every function?
12:03tomoj(I'm working on my own couchdb clojure library at the moment)
12:04ordnungswidrigtomoj: i'd like the choice
12:04danlarkinOne Of These Days™ I'll get around to updating clojure-couchdb, and doing it a little better, not throwing exceptions etc
12:04esjthanks guys... will check it out
12:04devlinsfnp
12:04the-kennytomoj: I managed my fork of clojure-couchdb to do this
12:04the-kennytomoj: passing it with a binding is a big pain if you use threading
12:04dnolenthe-kenny: ordnungsmidri: good to know.
12:04tomojah, I see
12:04ordnungswidrigoptionally a (with-db ) macro is nice
12:04tomojI have a binding now for host config and first param as the db name
12:05tomojwell.. providing your own with-db macro shouldn't be too hard, no?
12:05ordnungswidrigtomoj: you could fall back to the binding if no param was given
12:05tomojyeah that's what chous* recommended when I asked earlier
12:05ordnungswidrigleaving the train... cu all
12:06the-kennyShouldn't be hard to (partial) all functions in a macro
12:06the-kennyI want to do this for clojure-couchdb :)
12:06the-kenny1. Refactoring my project, 2. removing exceptions from my fork of clojure-couchdb and 3. adding a with-server/with-db macro :)
12:07tomojI wonder how common it would be to need multiple host configs
12:07tomojfor my uses I don't need that at all, so a binding doesn't seem bad
12:08the-kennytomoj: I liked bindings until I started working with threads
12:08ordnungswidrigtomoj: my problem was that a binding cannot be captured by a (fn ) form
12:08the-kennyordnungswidrig: And any binding will dropped in a new thread
12:08fliebelHow can I get the index of an item in a vector? I'm trying to do some sort of lazy slice thing, like Python. I'm doing this now, but that obviously only works for numbers: (def a (filter odd? (cycle [:a :b :c :d])))
12:08the-kenny+be
12:08tomojmaybe I will discover these problems when I actually start using my library
12:09the-kennytomoj: Try it with a remote server
12:09tomojeh?
12:09the-kennyAuthentication is also a problem which clojure-couchdb doesn't handle
12:10the-kennytomoj: Play around with your lib, think about use-cases and test them :)
12:10tomojeven in my wildest imaginations where I have a whole cluster of couches, they're all accessible from one host config
12:10jasappso who is going to write a query engine for couch in clojure?
12:10tomojit's already been done
12:10jasapphas it?
12:10tomojI also did it myself recently, it's easy
12:10the-kennyjasapp: clutch has a view-server
12:11jasappsweet, I had no idea
12:12tomojall you really have to do is parse json and use read-string :)
12:12jasappI didn't realize it was that easy
12:12Licenser_time to go home, see you all later!
12:13tomojmaking clojure tools to define design documents is what I'm working on now, not sure how best to do that
12:13tomojbut implementing the basic map/reduce/rereduce is simple
12:13jasappdo you have any good ideas for defining documents?
12:14jasappI'd like to do something similar for mongo
12:14the-kennyjasapp: How does mongo handle documents etc.?
12:14the-kenny(I'm only familiar with couchdb)
12:15jasappI think in a similar manner to couchdb, they're stored in binary json
12:15jasappbson they like to call it
12:15tomojI don't think I have good ideas
12:15jasappmongo doesn't have the nice versioning like couch
12:15fliebelHow would I get 2 lazy infinite seq with the odd and even indexes form a vector? I'm currently doing: (def a (filter odd? (cycle [1 2 3 4])))
12:16Chousukefliebel: don't def infinite sequences
12:16Chousukefliebel: they will never get garbage collected
12:17fliebelchousuke: hmmmm, so what should I do?
12:17tomojcurrently I'm thinking just like (def *my-design-doc* (couch-view design-name/doc-name (view1-name {:map (fn [doc] ..)}) (view2-name {:map...}))
12:17Chousukefliebel: just make the seq where you need it, or make a function that returns one
12:17tomojand then some function to create
12:17tomojcreate or update, I mean
12:18jasapphave you run into any mapping issues between clojure types and couch types?
12:19tomojthough I really like the idea of doing (defdesign db-name/doc-name ...) and having some evilness to automatically sync them..
12:19tomojnope it's just json
12:19fliebelchousuke: That is fine for the final thing, but for testing I did this… But I might as well use take 10 or something like that. The main problem is that I want it to work with strings, not numbers, so I'd need the index rather than the value. This would be quite easy with Python slices…
12:19defnChousuke: so instead of def a, defn a [] gets collected?
12:19tomojthe only issue I've run into is whether to allow users of my library to use string keys, and I say '
12:19tomoj"no, use keyword keys"
12:20jasapphmm
12:20tomojotherwise c.c.json takes care of everything
12:20Chousukedefn: if the result of the function is not bound to a permanent reference it can be collected
12:20jasappat one point in time, I was trying to save xml zippers in mongo
12:20defntomoj: i found that weird that the keys are "strings"
12:20defnlike ("text" tweet)
12:20jasappthat was giving me some trouble
12:21Chousukedefn: if you (def x (make-lazy-seq)) then that lazy seq will never be collected, of course.
12:21tomojrather (tweet "text") no?
12:21Chousukedefn: because x is a reference to it
12:21defnerr yeah sorry
12:21tomojbut I use the settings in c.c.json to make it (:text tweet)
12:21defnChousuke: ah-ha i see
12:21defnthat's good thinking
12:21defn@tomoj
12:21tomojand if you make a doc with a key like "_id" you're just screwed
12:21defnyeah, that's annoying -- i was frankly surprised that the keys from twitter were strings like that
12:22defnwhy wouldnt they use symbols or something?
12:22tomojis it json?
12:22defnkeywords,symbols
12:22defnyeah
12:22tomojin json object keys are always strings
12:22defnhuh, i didnt know anything about json
12:22defnit just seemed wasteful :\
12:22tomojbut c.c.json can autoconvert them into keywords
12:32the-kennyIs there a function to check if all values in a struct are valid (e.g. not-nil)
12:35gregorygmacs
12:35the-kennyhm.. clojure-mode needs a special face for (comment ...)
12:40stuartsierrathe-kenny: (every? identity things)
12:55technomancythe-kenny: actually I like that stuff in (comment) gets fontified normally since it's usually example code.
12:55the-kennytechnomancy: hm.. yeah, but I would like to see something like a small shade to show it's commented out.
12:55the-kennyI don't know if this is possible with emacs, but it would be cool.
12:56technomancyoh maybe a different background? that's not hard.
12:56the-kennya slight-gray background would be fine
12:57the-kennyjust to distinguish the code from the "active" code
12:58defnis there an easy way to comment a region in clojure-mode?
12:58the-kennydefn: Yes, (comment ...)
12:58technomancydefn: M-; (not just for clojure)
12:58defnthanks for both of those :)
12:58technomancyproblem is custom backgrounds are not very composable with color themes
12:59the-kennyhm.. maybe a customizable face for the background?
13:00technomancythe-kenny: I mean it works, it just requires everyone using a different color theme to also specify that one
13:00technomancymost color themes only specify new values for built-in faces
13:00the-kennytechnomancy: ah ok
13:00the-kennyI understand..
13:00tomojcolor themes seem pretty broken to me
13:01technomancyit's a hack job, no question
13:01defnyeah tomoj -- sometimes ill try to switch color themes mid-emacs-session
13:01defnapparently that is a bad idea
13:02tomojheh
13:02defnall sorts of colors hang around and mash with eachother
13:02tomojyup
13:02tomojand resetting doesn't seem to work
13:11defnwow -- guy steele lobbied sun to have tail calls in java in 1996
13:19kylesmith_Has anyone tried out the debug-repl?
13:19defnwith (ns myns [:use...]), i can list multiple namespaces right?
13:19the-kennydefn: yes
13:19defnlike [:use clojure.core clojure.contrib.seq-utils ]
13:20defnthe-kenny: cool thanks
13:20defnif i have (ns foo.core [:use compojure]), and in another file I do (ns foo.extra [:use foo.core])
13:21defndoes that inherit compojure?
13:21the-kennydefn: I think so.
13:21the-kennydefn: But I'm not sure
13:21stuartsierradefn: no, it does not
13:21defnis there a way to inherit?
13:22the-kennyLearned again..
13:22stuartsierra'use' only refers symbols interned in the namespace you are 'use'ing.
13:22stuartsierradefn: not in core
13:22defnk
13:22stuartsierraCompojure tries to do inherited namespaces, and it causes some problems.
13:23stuartsierraSee http://groups.google.com/group/compojure/browse_frm/thread/400aac94e536e633
13:23defnty
13:45Drakesondo you know of an example of using dbus in clojure?
13:49Licenseraloaeh!
13:51chouserDrakeson: I wrote some code that acts as a client for dbus, but it was horrible.
13:51chouserDrakeson: I was using some java dbus lib that really didn't help. I think I'd try with jna and the normal dbus C library.
13:52chousercan't imagine it'd be any worse at least.
13:52technomancyhas there been any talk of expanding the regex reader macro to support creating case-insensitive regexes?
13:52chouser#"(?i)foo"
13:52technomancy#"foo"i would be closer to other notations
13:53hiredman(?i)foo is java notation
13:53technomancybut I guess that's not bad
13:54chouserI don't love the extra "(?)" noise, but I actually like having it up front.
13:54chouserthose flags do change the way all the rest of the regex is compiled, so it's nice to see it early.
13:56chouser,(let [x "foo boo FOO Boo"] (re-seq #"(?i)f\w*"x))
13:56clojurebot("foo" "FOO")
13:59angermanincanter.stats/histogram is quite slow. which is very weird.
14:01Drakesonchouser: were you using libdbus-java by any chance? (I am on debian)
14:02chouserDrakeson: that looks right.
14:03chouserDrakeson: I don't remember the specifics of my pain, I'm afraid, but jna is quite pleasant considering the problem space it addresses.
14:05Drakesonchouser: I like jna, (and your clojure-jna), I am even increasingly finding myself using it to debug some C programs. I am not familiar with the regular (C) dbus libraries, so I thought a java one might be of some help
14:05alexykthe-kenny: where do you set those filters to get all twitter's URLs?
14:06DrakesonI'll try to see where http://dbus.freedesktop.org/doc/dbus-java/api/ breaks ...
14:06chouserDrakeson: I was using it to talk to Pidgin (libpurple)
14:07Drakesonoh! that's precisely what I am trying to do
14:07chouserso painful
14:07the-kennyalexyk: At the end of the url
14:07the-kennyalexyk: Just look at the doc
14:07chouseryou have to generate an interface to hand off to dbus-java
14:08alexykthe-kenny: What URL? Are you using the gardenhose/Streaming API?
14:08Drakesonchouser: I am not sure of that
14:08the-kennyalexyk: Yes, the streaming-api
14:08the-kennyalexyk: Wait
14:08the-kennyalexyk: "http://stream.twitter.com/1/statuses/filter.json?track=http&quot;
14:09Drakesonchouser: well, I have made a MethodCall without generating the interface
14:09lisppaste8Chouser pasted "dbus + pidgin = pain" at http://paste.lisp.org/display/91889
14:09Drakesonbut it looks like crap
14:09chouserDrakeson: perhaps you found a better way, then.
14:09alexykthe-kenny: do you have any permissions on your twitter account to access that?
14:09the-kennyalexyk: No
14:10the-kennyalexyk: Filters doesn't require additional rights
14:10alexykinteresting! we used to have to click on some EULA to get a slice
14:10alexykthe-kenny: I wonder if you can get retweets this way...
14:11the-kennyalexyk: hm.. Not sure if the rt-api is in this stream
14:11the-kennyalexyk: http://apiwiki.twitter.com/Streaming-API-Documentation#statuses/retweet
14:12the-kennyhm sorry, not generally available
14:14chouserDrakeson: also, setting up shared-native-library stuff is easier for jna than for libunix-java
14:15chouserwhich can matter a lot for desktop-deployment of the sort you'd expect with dbus and libpurple.
14:15Drakesonchouser: now that I look at it, mine is equally painful because I have to indicate the type on every object I pass to MethodCall.
14:17chouserDrakeson: macros might help yours, while mine requires AOT compilation regardless.
14:19Drakesonchouser: I took some parts of the examples in dbus-java-bin (e.g. it installs /usr/bin/DBusCall)
14:37lpetit_ato: hello
14:43lpetitrhickey: thanks again for having reminded me of the SchemeScript project. There's definitely tons of good things to read there, if not to copy, if not to share.
14:43lpetitrhickey: BTW, do you know to which extent EPL (under which CCW is released) and CPL (under which SchemeScript is released) are compatible ?
14:44rhickeylpetit: EPL is the successor to CPL, very compatible
14:44alexykhow do you instatntiate Java generics, e.g., what's the equivalent of this Java: Graph<String, MyLink> gr = new SparseGraph<String,
14:44alexykMyLink>();
14:44lpetitrhickey: I mean, I could grab some general info about EPL / CPL license compatibility by googling, but maybe you have the short answer (by having, I don't doubt it, thoroughly studied this at some point)
14:45lpetitalexyk: you just instanciate it like any other class
14:45lpetit,(java.util.ArrayList.)
14:45clojurebot#<ArrayList []>
14:46alexyklpetit: it takes other classes as parameters... what's the Clojure sugaring syntax for that?
14:47the-kennyalexyk: No, it's not a paramter. It's just a nicely wrapped type-annotation.
14:47the-kennyalexyk: You don't have to use Generics, you can just drop them and the collections work too.
14:47alexykthe-kenny: right. so how does Clojure do it? :)
14:47lpetitalexyk: anyway, parametric information (generics) are a java compiler trick, they are erased at runtime
14:47the-kennyalexyk: It doesn't
14:48lpetitalexyk: it doesn't do it differently than everywhere else: no static type checking
14:48the-kennyalexyk: The annotation are just there to help the compiler keep up the type safety
14:48alexykthe-kenny: so what would I do to achieve the above in Clojure? Just (SparseGraph.) ?
14:48the-kennyalexyk: Yes
14:48the-kennySame for ArrayList and any other generic
14:49alexykthe-kenny: so how will it know it's a <String,MyLink> kind? I.e. it won't check types in Clojure at all?
14:49the-kennyalexyk: It doesn't know it.
14:49lpetitalexyk: clojure does type inference to some extent, but that's with the goal of performance: finding at compile time as much as possible concerning the real type (class, interface) of called objects so that it avoids compiling reflexion but rather compiles direct method access
14:50the-kennyalexyk: As lpetit said: All these informations are dropped by the compiler in java, so they are just a small hack to keep type safety up. Everything works the same without generics.
14:51the-kennyalexyk: After compiling, all generics are gone. All collection work with java.lang.Object, the superclass of all classes in java.
14:51alexykinteresting... so now I understand clojure/java/scala differences better, or it seems so. Java and scala retain all this type info during compile time, but if clojure doesn't check it during compile time, then it's truly less strictly typed. Which is not a bad thing per se.
14:51lpetitalexyk: you should not be more or less annoyed by not being able to specify generic types than not being able to speficy e.g. function formal arguments types
14:52alexykwell you can't call it dynamic and still strictly typed -- it's loosely typed w.r.t. generics...
14:52alexykI c an stick random things into my graph
14:53the-kennyalexyk: Yes, and your graph sees nothing but "Object"
14:53the-kennyalexyk: This works in Java too, just drop the generic-instanciation and turn off warnings for that.
14:54lpetitalexyk: for a profound understanding of what really makes clojure different (and not just "surface" things such as syntax, strong typing, ...), viewing http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey is highly recommended
14:54the-kennyalexyk: That's also the cause why you can't stick a basic int or float into a collection - it isn't a subclass of Object
14:56alexykok! cool
14:56lpetitalexyk: watching this will be like Alice entering the world of wonders. At first it looks amazing and a little strange, but at the end of the journey, you're enlightened :-)
14:57alexyklpetit: after such ad, I can't help watching it :)
14:57lpetitalexyk: and you observe that you're not continuing to use clojure for the same reasons you came to it :)
14:57lpetitalexyk: to some extent, of course
14:58lpetitalexyk: you may be surprised, though. The link I provided will not talk a lot about clojure. But it's intentional. It justifies by itself clojure's existence.
15:00lpetitalexyk: once you're watched the first one, you'll be ready to watch this one, which will detail how the mechanisms and principles explained in the first video are implemented in clojure, straight into the language: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
15:00lpetitalexyk: enough for today, good watch :-)
15:00alexykthx :)
15:09mabeshow do you get the index of an element in a vector? find-doc is failing me...
15:10hiredman(.indexOf [1 2 3 4] 2)
15:10hiredman,(.indexOf [1 2 3 4] 2)
15:10clojurebot1
15:10alexykwatching the video, but my accent-placing skills are not definitive
15:11alexyk(unless related to Russian)
15:11hiredmanuh
15:11karmazillais there a continuous test runner for lein?
15:11mabeshiredman: oh, yeah, forgot about the java layer :) thakns
15:11mabeser.. thanks
15:12hiredmanalexyk: it's like newyorkish
15:12hiredmanthe state not the city
15:13alexykhiredman: really? sounded a bit British to me at first, or Aussie/NZ
15:13alexykless so than Peyton-Jones' though
15:14alexyk...then again we had tons of snow and it may have gotten into my ears...
15:14samlhey, how can I get a type of something in repl?
15:14saml(doc x) is only way?
15:14clojurebotIt's greek to me.
15:15alexyksaml: (class x)
15:15hiredman,(type :x)
15:15clojurebotclojure.lang.Keyword
15:15samli mean arguments it takes and return value
15:15hiredmansaml: dynamic language
15:15samlyah but it says keywords are also a function that takes map
15:15samloh i see
15:15hiredman,(:x {:x 1})
15:15clojurebot1
15:16hiredman,(ifn? :x)
15:16clojurebottrue
15:17samlIFn is interface function, right?
15:18hiredmanIFn is the function interface
15:19hiredman,(fn? :x)
15:19clojurebotfalse
15:19hiredman,(fn? (fn [] ))
15:19clojurebottrue
15:23angermanerm, how about incorporating something like http://gist.github.com/253288 into the emacs/clojure/lein support?
15:24the-kennyangerman: There's swank-clojure-project which does almost the same
15:24the-kenny(Just without the leiningen dependency :))
15:25angermanor integration.
15:28rulliewhat's lein
15:29angermanleiningen build tool for clojure
15:29the-kennyangerman: lein swank does the same like swank-clojure-project, as far as I know. The biggest difference is, that swank-clojure-project starts the repl inside emacs. I don't see why that should be replicated.
15:29rullieangerman: thanks
15:30angermanthe-kenny: that's the exact point. You need someone to maintain both and make sure they do the same.
15:31hiredmanfyi, depending on /bin/bash limits the range of systems you can run on, unless you use bash features go with /bin/sh
15:33angermanhiredman: thats right
15:33the-kennyangerman: Iirc, both was written by technomancy :)
15:33angermanthe-kenny: I think you get my point.
15:57neilmockif anyone's interested in the quartz scheduler and clojure i've got an example here http://github.com/neilmock/clojure-quartz-example
15:57neilmockand if anyone knows a way to get the job class going with out AOT compile that would be great :)
16:09arohner_neilmock: I've been looking at using some kind cron/scheduling thing for my own app. Why did you choose quartz over the other options (built-in, jcron, etc)?
16:09chouserneilmock: looks like you could probably use proxy to implement an org.quartz.Job so you wouldn't have to AOT
16:17neilmockarohner_: i needed possibly thousands of jobs to run at fine-grained timestamps and quartz seemed to be the most suited to that, although i haven't done an exhaustive search for other options
16:18neilmockchouser: i tried proxy, but i don't know enough to get the proper class object out of it
16:18technomancykarmazilla: if you check in the pom that lein generates, you can use hudson on the project
16:18technomancywe do that at work; it's not too hard to set up, plus you get a snapshot repository out of the deal for free
16:18chouseroh, I couldn't tell. The "job" you pass in is a class, not an instance?
16:19neilmockyes
16:19hiredmanweird
16:19arohner_reify might work for that
16:19hiredmanor just fn
16:19karmazillatechnomancy: what I mean by continuous test runner is something that runs my unit tests every time I save a file
16:20karmazillanot just every time I commit/push
16:20chouserbleh. proxy won't be reliable there.
16:20technomancykarmazilla: oh, locally? yeah, someone wrote autotest integration, but it starts a new JVM every time IIRC, which is really slow
16:20technomancykarmazilla: you really need to build that into your editor
16:20technomancyit's pretty easy to do in Emacs with clojure-test-mode
16:22drewrneilmock: I've wrapped cron4j in a reporting utility I'm working on
16:22drewrI need to generalize it a bit and release it
16:22karmazillaI forked lein and have written a test+cc function in src/test.clj that runs the tests at an interval. Now trying to figure out how I use it from the command line
16:22chouserI think reify would work -- you still don't get to specify a classname, but you do get a new class for each usage of (though not each call to) reify.
16:22neilmockreading about reify on assembla, looks like it would work if you could get a class out of it instead of an instance
16:23neilmockor maybe that's how it works and i'm misreading
16:23rhickeyneilmock: when do you need a classname for quartz?
16:23chouser(class (reify Job ...))
16:25neilmockrhickey: at schedule time, i think it stores the name and optionally parameters and instantiates and executes later
16:26drewrfwiw, I extended the cron4j Task class (similar behavior) with proxy and it works fine
16:26drewractually, it instantiates immediately but executes later
16:27technomancykarmazilla: you could tie into some kind of inotify or similar layer from within a lein-auto plugin
16:27drewrthe closed over methods keep their env
16:27technomancybut I prefer editor integration myself
16:27technomancythen you can get the results displayed overlaid on top of the tests themselves
16:29neilmockthere's an approach out there of a quartz java job that allows invocation of clojure functions, probably a preferable strategy but i was just exploring the options
16:29neilmockhttp://asymmetrical-view.com/2009/05/19/quartz-and-clojure.html
16:30hiredmandoes quartz scheduler execute in the same vm?
16:31chouser,(str (proxy [Object] [] (toString [] "foo")))
16:31clojurebotjava.lang.IllegalStateException: Var null/null is unbound.
16:31chouserooops
16:31chouseranyway, that returns "foo", but...
16:32chouser(str (.newInstance (class (proxy [Object] [] (toString [] "foo")))))
16:32hiredmana newInstannce of a proxyied class will be missing the fn map
16:32hiredmanI believe
16:32chouser...does not. Because the methods aren't held in the class, when you just use the class of what 'proxy' produces, you get only default implementations.
16:32chouserhiredman: right.
16:39hiredmangah, checked exceptions are so horrible
16:43hiredmanit seems there is no way to get an element an element from a List that does throw some checked exception
16:43hiredmanmaybe just call toArray and operate on that
16:45drewrhttp://gist.github.com/253711
16:46drewrchouser: ^ works for me
16:47chouserdrewr: make-task is returning a instance there. As long as that's what you need, proxy is perfect.
16:47drewryeah, I see what you were talking about now
16:48drewryou wanted to create a true subclass that could then be instantiated
16:48chouserright.
16:48chouserwell, apparently that's what some java libs, unfortunately, require. :-/
16:49drewrthen I recommend cron4j :-)
16:51chouser,(str (.newInstance (class (reify Object (toString [] "foo")))))
16:51clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IPersistentVector
16:52chouseranyway, that seems to work ok as long as you don't close over anything.
16:54neilmockdrewr: i was needing to possibly get down to the millisecond if necessary (extreme case) but normally right at a second mark, doesn't seem like cron4j is suited for that but i could be missing something
16:56drewrneilmock: no, cron4j wakes up every minute
17:06polypusyou guys know if this code has been released yet, and what it's called:
17:06polypushttp://vimeo.com/7722342
17:08alexykhow do I define a Clojure proxy equivalent to http://paste.pocoo.org/show/156231/ ?
17:10alexykspecifically, how do I define the constructor & weight and id members?
17:10hiredmanpolypus: they repo urls in the video
17:10hiredmanalexyk: you don't
17:11polypushiredman: thx, i must have scrubbed by it
17:11dabdhi I'm using enclojure and I'm trying to call some clojure code from java and I'm getting this error 'Could not locate Clojure resource on classpath'
17:11dabd the clj files are not included automatically in the classpath?
17:11alexykhiredman: hmm... but I need weight in there
17:11hiredmanproxy a. doesn't let you create a new interface (no new members) and b. proxy does not let you create constructors
17:12hiredmanproxy is not for creating classes, it is an interop construct
17:13alexykso I have to do it in Java?... unless there's an interface? this class is a parameter to a graph library
17:14hiredmanor use gen-class
17:14hiredmanyou can also proxy a class, not just interfaces
17:14hiredmanproxy "methods" are fns so they close over locals
17:15hiredmanand you can pass arguments through to an existing constructor
17:16alexykah, prolly gen-class then
17:16hiredmanI doubt it
17:17hiredmanif you are passing to an existing java library then that existing java lib expects something of a certain class and you can just proxy that
17:46danlarkinWhat's the reasoning behind (not= #{1} '(1))?
17:47stuartsierradanlarkin: different types
17:47danlarkinSince = check value, and their values are the same
17:47danlarkinbut (= 1 1.0), those are different types too
17:48stuartsierra= tests arithmetical equality, then Java .equals()
17:48danlarkinand (= [1] '(1))
17:48KirinDave_,(not= #{1} '(1))
17:48clojurebottrue
17:48KirinDave_That seems intuitive.
17:48stuartsierra,(= [1] '(1))
17:48clojurebottrue
17:49stuartsierraThat doesn't.
17:49KirinDave_Yeah
17:49chouserdanlarkin: should (= #{1 2} '(1 2)) ? what about (= #{1 2} '(2 1)) ?
17:49KirinDave_That's a little weirder.
17:49danlarkin= is value based, not order, not type
17:49hiredmanKirinDave_: a set is an unordered thing, and a list is ordered
17:49hiredman,(= [1] '(1))
17:49clojurebottrue
17:49KirinDave_hiredman: Don't have to argue with me.
17:50hiredmaner
17:50hiredmandanlarkin:
17:50hiredmanwhoever
17:50KirinDave_lol
17:51devlinsfHere's an interesting one
17:51devlinsf,(= (sorted-map "a" 1 "b" 2) {"a" 1 "b" 2})
17:51clojurebottrue
17:51hiredmanshould #{1 2} = '(1 1 2) then?
17:52technomancyit is a bit weird that comparing vectors and lists ignores type
17:52devlinsf,(= (sorted-map "a" 1 "b" 2) {""b" 2 a" 1})
17:52clojurebotjava.lang.Exception: Unable to resolve symbol: b in this context
17:52technomancybut I can see how orderedness could be considered part of the value of a list in some way
17:52technomancy*some way that doesn't apply to sets
17:52devlinsf,(= (sorted-map "a" 1 "b" 2) {"b" 2 "a" 1})
17:52clojurebottrue
17:53devlinsftechnomancy: Thought on my map examples?
17:54technomancydevlinsf: I'm puzzling over whether these are inconsistencies
17:54hiredmana sorted map is a map
17:54devlinsfbut a hash-map isn't sorted
17:54devlinsfSuppose I provide a different comparator to a sorted map
17:54devlinsfSimple as increasing & decreasing
17:55hiredmanbut the sort or not doesn't come into play when comparing maps to maps
17:55hiredmana set is not a list, so when comparing various other attributes are taken into account
17:56devlinsfWell, the problem is that I can't use the maps interchangably
17:56hiredmanso?
17:56danlarkinso maybe = takes into account value and ordering properties
17:56devlinsfRight.
17:56danlarkinbut not type in and of itself
17:56devlinsfOr is hiredman right and it doesn't matter
17:56devlinsf?
17:57devlinsfThis question hit me on the way home from work
18:00devlinsf,(= (sorted-map-by compare "a" 1 "b" 2) (sorted-map-by (comp - compare) "a" 1 "b" 2))
18:00clojurebottrue
18:01hiredmanboth maps, and for maps the value comparison has great presedence than order
18:02hiredmanwould you rather sorted and unsorted maps with the same content be considered unequal?
18:02devlinsfI'm not sure
18:02devlinsfWhat is "content" in this case?
18:02hiredmanthe keys and the values
18:02hiredmanare you kidding?
18:02devlinsfNope
18:03devlinsfIs the comparator part of the value?
18:03devlinsfThe issue is I'm talking about a more specific map
18:04hiredmansorry, "what is content" tripped my bikeshed-o-meter so I am no longer part of this
18:04LauJensenNew blogpost, explaining where ClojureQL is now and our recent move to a new build system: http://www.bestinclass.dk/index.php/2009/12/clojureql-where-are-we-going/
18:05devlinsfhiredman: okay, fine
18:06devlinsfhiredman: It's an academic discussion anyways
18:07replacaQ: I have a def with metadata: (def #^{...} sym val). I want to create a new root binding (i.e. a new def) and attach the same metadata, but I don't know how
18:07replacaSomething that feels like (def #^(meta #'sym) val), but that's not right
18:08replacaanyone know how to do that?
18:08hiredman.alterRoot
18:08hiredman(.alterRoot #'foo whatever)
18:09replacaahh, thanks. Does that just not touch the metadata?
18:09stuartsierraor (def thing) followed by (alter-meta! thing (meta #'foo))
18:09hiredmanI'm not sure. but I doubt it
18:10hiredman,(doc alter-var-root)
18:10clojurebotDENIED
18:10hiredman:|
18:10replacastuartsierra: cool, though I've obviously got to grab (meta #'foo) before the def
18:11hiredmanhmmm
18:11hiredmanalter-var-root does nuke the metadata
18:12replacaok. It would be nice in general if metadata were retained in all these situations if we didn't explicitly create new metadata
18:13replacafor example, (declare foo) nukes the metadata on foo
18:13replacawhich is bad if you've got a system that wants to not care about definition order
18:13replaca(like autogenerated code, sometimes)
18:16hiredmanreplaca: all declares should go at the top in that case regardless
18:18replacahiredman: yeah, but if you have separate components generating fragments, that might be a burden
18:19replacahiredman: generally, it feels like declare should be a no-op relative to value and metadata, just a statement about the fact that the symbol is a valid var
18:19replaca(or it does to me)
18:26hiredmanreplaca: a "metadata policy" compliance audit might be in order
18:27hiredmanit can be easy to overlook what happens to metadata when you write a new macro or whatever
18:28hiredmanand people use with-meta instead of vary-meta
18:31replacahiredman: good points - metadata in Clojure reminds me a little bit of locking in Java programs: programmers have a tendency to forget about it
18:32hiredmanwell, it is only metadata :P
18:35replacayeah, depends how real we want it to be
18:35replacaso far it's mostly a concept thing with a few hard uses (func info, :tag,...?)
18:35qedanyone here have some yasnippets made up already for clojure?
18:37skyboundi'd appreciate a hint on howto restructure a flat sequence to a nested one; for example given: '(1 :o 2 :c 3 :o 4 :o 5 :c 6 :c 7) how could i get this: '(1 (2) 3 (4 (5) 6) 7) ? my best guess is something using core.walk, but i don't get anywhere.
18:40technomancyqed: hopefully you don't need snippets for writing clojure since there isn't much boilerplate
18:41qedi dont really, but im mucking around learning yas, so im making a few
18:41qedjust made a simple little defn
19:14hiredmanhmmm
19:14hiredmandoing the quoting in macros that write macros
19:15hiredman:|
19:15_atotwbray: it's surprisingly hard to fully utilize the niagra isn't it? my first version maxed out at 900% CPU. I think it was bottlenecking because one thread was doing IO and passing chunks of lines to the other threads. I'm working on a version that has each thread doing its own IO
19:16twbray_ato: It's really easy to max the sucker out with a well-configured Apache + PHP or Rails or EE or whatever.
19:16twbraySo for Web serving, we don't have a concurrency problem. For lots of other stuff, though, it's way too hard.
19:17_atoyeah, if you can do more or less share-nothing it's no problem of course, but it's when you need communication between threads that concurrency gets hard
19:22twbray_ato: my code is up on http://kenai.com/projects/divide-and-conquer - you might want to look at read_lines.clj Another version at paralines.clj uses java NIO mapping, but its performance is weirdly variable.
19:23_ato14163 ato 65 0 0 2083M 799M cpu 9:17 2736% java
19:24_atoyay! that's more like it :)
19:25_msthah :)
19:25twbrayIn fact there are only 8 cores...
19:25twbray... each of which has two integer threads ...
19:26twbray... oops, eachof which *can run* two integer threads ...
19:26twbray... but has 4 thread caches which can switch in in 1 cycle ...
19:26twbray... and the OS can't tell whether a thread in one of the caches in runnable state is actually running ...
19:27twbray... which is to say, CPU reports up to 1600% or sort of believable. Above that it's sci-fi.
19:28twbrayIt will sometimes report up to 3200%, e.g. on a heavily loaded web server. But only 16* the clock rate is actually happening. Worse if there's floating point.
19:28twbraystill, 16 * 1.4GHz is a *lot* of computing.
19:29_atoah that's right. I think I attended a talk on the niagra. It picks whichever instruction it can execute from the 4 threads instead of doing reordering of the one thread like a typical x86 would
19:30twbrayIt has massive memory controllers, memory bandwidth is fantatic. This one has rather ordinary disks though.
19:30cp2 interesting
19:31twbrayShould be a good machine to run clojure on :)
19:31cp2i feel this is required...
19:31cp2imagine a beowulf cluster of those!
19:32twbrayDmitriy V'yukov is getting fantastic numbers < 4 min on the whole 45G. But he's using C and going obscenely close to the metal.
19:32_atowow
19:33twbrayDmitriy says: real 3m12.941s
19:34twbrayalso: I use things like "probing" data as to whether it's cached or not, switching between multithreaded read-based reading and single-threaded aio-based reading, dynamic thread count tuning, etc. Dirty...
19:34technomancyamazing speed, but at what cost? will he be sane a week from now? =)
19:35twbraytechnomancy: not clear to me that this community is 100% sane either. Look at you guys...
19:35technomancytouché
19:35twbrayI am deeply appreciative of this kind of insanity.
19:42devlinsfhttp://www.zazzle.com/my_other_car_is_a_cdr_bumper_sticker-128776132386843273
19:45technomancyyeah, that one. =)
19:56qedhaha that's a great bumper sticker
20:32chouser"my other first is a next" just doesn't have the same ring.
20:34meesome folks in here might find this interesting (or perhaps painful) http://chuck.cs.princeton.edu/
20:41chouserthe time it takes for me to understand a new language well enough to make any kind of judgement about it, or learn anything useful from it is still prohibitively high.
20:42chouserit's much easier to take shortcuts. "it has mutable locals? well, nevermind then..."
21:03devlinsfYo, when did flatten change
21:03devlinsf?
21:04devlinsfOkay... fixed.
21:10lghtng,(+ 2 2)
21:10clojurebot4
21:11lghtngthere was a guy in efnet #ai who made a prolog bot that did all kinds of amazing things
21:11devlinsfchouser: Hey, I left you with a riddle for using take-while with a map
21:11devlinsfchouser: Any ideas of a use case? :)
21:12dmiles_afklghtng: like what?
21:12lghtngit could run alot of prolog code
21:12lghtngas well as all the infobot stuff
21:13lghtngi dont know that it was a hacked eggdrop but i want to say it was
21:13hiredman"import infobot fact packs" has been in clojurebot's TODO forever
21:14hiredmanas in, add support for importing
21:15dmiles_afkyes it used an eggdrop as an outer skin
21:15lghtngwas that your bot?
21:16dmiles_afkbut underneath it was SWI-Prolog
21:16dmiles_afkit might have been
21:16lghtngi used to go in there once in awhile and goof around with it, this was in, like 98
21:16dmiles_afkbut havent ran it on irc for a while
21:17dmiles_afknow i am working a more complete Lisp+Prolog+CLojure+CYC version ;)
21:17lghtnghiredman: do you have an idea about what kind of format you want the data stored in?
21:17hiredmanuh
21:18hiredmanclojurebot stores stuff in triples
21:18hiredmansubject | predicate/verb | object
21:18lghtnglike allegrograph?
21:18hiredmanno idea
21:18hiredmanI just know clojurebot does it that way
21:18hiredmanif I recall infobot just keeps two dictionaries
21:19hiredmanare and is
21:19lghtng'howto Multi-Disk => <reply> $who, http://metalab.unc.edu/pub/Linux/docs/HOWTO/Multi-Disk-HOWTO'
21:19lghtng
21:19hiredmanyeah
21:19hiredmanand that would be in the is or the are dictionary
21:20lghtngshould it parse the file into its own db then discard it from memory? in other words can the import just be a read from the infobot site url holding the directory?
21:21dmiles_afkmight even be litterally a java.util.Hashmap by the time you get down to it
21:21hiredmandmiles_afk: infobot is perl
21:21dmiles_afkwell at least provides a java.util.Map interface to satisfy cojures want for a disctioary
21:21dmiles_afkoh i was fantisizing it was purely clojure
21:22hiredmanlghtng: easiest would be just to dump it in the existing db
21:22hiredmanclojurebot stores the tripples in derby
21:22hiredman(for some reason)
21:22lghtngso you really just need a function that will parse http://www.infobot.org/factpacks/ into derby
21:23hiredmanmeh
21:23hiredmanjust feed it through clojurebot's function for writing factiods
21:24lghtngor even query http://www.infobot.org/factpacks/ on the fly from the search term
21:24hiredmananyway, have fun
21:25lghtngok, it's now on my someday/maybe list :D
21:32interferonupdate-in can take an array of keys and update the array; is there a function that takes a map and an array of keys and returns the value there?
21:33hiredmannot an array
21:33hiredmanvectors are not arrays
21:33interferonyou're right
21:33interferoni guess it's probably actually a seq
21:33hiredman,(doc get-in)
21:33clojurebot"([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys"
21:33interferonbut is there a function that does that?
21:34interferonthanks
21:35dmiles_afklghtng: i am working on a more advanced factio system: http://logicmoo.ath.cx/manual/root/home/kifbot/testE2C
21:36dmiles_afkthe idea is it parses facts and queries into predicate logic
21:38dmiles_afkbetyter formated version http://opensim4opencog.googlecode.com/files/E2C.htm
21:39dmiles_afkopensim4opencog is a bot that is programmed in clojure for SecondLife
21:39dmiles_afkbut gotta get the bots brain caught up to understanding english again at that level
21:42alexykhow do you filter a map by deleting a set of keys?
21:42lghtnghttp://www.franz.com/agraph/support/documentation/current/agraph-introduction.html#header3-20
21:42devlinsfalexyk: What do you mean?
21:43alexykdevlinsf: I have a seq of maps and need to filter each by removing a set of keys
21:43hiredman,(reduce dissoc {:a 1 :b 2 :c 3} [:b :c])
21:43clojurebot{:a 1}
21:43hiredmanactually
21:43arbscht_,(doc dissoc)
21:43clojurebot"([map] [map key] [map key & ks]); dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s)."
21:43hiredman,(apply dissoc {:a 1 :b 2 :c 3} [:b :c])
21:43clojurebot{:a 1}
21:45dmiles_afklghtng: i keep trying to decide if Allegro Graph store is faster than a native prolog store.. almost tempted at some point to prsent a prolog store as a AllegroGraph store to lisp ;)
21:47lghtngfranz makes some pretty outrageous claims about its speed
21:47dmiles_afkthe arg indexing of AG though i think gets it fast as heck
21:47alexykhiredman: (apply dissoc m [keys]) is the same as (dissoc m k1 k2 ...) -- does apply do it slower?
21:48hiredmanalexyk: I doubt it
21:48dmiles_afklghtngL in a few days i should have SWI-Prolog vs "using prolog with AG"
21:48alexykhiredman: does apply create intermediate maps?
21:49hiredmannope
21:49hiredmanreduce does
21:49alexykcool
21:49dmiles_afklghtng: (i keep meaning to benchmark)
21:50alexykrhickey: great talk "are we there yet"! the only glitch is a bald pate in the center bottom of the frame :)
21:51alexykbut that's the cameraman's problem
21:53lghtngthe first hit on google for 'java rdf' is http://jrdf.sourceforge.net/
21:53lghtngbut jena might have more tools
21:54alexyklghtng: neo4j is good, too
21:54alexykI store triples in MongoDB via congomongo
21:55alexykand adjacency lists and anything else. I doubt you can go much faster...
21:58lghtngbut really, it might be more lispy to just worry about a clojure-sparkl library and let the chips fall where they may :D
21:59lghtngclorqle
21:59lghtngclojkle
21:59polypus there's also sesame and mulgara
21:59alexykI like clorqle. It's like gurgle.
22:01hiredmanhttp://github.com/richhickey/rdfm
22:03polypusalexyk: do you have the congomongo set up in production?
22:03alexykpolypus: I have no production. :)
22:04alexykacademic research...
22:04polypusjust curious cuz i'm now evaluating various rdf backends for a production app.
22:04alexykmongo is good for general DB
22:04polypusi don't even know if anybody in the real world is using anything other than rdf ontop of sql
22:05alexykJSON-like
22:06polypusnot that academic research aint real :)
22:06alexykhow do I pass functions in general? trying: (defn applyf [f s] (map f s)); (applyf #(print %) (1 2 3)) ; error
22:07polypusalexyk: your last list is not quoted
22:07hiredmanerror is the least informative possible desciption of an error
22:08alexykhiredman: the assumption it's obvious :)
22:08alexykpolypus: thx
22:08hiredman,(applyf #(print %) (1 2 3))
22:08clojurebotjava.lang.Exception: Unable to resolve symbol: applyf in this context
22:09alexyk,(member:defn applyf [f s] (map f s))
22:09clojurebotjava.lang.Exception: Unable to resolve symbol: member:defn in this context
22:09alexykit stuck 'member' in somehow
22:21lghtnglol, i found your nyc lisp page
22:24defnhey all
22:24devlinsfYo
22:24defnwhat's up
22:25devlinsfEh, writing code :)
22:26defnI wonder if clojure could be a part of the GSoC next year...
22:26defnthat'd be fun
22:36alexykare there ways to shorten this: (let [a (:a m) b (:b m)] ...) ?
22:37hiredman~destructuring
22:37clojurebotdestructuring is http://clojure.org/special_forms#let
22:38alexykcute!
22:49alexykhow do you convert :a to "a" ?
22:49chouser,(name :a)
22:49clojurebot"a"
22:50alexykthx
22:54alexyk,(doseq [x '({:user "a" :reps {:a 1 :b 2}})] (let [{ a :user rs :reps} x] (for [to (keys rs)] (print to))))
22:54clojurebotnil
22:54alexykwhy nil?
22:55lghtnglovely inspiration for me here tonight, im diving into the sparql tr
22:55defnso im in my REPL, and im interested in taking all of the forms in compojure/*, and printing their (doc *) for all of the possible completions, to a text file
22:55defnhow would i do that?
22:55alexykcompare:
22:55alexyk,(doseq [x '({:user "a" :reps {:a 1 :b 2}})] (let [{ a :user rs :reps} x] (print (keys rs))))
22:55clojurebot(:a :b)
22:56chouserdefn: ns-publics gets you the vars of a namespace, (:doc (meta a-var)) gets you the docs, duckstream can write to a file easily.
22:56chouserdefn: go!
22:56defnlol thanks :)
22:56chouser:-)
22:57chouseralexyk: map is lazy
22:57alexykso why above, (for [to (keys rs)] (print to)) prints nothing? is it map inside?
22:58chouseroh, sorry.
22:58chouseralexyk: for is lazy
22:58alexyk:)
22:58alexykshould I whip it with doall?
22:58chouser(for ....) returns a lazy seq, ready to print as soon as anything forces it.
22:59chouserbut doseq doesn't force it and always returns nil.
22:59chouseralexyk: why not another doseq?
22:59alexykchouser: print is for testing, I'll add edges to a Java graph. So should I doseq it too? without bindings?
23:00alexykah, doseq instead of for, ok.
23:00chouserif you're mutating things, doseq is good.
23:00alexykyep, works.
23:00chouserbetter would be of course to write it functionally, take input, return a graph. In that case, you'll want something other than doseq for the outer loop too.
23:01alexykwell, my graph is tens of millions of nodes...
23:04technomancychouser: I heard you decided on a name for the book?
23:05chousertechnomancy: that's what I heard too
23:05defndid someone say book?
23:05defnchouser: clojure book?
23:07interferoni have a map like this {:a {:b [1, 2, 3, 4], :b {:c [5, 6, 7]}} i'd like to apply a function to the map that transforms the vectors inside, so the result might be something like {:a {:b 10}, :b {:c 18}}
23:07devenderhi what does xrel mean ?
23:08devenderit is referred to a lot in the api
23:08devenderhttp://richhickey.github.com/clojure/clojure.set-api.html#clojure.set/index
23:08chouserdevender: just for clojure.set fns, right?
23:08devenderyeah
23:08devenderis it just a map ?
23:09chouserset of maps
23:09devenderoh ok thanks
23:09interferonin general, i have a hard time transforming arbitrary parts of a data structure like the one above
23:10chouserinterferon: update-in
23:10interferonhmm
23:10interferonthat would do it
23:11chouserhm, though if you're mapping...
23:12interferonis there a better way?
23:12interferoni should mention that i don't know the keys in advance
23:13interferoni'm manipulating a structure i created elsewhere that looks like {2009 {34 [ .... ] 45 [ ....]} 2008 {4 [ ...] }}
23:17defnhmm, chouser: (defn sort-ns [nspace] (sort (keys (ns-publics nspace)))) (defn emit-docs [file-name, nspace] (append-spit (file-str "~/path/to/" file-name) (map #(doc %) (sort-ns nspace))))
23:17defnsomething is funky there with the map #(doc %) im guessing
23:17defnUnable to resolve var: p1__2355 in this context
23:18interferonchouser: any other approaches? i could loop through each level of keys and then do an update-in
23:18chouserit is a bit tricky to think about. I don't think update-in gets you much closer.
23:19chouseryou want more of a map-in, if there were such a thing.
23:19chousermaybe devlinsf's visitor fns would help, but I haven't wrapped my head around them yet.
23:19devlinsfHey
23:20devlinsfGimme a sec...
23:21devlinsf(map-vals map #(map-vals map vec %) interferon-map)
23:22devlinsfThat should do the trick
23:22chousersee, that's much better than what I've got going here.
23:22devlinsfI'll post my stuff to github... gimme a sec
23:22chouserwait, that can't be right
23:23chouserhe wants to sum the vectors
23:23devlinsfHmmm
23:23devlinsfOkay....
23:23interferonsorry, i got dropped
23:24devlinsf(map-vals map #(map-vals map (partial reduce +) %) interferon-map)
23:24devlinsfThat should do it
23:24interferonis map-vals built-in?
23:25interferonand what is in interferon-map? :)
23:25interferonoh it's the variable?
23:25interferongot it
23:25devlinsfYour map
23:25devlinsfmap-vals is a visitor I wrote
23:25defn(map #(doc %) (sort (keys (ns-publics 'compojure))))
23:25defn=> Unable to resolve var: p1__2742 in this context
23:25chouser,(let [m {:a {:b [1, 2, 3, 4]}, :b {:c [5, 6, 7]}}] (into {} (map (fn [[k m2]] [k (zipmap (keys m2) (map #(apply + %) (vals m2)))]) m)))
23:25clojurebot{:a {:b 10}, :b {:c 18}}
23:26devlinsfhttp://github.com/francoisdevlin/devlinsf-clojure-utils
23:26chouserI'll be back a bit later
23:26devlinsfMy repo
23:26devlinsfCheck lib.sfd.map-utils
23:26devlinsfdocs are in process
23:26alexykdoes doseq take many forms or needs a do for many?
23:26defnCan anyone illuminate what the error I'm getting is caused by?
23:27defnIt seems rather natural to map #(doc %) across a collection of forms
23:27defnerr the form names
23:30interferondevlinsf: looks like map-vals is (map-vals f coll)
23:30technomancyreplaca: is there any way to indicate to pprint that values in a list should be lined up as key/value pairs like when pprinting a hash?
23:30devlinsfNo
23:30technomancy*a map
23:31devlinsfIt's a visitor. It modifies a higher order fn
23:31devlinsfLike I said, the docs are in process
23:31devlinsfIt's (map-val mappping-hof f coll)
23:31defn,(map #(doc %) (sort (keys (ns-publics 'compojure))))
23:31clojurebotjava.lang.Exception: No namespace: compojure found
23:32devlinsfOh, wait....
23:32devlinsfWrong fn!!!
23:32interferon:)
23:32defnwoops on the ',' -- just trying to figure out why I can't map #(doc %) across the collection of keys from ns-publics to get documentation for all of the elements in the list
23:32devlinsf(Work in progess, sorry)
23:32interferonnp appreciate the help
23:32devlinsfYou want vals-entry
23:33defni tried quoting '%, but no such luck
23:33devlinsfStart with this post
23:33devlinsfhttp://groups.google.com/group/clojure/browse_thread/thread/7bb01c23596f6636
23:34devlinsfIt explains the visitor hof I wrote
23:34devlinsfThen read this
23:34devlinsfhttp://groups.google.com/group/clojure-dev/msg/6c1bbce17cafdf52
23:35devlinsfI'll try to get some docs on github in the next 24-36 hours
23:35interferonthanks
23:36devlinsfNo problem
23:36devlinsfThe interesting fns are vals-entry, keys-entry, vals-pred & key-pred
23:39alexyktechnomancy: why run repl as -client, not always -server?
23:39alexyk(in lein)
23:39technomancyalexyk: java -server has a really rotten VM boot delay
23:40alexyktechnomancy: ah! then it may be an option, like, "script kiddie=>client, dataminer => server" :)
23:40defnhmm, what is this (:doc (meta %)) stuff
23:40defnhow do i find out more about :doc?
23:40technomancyalexyk: well it's unlikely to matter for the repl, but I suppose it could for other tasks
23:40technomancydefn: docstrings are syntax sugar for adding a :doc key to an object's metadata map
23:41technomancyalexyk: most lein tasks are meant to be run interactively though, which is what -client is meant for
23:42defntechnomancy: im not sure i follow
23:42alexyktechnomancy: I run long jobs in repl, is it sinful?
23:43technomancyalexyk: the general consensus is that you will need to say seven hail marys to atone.
23:43alexyktechnomancy: will the said marys run my code as fast as from a stand-alone jar?
23:44technomancydefn: (def #^{:doc "a function I wrote"} my-fn (fn [x] (+ x x))) => (defn my-fn "a function I wrote" [x] (+ x x))
23:44defnahh thanks technomancy
23:45technomancyalexyk: heh. the only reason I'm reluctant is that you'd have to add logic to the shell script to do that, and I hate maintaining shell code. but you may have a point.
23:46technomancyalexyk: but maybe honoring $JAVA_OPTS would be enough?
23:46KirinDave1technomancy: You have paren matching in irc?
23:47technomancyKirinDave1: natch, M-x erc
23:47KirinDave1lol lol lol
23:47KirinDave1I gotta say, I just can't get into emacs coding on a large scale
23:47KirinDave1I can do small things
23:48KirinDave1But I am amazed at people who go to great lengths to make things like irc clients. I think it's brutal
23:48alexyktechnomancy: let's start with $JAVA_OPTS and ramp up slowly :)
23:49alexykBTW: -client or -server can go into JAVA_OPTS.
23:49alexykso you may stick it there unless there's a -server or a -client there already
23:51technomancyalexyk: I checked; you can have -client and -server both; whichever is last wins. =)
23:51technomancyKirinDave1: the lack of lexical scoping is annoying, but hardly crippling. but UI work is always challenging.
23:51hiredmantechnomancy: while you are at it /bash/sh/s :P
23:52technomancyhiredman: I'm reluctant to do so since from what I understand Linux systems usually don't have sh; they just symlink bash to sh. so I don't have a way to make sure I don't accidentally rely on some bash-specific functionality
23:52technomancythough I could be misremembering
23:53hiredmantechnomancy: you dev on macosx right?
23:53technomancyhiredman: no, ubuntu
23:54hiredmanyou could install dash
23:54technomancyhiredman: is bash a problem on some systems?
23:54technomancy(systems people actually use, I should say)
23:54hiredmanhttps://wiki.ubuntu.com/DashAsBinSh
23:55hiredmantechnomancy: it's not always in /bin
23:55hiredmanlooks like since 6.10 ubuntu's /bin/sh is not bash
23:56technomancyhiredman: ah; I am woefully out of date
23:59KirinDave1technomancy: It's also annoying how everything needs to be so buffer centric