#clojure logs

2011-04-15

00:00livingstonbut all keywords are? (makes sense just checking)
00:00amalloylivingston: i stand by "all keywords are". refuse to make myself an idiot by asserting something i'm not sure of re: symbols
00:00livingstonand what happens if I scan through a 100,000,000 of these things ? how bad to I permanently crud up my symbol table?
00:01cemericksymbols are not interned, but their components are
00:01cemerick,(identical? (name 'f) (name 'f))
00:01clojurebottrue
00:02livingstonamalloy: that's actually a really nice example a potentially good argument (square brackets just seem more "angry" to me)
00:02amalloy&(name 'f)
00:02sexpbot⟹ "f"
00:02technomancychewbran1a: heya
00:02amalloyif you have a hundred million variations on foo1234, don't make them into keywords
00:02amalloybecause you won't be typing them literally
00:02technomancycemerick: "interned" means something different in CL-land IIRC
00:02livingstonthe names have to be identical, because they are java strings and thats the rule for the java string table, right?
00:03amalloylivingston: i don't believe so
00:03cemerickjava string table?
00:03amalloy&(identical? "a" (apply str (rest "ba")))
00:03sexpbot⟹ false
00:03amalloy&(= "a" (apply str (rest "ba")))
00:03sexpbot⟹ true
00:03cemericktechnomancy: Yeah, I've successfully forgotten all that.
00:03livingstontechnomancy: cemerick: in CL interned means in the namespaces symbol table (you can have symbols that aren't internned and thus not in the symbol table)
00:03chewbran1atechnomancy: hey how's it going? got a silly leiningen question for ya
00:04technomancychewbran1a: sure; go for it
00:04cemericklivingston: there is a keyword "table"; there is no such thing for symbols (they intern their string components in the JVM).
00:05livingstoncemerick: that makes sense, thanks
00:05cemerickamalloy: The keyword churn thing is apparently fixed in 1.3 head IIRC
00:05livingstonchurn thing?
00:05amalloycemerick: do keywords that nobody has a reference to anymore actually get un-interned?
00:06cemerickamalloy: AFAIK, yes
00:06amalloycool
00:06chewbran1atechnomancy: bah... like I said it was silly, was trying to add another dependency but forgot to restart my nailgun server
00:06cemerickThat was actually supposed to be the case in 1.2, but something went awry in the implementation.
00:06cemerickI think that fix is in 1.2.1 as well?
00:06chewbran1atechnomancy: finally diving into a small clojure project
00:07livingstonthe reason there will be boat loads of these things is I have an RDF triple store with say 6.8B triples in it... I'll run a query and look for something, I could get a lot of responses that I have to look through or process etc. they will be processed as symbols/keywords/whatever-you-all-tell-me-isn't-going-to-kill me
00:07cemericklivingston: i.e. the retention of created symbols even after they are no longer in active use.
00:07technomancychewbran1a: sweet
00:07technomancychewbran1a: yeah, it's a shame new dependencies can't be loaded up into the currently-running process; it's a silly limitation of the JVM =\
00:08cemericklivingston: Absolutely do not use symbols from that. Interned Java strings simply cannot be un-interned, period. You'll crush your permgen every time.
00:08chewbran1atechnomancy: hahaha yeah, just found that one out, good to know
00:08livingstonif symbols / keywords with no pointers to them, get GC'ed I'm ok...
00:09livingstoncemerick: right, I'm really worried about that, but if these things are fundamentally string data? what else could I do?
00:09chewbran1atechnomancy: any recommendations on a json lib?
00:09cemericklivingston: only keywords for you, then, unless the domain of name and namespaces used in the symbols in question is fixed/size-limited
00:09technomancythe keyword intern fix for 1.2.1 was about a race condition; apparently the weakref fix didn't get included
00:10livingstoncemerick: namespace is finite, names is finite but the number is in the billions
00:10technomancychewbran1a: we are using https://github.com/dakrone/cheshire at work; danlarkin's json lib is also good.
00:10cemericktechnomancy: so 1.3 HEAD it is, I take it?
00:10technomancycemerick: ja
00:11cemericklivingston: get thee on the latest of 1.3, and use keywords
00:11livingstonkeywords know their name though, right? so that had to be a string at one point and will end up doing whatever every other string does, right?
00:11cemerickKeywords' strings aren't interned though.
00:11cemerickThey will get GC'd.
00:11chewbran1atechnomancy: cool, cheshire looks like it will do the trick
00:12livingstonoh, you can do that in the jvm?
00:12cemerickdo what?
00:13amalloylivingston: i just demonstrated that not all strings are interned, didn't i? "a" wasn't identical to "a"
00:13livingstoncemerick: not intern a string
00:13cemerickno, strings are not interned by default
00:13mecliteral strings are interned
00:13amalloy&((juxt = identical?) "a" (apply str (rest "ba")))
00:13sexpbot⟹ [true false]
00:13mec,(identical? "a" "a")
00:13clojurebottrue
00:13livingstonthe a that you chopped out of a string, yeah
00:14chewbran1ahey not sure if anyone is around who works with clojars.org, but couple comments, first thanks for building it, very useful, as someone new to clojure, I see two issues, first, you sort by modified time in ascending order, that is backwards, I want to see what is actually up to date, not what was updated possibly years ago, second, more meta data about the projects would be nice, I'm having trouble parsing lists of resources to f
00:14amalloylivingston: as long as your .clj file doesn't have 100 million strings typed into it you're okay
00:15chewbran1anot trying to be rude by any means, just giving some feedback
00:15technomancychewbran1a: yeah, clojars search needs to be totally rewritten.
00:15technomancyit's doing a sqlite query for each search even though there are lucene indices on disk
00:15technomancychewbran1a: I'm actually thinking about doing that for a seajure hack night =)
00:15technomancywell, I was going to do it client-side, but that code could be adapted for the web site too
00:16livingstonso just to be clear ... I'm making the vast majority of these "tokens" from the output from another data source coming at me effectively as strings and I have (filter :foo (map keyword giganto-stream-of-output)) I'm not going to blow anything up?
00:16chewbran1atechnomancy: oh cool, that would be fun
00:16technomancychewbran1a: it's super rough-around-the-edges, but https://github.com/technomancy/lein-search/tree/lucene might be better than the current search on clojars.org
00:16amalloylivingston: cemerick says you would blow things up iff you used symbols instead of keywords
00:16technomancyplus it searches any repo you've got configured
00:16cemerickamalloy: way to pass the buck, man! :-P
00:16cemerick;-)
00:17amalloycemerick: that's what you get for being helpul. you get blame
00:17livingstonamalloy: no the clj files will have comparatively few symbols/keywords in them ... the rest come from interpreting the output of the triplestore
00:17chewbran1atechnomancy: interesting, how well does lucene integrate with sqlite? haven't combined the two before, my first instinct would be to use something like couchdb, seems ideal to be able to just store arbitrary json for project data
00:17cemerickhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Symbol.java#L50
00:17technomancychewbran1a: in this case they are totally separate
00:18technomancythe lucene index is built from the poms on disk
00:18technomancychewbran1a: I tried to convince them to use couch so that 3rd-party mirrors down the line would be really easy to do with replication, but I think that never went past the exerimental stage
00:18technomancysqlite seems to be doing the job fine for everything except search
00:19technomancyapparently the traffic is low enough that getting mirrors set up is not a high priority
00:19chewbran1ayeah I'm biased towards couch, but sqlite can get the job done, and besides you would have to hooked up lucene to it anyways
00:20chewbran1awhat are the plans for clojars?
00:20technomancyI don't know of any plans really
00:20technomancya while back there were a couple guys who were interested in contributing
00:20chewbran1aas in is it something that is considered mostly feature complete, or is there plans to extend it farther to something like cpan that has automated testing and comments and what not
00:21livingstonunless I'm mistaken keywords do the same thing no? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java
00:21technomancyI poked the maintainer and got some "getting started hacking on it" instructions, but I don't know if they went anywhere with it
00:21technomancychewbran1a: automated testing would probably be a stretch. there are other sites that offer review/comment features though
00:22amalloylivingston: you are mistake
00:22amalloyn
00:22chewbran1atechnomancy: you think so? I figured since its mostly (completely?) all leiningen projects, that it would be too hard to just run lein test on everything
00:22cemericklivingston: Keyword.java maintains its own interning map, using WeakRefs and a ReferenceQueue to ensure that unused keywords are ejected. Symbol.java interns component strings in the JVM itself, and has no way to "unintern" those strings.
00:22technomancychewbran1a: well, it's more a question of sandboxing untrusted code, I think
00:23chewbran1atechnomancy: fair enough
00:23livingstonamalloy: all the constructors take either symbols or two strings that are immediately turned into a symbol though? wouldn't that entail the same thing as creating a symbol?
00:23amalloylivingston: well. kinda seems that way to me so i'ma let cemerick tell us why he's right
00:23chewbran1atechnomancy: it might just be because I'm still getting familiar with clojure, but when I know of a library I want, clojars/leiningen rocks and works perfectly, but finding those libraries is difficult
00:24_ato````chewbran1a: I'm the Clojars guy. Yeah, good idea about descending sort, that's a tiny fix and you're right it would help a lot.
00:25chewbran1atechnomancy: for instance, I'm looking for a couchdb api, and I'm leaning towards rolling my own because the list of couchdb plugins I get doesn't tell me much: http://clojars.org/search?q=couchdb
00:25technomancy_ato````: I'll ping you once I've rewritten lein-search to use lucene
00:25technomancythat code could probably be adapted for server-side use
00:26_atotechnomancy: cool, yeah that'd be good.
00:26chewbran1a_ato: hey glad to get in touch with you, yeah the sorting through me off for a second, thanks for clojars and I hope my criticisms comes off as positive, I'm just on the new to clojure side of the fence so I figured something I could actually contribute to is how the experience is for new users
00:27technomancy_ato: are you still in school these days?
00:27cemerickUgh. :-(
00:27_atotechnomancy: nope
00:28cemericklivingston, amalloy: I retract my statements re: Keyword component interning.
00:28livingstoncemerick: it's cool
00:28livingstonit would have been awesome if you were right
00:29chewbran1aas for the couchdb lib thing, just kind of throws me off, at least the 5 most recently updated repos don't have any links to code repos, so I'm just kind of curious, how do you guys go about finding new libs to work with? hit clojars and google down a code base? come in here and ask? or what?
00:29livingstonit looks like there's no option that precludes loading the java string table / creating symbols etc.
00:30cemericklivingston: Simply using strings for your data avoids the whole mess, though I'll recuse myself at this point.
00:30hiredmanor byte[]s
00:30_atochewbran1a: I follow the mailing list, people tend to announce stuff there. But also: http://www.clojure-toolbox.com/
00:31_atoI should probably link that from Clojars
00:31technomancysimple ratings might be nice to add to clojars, but you'd have to worry about gaming the ratings then.
00:31technomancythere's also http://clojure-libraries.appspot.com/
00:32chewbran1a_ato: ahhh nice, good link
00:32livingstoncemerick: hiredman: neither of those options really seem appealing
00:33technomancyI think hiredman was joking
00:33technomancy?
00:33livingstonI think I'll just make the thing work like mad, and if it dies I'll deal with it then
00:33hiredmanwell, keywords used to be permanently interned, so possible some solution can be found for symbols
00:34chewbran1awell here's the thing, searching couchdb on clojars gives me close to 20 results, so there is bound to be something that will do what I want, so I go down and look at the most recently updated link, and its called 'clojure-couchdb', ok, so I hit google to search for it, and turn up half a dozen different repos on github alone named 'clojure-couchdb'
00:34brehautchewbran1a: have you looked at clutch?
00:34livingstonI mean making things be pointer equal (which is a really obvious advantage) necessarily requires some kind of interning... it'd be nice if there was a way to know when that interning could go away or somethinng though
00:35hiredmanbut is it required that 'foo be .equals to 'foo
00:35technomancychewbran1a: yeah, a lot of that is just shared community knowledge that isn't captured anywhere canonical. there's still no replacement for asking on IRC.
00:35hiredmanlivingston: well, you would do the samething with keywords, weakref, etc
00:36technomancywhich is fine by me; I like IRC =)
00:36livingstonhiredman: right - that's what I want
00:36chewbran1abrehaut: yeah I started in on this last night and came across clutch, and it looked interesting, but more heavily focused on creating a clojure based view server when all I'm looking for is a minimal client lib
00:36livingstonpointer = that is
00:36banjiewenchewbran1a: part of the 'problem' may lie with couchdb's interface more than anything - if there are 20 libraries, it's because it's so easy to write one.
00:36hiredmanI did the original weakref patch for keywords, which never got applied, and then what was applied had a nasty race condition in it
00:37brehautchewbran1a: there is a minimal client lib in there too
00:37brehautchewbran1a: ive not worried about the view server stuff at all and its worked well for me
00:37cemerickchewbran1a: FWIW, clutch's client lib is particularly complete -- the view server is there, but hardly the focus (at least by the devs).
00:38chewbran1atechnomancy: yeap I'm fine with irc too, but I've been following clojure for a bit now, and one of the things I've seen repeatedly brought up is difficulty for new people to figure out tools and how to get up and running with things, so I figured I would take some 'notes' while going through the process
00:38livingstonhiredman: bummer
00:38chewbran1abanjiewen: yeah agreed, which is why I was about to just roll my own (still might for educational purposes)
00:38hiredmanwell, the race condition was fixed
00:38hiredmanbut was arond in 1.2.0 for a long time
00:38chewbran1abrehaut: ok cool, I'll take another peek at clutch
00:38hiredmanaround
00:39livingstonoh
00:39technomancyyeah, I wired up clojure-http-client to couch in ~40 LOC back in the day just for kicks =)
00:40banjiewenchewbran1a: for sure, yeah. I've been up to my eyeballs in couch for nearly 2 years now and haven't found anything more useful than an httpclient and a couple of helpers for formatting querystrings.
00:40livingstonalthough the keywords using symbols code entails that every keyword calls symbol, right? so unless symbols (which are two string pointers) and their underlying strings go away everything is there for the long haul
00:40chewbran1alol... so I did actually manage to track down the 'clojure-couchdb' library last updated on clojars.org by pieterbreed, its literally a fork of a fork of a fork of a fork of clojure-couchdb
00:41banjiewen*chuckles*
00:41technomancythat's another thing that clojars needs; a way to visually emphasize the original over the forks.
00:41technomancyit's debatable whether org.clojars.foo hits should even show in the default search at all
00:42chewbran1abanjiewen: yeah that's definitely one nice thing about couchdb, if you have an http client, you're set, and I just got setup with clj-http ;-)
00:42technomancyyeah, gnir is great
01:09semperosI second "make finding 'the right' jar on Clojars more intuitive", esp. WRT org.clojars.foo
01:20carllerchewhat are people's preferred testing libraries?
01:22amalloycarllerche: midje looks crazy-awesome, but when i tried to use it i couldn't figure out the syntax. i'd say take a look at that and if you figure it out plz teach me
01:22carllercheamalloy: alright, i'll take a look!
01:23carllerchehuh, it does look interesting
01:25livingstoni love when I have apparently equal code that does two different things deterministically... maybe I need a testing library
01:31livingstonoh that was a huge waste of time... so a lazy seq that is actually read outside of the (binding) block that created it will use the values for the *var* in the scope when the lazy seq is expanded?
01:31livingstonnot those that were in play inside the binding scope that created it?
01:33amalloylivingston: that's exactly the difference between dynamic and lexical scope
01:35livingstonbut this isn't good: (def *foo* 1) (binding [*foo* 2] (map (fn [x] *foo*) '(2 3))) versus (binding [*foo* 2] (doall (map (fn [x] *foo*) '(2 3))))
01:35livingstonthe first returns (1 1) the second (2 2) that seems really off to me
01:36amalloylivingston: because you are imagining that dynamic scope is lexical
01:36amalloyyou can use ##(doc bound-fn) to work with this
01:36sexpbot⟹ "Macro ([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."
01:36livingstonyeah, well crap
01:37livingstonI want lazy seqs, but I also want them to have my bindings, os I need to call fntail and create a new function before I map
01:40livingstonI have a library that has helper methods like (foo kb query) and if it's called with out the first arg (foo query) it just uses the value of *kb* for the kb. but now anything it produces is potentially borked.
01:56amalloyto...call...fntail?
01:57livingston?
01:59amalloylivingston: fntail does not exist as a callable thing. it is the name of the argument to boundfn
02:00livingstonoh
02:00amalloyit's not exactly well documented, but there are several places that use "fntail" to mean "whatever you would use to fill in the blank in (fn ____)"
02:00amalloythe "tail" of a fn
02:01livingstonah
04:17markomanhow can you match and replace list of items? (s/replace "1234" [2,3] "") -> "14"
04:18markomandocumentation says match can be a pattern or function
04:20tomojmatch can be a string, char, or pattern
04:20tomojit's replacement that can be a function
04:21tomojdo you really have a vector of integers?
04:24markomanhmh, ids might be integers yes, but can be converted to strings, or should in this case
04:25tomojpretty weird
04:25raek,(clojure.string/replace "1234" #"2|3" "")
04:25clojurebot"14"
04:25raek,(clojure.string/replace "abcd" #"[bc]" #(.toUpperCase %))
04:25clojurebot"aBCd"
04:25tomojare all the ids single-digit?
04:26raek,(re-pattern (apply str (interpose "|" [1 2 3])))
04:26clojurebot#"1|2|3"
04:27raekmarkoman: one way to do it could be to construct a regex from a sequence of integers as in the above example ^
04:28markomani was trying to use regex and its working here well. thanks.
04:28raekmarkoman: but if you will parse the string later anyway, you might instead want to parse it first and then do the substitution
04:29markomantomoj: i have a bad habit of simplifying problem here on channel, so actual case, these no need for int conversions, its all string
04:30markomanbut good talk and im learning more than I asked again :)
04:31markomanbtw, what is espace char in clojure regex?
04:34tomojmarkoman: ah, I had wondered what the heck you were doing :)
04:40raekmarkoman: if you enter #"foo\bbar", the string containing f o o \ b b a r will be compiled with java.util.regex.Pattern. the regex pattern compilator also understands the usual \\ \t \n \u1234 escapes, so those are handled correctly too
04:42raekso basically, you don't have to escape backslashes an extra time, as you need in elisp: #"\\" (matches one backslash character), and not #"\\\\", #"\b" (matches a word boundary), and not #"\\b"
04:42markomanso if i want to match [ which is a group indicator on regex, then i should use \\[ not \[ as i was trying
04:43raekyou should use \[
04:43raekyou write exactly as it says in http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
04:43raekso there is no need to insert extra backslashes
04:43markomani get Unsupported escape character: \[
04:44raekoh, is this in a regex literal or in a string literal?
04:44raek,#"\["
04:44clojurebot#"\["
04:44raek,"\["
04:44clojurebotUnsupported escape character: \[
04:44raekclarification: what I said only applies to regex _literals_ in clojure
04:45raek,(re-pattern "\\[")
04:45clojurebot#"\["
04:45markomani see, i see
04:46ejacksonFriday !
05:37matthias_what's theb est thing to read to learn clojure?
05:42ejacksonmatthias_: what level are you at with programming in general ?
05:42ejacksonI'd probably suggest starting with "Programming Clojure" by Halloway, and follow that up with "The Joy of Clojure" by Fogus+Houser
05:43fliebelejackson: Are you still being ignored by the air guys?
05:44ejacksonoh I gave up on that
05:44ejacksonbeing ignored by more important people that I need to chase :)
05:45matthias_im a good programmer but new to clojure
05:45matthias_my "mothertongue" is c++
05:45ejacksonthen you might be OK to start with JoC
05:46ejacksonfunctional programming is a bit odd at first
05:46fliebelejackson: Hm, I could give it a try, but I doubt I sound any more authoritative than you do.
05:46matthias_ive been learning some haskell
05:46ejacksonyou'll be fine then
05:46ejacksonenjoy :)
05:46matthias_still a noob at it though, just wrote half a raytracer with terrible code
05:46matthias_thanks, i shall google joc
05:49ejacksonIts by manning
05:49ejacksonand is excellent
05:56matthias_ordered
05:58ejacksonmatthias_: well done.
06:01matthias_gonna take two weeks to arrive D:
06:01matthias_(im in germany)
06:03ejacksonit comes with a free ebook, did you not get details of that with the purchase ?
06:03ejacksonthat would suck
06:30clgvejackson: do you also get the ebook when ordering via amazon ?
06:31ejacksonclgv: Most likely. I got the MEAP back in the day, so got ebooks that way, then when the deadtree came it had a flyer inside letting me know how to get a .pdf version.
06:31clgvah ok :)
06:32clgvamazon still displays 3-6 weeks delivery time... :/
06:32ejacksoneish
06:32ejacksonmine is at my elbow, and I'm in the UK
06:33clgvamazon UK displays some weeks as well...
06:34ejacksoncan you get it direct from Manning ?
06:38clgvejackson: might be an option. or I get it from amazon market (less shipping fee)
06:40clgvejackson: I want to let the company of my side shop order the book for me ;)
06:40clgvs/shop/job/
06:40sexpbot<clgv> ejackson: I want to let the company of my side job order the book for me ;)
06:40ejacksonyeah, having companies willing to do that sort of thing is nice
06:40ejacksonprovided its your company of course
06:41ejacksonor they let you keep the books they order for you
06:43clgvthey can compensate some overtime for it ;)
07:14markomans/what/is/this
07:14ejacksonsearch and replace
07:14ejacksonso if I type s/this/that/ on the next line
07:14ejacksons/this/that/
07:14sexpbot<ejackson> so if I type s/that/that/ on the next line
07:15ejacksonsexpbot will helpfully replace this with that
07:15markomanheh, nice
07:15markomans/nice/cool/
07:15sexpbot<markoman> heh, cool
07:16markomanwhat about the other special features ## , ?
07:18markoman,(println "this I know")
07:18clojurebotthis I know
07:19markomanis there some help available for channel bot features?
07:28BorkdudeWhat is currently the common way to query a nested map structure?
07:29Kototamaget-in
07:31thorwilis there a common name/idiom for functions that are like predicates, only that they pass there argument on, if it's "true" (so returning either the arg or false/nil)?
07:32arbschtthorwil: like or?
07:34thorwilarbscht: no, i mean the general case of something like http://paste.pocoo.org/show/372107/
07:34tomojdoesn't identity satisfy that?
07:35tomojoh, the truthiness check isn't of the argument
07:36thorwili need functions like that for routing with moustache
07:37Borkdudethorwil: like this? (fn [arg pred] (if (pred arg) arg nil))
07:37thorwilif i use a predicate in the url-match, the handler only gets to see "true", instead of the value that i tested
07:38thorwilBorkdude: yes
07:38thorwili was just thinking this must be common enough to have a label, but if there's none, i guess i will call these "guards"
07:42thorwilanyone with experience with multiple file upload and appengine-magic around?
07:42tomoj(if x y false) seems at the same time strange and more clear
07:44Borkdudethorwil: https://gist.github.com/921568 ?
07:44raekthorwil: in the moustache library, they are called validators
07:47thorwilBorkdude: cool, thanks
07:47thorwilah, i should look into the libraries i use some more :)
09:11zoldarhello, I'm trying to use multimethod with dispatch on first argument's class: (defmulti physics-apply (fn [arg & _] (class arg))) - methods have varying number of arguments; I'm getting an error of too many arguments passed to "class" - what am I missing?
09:14hoeckzoldar: looks good so far, sure that your error is coming from the dispatch fn and not some other fn being called?
09:15zoldarhoeck, honestly I'm not sure, because stack trace is cryptic, but that's the only possibility in scope of currently compiled namespace
09:16raekzoldar: note that if you redefine the dispatch function, you need to "flush out" the old one first by doing (def physics-apply nil)
09:16hoeckzoldar: I remember multimethods being hard to reload properly, often I still was using an old dispatch function even after redefining
09:16raekdefmulti will do nothing if the var already exists
09:17zoldarraek, that was it, thank you
09:17raekit is similar to defonce
09:22zoldarare multimethods deprecated in any way?
09:23raekno
09:24raekthey have some overlap with protocols for the scenario when you only dispatch on the type of the first arg
09:24zoldarraek, protocols probably give better performance?
09:25raekzoldar: you can also solve the defmulti problem like this: (defn physics-apply-dispatch [arg & _] (class arg)) (defmulti physics-apply #'physics-apply-dispatch)
09:26raekzoldar: yes they do. that's one the of the big motivations for them
09:26zoldarraek, looks the same to me - what's "#" here for? looks like CL :)
09:27raekinstead of taking the current value of the physics-apply-dispatch var, that yields the var itself
09:27zoldarah
09:28raekand vars can be used as functions too (the simply call the function they contain currently)
09:28zoldarthanks for tips
09:28raeknp :)
10:21zoldarhow should I refer to a record defined through defrecord from different namespace? now I'm getting something along "No such var: remote-ns/ExampleRecord"
10:22zoldarshould I compile that namespace explicitly at the beginning?
10:25raekzoldar: in addition to require the namespace, the client needs to import the record class too
10:25raekthis is one of the reasons you often see constructor functions
10:26raekthis is being thought upon: http://dev.clojure.org/display/design/defrecord+improvements
10:26zoldarok, got it, I need to import it
10:28zoldarI had common constructor, to which I would pass record class as the first argument - now I'm adding wrappers
11:35matthias_what the hell? fn is being converted into some weird f in my emacs... that just caused me some confusion. :|
11:36jlf`matthias_: sounds like you have http://www.emacswiki.org/emacs/PrettySymbol or something like it running
11:38matthias_i installed the starter kit. so it musth ave come with that.
11:38matthias_not sure if i like it
11:39fliebelThere was a trick to run -main of a ns without aot, right?
11:40jlf`matthias_: yep, i see pretty-lambdas mentioned in starter-kit-defuns.el
11:41clgvfliebel: just tape (-main) on repl ;)
11:41clgvs/tape/type/
11:41sexpbot<clgv> fliebel: just type (-main) on repl ;)
11:42fliebelclgv: nono, without the repl. just an option to lein I think.
11:43clgvah kk. dont know that. lein only builds uberjars for me ;)
11:43clgvwell gotta go now. cya
11:45raekfliebel: lein run
11:46raekor in clojure 1.3: java .... clojure.main -m the.ns
11:50fliebelraek: Cool, thanks.
11:57jashmennhey, how can i "apply" the dot (.) operator?
11:59dnolenjashmenn: wrap it in a fn, . is a special form.
12:00dnolen,(apply #(. % length) ["foo"])
12:00clojurebot3
12:04jashmennsure but what if you want to apply the "length" + args part?
12:05jashmenn,(apply #(. "foo" %) 'length)
12:05clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
12:05jashmenndoesn't work
12:06raekjashmenn: you have to use reflection in if you want to look up the method at runtime like that
12:06jashmennah ok
12:06raekmethods are not first class values like functions
12:07jashmennis it possible to use a macro to "trick" the dot operator without using reflection?
12:07jashmenni tried (and failed) to do that
12:08jashmennlike
12:08jashmenn,(defmacro dot-apply* [t m a] `(. ~t ~m ~@a))
12:08clojurebotDENIED
12:08raekyes, it is indeed possible to use a macro to generate (. "foo" length) given 'length
12:09raekyou should be able to use (dot-apply "foo" length) with that
12:09raekoh, sorry. (dot-apply "foo" length [])
12:10raek...but you can't do this with a "length" only known at runtime
12:11jashmennright
12:11jashmennwhich is why i'll have to use reflection (?)
12:11raekthink of macros as functions that take and return code
12:11raekjashmenn: is the method name only known at runtime, or is it known when your program starts up?
12:12jashmennthe method name is known at startup, the number of arguments is variable
12:13matthias_hmm, shouldn't paredit highlight the parenthesis you're currentliy in? i mean if yo ugot (bla bla) and the point is in the middle, it should somehow hightlight all of (bla bla). with a different background or but just highlighting the parentheses
12:13raekah, then the method is not known at startup, since methods with the same name but different arities are different methods
12:14raekjashmenn: note that vararg parameters (those that look like foo(int x, int... y) in java) are only an invention of the java compiler. they are actually passed as an array as the last argument
12:14raekmatthias_: that sounds like http://www.emacswiki.org/emacs/HighlightParentheses
12:15jashmennraek: right. i think im going to just go with varargs
12:15jashmennthanks for your help raek
12:16raek,(String/format "%d %d %d" (into-array [1 2 3]))
12:16clojurebot"1 2 3"
12:17raek,(#(String/format %1 (into-array %&)) "%d %d %d" 1 2 3)
12:17clojurebot"1 2 3"
12:17raekjashmenn: you can "functionize" a vararg method like that ^
12:17jashmennperfect
12:18raekhave fun :-)
13:53no_mindis there a way to store the result of *print-dup* to a string ? I need to serialize a map and store it in db
13:54stuartsierra`with-out-str`
13:54no_mindk
13:55amalloyor just pr-str
13:55amalloy&(binding [*print-dup* true] (rest (pr-str *ns)))
13:55sexpbotjava.lang.Exception: Unable to resolve symbol: *ns in this context
13:55amalloy&(binding [*print-dup* true] (rest (pr-str *ns*)))
13:55sexpbot⟹ (\= \( \f \i \n \d \- \n \s \space \s \a \n \d \b \o \x \1 \5 \7 \6 \4 \))
14:00choffsteinhey all. I have an algorithm question. Basically, I have two lists that look like this: [5 1 3 9 0 6 2 5 1] [:h :h :h nil nil :h :l nil :l]. I would like to transform this into [nil nil nil :h nil nil nil :l], where for consecutive :h (or nils), the highest value is selected and the rest are set to nil, and for consecutive :l (or nils), the lowest value is selected. Any ideas? I'm stumped on how to do this one
14:00choffsteinwithout multiple passes. It seems like the best way is to break it down into blocks of consecutive signals, work on that list, and re-assemble. Any ideas?
14:01amalloyhuh?
14:01ataggartditto
14:01amalloythe problem specification could use some work
14:02znutar_yeah I thought as described you'd get [::h nil nil nil nil :l nil :l]
14:03znutar_er, extra :h in there before the first :l
14:03Rayneswut
14:07choffsteinHerm, badly specified...
14:09choffsteinMainly because I am wrong in how I explained it. Okay, so, basically, we have three signals -- high, neutral, and low. For a sequence of highs and neutrals, uninterrupted by lows, we select the highest value previously marked as 'high' and set everything else to neutral. For a sequence of lows and neutrals, uninterrupted by highs, we select the lowest value previously marked by 'low' and set everything else to neu
14:10choffstein So, given [:h nil :h :l nil] [5 4 6 2 4], we would get [nil nil :h :l nil] back.
14:11choffsteinit's ... sort of a strange problem
14:11ataggartnil is neither high nor neutral nor low, so why are they in the first vecotr?
14:12choffsteinyeah, sorry. nil is the neutral value
14:12choffsteinmy head is swimming.
14:12choffsteini'm trying to break this down into smaller problems
14:13ataggartit might help to give an example that actually has uninterrupted anythign.
14:14ataggartalso if you're "select[ing] the highest value previously marked as 'high'" why does the resultant vector not contain the numerical values?
14:14ataggartI'm assuming there's spome correlation between the first and second vector, but it's not apparent
14:18choffsteinataggart: yes, there is, but for all intents and purposes, they can be thought of separate time series. So the first is a time series of 1, 0, and -1. The latter is a time series of floats. When the first time series goes positive, it should start reading the second time series and record all values marked as 1. It should stop reading when the first signal goes negative. It should then find maximum of the values
14:18choffsteinrecorded and mark it. A similar process should occur for when the first time series goes negative -- record all values in the second time series marked as negative and find the lowest when the first series goes back positive. If the first time series ends, it is considered to be the same as the time series changing signal.
14:19choffsteinI think I am just going to need to do a recursive function and keep track of some state...
14:20amalloychoffstein: if you don't know how to solve the problem, saying "i will just do x" means you will waste some time writing code that doesn't solve the problem. better to think about it for a while longer
14:21znutar_yeah you should just need to keep track of the length of the current :h/:l run, the position and level of the peak, and accumulate until you switch from high to low or vice verse
14:21choffsteinamalloy: very true -- but i'd rather hack and re-factor to see if it spurs some creativity.
14:21amalloygo for it, then
14:22choffsteinamalloy: don't worry, i'll come back crying in half an hour ;)
14:24ataggartchoffstein from your description: (f [1 0 0 -1 0 0 1 0 0 ] [1 2 3 4 5 6 7 8 9]) => [3 4 9] but your examples don't return a vector of the numeric values. A better grasp of the question would probably lead you to a batter answer.
14:25choffsteinataggart: My description was wrong :)
14:25ataggartgood luck
14:25choffsteinHaha, thanks. I'll need it.
14:25choffsteinI'll come back with a clearer head and try again. might be time to step away from the computer
14:50P_E.
14:51P_EI need a macro that I basically use as (for), but it wraps it into (doall (for)) instead.
14:52P_ECould someone help with this?
14:53P_EThe goal is to be able to update java arrays in for loops.
14:53no_mindI have to represent a DAWG in clojure. any idea which data structure will be most suitable for this ?
14:56thorwili'd like to chain validators (functions that either return their single arg, or false). trying to make sense of the maybe monad, i arrived at: (defn dodo [a] (domonad maybe-m [x a, y (fn [x] (if (< x 10) x false))] (fn [y] (if (> y 5) y false)))) but how do i realize that?
14:57fliebelP_E: Have you seen doseq?
14:57P_Efliebel: no, haven't, I'll take a look
14:58P_Efliebel: awesome, thanks, that's just what I need
14:59fliebelno_mind: Maybe a nested map?
14:59fliebelno_mind: Or you'd have to implement your own.
15:00fliebelthorwil: Have you seen -?> It's somewhere in contrib, or on the webz.
15:02thorwilhmm, google seems to like to ignore things like "-?>"
15:02P_Ethorwil: maybe you can search github fori t
15:02fliebelthorwil: It's like ->, but stops when something returns false.
15:03manutterwould it be listed in the clojuredocs site?
15:03replacahttp://clojure.github.com/clojure-contrib/core-api.html#clojure.contrib.core/-?&gt;
15:04fliebelthorwil: Oh, it returns nil, is that what you wanted, or do you want the last value?
15:04thorwilfliebel: i need the last value
15:06fliebelthorwil: Then modify the when-not to an if that returns ~'i# https://github.com/clojure/clojure-contrib/blob/b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6/src/main/clojure/clojure/contrib/core.clj#L22
15:06P_EAt the point of mvn installing clojure-contrib at http://riddell.us/ClojureOnUbuntu.html, I'm running into a problem: "Unable to find resource 'org.clojure:clojure:pom:1.2.0-master-SNAPSHOT' in repository clojure-snapshots (http://build.clojure.org/snapshots)&quot;
15:07stuartsierra1.2.0-master-SNAPSHOT is a very old version number.
15:07stuartsierraand build.clojure.org is no longer the host for the latest snapshots.
15:07thorwilactually, the way i read it, -?> should be appropriate, but i have to try. still would like to make sense of the domonad business :)
15:07no_mindfliebel: the problem with nested map is that for a given node, I need to store a) the sub tree b) auxiliary information about the node for search terminating at the node. So how do I store two piece of information with one key in nested map ?
15:08stuartsierraP_E: Those instructions are way out of date.
15:09P_Estuartsierra: where would I be able to find a newer version?
15:09fliebelno_mind: metadata? I honestly don't know.
15:09stuartsierraP_E: Just download the latest release from clojure.org
15:09stuartsierraIf you want the source, use github.com/clojure, not github.com/richhickey
15:09stuartsierraSee also http://dev.clojure.org/display/doc/Getting+Started
15:11P_Estuartsierra: ok, but where do I find general getting started for setting up clojure? I'm using Vim, but it already assumes I have the install ready.
15:11stuartsierrajust download it
15:11stuartsierraIt's Java: no installation necessary.
15:12technomancythat really ought to be called out explicitly on the getting started pages; something like "you don't need to install clojure"
15:13ataggartthorwill: I'm probably misreading your question, but why wouldn't 'and work?
15:13P_Estuartsierra: ok, I did do that initially, but I had problems with clojure-contrib.jar. I included it into the classpath in my clojure alias java -cp "clojure.jar:clojure-contrib.jar" clojure.main, but it has problems when I :require say clojure.contrib.string
15:14stuartsierrawhat problems?
15:14markskilbeckHas anybody read Paradigms of Artificial Intelligence Programming?
15:15P_Estuartsierra: could not locate string__init or string on classpath
15:15P_Efile not found error
15:15maaclCan anyone explain why hiccup 0.3.4 blows up on compile when I try to use in a project with cake or lein? I get Unable to resolve symbol: resolve-uri in this context (core.clj:10)
15:16stuartsierraclojure.contrib.string does not exist after 1.2, maybe that's what you're running in to.
15:17P_Estuartsierra: could you tell me something that does then?
15:17P_Estuartsierra: I also tried xml and sql
15:18stuartsierraclojure.contrib.xml never did exist. I think clojure.contrib.sql still does, though it will also be moving to a separate repository soon.
15:18P_Estuartsierra: sql doesn't work
15:19P_Estuartsierra: same error there
15:19stuartsierra(require 'clojure.contrib.sql) ?
15:20amalloyno_mind: {:k [some-meta sub-tree]}?
15:20P_Estuartsierra: (ns solution (require 'clojure.contrib.sql)) ?
15:22P_Estuartsierra: I'm getting the same error without the namespace specifier
15:22amalloyP_E: that is not a well-formed ns form
15:22fliebelP_E: Oh, ns uses a different syntax. Make it a keyword and strip the quote.
15:22P_Eyeah that's how I previously wrote it
15:22P_Estill doesn't work
15:22fliebel(ns solution (:require clojure.contrib.sql))
15:22stuartsierraCheck this: (System/getProperty "java.class.path")
15:25P_Estuartsierra: OK so I actually have it in the path now, but there's a different (bigger) error
15:25stuartsierraok
15:25P_Estuartsierra: it's out of bounds in Vim so let me get that in a repl
15:26P_Estuartsierra: user=> (require 'clojure.contrib.sql) NoSuchMethodError clojure.lang.RestFn.<init>(I)V clojure.contrib.def/defmacro---509 (def.clj:39)
15:27stuartsierraThat's a version mixup. You have an old version of clojure-contrib with a newer version of Clojure, or vice-versa.
15:28P_Estuartsierra: ok I'll try to git the very newest versions now properly
15:29stuartsierraRemember, you don't really need "clojure-contrib.jar"
15:29stuartsierraEspecially just getting started.
15:29P_Estuartsierra: I just want to have it in case I need something for Google Code Jam
15:29P_Estuartsierra: I'm gonna try to use clojure there
15:30fliebelP_E: Have you looked into use Lein instead? Might be easier.
15:30choffsteinanyone know any good tutorials on how to use defmulti and defmethod? I can't seem to dig up any really clear examples on google.
15:31stuartsierraP_E: If the Google Code Jam problems are algorithmic, it's highly unlikely you will need anything in clojure-contrib.
15:31P_Estuartsierra: combinatorics might be useful
15:31ataggartchoffstein: look at how it's used here https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj
15:31choffsteinataggart: Thanks :)
15:31P_Estuartsierra: and complex numbers as well
15:32stuartsierraBoth are unmaintained.
15:32P_Efliebel: no I didn't even know what Lein was
15:33amalloyclojurebot: lein?
15:33clojurebotlein is http://github.com/technomancy/leiningen
15:33P_Efliebel: I don't yet need to build projects
15:33amalloyP_E: doesn't matter, you want lein or cake anyway
15:34fliebelP_E: Lein also works as just a repl.
15:34kingpotatoLein is a lot more than just a build tool... it has a lot of other stuff that will help you get going
15:36amalloyi wonder if technomancy should change the summary of lein so that new people will stop saying "but i don't need a build tool"
15:36choffsteinlein is ammmaaaazzziinnnnggg
15:37choffsteincan I invoke a multimethod based on the number of elements in a list?
15:37amalloyindeed! (defmulti foo count)
15:37P_Ewhat is the difference between leiningen and cake?
15:37P_Eand do they actually help me install clojure?
15:38amalloyP_E: they're basically the same from an end-user (ie you and me) perspective
15:38stuartsierraDifferent people wrote them. Neither is official.
15:38amalloyand yes
15:38P_Eand which one would you suggest for the long haul?
15:38choffsteinahhh, count. duhhh
15:38stuartsierraClojure's only 3 years old, there is no long haul yet.
15:38P_Efair enough
15:39matthias_does cake also give you a repl?
15:39P_Eyes
15:39amalloymatthias_: yes
15:39amalloychoffstein: i could swear i've actually done this before, but i guess i threw it out and replaced it with something else
15:39matthias_which is better? :p
15:39dnolenP_E: Clojure itself probably won't ship with any sort of build/packaging solution anytime soon. lein and cake both are useful and supported by the community.
15:39amalloymatthias_: the one you're usef to using
15:39RaynesCake gives you an REPL with completion and a global project so you can have dependencies in it like with cljr.
15:40matthias_usef?
15:40amalloyused
15:40dnolenP_E: the main advantage of cake is instant-on REPL
15:40amalloyjeez, picky in here today
15:40RaynesAlso, I'm covering cake in my book. That makes it awesome. ;>
15:40choffsteinamalloy: count works perfectly. I am just really used to pattern matching in Haskell / ML -- so using 'dispatch' methods for 'matching' is messing with my head a bit.
15:40matthias_which book?
15:40Raynesmatthias_: http://meetclj.raynes.me/
15:41amalloychoffstein: funny. i'm trying (again) to teach myself haskell
15:41kingpotatothe only problem with lein is the awful teutonic name
15:41choffsteinamalloy: Yeah ... Haskell and I have a love hate relationship. It loves itself, and I hate it.
15:41amalloyoh burn
15:41matthias_i like the name. but im german
15:41redingerkingpotato: Makes it easy to google info on it though
15:42kingpotatono offense intended but German is just to harsh a language for naming things
15:42choffsteinSo this might be stupid, but can I do a match on keywords with defmulti? Like, if one of the args I pass in is a keyword, I handle my methods on that keyword...
15:43Raynesredinger: Is it pronounced "red-ing-er" or "red-in-jer"?
15:43fliebel$mail ejackson I just found out some airlines offer group discounts, this might be an easier and financially viable alternative.
15:43sexpbotMessage saved.
15:43raekchoffstein: yes, just make the dispatch fn return that keyword
15:43redingerred-in-jer
15:43redingeryes, it's German :)
15:43RaynesAlan Dipert pronounced it when we were talking on the phone last week, but I can't for the life of me remember.
15:43RaynesAwesome, thanks.
15:43choffsteinraek: Herm, I tried that. I think I must be doing it wrong :D
15:43matthias_you can install cake with gem? isnt that the ruby package manager? Oo
15:43amalloy(defmulti kwmulti (fn [_ kw _] kw))
15:44raekthe dispatch fn needs to take the same number of args (at least) as the implementation
15:44amalloy(defmethod kwmulti :foo [size this-is-foo data] (...))
15:44P_Edo I need a cakefile for doing "cake repl"
15:44amalloymatthias_: cake is clojure with a thin layer of ruby
15:44RaynesP_E: Read about the global project in the cake README.
15:45RaynesEven outside of a project, you're always in a project.
15:45RaynesHence the ability to add dependencies to the 'outside-of-a-project' REPL.
15:45RaynesKind of like cljr.
15:45amalloycakefiles don't really exist. they're part of coffeescript's cake, not clojure's, iirc
15:45P_Ecrap
15:45P_Ewhen I write cake, it sort of tries to use the coffeescript cake
15:45stuartsierraOh yeah, Clojure's got its "getting started" story ALL figured out.
15:45matthias_heh
15:46fliebelRaynes: How are the Swing wrapper plans? I have an idea for a GUI app, but I don't want to die-ie-ie!
15:46matthias_someone needs to make clojure platform
15:46RaynesP_E: I support a name change, but ninjudd isn't into it. :\
15:46raekchoffstein: note that in order to redefine a defmulti, you need to either remove the var or give it a non-multimethod value first: (def the-multimethod nil)
15:46Raynesfliebel: Non-existent would classify them well.
15:46raek(since it behaves as defonce)
15:46P_Eok so I'm actually switching to lein because of this
15:46choffsteinraek: Yep, that is exactly what is going wrong
15:47raekchoffstein: this works more nicely when doing interactive development: (defn foo-dispatch [...] ...) (defmulti foo #'foo-dispatch)
15:47raekalso, why isn't this in the docs? >:(
15:47choffsteinraek: Ah, awesome. Thanks :)
15:48fliebelRaynes: non-existent (yet/anymore)?
15:48RaynesYet. Too much busy.
15:48amalloyfliebel: i tried to warn him about announcing the project before he had any ideas or time :)
15:49redingerstuartsierra: There are lots of "getting started" stories. Should we just have one official one that we point people to?
15:50stuartsierraredinger: There should be no story except "Download, Unzip, Run."
15:50redingerThat's what's on the getting started page
15:50fliebelamalloy: Well, the idea was certainly there, and "no time" is crap, that just means "no priority".
15:51stuartsierraredinger: yeah, but it doesn't handle anything beyond the first steps into the REPL.
15:51stuartsierraIf people can't manage a classpath (anyone who hasn't worked extensively with Java) you're kind of stuck at that point.
15:57SomelauwIs clojure most suitable for web applications, desktop applications or what is it most suitable for actually?
15:57stuartsierraEverything!
15:57RaynesEverything and more.
15:57choffsteinIs there a function to find the index of an element in a list?
15:57choffsteinAnd why do I have so much trouble googling for this info?
15:57RaynesI once built a spaceship in Clojure and visited Mars.
15:58SomelauwSo, what big projects have been created in clojure so far?
15:58stuartsierraummmmmm
15:58RaynesI imagine nobody has asked that question before in such a way that it was easily googleable.
15:58SomelauwExcept your paper spaceshit :P
15:58Somelauwspaceship
15:59redingerNo luck finding the trip to mars on Google
15:59stuartsierraAltLaw, Sonian's stuff, various client projects at Relevance.
15:59SomelauwWas what I wanted to say.
15:59Somelauws*** was a typo
15:59redingerhttp://flightcaster.com/
16:00stuartsierraoh yeah, that too
16:01redingerDo we know yet which part of Akamai is using Clojure?
16:01stuartsierraThe good part.
16:01choffsteinBut...seriously, is there a function that tells me the indices that an element occurs in a list?
16:01SomelauwI was thinking of learning how to write web applications or something, but that would probably require me to learn how web applicatrions work in java first.
16:01stuartsierrachoffstein: map-indexed in some combination
16:03stuartsierraSomelauw: It's not that bad. Jetty + Ring gets you 85% of the way there.
16:04redingerI found this helpful: http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
16:04choffsteinstuartsierra: yep ... that worked. can't believe I had to write that code though
16:04SomelauwWhat in that other 15% case?
16:04stuartsierraLearn Java.
16:04tufflaxchoffstein http://stackoverflow.com/questions/4830900/how-do-i-find-the-index-of-an-item-in-a-vector and http://www.mail-archive.com/clojure@googlegroups.com/msg34159.html
16:04amalloychoffstein: .indexOf
16:04choffsteinAh, cause Java has it
16:04choffsteinFreakin' Java.
16:04SomelauwI already learned java syntactically.
16:05stuartsierraThen pick your deployment poison: Jetty, JBoss, Glassfish, etc. etc.
16:05amalloybut srsly you should think about not doing that. there are certainly times when managing indices is the right thing to do, but usually they complicate things for no particular purpose
16:07stuartsierraClojure's very Zen about things. "How do I do X?" "The only way to do X is to not try."
16:07SomelauwSo how to do X?
16:08SomelauwBy doing y instead?
16:08RaynesYes.
16:09choffsteinamalloy: in time series work, sometimes I need to pull the index of something
16:12ataggartchoffstein: you only think you do.
16:13ataggartheh
16:13choffstein...
16:13choffsteinO_o
16:13choffsteinI think I just reached enlightenment
16:14choffsteinAnd/or my brain exploded
16:14markskilbeckI thought that once.
16:14markskilbeckWas just heartburn.
16:14ataggartwhich only proves you didn't
16:15markskilbeckWhoa.
16:15markskilbeckI know kung fu.
16:22TimMcstuartsierra: http://www.kendall-online.com/blog/uploaded_images/software-project.jpg <-- "How do I attach this rope around the trunk of the tree?"
16:23TimMcI feel like a very good programming idiom parody could be made of that image.
16:35SomelauwWhy would a customer want a wheel hanging by a rope on a tree?
16:35Somelauwlol
16:38amalloySomelauw: is this clever satire, or genuine confusion?
16:43matthias_i need to modify penumbra. is that easy to do? i mean i have it auto installed via leiningen, i dont even know where it puts stuff
16:44matthias_hmm, i have a jar file. maybe i dont even have the code
16:44technomancymatthias_: you probably want checkout dependencies; see the lein faq in the readme
16:45TimMcSomelauw: You're either joking or have never seen a tire swing.
16:48amalloyTimMc: if it's satire it's pretty good though
16:48TimMcyeah
16:48matthias_thanks, technomancy
16:52fliebelTimMc: I must admit that I do not really get the wheel thing either. Except… It's probably the only image that works, besides the roller coaster.
16:57amalloy$google tire swing
16:57sexpbotFirst out of 250 results is: Tire swings
16:57sexpbothttp://www.pppresentations.com/
16:58amalloymaybe it's an american thing, but they're iconic. an easy way to make your own swing with no real engineering skills or raw materials that are hard to find
16:59fliebelamalloy: No, we have them as well. It was the "Easy to make" part I was overlooking.
17:00amalloyi'm not sure that part is really relevant to the comic, but maybe it is
17:01fliebelamalloy: If it's not, what is?
17:02amalloythat what the customer asked for isn't really what they wanted
17:03fliebelwell, true, but how is the tire relevant in *any* way then? Oh, wait, maybe it isn't, and that is how I got confused :P
17:04matthias_so leiningen stores the same files multiple times on your computer hwen you use them in more than one project?
17:04fliebelmatthias_: Yes, or maybe it syslinks them, don;t know.
17:04TimMcamalloy: that first google result is what happens when the client gives up and has their nephew make the website
17:04amalloyyeah, that was a horrible page
17:05amalloyit stores them several times, for now
17:05fliebelYou know, as a child, it is really hard to make swings.
17:05SomelauwI don't remember having ever sit on a tire swing as a kid.
17:06fliebelSomelauw: There is still time, do it now!
17:07TimMcNever too late.
17:08SomelauwBut I might have.
17:08SomelauwThen I will need to find a playjard somewhere that has it first.
17:09fliebelSomelauw: Or make one yourself, double fun :)
17:10TimMcMy dad made me a swing when I was a child. It was a wooden slab with a rope running up from a hole in the center to a tree branch far above.
17:10TimMcSo much fun.
17:10fliebelWe all love Swing ;)
17:11SomelauwBut I do remember th hours I spend on a regular swing.
17:11Somelauwspent
17:15matthias_any hints about how i tell leiningen that i want it to use a local version of a library? i successfully made my change and compiled a new .jar i believe
17:18technomancymatthias_: using checkout deps should get that for you
17:19technomancyotherwise fiddle with the version and do lein install, then lein deps on your other project
17:19ataggartit'd be nice if there was just a way to specify an additional local lib dir.
17:22P_Ewhat is the most common function for splitting a string nowadays?
17:22amalloyre-seq? it kinda depends how you want to split it
17:23technomancyataggart: you can specify :repositories with file:/// notatino
17:24technomancybut nearly every time it's more fruitful to ask yourself why you think you want it
17:24P_Ermarianski: cool that's what I needed, thanks
17:29matthias_i dont quite get that checkouts stuff. i got a folder named checkouts in my project root directory and in it i have a symlink called penumbra to the root folder of where my changed version of penumbra is
17:29matthias_do i need more than that to let lein find it?
17:30matthias_does the symlink have to have a specific name?
17:30technomancyno, that should be all you need
17:30technomancyas long as penumbra is in project.clj as a :depedency too
17:30matthias_yes. i even changed the version number of my version of penumbra and changed it in the dependencies of my actual project
17:31matthias_before that, it just kept using the old version
17:36dnolenhuh, since Clojure enforces an order of definition seems like that would make an optional type system much simpler ... no need for multiple passes ...
17:38dnolensometimes rhickey's decisions really only make sense 3 years later.
17:38hiredmanwell, it makes the compiler much simpler in general
17:47matthias_technomancy, i've been looking around in the leininge code on github a bit and it actually seems like checkout_deps.clj doesnt even exist in the main branch
17:52technomancymatthias_: that's correct; it is not a namespace or file.
17:52technomancyit's just a feature
17:53matthias_i just tried simply overwriting the old .jar with my new one in my libs folder. it still know that that one function i added doesnt exist. hmm
17:57technomancyyou need to restart you clojure process; that stuff is cached
17:59matthias_now it worked. i had forgotten something.
17:59matthias_of course this is a rather ugly way of doing this
18:34TimMcSomething is not quite right with my ray-tracer... http://i.imgur.com/VPay2.png
18:37choffsteinAnyone use Sphinx with clojure?
18:39technomancychoffstein: not much call for Sphinx when Lucene is readily available as I Understand
18:39choffstein...yeah, that makes sense
18:39choffsteinI'm full of stupid questions today
18:39choffsteinI think it's time to just "call it Friday" and move on
18:39carllerchehas anybody tried using ClojureCheck (quickcheck for clojure)?
18:47TimMcOK, in my ray tracer, I can compute a seq of intersections of objects with a given ray. Each has a :dist -- I want the closest intersection.
18:47TimMcNaïvely, I used reduce to find the min.
18:48TimMcThe complication is that I need to throw away the closest (and use the second closest instead) if it meets a certain predicate.
18:49TimMcOptions: A) sort the seq by distances and take either the first or second.
18:49choffsteinyou could use sort-by :dist
18:49TimMcB) reduce to find min and next-min and choose between them.
18:49TimMcsort-by does more work than necessary, but finding the min-2 is a more challenging algorithm, I think.
18:49amalloyTimMc: C) generalize to n-smallest?
18:50technomancydoes anyone use the user/*classpath* var that leiningen creates?
18:50amalloyTimMc: On Lisp has an implementation of n-smallest
18:50TimMchmm
18:50TimMcDo you know of such an implementation in Clojure?
18:50technomancyI was going to wait till 2.0 to remove it, but it's kind of dumb, and if nobody uses it I will just cheat and do it in a minor-point
18:51choffsteinTimMc: sort-by would be computational over-kill compared to a linear search for just the min...
18:51technomancyTimMc: ಠ_ಠ
18:51TimMcchoffstein: Right.
18:51choffsteinTimMc: But starts to make sense when you need to find the n-smallest
18:52amalloyTimMc: page 183 of On Lisp. translation to clojure would be pretty trivial
18:52amalloymaybe
18:53choffsteinamalloy: nthmost function? because looking at it is blowing my mind.
18:54amalloychoffstein: the punctuation in CL, and especially the font he uses, makes it look worse than it is
18:54TimMcI think I'll look elsewhere for an algorithm. o.o
18:55choffsteinTimMc: Don't think you're going to get much faster than O(2N) for first and second min unless the points are pre-sorted
18:55TimMclinear is fine
18:55TimMcHell, sort-by is probably fine for my purposes.
18:56TimMcThat's what I'll use for the first commit anyway, just to make writing unit tests easier.
18:58choffsteinTimMc: Can you just keep track of the min 2 as you trace the rays? It is a bit rigid, but sometimes it is better to choose rigidity if the problem is defined over an over-generalized function that you never reuse in a general form.
18:58choffstein...that was a horribly written sentence
18:58choffsteinwhat is going on with me today
18:58choffsteini feel like a big barrel of stupid. It took me 2 hours to write 14 lines of clojure code...
19:01amalloychoffstein: put in some more newlines
19:01choffsteinit's already 8 lines of comments :D
19:02amalloyTimMc: okay, i take it back, that nthmost macro is complicated
19:03TimMcIt's a *macro*. Why?
19:03amalloyTimMc: pushing bounds checking and iteration to compile time
19:03choffsteinSeems like C++ template wizardry to me
19:04TakeVIs there some sort of system to be able to add new code to a file through the repl, without having to copy and paste it into the file?
19:05hiredman"emacs"
19:05amalloyTakeV: go the other direction. put code in the file, and let swank/slime send that to the repl
19:05TakeVI don't use swank/slime. :\
19:05TakeVVim/Lein for me.
19:06amalloyso, vim has something similar to slime
19:06hiredmanlein is orthogonal
19:09taliosvimclojure is good
19:09TimMcBy the way, here's what happens if I *don't* drop the first intersection under certain conditions: http://i.imgur.com/VPay2.png
19:09taliosuses screen
20:07lancepantzTakeV: still around?
20:08lancepantzTakeV: I used to use this setup when using vim, i think it's what you're looking for. http://writequit.org/blog/?p=386
20:09lancepantzbut switching to emacs was the best decision i ever made :0
20:11technomancythe author of that post switched too =)
20:13TimMcAhh, much better: http://i.imgur.com/ZgmIq.png <-- Still too bright, but now reflected rays do not accidentally register a hit on their point of origin half the time.
20:15carllercheWhat would be some good idiomatic OSS clojure projects that could be interesting to read over to learn how to structure a clojure app w/ a somewhat complex data model? (yeah, i know it's a vague question :P)
20:17lancepantztechnomancy: hah! that's classic
20:17technomancyring is probably too simple. incanter maybe?
20:22carllerchei'll take a look... I'm trying to figure out how to organize stuff
20:25rak85how do i transform a keyword into a string?
20:25technomancy,(name :my-keyword)
20:25clojurebot"my-keyword"
20:26rak85thanks!
20:26technomancynp
20:27TimMcrak85: /msg sexpbot $findfn :foo "foo"
20:27TimMc:-)
20:29TimMce.g. ((findfn :foo "foo") :blarg)
20:30rak85((findfn :foo "foo") :blarg)
20:30rak85hahah
20:31TimMcIt would take the first in the list, appropriate or not. :-)
20:42amalloyTimMc: feel free to fork sexpbot. you could get him to expose findfn to clojure evaluation requests
21:38TimMcOK, ray tracer is definitely doing mirror reflection properly now: http://i.imgur.com/ktXQ7.png :-D
22:05carllercheIs there a function to go from [[1 2] [3 4] [5 6]] -> [[1 3 5] [2 4 6]] ?
22:06amalloy&(apply map vector [[1 2] [3 4] [5 6]] )
22:06sexpbot⟹ ([1 3 5] [2 4 6])
22:07carllerche&(+ 1 1)
22:07sexpbot⟹ 2
22:07carllerchecool! (thx btw) :P
22:07amalloycarllerche: it's good practice to understand why that transposition works, btw
22:08carllercheyeah... not sure what vector does. gonna look it up
22:08amalloy&(vector 1 2 3)
22:08sexpbot⟹ [1 2 3]
22:09amalloyapply turns it into (map vector [1 2] [3 4] [5 6]), which is the same as [(vector 1 3 5) (vector 2 4 6)]
22:09carllerchehuh, that's cool
22:10amalloyyeah, map is a really powerful combination of several ideas that are separate in some other functional languages
22:15carllercheamalloy: makes sense... i still have a ways to go before i can wield all of these functions
22:17TimMccarllerche: Look up juxt.
22:18amalloy&((juxt inc dec) 1)
22:18sexpbot⟹ [2 0]
22:19TimMcAt first, you won't have any clue why you'd want to use it... but you'll eventually find uses. :-)
22:21amalloywell, i think my first "high-power" use of juxt was like ##((juxt quot rem) 52 10)
22:21sexpbot⟹ [5 2]
22:22TimMcDid we decide if there was a good reason that there isn't a native divmod function?
22:23TimMcI mean, ISAs generally have something like that.
22:23amalloyTimMc: probably because it would be inconvenient to use in java?
22:23amalloyint[]s are not very handy to work with
22:23TimMcpoint
22:24amalloyallocating the eight bytes probably costs more than just doing the division twice anyway
22:33dnolen,unchecked-remainder
22:33clojurebot#<core$unchecked_remainder clojure.core$unchecked_remainder@51e62>
22:35dnolenLogos now has support for declaring facts, and indexing those facts, https://gist.github.com/922790, predicate dispatch here we come!
22:36amalloy&(doc unchecked-remainder)
22:36sexpbot⟹ "([x y]); Returns the remainder of division of x by y, both int or long. Note - uses a primitive operator subject to truncation."
22:36amalloy&(unchecked-remainder 52 1-)
22:36sexpbotjava.lang.NumberFormatException: Invalid number: 1-
22:36amalloy&(unchecked-remainder 52 10)
22:36sexpbot⟹ 2
22:37dnolenon a side not, ints[]s are fine to work if you take the time to write some macros.
22:37dnolens/not/note
22:37sexpbot<dnolen> on a side note, ints[]s are fine to work if you take the time to write some macros.
22:37dnolennight folks
22:37amalloydnolen: well of course. but not in java
22:42TimMcIt's all well and good in assembly languages, where the results of divmod go into two predefined registers (generally.)
22:43amalloyTimMc: it's fine for the jvm too. put them both on the stack and pop them to wherever you want
22:43amalloybut java doesn't have syntax that would make it easy to say where to put them
22:46amalloyeg: a, b = 52 %/ 10;
23:28chewbran1atechnomancy: ping
23:36technomancychewbran1a: sup
23:37chewbran1atechnomancy: hey man, having a hell of a time getting a dependency loaded in leiningen, was wondering if you had a minute to check it out
23:38technomancysure; paste project.clj?
23:38chewbran1aI'm tryin to install: http://clojars.org/org.clojars.pieterbreed/clojure-couchdb
23:38chewbran1asure just a second
23:40chewbran1atechnomancy: http://paste.lisp.org/display/121541
23:40chewbran1aso anytime I try and required the couchdb jar, I get a file not found error, I've tried requiring 'clojure-couchdb, 'org.clojars.pieterbreed/clojure-couchdb, 'org.clojars.pieterbreed.clojure-couchdb
23:41amalloychewbran1a: but lein deps works?
23:41amalloyassuming that much, your problem isn't related to lein at all
23:41chewbran1aamalloy: yeah works fine, I've got clojure-couchdb-0.4.7.jar in lib/
23:42technomancychewbran1a: if you open up the jar, you can see that the only clojure file it contains is couchdb/client.clj
23:42technomancyso that's your ticket
23:42amalloychewbran1a: so just (require) the usual couchdb stuff. putting the clojars crap in front of it is a misunderstanding of how namespaces and jars interact
23:42technomancysounds like a case of lousy docs though =\
23:44chewbran1atechnomancy: ahhh ok
23:44chewbran1aamalloy: yeah I was tried 'clojure-couchdb first, then went on to trying other varients
23:48tomojsomeone with reach should blog "remember to put your namespaces in the readme"
23:53chewbran1aok great, got it working, I forgot you could just open up jars directly, good to kno
23:53chewbran1a*know
23:55technomancyyeah, emacs lets you just open up jars like directories; you can probably do that in vim too
23:55technomancyvery useful
23:56chewbran1ayeah just opened it in vim and it was a typical directory listing, definitely useful
23:57justinlillyalso, zgrep
23:59chewbran1ajustinlilly: does zgrep work on jars?
23:59justinlillyseems like it ought to..