#clojure logs

2010-12-13

00:29ossarehzach kills me with how good aleph is!
00:30LajlaRaynes, I think you should call her sexbot
00:45ossarehLajla: false advertising?
00:46Lajlaossareh, I worship Your Shadow
00:46ossarehhobbies yield better results.
02:10zmyrgelhi, if I have (:use (foo bar)) in my file's ns macro, shouldn't I be able to refer constants defined in foo.bar?
02:10zmyrgelnow I just get Unable to resolve symbol error
03:41amalloyzmyrgel: yes, you should be able to refer to def'ed variables. though (:use foo.bar) is a bit simpler if you're not doing other foo.baz imports
03:52_na_ka_na_,(compare '(1 2 3) '(1 2 3))
03:53clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Comparable
03:53_na_ka_na_,(compare (vec '(1 2 3)) (vec '(1 2 3)))
03:53clojurebot0
03:53_na_ka_na_why can't I compare PersistentLists ^^
03:54amalloy_na_ka_na_: good question
03:55amalloy&(map (comp supers class) [() []])
03:55sexpbot⟹ (#{clojure.lang.Sequential clojure.lang.IPersistentCollection java.io.Serializable java.lang.Object clojure.lang.Counted java.lang.Iterable clojure.lang.IPersistentStack clojure.lang.Obj clojure.lang.IObj java.util.Collection clojure.lang.IPersistentList java.util.Li... http://gist.github.com/738808
03:57amalloy_na_ka_na_: i mean, the answer is what you'd expect: () doesn't implement Comparable. but why is that? i don't know any better than you do
03:57amalloy&(apply compare (map seq [[1 2]
03:57sexpbotjava.lang.Exception: EOF while reading
03:57amalloy&(apply compare (map seq [[1 2] '(1 2)]))
03:57sexpbotjava.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to java.lang.Comparable
04:05kryftOo, there's a clojure course coming up at Helsinki University.
04:06opqdonut yes, I'm teaching :)
04:06Licensermorning
04:09kryftopqdonut: Sattuuko se olemaan jatko-opintokelpoinen? :P
04:09opqdonutkryft: juttelen tänään opintoesimiehen kanssa, varmaan onnistuu
04:09kryftopqdonut: Also, if I want to attend the course, is it a problem that I'll be in London until the end of April?-)
04:10opqdonut:D I'm sure we'll figure something out
04:10opqdonutif you want the credit
04:11opqdonutthe course is going to be workshop-like, students can work on their own projects or given exercises
04:11kryftGreat.
04:11opqdonutthat'll leave us with more time to focus on those who haven't done lisps before
04:12opqdonutbut there'll be mini-lectures on advanced stuff like performance tuning
04:12opqdonutI'm hoping 1.3 will come out before the course starts... :)
04:13kryftI haven't done lisps before, although I do feel I've grasped the basics of the functional programming paradigm.
04:14opqdonutthe material will be on the web
04:15opqdonutas I said, we'll figure something out. you can email me when the course starts or something
04:15kryftGreat. :) When does it start?
04:16opqdonutwell that's what I'm going to sort out today :D
04:16opqdonutthe course will probably be during period III
04:16opqdonutso about 17.01.-06.03.
04:17opqdonutbut we might do something like have teaching in pIII but let people hand in stuff during pIV too
04:17kryftopqdonut: Oh, and the credits would be nice because then I could study at work with a clean conscience. ;)
04:18opqdonutyes of course. if you participate you will get the credits. and I'm quite open to "vaihtoehtoiset suoritusmuodot"
04:20kryftopqdonut: I have some work-related ideas for small projects that I was planning to do anyway after reading The Joy of Clojure (eg. implementing a dimensionality reduction algorithm that I've previously written in C++).
04:20opqdonutwith parallelism?-)
04:20kryftYes. :)
04:20opqdonutsoudns good
04:20opqdonutbut I gtg ->
04:21opqdonut(you might want to join the lambda mailing list if you're into stuff like this, see http://lambda.fi)
08:33jcromartieoi vey, so let me tell you what's a bad idea
08:34jcromartieapproaching data obfuscation by selecting every distinct value in each column of each table, transforming it, and updating that distinct value with the new value
08:34jcromartie6 hours for one column in one table
08:39kzarI have a ref of a vector of stuff, I want to filter the vector taking what I need and at the same time removing it from the original vector. I can't figure out how to update the vector in such a way that I get the removed values returned without duplicating the work
08:40kzar(So I get a vector of the stuff I've filtered for and the original vector that's referenced is updated so that only things that didn't match the filter are left.)
08:41chouserkzar: I think you might need loop/recur for that.
08:41kzarchouser: Cool OK I rekon I can figure it out in that case :D
08:42chouserIf there's an existing HOF that'll do that, it's not coming to mind at the moment.
08:44kzarHOF
08:45chouserHigh Order Function
08:45kzarheh
08:45chouseroh
08:45kzarLowest order joke, sorry heh
08:51Licensercookies
08:52islonis this the right way to define a private var? (def ^{:private true} background Color/WHITE)
08:52islon?
08:53stuartsierrayes
08:53Licenserwhat is the reason for not having def-?
08:53LicenserI mean there is defn- too
08:54islonthats exactly what I was thinking
08:55LicenserI wondered that a time ago, then just forgot it, but now that you mention it I wonder why tzhere is no def- I am sure there is a very reasonable explenation since I doubt Rick or any other of the core defs for that matter would just forget something like that
08:55Licenser,,,,,, <- put them where apropriate
08:55clojurebotjava.lang.Exception: Unable to resolve symbol: <- in this context
08:56raekget assoc dissoc ______
08:56Licenserupdate-in?
08:57raekget-in assoc-in _________ update-in
08:57Licenseroh cheater!
08:57s450r1kzar: doesn't split-with get you most of the way there?
08:57chouserupdate-in fills all three slots
08:57Licensersee that is why it is a good answer :P
08:57Licenserso I'm not even sure what the question was
08:58kzars450r1: Oh yea, I'm just writing it now but I didn't think of using split-with good idea
08:58kzars450r1: This is good practice for me :D
08:59chouserI don't think split-with returns what he wants, and runs pred twice for every input element until it returns false
08:59fliebelkzar: (juxt filter remove)
08:59chouserfliebel: I think that returns what he wants, but runs pred twice for every input element. :-)
09:00LicenserI think to think I found a bug ccw
09:00fliebelchouser: true
09:00kzarit's elegant though
09:00tonylmorning
09:00islondoes it work? (defmacro def- [name value]
09:00islon `(def ^{:private true} ~name ~value))
09:04kzaralthough doing it that way with juxt makes us calculate the new value outside of updating the ref, so we can't use alter
09:04s450r1chouser: thanks for the correction
09:04chouser,(map #(map second %) ((juxt filter remove) first (for [i (range 10)] [(odd? i) i])))
09:04clojurebot((1 3 5 7 9) (0 2 4 6 8))
09:06fliebelkzar: Using alter wont work anyway, because you can't return the values you want, set, and still return values somewhere else.
09:07fliebelkzar: I havn;t worked with refs much, but is'nt the whole point you start a stransaction and do whatever you like inside it?
09:07bartjI have the following scenario:
09:07bartjdefined a buffered writer, some print statements, defined method
09:07chouser,(loop [[x & xs :as c] (range 10), f [], r []] (if c (if (odd? x) (recur xs (conj f x) r) (recur xs f (conj r x))) [f r]))
09:07clojurebot[[1 3 5 7 9] [0 2 4 6 8]]
09:07bartjmethod has a couple of print statments but this time with *out* being bound to a file
09:08bartjbut despite the call to the method being *after* , it gets printed first!
09:09bartjis there some precedence w.r.t *out* being given precedence over BufferedWriters ?
09:10fliebelbartj: have you tried (flush)?
09:10fliebel(wild guess)
09:12raekbartj: are you sure this is not caused by that you return a lazy seq out from the binding form?
09:13raek(binding [*out* ...something...] ...some-lazy-seq...) --> (binding [*out* ...something...] (doall ...some-lazy-seq...))
09:15bartjraek, I seem to return a PersistentList
09:15fliebelkzar: ##((juxt #(apply concat (take-nth 2 %)) #(apply concat (take-nth 2 (next %)))) (partition-by odd? [1 2 2 3 4 5 5 7 8 9]))
09:15sexpbot⟹ [(1 3 5 5 7 9) (2 2 4 8)]
09:17raeklaziness plus binding is often a source of problems...
09:17kzarfliebel: to be honest some of those ideas are going over my head
09:18fliebelkzar: It's pure evil. It least make the apply a reduce.
09:18bartjraek, lists are not lazy, no?
09:19kzarfliebel: heh
09:19raekPersistentLists (from 'list' or conjing onto () or nil), no
09:19fliebelkzar: look up partition-by, and you'll understand… maybe.
09:20kzarfliebel: heh OK, gimme a min I'm going to try my idea for solving it
09:20fliebelkzar: sure :)
09:22fliebelWill sexpbot on Twitter only respond to replies, or also to mentions?
09:23iveysexpbot is on Twitter now?
09:23iveyRaynes: using my code, or has it changed? I haven't had time to look at it in a while
09:28fliebelRaynes: Seems sexpbot is down on Twitter?
09:38kotarakSingle pass separate-by. Can this be de-uglified? http://paste.pocoo.org/show/304306
09:44karmazillakotarak: what's it do?
09:49kotarakkarmazilla: it returns [(filter pred coll) (remove pred coll)] in one pass
09:50kotarakkarmazilla: hopefully as lazy as possible
09:51karmazillakotarak: I guess somehow using reduce in there would make it less ugly
09:51fliebelkotarak: Did you see my 'solution'?
09:52kotarakfliebel: eh. No?
09:52fliebelkarmazilla: I think so to… one min
09:52kotarakfliebel: you mean juxt?
09:52fliebel&((juxt #(reduce concat (take-nth 2 %)) #(reduce concat (take-nth 2 (next %)))) (partition-by odd? [1 2 2 3 4 5 5 7 8 9]))
09:52sexpbot⟹ [(1 3 5 5 7 9) (2 2 4 8)]
09:53kotarakfliebel: reduce smell like "non-lazy"
09:54fliebelkotarak: True
09:54fliebelBut how can you make something that returns a vector lazy?
09:54kotarakfliebel: the requirements are: as lazy as possible, only one pass of predicate check
09:55kotarakfliebel: the contents are lazy
09:55kotarakand thread-safe of course (re requirements)
09:55fliebelSo you're doing a lazy asynchronous recur? :)
09:56kotarakfliebel: well, it's synchronous: when asked for it it happens on the calling thread.
09:57fliebelkotarak: But you add elements to both queues as much as needed for the one that is consumed, right?
09:57kotarakfliebel: yes. This is obviously necessary.
09:59fliebelIt's an interesting problem for sure :)
10:00kotarakfliebel: and it is kind of tricky re threads. atoms don't work, refs don't work... I think one needs a locking here.
10:01fliebelkotarak: I'm not sure I understand.
10:01karmazillato prevent two threads from calling pred on the same element, one needs mutual exclusion
10:01kotarakfliebel: transactions get merged with surrounding ones, so we kind use refs, because the our changes might get replayed if the surrounding ref retries.
10:01kzarCan you duplicate a mutable value to somewhere immutable so you know it's safe to use later?
10:02kotarakfliebel: atoms don't work, because we cannot handle things in one call.
10:02kotarakfliebel: still some kind of sync is required. as karmazilla said: one might realise the true and the false seq in parallel.
10:03karmazillathe choices seem to boil down to eager, synchronized or thread-unsafe
10:03fliebelouch… it's more complicated than I thought.
10:04islonhow do i remove the reflection warning from (proxy-super paintComponent g)?
10:04kotarakhmmm the drawback of this solution is, that one seq can block the other if the items are ill-distributed in terms of satisfying the predicate... In particular on an infinite seq. *grmpf* Maybe two passes are still better?
10:05fliebelkotarak: simpler for sure...
10:05kotarakfliebel: nice golf anyway :)
10:05fliebelgolf?
10:06LauJensenkarmazilla: Hey - Coming this thursday for the Clojure meetup in Cph ?
10:06kotarakfliebel: code golf - some play to solve a fun problem
10:06fliebelah
10:06karmazillaLauJensen: yes I am :)
10:06LauJensenkarmazilla: Look forward to seeing you there :)
10:07karmazillaLauJensen: me too. I wanted to go last time, but other plans got in the way :-/
10:08LauJensenkarmazilla: Last time we had some improv fun with Moustache and Enlive, next up is Cucumber I think
10:08fliebelkotarak: Must… Think… About… A… Better... Solution...
10:08kotarakfliebel: hehe :)
10:08karmazillaLauJensen: which I really look forward to. BDD is a pretty vague concept to me still
10:09LauJensenkarmazilla: Fortunately Martin (mjul) seems to be somewhat of an authority on the issue
10:09karmazillanice
10:09kzar(let [val (nth @some-ref 2)] ...somechanges... val) is screwing me because val changes as some-ref does, how do I get the value val in a safer way?
10:20kzaroh unless it's something to do with laziness
10:23LauJensenHas anybody made some Google Maps integration for Clojure?
10:24fliebelkotarak, kzar: https://gist.github.com/739089
10:26fliebelkotarak: Am I right that this is lazy al the way through, and only evaluates pred once?
10:26kotarakkotarak: I think so.
10:28kotarakfliebel: But the sequence must not include nils.
10:28kotarakfliebel: the input sequence that is
10:29fliebelkotarak: True. But other than that, it seems to work like a charm.
10:30kzarfliebel kotarak: Here's my version http://paste.lisp.org/display/117638
10:30kzarIt's aim is a bit different from yours, it's also slightly broken the results are wrong
10:32fliebel$sed -kzar s/it's/its/
10:32sexpbot<kzar> its aim is a bit different from yours, its also slightly broken the results are wrong
10:32fliebelhey, I din't gave you the g option, sexpbot!
10:33kotarakkzar: You cannot reliably deref an agent. (you can that is, but you cannot be sure to not miss something if you do it two times)
10:33kzarfliebel: Thanks I struggle with grammer / spelling
10:34gtrakbut the second it's is right
10:34fliebelkzar: It's not important, I was just trying to figure out sexpbot.
10:34kzarheh well I care, I'm working on it
10:35fliebelgtrak: That is why I complained, I didn't add the g option at the end. Real sed would've only replaced the first one.
10:35gtrakah
10:35kzarkotarak: Hmm balls so maybe my idea is pretty much broken
10:36gtrakdo you guys generally prefer clojure for utility type stuff?
10:37fliebelgtrak: Meh, JVM, classpath, startuptime… I prefer Python for that kind of stuff.
10:38gtrakyea I like python too
10:41karmazillafliebel: some Either type/api could make your version support nil values, I think
10:42fliebelkarmazilla: I think so to...
10:44kzarfliebel kotarak: http://paste.lisp.org/display/117638#1 this one is working pretty well but you might hate it after all the clever solutions you found heh
10:45kotarakkzar: split-with is cheating: it's two pass ;-P
10:46fliebelkarmazilla: I like my solution, so I'm not going to bother making it ugly with extra conditionals and checks.
10:46kzarI might make a three pass version just to annoy everyone
10:49kotarakfliebel: fixed for nils http://paste.pocoo.org/show/304345
10:49kotarakfliebel: Although this really creates a lot of short-lived garbage objects... (<- premature optimiser in me...)
10:50fliebelkotarak: I think I prefer mine, as long as I don't need nil values :)
10:51Raynesfliebel: You still need to prefix with & to evaluate code on twitter.
10:52fliebelRaynes: Does ## work as well?
10:52RaynesYes.
10:52fliebelAnd a mention rather than a reply?
10:53RaynesI didn't see an API function for replying.
10:53RaynesI'll look later.
10:53fliebelRaynes: No, I think it's awesome to be able to do ##(prinltn "hi") and /cc @sexpbot
10:53sexpbotjava.lang.Exception: Unable to resolve symbol: prinltn in this context
10:55bartjhow can I ask clojure.java.io/writer to open a file in append mode?
10:56bartj:append true
10:58kzarfliebel kotarak: http://paste.lisp.org/display/117638#2 <- my one pass seperate by
10:59karmazillalooks eager
11:00bartjare the options to clojure.java.io/writer sent as a hash-map?
11:00kzarkarmazilla: crap I didn't think of that side of things
11:02kotarakkzar: Sorry, couldn't resist: made things a bit more "idiomatic" for this style of programming: http://paste.lisp.org/display/117638#3 Also: your solution gives the results in the wrong order. (because of cons to lists)
11:04karmazillaI think fliebels unzip-like approach is good
11:04kzarkotarak: Oo thanks
11:21FireSnakehello anyone here use appengine-magic?
11:22FireSnakecan anyone hear me at all?
11:23ohpauleezFireSnake: Loud and clear, I don't use it though
11:23FireSnakehow come I can't hear everyone else?
11:24fliebelFireSnake: It's just rather quite in here.
11:24FireSnakewhat do you all come here for then?
11:24FireSnakeif not to talk?
11:24fliebelHammocking :)
11:25FireSnake? What's hammocking?
11:25FireSnakeor just joking around
11:25fliebelFireSnake: http://blip.tv/file/4457042
11:26FireSnakewon't load in my page
11:26VinzentFireSnake, probably you should ask your question and we'll try to help you
11:27FireSnakeI'm trying to deploy a Google App Engine app and don't know how to set the default war file
11:28FireSnakefliebel I can't open your link
11:29FireSnakeon Ubuntu Firefox
11:29FireSnakehow does everyone in here deploy their clojure web apps?
11:30fliebelFireSnake: Unfortunate :( You might Google it: "Hammock-driven Development" Though it's not that important.
11:35fliebelDoes anyone have inspiring insights or code on how to find the best mach for a map like the ones coming from frequencies against a whole list of them? Ouch, I can't even explain what I mean.
11:36edwcascading
11:37fliebeledw?
11:38lrennFireSnake: have you googled "clojure google app engine"? There seems to be quite a bit of info floating around.
11:39FireSnakelrenn yes I have and am in the middle of my tutorial but don't know how to set the default war file
11:41lrennFireSnake: /join #compojure
11:42FireSnakeok thx
11:42r0manLauJensen: I have some basic google maps stuff over here: https://github.com/r0man/google-maps-clj
11:42LauJensenr0man: Thanks I'll take a look, but I already rolled my own
11:42lrennFireSnake: sorry, didn't actually mean to send you there just yet. was trying to see how many folks were in there. They might have more experience with it than the folks here.
11:49fliebelWhy doesn't reduce take more colls, just like map?
12:06fliebelAwesome, I can do language detection :)
12:09LauJensenfliebel: me too, Ive detected you're speaking english
12:11fliebelLauJensen: Hah! Wrong, it's actually Denglish. (English spoken by Dutch people, according to "I always get my sin")
12:12fliebel(zin ~= desire)
12:13fliebelLauJensen: But what I meant to say is that I managed to compare the output of (frequencies "some text") to decide which language it is.
12:14amalloyfliebel: the behavior of reduce working on multiple maps is not obvious. should f take N arguments, or what?
12:15fliebelamalloy: Yes, this is the same for map, right?
12:15hiredmanif reduce takes multiple collections, does it an init value or not?
12:16fliebelhiredman: Good, point… What if…
12:17cemerickit's still reducing to a single value…why not?
12:17amalloycemerick: because it can't figure out which args are init values
12:17amalloy(reduce f x y)
12:17fliebelcemerick: What if there isn't a init value? Would you take the first of the first, of a seq of all firsts?
12:18amalloyis x a coll, or an init value?
12:18hiredmancemerick: I'm just saying it's debatable, so by not taking multiple collections we can avoid debate
12:18clizzin_so i was dumb and misunderstood a serialize function that actually serialized to a clojure map instead of a string, and then wrote that map to a file, where it's represented by one map entry per line. is there a way i can read this back in and make it a clojure map again?
12:18fliebelamalloy: Also true....
12:19clizzin_the file looks something like: [:foo1 {:bar1 0.00134 :bar2 4.34934}]\n[:foo2 {:bar1 3.4562 :bar2 9.24343}]
12:20fliebelSo the way to do this is (reduce f i (map vec col col col))
12:20hiredmanvector
12:20hiredmanvec doesn't do what you want
12:20kotarak,(read-string "[:foo1 {:bar1 0.00134 :bar2 4.34934}]\n[:foo2 {:bar1 3.4562 :bar2 9.24343}]")
12:20clojurebot[:foo1 {:bar1 0.00134, :bar2 4.34934}]
12:21kotarakclizzin_: I guess you just read the stuff back in with—eh—read.
12:22kotarak,(read-string (str "[" "[:foo1 {:bar1 0.00134 :bar2 4.34934}]\n[:foo2 {:bar1 3.4562 :bar2 9.24343}]" "]"))
12:22clojurebot[[:foo1 {:bar1 0.00134, :bar2 4.34934}] [:foo2 {:bar1 3.4562, :bar2 9.24343}]]
12:22kotarak,(into {} (read-string (str "[" "[:foo1 {:bar1 0.00134 :bar2 4.34934}]\n[:foo2 {:bar1 3.4562 :bar2 9.24343}]" "]")))
12:22clojurebot{:foo1 {:bar1 0.00134, :bar2 4.34934}, :foo2 {:bar1 3.4562, :bar2 9.24343}}
12:23clizzin_kotarak: thanks! was not aware of the read-string function, that looks like just what i want.
12:24kotarakclizzin_: you might also want to read several times from a reader incrementally using read instead of read-string. YMMV
12:24fogus`cemerick: Don't cha know... nothing worth talking about happens in software outside of the Bay area. Sheesh
12:25cemerickfogus`: Yeah, they've only got COBOL books down here at the 5 and dime.
12:26ejacksonfogus`: and in the UK we spell it Clojoure.
12:26fogus`"self-righteous metropolitan exceptionalism" -- wow!
12:26cemerickfogus`: too harsh? :_)
12:26cemerick:-)
12:27fogus`cemerick: Well, I posted it to HN for you. :-) http://news.ycombinator.com/item?id=2001177
12:27cemerickDOOM awaits me, surely.
12:27fogus`cemerick: It's no more harsh than it needs to be.
12:28technomancycemerick: I've got a rocket launcher if you need to borrow one.
12:28chouserI'm in Fort Wayne, loving my job. No argument here.
12:28kzarI'm an idiot wherever I go heh
12:28cemerickfogus`: I happened to hear a half-dozen offhand comments in that direction last week, one personally in my direction. Had to put it out there.
12:29chouseroh, and I've been to the bay area on business and have simply no interest at all in living there.
12:30cemerickchouser: in that case, you will simply never amount to anything! ;-)
12:30cemericktechnomancy: huh, I thought you were in portland!
12:31fogus`I did the whole Sillicon valley interview tour a few years ago and while it was very exciting to see it for the first time, I didn't feel a connection with the area
12:31technomancyPortland is where I'd be if I weren't in Seattle
12:32cemerickRight…SEAjure. Dummy. :-(
12:32technomancythis is my favourite post on the bay area mindset: http://gilesbowkett.blogspot.com/2008/05/never-hate-only-ever-destroy.html
12:33cemerickYeah, that's classic.
12:34pjstadigi think there may be some business arguments to being near VCs and corporate customers, but i'm not nearly an expert in this
12:35pjstadigif you're going to bootstrap and sell direct to consumers, then there's probably nearly zero reason to *have* to be in the Bay area
12:35pjstadiggreat technical talent lives everywhere, as we know at sonian
12:36cemerickOf course, the corporate customers are surely everywhere, and not just in sfbay.
12:36pjstadigtrue and there's always this thing called plane travel
12:36ejacksonits nice to be near universities because of the interesting people that tend to be around
12:36cemerickAnd I always ignore any arguments that might include deference to VC-anything.
12:37cemericks/ignore/discount
12:37sexpbot<cemerick> And I always discount any arguments that might include deference to VC-anything.
12:37cemerickMaybe much to my detriment.
12:37chouseroh, I'm sure I'd have a wider selection of great jobs if I were willing to move to Silicon Valley. But I have some selection of great jobs right here, and moving there would simply not be worth it.
12:37pjstadigyeah i agree with you, i think the argument is weak, but i think its the only argument you can make
12:37cemerickejackson: That's probably a much better indicator for a good area to be in.
12:38ohpauleezcemerick: Awesome post man
12:39technomancychouser: the thing about jobs is you only need one =)
12:40chousertechnomancy: exactly
12:40ckychouser: You can move to the Triangle, where Relevance is, and work in Clojure. :-P
12:40ohpauleezI will say that being near universities or interesting user groups/hacker-spaces that are pushing the envelope is nice
12:40ckychouser: It's a lot cheaper living than Silicon Valley. :-P
12:40ohpauleezyou can find those almost anywhere, but you almost always find them in large cities
12:41chousercky: yup. Or I can live right here, which is cheaper than both, and work in Clojure. :-)
12:41cemerickohpauleez: thanks :-)
12:41ckychouser: :-P
12:41ckychouser: Where is Fort Wayne, anyway?
12:42chousercky: http://maps.google.com/maps?oe=UTF-8&amp;q=fort+wayne&amp;ie=UTF8&amp;hq=&amp;hnear=Fort+Wayne,+Allen,+Indiana&amp;gl=us&amp;ei=DVsGTZeRHM-4ngfH-cHlDQ&amp;oi=geocode_result&amp;ved=0CCsQ8gEwAA&amp;ll=40.32142,-85.561523&amp;spn=7.637564,10.327148&amp;t=rm&amp;z=7
12:42chouserugh. sorry, that's ugly
12:43fogus`cemerick: This is a nice juxtaposition to your post. http://svstartup.com/~svstartu/index.php?title=Main_Page
12:43ckychouser: It's okay. At least I could tell from the URL that it's in IN.
12:43cemerickfogus`: yeah, I saw that at the top of HN, so I figured I should go ahead and retweet the post :-)
12:46fogus`Living in the DC area, there is a related idea that if you're not working in Govt contracting then you're less than human.
12:46fogus`In my experience anyway... maybe pjstadig has different experiences
12:47amalloychouser: /msg sexpbot bitly <URL>
12:50amalloyhe also supports isgd, and (i think) tinyurl
12:50zemariammhello everyone
12:50ohpauleezhi zemariamm
12:51zemariammback to clojureland after some time away :)
12:51zemariammI just started using leiningen
12:51zemariammhowever I'm having a problem which I believe is pretty common
12:51zemariamm(since I found a bunch of posts about it on the clojure group :) )
12:52zemariammhere's the deal, I need to use some external jar on my app, this works fine during development
12:52zemariammI just place them under my lib/ dir
12:52zemariammand no problem
12:53zemariammhowever I need to build a standalone jar
12:53zemariammso lein uberjar
12:53zemariammhowever
12:53zemariammthat command will first call "lein clean"
12:53zemariammand delete my external jar and the compilation fails
12:53kumarshantanuzemariamm: you may find this thread useful -- http://groups.google.com/group/leiningen/browse_thread/thread/88a4052507197cbb
12:53zemariammhow do you guys solve this ?
12:55zemariammkumarshantanU: thanks I'll have a look
12:58amalloyzemariamm: istr the easiest way is to install the jar to your local repo and then depend on it
12:58zemariammso
12:59zemariammI can put it under ~/repository/
12:59zemariammand add this :repositories { "localShared" "file://~/m2"} to my project.clj , right ?
12:59zemariammI meant ~/m2/repository
12:59kumarshantanuzemariamm: yes, but you should put the files under ~/m2 then
13:00kumarshantanuyes, right
13:00zemariammawesome, going to try it :)
13:00amalloyzemariamm: ~/.m2 is already on your repo path, i think
13:00kumarshantanuamalloy: what is istr? any URL?
13:00amalloy$google istr
13:00sexpbotFirst out of 58400 results is: International Society for Third Sector Research(ISTR)
13:00sexpbothttp://www.istr.org/
13:00amalloydamn
13:00amalloyi seem to recall
13:00amalloykumarshantanu: ^^
13:02gtrak$lein repl
13:02zemariammhumm
13:02zemariammstill doesn't find it
13:02zemariammso , I added :repositories { "localShared" "file://~/.m2"}
13:02zemariammto my project.clj
13:02zemariammand added the external jars under ~/.m2/repository
13:03amalloyzemariamm: i'm afraid my maven know-how begins and ends with "cake/lein use it; ~/.m2 is important somehow"
13:03zemariammlool
13:03zemariammyet my maven knowledge is about zero
13:03zemariamm:)
13:04kumarshantanuzemariamm: you may need to follow this http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html to install the JAR in the repo
13:04zemariammah thanks, I'll have a look
13:04kumarshantanubecause it needs a pom.xml file too, which is generated when you do a "mvn install"
13:04zemariammI see
13:05kumarshantanuMaven is insane, you see ;-)
13:06kumarshantanuzemariamm: forgot to mention, you wil need to install Maven2 if you want to run "mvn install"
13:06zemariammgot it
13:06zemariammthis seems to help too: http://groups.google.com/group/clojure/browse_thread/thread/3a20228de255afa9
13:08kumarshantanuzemariamm: what's interesting is -- if you run "mvn install" for the local JAR then you don't need that ["localShared" "~/m2/"] thing
13:09zemariammhumm
13:09kumarshantanubecause the local JAR is already part of the local maven2 repo
13:09zemariammI'm still trying to hack something out , a simple shortcut :)
13:10amalloyzemariamm: mvn install is a shorter cut :P
13:10Licenseraloa
13:11zemariammhehehe
13:11zemariammok, I'm sold, going to try maven :)
13:11Licenseryou can also run lein install I think
13:11Licenserthen everything works splendid without the other stuff
13:12kumarshantanuLicenser: you can? I thought "lein install" works for a project.clj only
13:13Licenseryes but when he wants to add stuff for the project.clj he seems to have one
13:13Licensermvn instal only works on pom.xml as well right?
13:14kumarshantanu"lein install" degenerates into (1) generate POM (2) mvn package and (3) mvn install
13:14Licenserit still works :P also it shields you from writing 200+ lines XML files for maven
13:14kumarshantanuor the equivalent
13:15gtrakmore like copy-pasting 200+ lines :-)
13:15Licenserstill 200+ lines
13:15gtrakmaven's not THAT bad
13:15LicenserI have to use it on winows so yes it is :P
13:15Licenserat least for me
13:15ohpauleezhe's a witch, kick him out of the channel :)
13:15gtrakheh me too
13:16Licenserwhat I'd wish was if there was a way to write a project.clj then 1:1 translate it to the corresponding pom.xml
13:16ohpauleezEverytime I have to start using maven on a project, a childhood memory dies, and somewhere, a kitten dies
13:17Licenserwhat is childhood?
13:17kumarshantanuas the folklore goes: once there was a bright programmer who went to work for a Java enterprise; he reported mentally unstable the next day...it was later heard he was actually asked to debug the build process involving 4096 lines of pom.xml ;-)
13:17gtrakjesus
13:18gtrakwhy such a round number?
13:18LicenserI don't belive a word
13:18Licenserit surely were more then 4k lines :P
13:18ohpauleezhaha
13:18cemerickgtrak: take heart, those of us in #clojure that use maven simply ignore the hyperbole. You're far from alone. :-)
13:18zemariammnice, maven installed
13:19gtrakhaha, well, it's waht I'm used to with java, but i agree maven has a lot of ceremony you're forced to go through
13:19zemariammI see a groupId, artifactId version and packaging, where can I learn about this ? Since I can't omit it (it will give me an error back)
13:19cemerickgtrak: it's the ceremony/capability ratio that you want to worry about :-)
13:19gtrakpretty arbitrary zemariamm
13:19LicenserI don't mind maven I mind the pom.xml and the sometimes horrible documentation and overcomplexity
13:20zemariammgtrak: awesome, that's the answer I was looking for :)
13:20gtrakjust make sure they line up
13:20Licenserzemariamm: to learn maven you are required to know maven!
13:20zemariammLicenser: LOOOOOL
13:20zemariamm:)
13:20gtrakalso, you might want to make sure there isn't already an existing pom, but I guess you know that?
13:20ejacksonACK - I'm going to cook supper.
13:21kumarshantanuzemariamm: lein [org.apache/foo "1.1.0"] -- translates to groupId=org.apache artifactId=foo version=1.1.0
13:21gtrakif it's in a repo online, it'll be cleaner
13:21zemariammahh, awesome
13:30LauJensenkumarshantanu: same for cake
13:30zemariammfellas, I think it worked!
13:31kumarshantanuLauJensen: Yes project.clj is the same for lein and cake now I think
13:31LauJensenkumarshantanu: not quite, but we're working on the unification
13:32kumarshantanuLauJensen: oh okay
13:33kumarshantanuzemariamm: cool
13:33zemariamm:D
13:33zemariammguys thanks so much for the help
13:33zemariammi owe you a couple of beers
13:34zemariammI'll post every step on a blog post or something like that, it's kind of useful :)
13:34kumarshantanuzemariamm: +1
13:38Licenserout of curiosity what are the advantages/disadvantages of cake and lein
13:38Licensersave for one being tastier from the name
13:39kumarshantanulein can fight the ants, and cake attracts them ;-)
13:39zemariammhumm
13:40zemariammguys, related question
13:40zemariammI've my main function defined as expected
13:40zemariammand I have no problem
13:40Licenserbut I can eat cake and I can't eat lein, well I think I could but it would be illegal
13:40zemariammrunning "lein run"
13:40zemariamm(I specify :main in the project.clj file)
13:40zemariammhowever I cant run a standalone jar
13:41zemariammi get back a Exception in thread "main" java.lang.NoClassDefFoundError
13:42kumarshantanuzemariamm: does "lein uberjar" followed by "java -jar uberjar-name.jar" work?
13:42zemariammnope, I get back a Exception in thread "main" java.lang.NoClassDefFoundError: qrdecoder/core
13:42zemariammqrdecoder/core has my main function
13:43kumarshantanuzemariamm: did you declare :gen-class in the ns of the file containing -main ?
13:43zemariammyep
13:43zemariamm(it works with "lein run")
13:45Licenserhmmm hmmm
13:46kumarshantanuzemariamm: did you specify the main name in project.clj?
13:46zemariammyep: " :main qrdecoder.core"
13:46zemariammif I didnt specify it, lein run would break I think
13:47amalloyzemariamm: one thing i like about cake is the persistent jvm. i think lein is adding that feature soonish, or maybe already has
13:47zemariammamalloy: what's cake ?
13:47technomancyamalloy: it has interactive mode that keeps JVMs resident, yes
13:48amalloyoh, Licenser was the one who asked that questions, not you zemariamm. sorry about that
13:48zemariammamalloy: np
13:48kzarAm I right in guesing "B cannot be cast to clojure.lang.IFn" means I'm trying to call a byte as if it where a function?
13:48kumarshantanuzemariamm: I have seen this NoClassDefFoundError couple of times myself, but can't remember what solved it -- there is a checklist for getting standalone JARs to run
13:48amalloykzar: ##((byte 1))
13:48sexpbotjava.lang.ClassCastException: java.lang.Byte cannot be cast to clojure.lang.IFn
13:49kzaramalloy: Oh, then what does it mean by B?
13:49zemariammkumarshantanu: you mean, building the standalone jar without uberjar ?
13:50amalloykzar: not sure. maybe you actually have a class named B somewhere? i think (IFn)(byte 1) in java would be a compile error, not a run-time error, but i could be wrong
13:50kumarshantanuzemariamm: no "lein uberjar" followed by running the standalone JAR
13:50gtrakfirst arg in a list is evaluated as a function unless you quote
13:50amalloy&(^"B" (byte 1))
13:50sexpbotjava.lang.ClassCastException: java.lang.Byte cannot be cast to clojure.lang.IFn
13:50gtrak&'(byte 1)
13:50sexpbot⟹ (byte 1)
13:51amalloygtrak: we know
13:51gtrakso what's (byte 1) mean otherwise?
13:51kumarshantanu&(^"[B" (byte 1))
13:51sexpbotjava.lang.ClassCastException: java.lang.Byte cannot be cast to clojure.lang.IFn
13:51gtrakconfused
13:51amalloy&(byte 1)
13:51sexpbot⟹ 1
13:51gtrakhmm
13:51zemariammkumarshantanu: http://stackoverflow.com/questions/3677372/lein-jar-and-lein-uberjar-not-setting-the-main-class-properly
13:52kzarbyte turns a number into a byte, useful sometimes when you need a byte for java interop
13:52gtrakah, so having double parenthesis evaluates it again
13:52kzargtrak: I need to turn my seq of numbers into a byte array so I have to apply byte and then call byte-array
13:52kumarshantanugtrak: what are you trying to do?
13:52amalloygtrak: not "evaluates it again"
13:52amalloy"after evaluating it, calls it as a function"
13:52gtrakevaluates it
13:53gtrak&(1)
13:53sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
13:54amalloykzar: ##(into-array (map byte [1 2 3]))
13:54sexpbot⟹ #<Byte[] [Ljava.lang.Byte;@be9943>
13:54clizzin_if i want to apply a function to all the values in a map, is (zipmap (keys m) (fn (vals m)) the most idomatic/efficient way to go about doing this?
13:54clizzin_that's what i've been doing for a while, but it just occurred to me that perhaps there's a better way -- having to get the keys out seems kind of unnecessary.
13:54amalloy&(use 'clojure.contrib.generic.functors)
13:54sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/generic/functors__init.class or clojure/contrib/generic/functors.clj on classpath:
13:55kzar((byte-array (apply byte (range 100))))
13:55kzar,((byte-array (apply byte (range 100))))
13:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args (21) passed to: core$byte
13:55kzar,((byte-array (map byte (range 100))))
13:55clojurebotjava.lang.ClassCastException: [B cannot be cast to clojure.lang.IFn
13:55amalloy&(use 'clojure.contrib.generic.functor)
13:55sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/generic/functor__init.class or clojure/contrib/generic/functor.clj on classpath:
13:55kzarthere we go, B means Bytearray
13:55amalloywhatever. clizzin_, clojure.contrib.generic.functor/fmap does what you want
13:55kzaramalloy: Cool thanks, I'll do it like that
13:56amalloykzar: [B means byte[]
13:56zemariammkumarshantanu: I opened teh jar, I do have qrdecoder/core$_main.class
13:56amalloyi could tell you that if you hadn't said it was B
13:56zemariammit should be it right ?
13:56clizzin_amalloy: thanks
13:56Surgosilly newbie macro question...I'm attempting to set a var of a name given as the macro parameters (at compile time), and later access it...but it seems when I run (def) in a macro, it doesn't make the var accessible non-locally (or at least when I try to resolve it it's not there).
13:57amalloySurgo: it should work. make a paste?
13:57Surgocode example: http://pastebin.com/eCBHqv31 . Run with abcd, then I try resolving abcd after the macro runs...and nothing.
13:57kumarshantanuzemariamm: I think you should rather have core.class because it's supposed to be gen-class'ed (but not sure at the moment)
13:57Surgo(well, there is something, "Unable to resolve symbol" :P)
13:58amalloySurgo: you want this var accessible at compile-time, or at runtime?
13:58Surgocompile-time
13:58Surgoit'll actually be gone by the time run-time comes around
14:00zemariammkumarshantanu: by reading the docs I think you are absolutely right
14:00amalloySurgo: it's somewhat tricky, because def is a special form that needs its argument as a literal
14:01amalloy(def fname) defines a var called fname, not one whose name is the contents of fname
14:01zemariammkumarshantanu:oh shit, I had gen-class instead of :gen-class in my ns definition
14:01Surgoamalloy: yeah, that's what I want (the var being called fname)
14:01amalloyoh. really?
14:01Surgoits contents should just be (list)
14:01amalloyokay
14:01kumarshantanuzemariamm: the funny part about the ns macro is - if you mis-spell something in this macro it may not throw any error and still ignore it
14:02kumarshantanuzemariamm: so watch out for that too
14:02zemariamm:D
14:02amalloybut...your code doesn't look that way. why are you taking fname as a parameter
14:02zemariammrebuilding :)
14:02amalloyif you want the name to always be the literal symbol/string "fname"
14:02Surgooh, I see the confusion
14:03SurgoI want the name to be different, depending on what "fname" is -- it should just be called fname. Maybe this communication would be easier if I tried to state what I was trying to do :-P
14:03amalloySurgo: i can see what you're trying to do, you just keep claiming you're trying to do something else :)
14:03SurgoI think that might have something to do with how little I know what I'm talking about
14:03zemariammkumarshantanu: thanks so much, it finally rans, with another error, but a different one :)
14:04zemariammruns*
14:04kumarshantanuzemariamm: \m/
14:04Surgowhat I want...the var to be named based on the parameter given (fname), but whose contents is just (list). Am I still misunderstanding?
14:04zemariammthe error I get back is exactly this one: http://stackoverflow.com/questions/4354293/jar-produced-with-lein-uberjar-fails-on-noclassdeffounderror , researchign it
14:04amalloyno, you've now stated what you meant all along
14:04amalloyhurrah!
14:05Surgothank you
14:05amalloyso the way to do that is `(def ~fname (list))
14:05Surgohopefully as I become less of a newbie to all of this I will become better at communicating
14:05zemariammleinigen 1.4.0 bug ?
14:06kumarshantanuzemariamm: (1) lein clean (2) rm -rf lib (3) lein ubderjar
14:06amalloybut that is a little tricky, because it expands into code that defs, rather than doing the def itself; the def won't happen unless (mactest foo) is in code that is doing something at compile time already
14:06Surgohmm...wouldn't that cause the code to be run at run-time?
14:06kumarshantanus/ubderjar/uberjar/
14:06sexpbot<kumarshantanu> zemariamm: (1) lein clean (2) rm -rf lib (3) lein uberjar
14:06zemariammgoing to try it
14:07zemariammit works!!!!
14:07zemariammI ended up adding :keep-non-project-classes true
14:07amalloySurgo: you can't really do it otherwise, because at the time that mactest is itself compiled (not the call to mactest), it doesn't have the name of the var to def, and it needs a compile-time literal
14:07zemariammto my project.clj
14:07Surgoit's not really clear to me what a (do `(def ~fname (list)) (do-other-stuff)) would do, actually
14:08Surgoamalloy: hrm, maybe there's another way to get to the same effect without needing a persistent var
14:08amalloyyou *might* be able to do it by creating another macro that builds mactest-like macros that know what to def at compile-time, but that is getting pretty intricate
14:09Surgowhat I'm trying to do is simply allow piecewise function composition using pattern matching (like ML), so what I figured was I'd define a macro that just stuffed all the piecewise definitions in a list named the same as the function (to guarantee uniqueness), then have a final macro that composed them into an actual (defn)
14:09Surgono real reason to do this, just trying to learn clojure :)
14:10amalloySurgo: (eval `(def ~fname (list))) would work for sure, if you ever get desperate enough to use eval
14:12Surgobrilliant! though if I could bother you to help me understand how that's different than a plain (def fname (list))?
14:13SurgoI mean, seems to me at first to just be the evaluation of fname
14:13amalloySurgo: yep
14:13amalloythat is the only difference
14:13Surgoah
14:14amalloyand because def doesn't evaluate its first argument, it is a necessary difference
14:14Surgoand def, being a special form, barfs at (dev (eval fname) (list))
14:14Surgo(just tried it)
14:14chouserPop quiz!
14:14Surgothank you very much, this has been quite informative and helpful
14:14amalloy(eval fname) probably wouldn't work anyway
14:14amalloyor i guess it would, i dunno
14:15chouserhm, wait a sec.
14:15Surgonow let's see if I can finish that macro array
14:15amalloychouser: now that we've had time to prepare, is it still a pop quiz?
14:15chouseryes it is
14:15chouserthe question is:
14:16chouserwhat clojure.core function or macro whose name starts with "with-" has nothing to do with dynamic scope?
14:16amalloywith-command-line-args?
14:16amalloyor whatever it's called
14:17chouserthat is, it doesn't refer to binding or try/catch in its docstring or source
14:17chouseramalloy: I think that's in contrib somewhere
14:17amalloyoh, so it is
14:17hiredmanthe local vars thing?
14:17chouserthat's dynamic scope
14:17technomancywith-meta
14:17hiredmanmaybe with-open, I always forget if that uses binding or let, must be let
14:17hiredmanchouser: is it?
14:17danlarkinwith-open uses try/finally
14:18chouserand uses try/finally to pop thread bindings
14:18zemariammguys I'm out, thanks so much for the help :D
14:18hiredmanchouser: are you sure?
14:19hiredmanah, I guess it does
14:19hiredmanlet+binding
14:20amalloyanyway, technomancy surely wins the prize for with-meta
14:21hiredmanchouser: so why does having try/catch disqualify from "nothing to do with dynamic scope"
14:21chousertry/catch is dynamic scope
14:21amalloyhiredman: try/catch is how clojure gets dynamic scope, isn't it?
14:21chouseroh, missed it.
14:21chousertechnomancy: right, with-meta
14:22hiredmanamalloy: no
14:22chouser(defn foo [] (throw x)) (try (foo) (catch ...))
14:22hiredmanchouser: ok, but try/finally?
14:22chouserthrow x happens in the dynamic scope defined by try/catch
14:22chousersame thing with try/finally
14:23amalloyi think hiredman's point is the finally has no access to whatever was thrown
14:23chouserah, interesting point.
14:23hiredmanit also get's executed regardless of something being thrown
14:24chouser& (remove #(re-find #"binding|try" (clojure.repl/source-fn %)) (filter #(re-find #"^with-" (str %)) (keys (ns-publics 'clojure.core))))
14:24sexpbotjava.lang.ClassNotFoundException: clojure.repl
14:24chouseraw
14:24chouser, (remove #(re-find #"binding|try" (clojure.repl/source-fn %)) (filter #(re-find #"^with-" (str %)) (keys (ns-publics 'clojure.core))))
14:24clojurebotjava.lang.NullPointerException
14:24chouser:-P
14:24hiredmanreally, my point is, I should get points for with-open
14:24chouserheh
14:24chouser(inc technomancy)
14:24TordmorLet's say I have a quoted form in a var like (def f '(+ 3 4)) how would I turn this into a function?
14:24hiredmanthe binding it creates are all lexical
14:25sexpbot⟹ 2
14:25chouser(inc hiredman)
14:25sexpbot⟹ 1
14:25technomancyI used tab-completion on slime; I don't know if that's cheating.
14:27amalloy(inc slime)
14:27sexpbot⟹ 1
14:27Surgothe clojure docs say you can't change the root binding of a var with set!; so, how would you change it? (it's kind of silly but it'd be nice if that was the next sentence in the docs)
14:27amalloySurgo: ##(doc alter-var-root!)
14:27sexpbotjava.lang.Exception: Unable to resolve var: alter-var-root! in this context
14:27amalloySurgo: ##(doc alter-var-root)
14:27sexpbotjava.lang.SecurityException: You tripped the alarm! alter-var-root is bad!
14:27chouserSurgo: you're generally not meant to
14:28amalloysexpbot: stuff it
14:28TordmorHow would I build a clojure function at runtime?
14:29SurgoTordmor: you can just (eval f), given your above example
14:30amalloyTordmor: (fn [x] (eval `(let [~'x ~x] ~@myfn-code))), if you want to pass it x as an argument
14:30gtrak&(find-doc "alter-var-root")
14:30sexpbot⟹ ------------------------- clojure.core/alter-var-root ([v f & args]) Atomically alters the root binding of var v by applying f to its current value plus any args ------------------------- clojail.core/sandbox ([tester & {:keys [timeout namespace context jvm?], :o... http://gist.github.com/739467
14:33gtrak&(eval (list inc 1))
14:33sexpbotjava.lang.SecurityException: You tripped the alarm! eval is bad!
14:33gtrak&(list inc 1)
14:33sexpbot⟹ (#<core$inc clojure.core$inc@16968c4> 1)
14:34gtrakdoes that work?
14:34amalloygtrak: yes
14:34gtrakok cool :-)
14:34amalloybut you have to be careful if you want a function that isn't in clojure.core like inc is
14:34gtrakhow so?
14:34amalloy(eval `(inc 1)) is a fair bit safer
14:35gtrakb/c it figures out namespaces for you?
14:35amalloygtrak: if you return (myfoo 10) and the caller hasn't :use'd myns, then myfoo will be an error when they run it
14:35gtrak&`inc
14:35sexpbot⟹ clojure.core/inc
14:35gtrakgot it
14:36amalloy` resolves the namespaces in the context of building the list rather than executing it, as you have demonstrated
14:37ckyMaybe it's just a personal style thing, but when there are no unquotes, I vastly prefer to use quote, not quasiquote.
14:37ckyThat way, when I read the code, I know that nothing in there is going to get evaluated.
14:37cky&'(inc 1)
14:37cky&`(inc 1)
14:37sexpbot⟹ (inc 1)
14:37sexpbot⟹ (clojure.core/inc 1)
14:38ckyamalloy: That makes more sense.
14:38gtrakcky: not sure I get what you mean
14:38SurgoThis is strange...when I set up the var in the macro, using alter-var-root, to cons another list on, it gets altered appropriately within the macro, but when I resolve the var outside of the macro, it doesn't change. When I try accessing it in another macro, it is changed. Is there some scoping information I'm missing here?
14:39ckygtrak: amalloy has just explained why '(foo bar) is not the same as `(foo bar) in Clojure.
14:39ckygtrak: My background is in Scheme, where the two are no different at all.
14:40Surgoor...hmm. could it be that the binding is different because this is a 'pure' functional thing, and it still thinks that me in the REPL is using the old binding so it hasn't gotten rid of it yet
14:40cky&'(non-existent 1)
14:40sexpbot⟹ (non-existent 1)
14:41cky&`(non-existent 1)
14:41sexpbot⟹ (clojure.core/non-existent 1)
14:41ckyO_o
14:41gtrakso, it's late symbol resolution vs early?
14:41gtrakwhat's the issue?
14:41amalloyresolution at macro time, yes
14:41fogus`&'(clojure.core/non-existent 1)
14:41sexpbot⟹ (clojure.core/non-existent 1)
14:42gtrak&'(random-symbol 1)
14:42sexpbot⟹ (random-symbol 1)
14:42gtrak&`(random-symbol 1)
14:42sexpbot⟹ (clojure.core/random-symbol 1)
14:42gtrakhuh?
14:43gtrakoh weird
14:43gtrak`(asdflasdf)
14:43gtrak&`(asdflasdf)
14:43sexpbot⟹ (clojure.core/asdflasdf)
14:43gtrakthat's a little weird
14:46fogus`gtrak: What do you suspect would happen if you ran: (eval `(non-existent 1))?
14:46chousergtrak: sexpbot must be evaluating our expressions in the clojure.core namespace
14:46chouser& *ns*
14:46sexpbot⟹ #<Namespace sandbox6362>
14:46chouserhm
14:47gtraki would think it would just ignore it
14:47fogus`gtrak: wrong person. :-( sorry.
14:47chousersexpbot must be reading our expressions in the clojure.core namespace
14:50alpheusCan anyone direct me to an example of destructuring with :strs?
14:51chouser& (let [x {"one" 1, "two" 2, "three" 3}, {:strs [one two three]} x] ['counting one two three])
14:51sexpbot⟹ [counting 1 2 3]
14:53chouseralpheus: ^^^
14:54alpheusoh, you don't quote the strings
15:02alpheusHow would I represent a key that is a string containing a space?
15:05Tordmoralpheus: As a string?
15:08ohpauleezalpheus: You could string replace each space with an underscore, and keyword that string
15:08ohpauleezbut it won't be reversible
15:08alpheusYes, I'm trying to destructure a map having some keys that are strings with spaces.
15:08ohpauleezexample "here is a_string" => :here_is_a_string => "here is a string"
15:09ohpauleezif you only need the first two, just do a string replace
15:09alpheusThe map is externally defined, since it comes from a csv file that I'm loading.
15:10ohpauleezwell, trim the string, then replace all spaces with underscores, then call keyword on it
15:11alpheusI can think of various ways to solve the problem, but I can't find a definition of what destructuring with :strs is actually supposed to do. The example that chouser gave above is the only example I've seen so far.
15:12alpheusI'm sure I've just missed it, not saying that the docs are deficient or something.
15:19amalloyalpheus: it's supposed to do exactly what chouser's example does...(ie, like :keys but with "foo" instead of :foo)
15:35fogus`:strs comes in handy when dealing with maps built from a JSON source
15:54jweiss_Can I extend a protocol to another protocol?
15:55jweiss_eg, if i have a protcol Raisable that has a interface with "raise", and i want to extend it to my protocol "Condition" so that every concrete condition can be "raised"?
15:55nickiknot possible.
15:55brehautjweiss_: i dont think you can [citation needed]
15:56jweiss_ok then can two protocols share the same fn?
15:56jweiss_i'm guessing now
15:56jweiss_not
15:56brehautjweiss_: if namespaced yes
15:57brehautfoo/my-proto-fn and bar/my-proto-fn are different funs
15:57brehautbut otherwise no
15:57jweiss_no, what i've got here is that all Conditions are Raisable, but not all Raisables are Conditions.
15:58jweiss_so how do i specify the "raise" fn for all Conditions?
15:58jweiss_just have to have all their concrete types implement it i guess
16:21amalloyjweiss_: i don't think you want two protocols here, really, do you? protocols don't really have a hierarchy
16:22amalloyyou want a raise protocol, and two interfaces Raisable and Condition:Raisable; then you can extend the raise protocol to the Raisable interface
16:30clizzin_what's a typical use case for constantly? it seems like a weird function to have...
16:30dnolen_,(interleave [1 2 3 4] (constantly 'foo))
16:30clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__3551
16:31pjstadigwhen you think you want to do something like #(foo) you want constantly instead
16:31hiredmandnolen_: you are thinking of repeatedly
16:31dnolen_,(interleave [1 2 3 4] (constantly (fn [] 'foo)))
16:31clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__3551
16:31dnolen_hiredman: yeah
16:31dnolen_(doc constantly)
16:31clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
16:31ohpauleezwhen you want to use constant, but off of a function value
16:32hiredmanconstantly is useful for representing constants when you are dealing with higher order functions
16:32ohpauleezthat's also a good way to phrase it
16:32hiredmanupdate-in, swap!, send-off, send, etc
16:34kzarbooya my step sequencer no longer crashes Java
16:34duncanmin slime/swank, isn't there a way to get the last result from the REPL?
16:34duncanmsomething like $1, or #1 ?
16:34duncanm%1 maybe?
16:35ohpauleez*1
16:35ohpauleezyou can get the last three
16:35duncanmohpauleez: yes!
16:35ohpauleez*1 *2 *3
16:35duncanmohpauleez: it was you who told me about this last time ;-)
16:35ohpauleez:)
16:35ohpauleezduncanm: I'm glad I can help
16:35ohpauleezsuper useful
16:36duncanmohpauleez: indeed
17:08clizzinohpauleez, hiredman: re constantly, i get the general idea of wanting to save the output of a higher-order function, but why not just bind that in a var? the code i'm looking at takes a seq or vector foo and binds foo-fn to (constantly foo). i feel like there's a performance improvement here but am not sure why/how.
17:09amalloyclizzin: you don't get the idea; you're upside-down
17:10amalloysay you want to call a library function asks you to pass it a function; it's going to call that function ten times with different arguments to decide how to populate a list it gives you
17:11amalloybut your program is really simple and you want the list to just be full of zeros. so you call (libfn (constantly 0))
17:12amalloymaking more sense now?
17:12clojurebotTitim gan éirí ort.
17:16clizzinamalloy: i see. okay, i get both that case and the case in the code i'm reading now. awesome. thanks!
17:18ohpauleezclizzin: Also, think about a framework, that needs to always start with a default reply
17:19ohpauleezit's easy to make that a function call, and then redefine that function call in other namespaces or what-have you
17:19ohpauleezmaking stubbing easier, while keeping the calling and composition of functions of the framework intact
17:23NikelandjeloWhich variant is correct (defn tst [^long x] ... ) or (defn tst [^:long x] ...) ?
17:24amalloyNikelandjelo: the first
17:24amalloy(or maybe neither? i don't think clojure functions can accept primitive args before 1.3)
17:26ohpauleezamalloy Nikelandjelo: right, before 1.3, you could only cast in a let and use the primitive there
17:26ohpauleezotherwise, you could only type hint (objects) for java purposes
17:27NikelandjeloThanks. I still use 1.2 I should switch to 1.3 :)
17:27NikelandjeloI read, 1.3 version is slower than 1.2 Is it still actual?
17:28ohpauleezNikelandjelo: There were some speed regressions for certain tasks in 1.3. When those get discovered, they get fixed rather quickly
17:28ohpauleezI have never personally hit any of them, and in fact have been able to write pretty fast 1.3 stuff
17:40edw`choose': is this a standard clojure procedure?
17:41amalloyedw: i choose things all the time. what do you want "choose" to do?
17:41edwI'm looking at some sample code, and choose is undefined.
17:41amalloy&(doc choose)
17:41sexpbotjava.lang.Exception: Unable to resolve var: choose in this context
17:41jcromartiecritique please! (inspired by Compojure's route/clout mechanism) https://gist.github.com/c9522a2f56722f2a0d8e
17:42ohpauleezit's in contrib
17:42ohpauleezand in incanter
17:42amalloyedw: link it? it's probably in their use/require
17:42ohpauleezhttp://clojuredocs.org/clojure_contrib/clojure.contrib.probabilities.finite-distributions/choose
17:43edwAh. Thanks. I searched through core but not contrib: finding the contrib doc page is sometimes surprisingly difficult.
17:43jcromartieall the "normalize" is a little clunky
17:43jcromartieI could clean that up
17:43amalloyedw: yes, google helpfully provides old-old links to wrong places. you could try clojuredocs.org, which is usually pretty good
17:43ohpauleezyes, I have just defaulted to ClojureDocs, and if I refuse to use a browser, I usually just hit the API with python
17:50jcromartiewhat is the leiningen project/script/ directory for?
17:50ohpauleezI use it for one off scripts I need. Like my repl-init script
17:51ohpauleezor provisioning scripts, for example
17:51jcromartieprovisioning?
17:51ohpauleezlike for kicking off builds or pushing something to a staging server
17:52ohpauleezI'm sure I abuse it, but that's what I put in there
17:54jcromartieheh, I don't think there's a defined use
17:54jcromartieseems handy though
17:54jcromartielike for usage examples, perhaps
18:03clizzinjesus, quora is devastatingly slow
18:05amalloyam i guaranteed that (= (byte 1) 1), or may that stop being true, eg as part of the auto-promotion changes in 1.3?
18:06clizzin^ whoops, wrong room =(
18:08ohpauleezamalloy: I think you'll be ok
18:09ohpauleezdo not quote me on that, I haven't seen the latest work that has gone into that
18:24dnolen_amalloy: you will need to use == in 1.3.0 to avoid things like (= 1M 1) ; false, and (= 1.0 1) ; false
18:27amalloydnolen_: thanks
18:33joegallofinished up 102, will merge into qa tomorrow, heading out.
18:33joegallowrong channel, I'm a moron.
19:36amalloycan someone look at http://is.gd/iHwv0 in paredit for me? mine refuses to delete anything in the last defn because of unbalanced " characters, but (a) they're balanced, and (b) it thought they were balanced enough to enter paredit mode
19:51devinusjust curious, but why can't clojure do TCO the way scala does it?
19:57chouserdevinus: it could, but 'recur' is nicely explict -- if you think you have written something tail-recursive when you haven't, 'recur' will give you an error
19:57amalloydevinus: my quick search indicates that how scala does it is "barely"
19:57amalloythough personally i like chouser's reason
19:57devinuschouser: oh nice
19:58chouserif you think you've written something tail-recursive with a plain function call, but you haven't, you won't know until you blow the stack at runtime
19:58amalloychouser: or you ask chouser about it :)
19:58chouseras far as I know, Scala only does automatic tail recursion optimisation in cases where 'recur' would work in clojure
19:59gtrakyea... if you're coming from static languages it feels worth it to know what's going to happen, i think people from scheme think it's less elegant
20:00gtrakat least that's how I think of it
20:00gtrakno reason to have any doubt whether it'll tail-recur or not, the compiler will tell you
20:00gtrakit's not like you don't have to think about it when you're writing scheme
20:01chouserright
20:02chouserand Clojure can't give full TCO (in mutual recursion cases etc.) while keeping Java calling conventions, so you'd have to know that caveat too.
20:02gtrakhmm, how do you do that anyway?
20:02brehautgtrak: scheme does have a difference in that everything is rewritten to continuations though right?
20:02gtrakactually I don't know
20:03gtrakI took a course on it a long time ago, and now I'm learning clojure :-)
20:03hiredmanbrehaut: doesnn't have to be, that is just a technique for implementing scheme
20:03brehautgtrak: it was definately the case with steele's original scheme. i dont know if it still holds
20:04brehauthiredman: cheers
20:13Adamantbrehaut: only if CPS is used
20:14brehautAdamant: can you clarify for me; do you mean for the scheme implementation or the scheme users program?
20:14Adamantimplementation
20:14Adamantat the user level, everything is not continuations
20:14brehautyes thats what i thought
20:14Adamantalthough you can use CPS at user level if you want
20:15Adamanthaving explict recur is definitely ugly for people used to Scheme, like me
20:16Adamantsadly adding TCO to the JVM is not a current priority
20:16Adamantthey're busy with the dynamic support it seems
20:17brehautreal? i thought they were busy painting the bike shed
20:18Adamantbrehaut: I was whining on here about that and got asked to put my money where my mouth was by Rich
20:18brehautfair nuff :)
20:18AdamantI tried, but the JVM folks aren't interested at the current juncture
20:18Adamantthey are interested though
20:18gtrakapparently the apple jvm had TCO
20:19gtrakbut now it's hosed?
20:19Adamantyeah, Apple now hates Java
20:19Adamantof course Apples hates everything not Apple
20:19gtrakstill, their TCO must not be platform specific, right?
20:20Adamantgtrak: no idea, and the basic thing is the guys working on extended the JVM don't want the trouble right now
20:20Adamantthey're loaded to the gills with dynamic support
20:20gtrakah
20:20AdamantTCO is one other thing to add they don't have time for, even if other people do most of the coding
20:23Adamantit will definitely have an effect on stack walking stuff, which for one thing lots of the security mechanisms do
20:28tomojI haven't found myself missing TCO
20:34brehauttomoj: its incredibly rare that i even have to bust out a recur
20:36joshua__ (:require ((net.cgrand.enlive-html :as html)
20:36joshua__ (compojure.route :as route))))
20:36joshua__whats wrong with that?
20:37brehautjoshua__: you arent quoting your symbols?
20:37brehauthmm no
20:38joshua__will give more info in a second..
20:39tomojyou don't need to quote there
20:39joshua__I'm trying to do something like: http://pastebin.com/SrwSpSyx with only one :require
20:39brehautjoshua__: try (:require [net.cgrand.enlive-html :as html] [compojure.route :as route])
20:39brehaut(asuming this is in a ns form)
20:43gertalothey everyone! I'm trying to figure out a way to do something similar to prewalk-replace or postwalk-replace, that only changes at most a single element (not every element like these functions)
20:43gertalotand I'm stuck (or I wouldn't bother you) :)
20:44gertalotor a clojure.core/replace that only replaces the first occurrence of something that's replaceable
20:45clizzinhow can i pass a static java function as an argument to map? i just tried (map java.lang.Math/log foo), but it looks like clojure tries to look for a static field instead of a method. any way to do this without just using an anonymous function?
20:46notsonerdysunnyHello everybody I required clojure.contrib.generic.math-operations as gm and now I want to bind the default / with gm// but it is telling me that the gm// is not a correct token .. so how can I / with gm// ?
20:47scgilardiclizzin: afaik there isn't. using an anonymous function is a good choice.
20:47clizzinthanks scgilardi
20:54scgilardinotsonerdysunny: I haven't done what you're trying to do, but does the qsym macro (http://richhickey.github.com/clojure-contrib/generic.arithmetic-api.html) help?
20:55joshua__brehaut: thanks that worked (would have told you sooner but I had to close the webserver, using compojure without gae this time and not sure how to do interactive development just yet)
20:55brehautjoshua__: no problem
20:58notsonerdysunnythanks scgilardi
20:58notsonerdysunnythat worked
20:58scgilardicool
21:00brehautjoshua__: i use moustache for my routing and for everything other than redefining routes holding the repl open and using (use :reload my-ns.foo) is sufficient to do interactive development
21:00brehautjoshua__ ive got something messed up though which means if i change my routes i have to quit the repl because it breaks something on the jetty server and ive been too lazy to fix it
21:02brehautjoshua__: the other thing to consider is looking at lazytest ( https://github.com/stuartsierra/lazytest ) im pretty sure it does a simple watch on your clj files and reloads them when they change and reruns any appropriate tests
21:12joshua__brehaut: I found a simple way to do it, though I don't like it as it always throws an exception. I can wrap my handler in a (var hanlder) when passing it to jetty. Hopefully I'll find a way that doesn't cause an exception when you compile, despite working. Reading: http://groups.google.com/group/compojure/browse_thread/thread/5606760b86cfd49c
21:15joshua__I think I've got a solution to the exception thrown despite it working.. how do I catch exceptions in clojure?
21:26brehautjoshua__: you might be surprised to discover that you use try catch http://clojure.org/special_forms#Special%20Forms--(try%20expr*%20catch-clause*%20finally-clause?)
21:28joshua__brehaut: Just got it working not ten seconds ago. You can see my solution here: http://pastebin.com/Bv0Y2DVF
21:29joshua__brehaut: better doc of how to use the try catch is what slowed me down the most, but this helped: http://en.wikibooks.org/wiki/Clojure_Programming/Concepts when I searched it for examples of try
21:30notsonerdysunny~(clojure.contrib.generic.arithmetic/* (struct clojure.contrib.complex-numbers/complex-struct 10 20)
21:30clojurebotant clean and rebuild contrib
21:30notsonerdysunny (struct clojure.contrib.complex-numbers/complex-struct 2 1))
21:31notsonerdysunny~(clojure.contrib.generic.arithmetic/* (struct clojure.contrib.complex-numbers/complex-struct 10 20) (struct clojure.contrib.complex-numbers/complex-struct 2 1))
21:31clojurebotcompiling clojure is rarely necessary to do yourself.
21:31notsonerdysunny~(clojure.contrib.generic.arithmetic/* (struct clojure.contrib.complex-numbers/complex-struct 10 20) (struct clojure.contrib.complex-numbers/complex-struct 2 1))
21:31clojurebotpcl → clojure is http://blog.thinkrelevance.com/2008/09/16/pcl-clojure
21:32notsonerdysunnythe s-expression (clojure.contrib.generic.arithmetic/* (struct clojure.contrib.complex-numbers/complex-struct 10 20) (struct clojure.contrib.complex-numbers/complex-struct 2 1)) gives me the exception
21:33notsonerdysunnyNo method in multimethod '*' for dispatch value: [clojure.lang.PersistentStructMap clojure.lang.PersistentStructMap]
21:33notsonerdysunny [Thrown class java.lang.IllegalArgumentException]
21:33notsonerdysunnycan anybody help me understand what is happening here?
21:51amalloynotsonerdysunny: c.c.g.a doesn't support the types in c.c.c-n, it just leaves space for you to add your own implementation
21:53amalloy&(require 'clojure.contrib.generic.arithmetic :as 'math)
21:53sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/generic/arithmetic__init.class or clojure/contrib/generic/arithmetic.clj on classpath:
21:58notsonerdysunnythanks amalloy ..
22:17notsonerdysunnyI am defining a protocol which defines the functions +,-,*,/ .. so I am excluding those symbols when I do :refer-clojure but I would like to give an alias to say something like c+ c- c* and c/ how can I do this?
22:25amalloy(:require clojure.core :as c) should do it
22:28amalloyokay, i was close. this works: (ns foo (:require [clojure.core :as c]))
22:31defnyeah i always forget when to wrap in []
22:32amalloynotsonerdysunny: ^^
22:34tomojnotsonerdysunny: use :rename instead of :exclude?
23:03notsonerdysunnythanks tomoj ..
23:03notsonerdysunnythat did the trick
23:05amalloy&(let [[a & [b & c]] [1 2 3 4]] [a b c])
23:05sexpbot⟹ [1 2 (3 4)]
23:15Guest28208do you ever really need to call "apply"?
23:15amalloyGuest28208: yes
23:15Guest28208like when?
23:16ckyGuest28208: When you need to take the arguments from a list.
23:16amalloyin general: when you get a list from some outside source that had no choice but to give you a list, and need to treat them as separate arguments to a function
23:17Guest28208ok. makes sense
23:17Guest28208thx amalloyand cky
23:17amalloyeg, (concat [1 2] [3 4]) should clearly return [1 2 3 4], but what if someone passes you the vector [[1 2] [3 4]]
23:17joshua__Do you still serve files in compojure with serve-file?
23:18joshua__nervermind
23:20auserhow do you go over a string, character by character?
23:21amalloyauser: strings are seqs of chars, so map et all work
23:21auserah, cool
23:21auserthx
23:21amalloyyou probably have to call (seq) on it first
23:21hippiehunterdoes anyone else ever have any trouble with slime after disconnecting/reconnecting swank? Ive reconnected but it just keeps saying "connection closed" whenever i try to do anything slime related
23:28amalloyi can never quite remember how to use :or map destructuring
23:29amalloyanyone have a pointer for me?
23:30Raynes&(let [{:keys [x y] :or {y 2}} {:x 3}] (+ x y))
23:30sexpbot⟹ 5
23:30amalloythanks. i usually try :or {:y 2}
23:30amalloyso far it hasn't worked, but i'm still hoping
23:32tomoj&(let [{:keys [x y] :as opts :or {x 1}} {:y 2}] [x y opts]) ; seem funny?
23:32sexpbot⟹ [1 2 {:y 2}]
23:33tomojguess not
23:33hippiehunterraynes: do you have that response bound to a key? I think thats the single most frequent question ive seen in here, and you answer it everytime.