#clojure logs

2011-11-03

00:07zakwilsonI want to start a repl in my namespace from my -main function. What's the easiest way to do this? Looking at clojure.main/repl, it doesn't seem to be able to do that.
00:14hiredmanzakwilson: why not?
00:15zakwilsonhiredman: because I'm bad at reading documentation. Looks like :init #(in-ns 'my-ns) does the trick.
00:28brehautenlive nerds: thoughts on (defn enlive-render-wrap [f] (fn [req] (update-in (f req) [:body] #(if (:tag %) (enlive/emit* %) %)))) ? (removing template, and just using snippets, relying on the middleware to render)
01:27callenkorma looks nice.
01:33ibdknoxcallen: hopefully ;)
03:33callenhttps://github.com/getwoven/clj-time/blob/master/src/clj_time/core.clj trying to use this code, having a weird issue specific to inside a defn.
03:33callen(defn unix-now [] (use 'clj-time.core) (in-secs (interval (epoch) (now))))
03:33callenthat fails
03:34callensimply using the namespace inside a repl works.
03:34hiredmanyeah, don't do that
03:34callenhiredman: feel free to explain the idiomatic approach.
03:34hiredmanuse is a global
03:35callenwhat should I use? in-ns?
03:35hiredmanwhy do you want to use either?
03:35hiredmandon't use any of them like that
03:35callenI need to use clj-time.core
03:35callenit has a namespace defined
03:35callenhow do I make my helper function work?
03:35hiredmanso put a (:use clj-time.core) in your (ns ...) form
03:35RaynesYou don't. You want to use the namespace in your ns form.
03:36ibdknoxwoah
03:36RaynesWhat's up?
03:36ibdknoxthey used Noir in the 2nd edition of programmin clojure?
03:36ibdknoxprogramming*
03:37callenRaynes hiredman my naive attempt at doing what you just said failed.
03:37RaynesIf you makes you happy, I plan to use it in my book as well.
03:37hiredmanwell, learn how to do and do it better
03:37callenas you said, it's a global and appears to break other things.
03:37callenhiredman: I asked for the idiomatic approach.
03:37hiredmanread the docs, read some code
03:37callenhiredman: I have the pragprog book in front of me.
03:37hiredmanI gave it to you
03:37callenhiredman: and the code.
03:38ibdknoxcallen: the idiomatic approach is to do one of two things
03:38ibdknoxcallen: in your ns declaration (ns my-things.foo ..)
03:38hiredmanif you failed to make the idiomatic approach work, you need to read more docs, look at more examples
03:38ibdknoxcallen: you can either do :use or :require
03:38callenI don't know the idiomatic approach, I just spent half an hour ctrl-f'ing through the book
03:38callenwhy :use instead of use?
03:39RaynesBecause that's what ns takes.
03:39ibdknoxcallen: in general, if you do use, you want to do it like so (:use [some-thing :only [the-thing-I-need]])
03:39callena new and interesting error that I don't understand.
03:39clojureboterror-kit is http://pragprog.com/magazines/2009-07/when-things-go-wrong
03:39ibdknoxcallen: if you do require, you then need to prefix your usages with the alias you give the required namespace: (:require [clj-time.core :as time])
03:40callen(:use 'clj-time.core [in-secs interval epoch now]) like so?
03:40Raynescallen: We don't even know what your doing. We don't know what your code is, how you're running it, what error you're getting, etc.
03:40callenRaynes: I tried to isolate the question so that it wouldn't be necessary.
03:41RaynesIsolate the code and show us a small example that is breaking. It'll be easier to help you like that.
03:41callenI did print my function.
03:41ibdknoxcallen: (:use [clj-time.core :only [in-sexs interval epoch now]])
03:41callen(defn unix-now [] (in-secs (interval (epoch) (now))))
03:41callenthat's what's breaking
03:41callensays in-secs doesn't exist.
03:41RaynesShow us the entire file.
03:41ibdknoxin a gist
03:41RaynesYes.
03:41Raynesgist.github.com
03:41callenthis is partially mutilated
03:42callenin my attempt to follow your advice.
03:42ibdknoxthat's ok
03:42RaynesWell, mutilate it less partially and show us the file.
03:42RaynesOr just show us the unmutilated file.
03:42RaynesI'm sure we can take it. :p
03:42ibdknoxtotally can't. I might explode
03:42RaynesWe need to see how you're using clj-time. Your ns declaration and stuff.
03:42callenhttps://gist.github.com/1335982
03:43callenin-secs, interval, epoch, now are all clj-time
03:43ibdknoxyep
03:43callenand are all representative of how the library's documentation instructs itself to be used.
03:43ibdknoxso you just need what I wrote before
03:43callenI tried that.
03:43ibdknox(:use [clj-time.core :only [in-sexs interval epoch now]])
03:43ibdknoxbut not sexs
03:43callenibdknox: look dude, it's in the comments
03:43ibdknoxlol
03:43ibdknoxno
03:43ibdknoxyou did something entirely different
03:44ibdknoxlook at my form
03:44ibdknoxand your form
03:44callensee it
03:44callentrying it
03:44callenjava.lang.IllegalStateException: Var irc/unix-now is unbound.
03:44callen?_?
03:45callenUnable to resolve symbol: in-secs in this context
03:45callenstill doesn't work.
03:45callenupdating gist.
03:46callenibdknox: https://gist.github.com/1335982
03:46ibdknoxyou still don't have the same form
03:46ibdknox(:use [clj-time.core :only [in-secs interval epoch now]])
03:46ibdknoxnote that there's no apostrophe and that it's all wrapped in a vector
03:47ibdknoxyours has a quote
03:47ibdknoxand is missing the vector
03:47ibdknoxI'm surprised that compiles
03:47callenclj-time.core [Thrown class java.lang.ClassNotFoundException]
03:48callen(:use [clj-time.core :only [in-secs interval epoch now]])
03:48callenit's identical now.
03:48callenand it fails with that exception.
03:48hiredmanibdknox: please make a note of the location of the closing paren of the ns form
03:48ibdknoxit needs to be part of your ns declaration
03:48ibdknoxhiredman: yeah, just noticed
03:49ibdknoxI will gist exactly what that should look like
03:49ibdknoxone sec
03:49ibdknoxhttps://gist.github.com/1335992
03:50ibdknoxcallen: ^
03:50callenI already got it
03:50Raynescallen: Unrelated entirely to your project, but if you're doing IRC-related stuff, check out http://github.com/Raynes/irclj sometime. It wont help you if you're just doing this as a learning experiment, but it might be interesting to you in the future. lazybot runs off of it.
03:50callenthe datetime object is fucked up
03:50callenRaynes: love it, thank you.
03:51callenibdknox: thank you for the help, why does the namespace stop before all the func defs?
03:51callenibdknox: I'm taking my cue from code that I'm building upon, but didn't write de novo.
03:51callenibdknox: shouldn't all the defs/defns be part of the ns?
03:51callenibdknox: at least if I'm following the example of other code I've seen.
03:51RaynesYou *can* use and require namespaces dynamically, but you should almost never want to.
03:51ibdknoxcallen: think of it as setting a marker
03:52ibdknoxcallen: everything after here, until you find another ns decl, or something that resets the marker (like in-ns) is part of this one
03:52ibdknoxwe can't expand macros with the bots can we?
03:52callenibdknox: then how does the reference in the defn which isn't part of the ns have a valid reference to clj-time.core's functions?
03:52brehautRaynes: if ypu are pimping irclj does that mean you are working on it again?
03:53Raynesibdknox: Sure, as long as it isn't bad.
03:53Raynesbrehaut: Not at the moment, but I fully intend to partially rewrite it once I've got some time.
03:53RaynesLike, after the conj and I get caught back up with my book.
03:53ibdknoxcallen: because use loads all of the symbols from that other namespace into the current one
03:53callensweet. all my code works now.
03:53ibdknox,(doc refer)
03:53clojurebot"([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to somethin...
03:54brehautRaynes: fair enough :) if im not busy at the time, i'd be happy to help
03:54callenibdknox: that doesn't make a huge amount of sense to me.
03:54ibdknoxyeah that's not very clear
03:54callenibdknox: I'm used to python which has a very flat and easy to understand scoping/namespace mechanism.
03:54Raynesibdknox: Not trying to pimp lazybot here, but if you do that kind of thing in lazybot, he gists the truncated output for you.
03:54ibdknoxoh?
03:54Raynesbrehaut: That's be great.
03:54Raynes&(range 10000)
03:54callenibdknox: I have no idea why references loaded via :use would be pushed out of an inline namespace into the one above it.
03:54lazybot⇒ (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ... failed to gist: Connection reset
03:54RaynesWell, that's too long.
03:55RaynesBut you get the point.
03:55ibdknoxyeah
03:55ibdknoxcallen: sorry inline namespace?
03:55callenthe ns ends before the rest of the code
03:55callenthat, structurally to my limited understanding, looks like it has ceased to be relevant at that point.
03:55callenthe fact that it can mutate what is accessible in what is outside of it makes little sense to me.
03:55ibdknox##(macroexpand ns)
03:55lazybotjava.lang.RuntimeException: Can't take value of a macro: #'clojure.core/ns
03:56ibdknox##(macroexpand '(ns))
03:56lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: core$ns
03:56ibdknox##(macroexpand '(ns blah))
03:56lazybot⇒ (do (clojure.core/in-ns (quote blah)) (clojure.core/with-loading-context (clojure.core/refer (quote clojure.core))))
03:56ibdknoxlol
03:56RaynesWell, your ns doesn't 'end' until the file is done.
03:56ibdknoxcallen: like I said, it sets a marker
03:56callenthen why declare the ns?
03:56Raynesns sets the ns for the code.
03:56RaynesBecause it sets...
03:56ibdknoxbecause you need to know what ns you're in
03:56ibdknoxlol
03:56callenthen why do people put stuff inside the ns block if you don't need to?
03:57ibdknoxyou *do* need to
03:57callenmy code works
03:57ibdknoxyes it does
03:57ibdknoxlol
03:57RaynesNot that's necessarily your fault for not understanding. Could easily be our fault for failing to explain things properly.
03:57callenwhat changes if I move my defns and defs inside the ns?
03:57RaynesThe problem is that I'm writing a book, and if I can't explain it...
03:57ibdknoxI'm not sure, probably something terrible
03:58callenafter herbert, I don't trust writing a book as a mark of expertise.
03:58RaynesThe problem is that you think ns does something that it does not do.
03:58callenibdknox: if you can't explain the difference, then how do you know you should do it one way or the other?
03:58callenRaynes: I have no idea at all what it does.
03:58RaynesThe parentheses do *not* indicate the scope of the namespace.
03:58ibdknoxcallen: sorry, are you trying to be jackass now?
03:58Raynesns sets the namespace for the *entire file*.
03:58callenI've established that.
03:58callenno, I'm not
03:58callenI'm actually quite sad and tired right now
03:58callenand just trying to understand code that already works.
03:58ibdknoxperhaps you should sleep
03:59callenI won't until I understand this properly.
03:59callenyou won't be rid of me that easily.
03:59RaynesThings might be clearer when the sun rises.
03:59ibdknoxlol
03:59ejacksonsleep is my ultimate debugging tool
03:59callenChapter 2.4 "Vars, Bindings, and Namespaces" in the pragprog book doesn't explain it very well, at least from my POV
04:00ibdknoxas Raynes said, the only thing you really need to understand is that you set the namespace for the entire file
04:00ibdknoxit's idiomatic to place your uses and requires there
04:00callenand as I said earlier, I understood that much.
04:00callenI don't understand the point of it yet.
04:00RaynesNo, I don't think so.
04:01callenis it to group everything you're doing in that file into that var?
04:01ibdknoxno.
04:01ibdknoxit's to group it in the namespace
04:01RaynesEverything you're questioning relies on Clojure setting the scope of the ns to the ns macro's scope itself, which is not the case and thus invalid.
04:01ibdknoxthis isn't actually different from python...
04:01RaynesYou actually might be looking into it too much.
04:01callenI already sdaid I understood that.
04:01callenI keep trying to tell you
04:01ibdknoxhaha
04:01callenI understand that it sets it well past the end-paren.
04:01ibdknoxalright man
04:01callenI am trying to understand the rest of its purpose.
04:02ibdknoxYou've got it all.
04:02ibdknoxthere isn't one
04:02RaynesI'm tired and quite sad right now.
04:02ibdknoxdon't use it :)
04:02ibdknoxhahaha
04:02callenI am trying to explain that I understand a particular iota of the question at hand
04:02callenand you keep re-raising the single iota I *do* understand
04:02callenand aren't fucking listening to me
04:02callenwhen I say I understand that one bit
04:02callenand that we established that earlier
04:02callenthan you patronize me
04:02callenand laugh at me when I try to get you to understand that
04:02callenthis channel was better a year ago.
04:02ibdknoxcallen: you're antagonizing the people trying to help you
04:03RaynesYou're raising questions that don't actually exist, I think. I can't tell. Do you actually have a question to ask?
04:03ibdknoxI'm not sure how much better I can react
04:03callenRaynes: I asked earlier and was told they didn't know the answer.
04:03callenRaynes: I'll ask again.
04:03RaynesThe last thing you asked was "what happens if I put the defs in the ns declaration" which makes utterly no sense given what you claim to already understand.
04:03hiredmanibdknox: /ignore
04:03RaynesWe're not trying to patronize you or be mean to you or anything like that.
04:03RaynesWe love to help.
04:03callenRaynes: currently my ns closes after a :use and an :import. (end-paren)
04:03callenhiredman: that doesn't help either.
04:04callenhiredman: you're borderline trolling when you publicly declare you're ignoring people.
04:04callenRaynes: now, I have my defs and defns after that end-paren, that is, it's not part of the syntactic portion of the ns.
04:04RaynesRight.
04:04callenRaynes: I understand FULLY that they are going to be in the ns.
04:04callenRaynes: What I do not understand is that if I shift it to the syntactic portion of the ns, what it changes, if anything.
04:04callenRaynes: in idiomatic Clojure code, it's usually part of the ns body.
04:04callenRaynes: such as in clj-time.core
04:04callenfrom what I can tell.
04:04RaynesUh, really?
04:04callenRaynes: I am asking why and what it changes if anything.
04:05RaynesCan you show me an example?
04:05callenRaynes: I could be wrong, let me double-check.
04:05ibdknoxcallen: there's never code aside from :use :require, and a couple others inside of an ns decl
04:05callenfuck, no, nevermind.
04:05callenRaynes: nope. the way my code is written is idiomatic.
04:05RaynesAnyways, I'm not going to ignore people when I still have at least a partial chance at helping them.
04:05callenRaynes: nevermind.
04:05callenRaynes: I was mistaken.
04:05callenRaynes: hence confusion.
04:06callenibdknox: that explains a lot, thank you.
04:06ibdknoxwe tried to clear that up, sorry it took so long.
04:06RaynesNobody here but maybe hiredman actually wants to see people dissatisfied with the help they receive in this channel.
04:06Raynes;)
04:07callenRaynes ibdknox thank you both for tolerating my long enough to eliminate the source of my confusion.
04:07callens/my/me/g\
04:07Raynescallen: Anyways, you can probably understand now why it sounded silly to us and like you weren't listening. What you were asking really didn't make much sense at all! If we got snarky, it's because we were probably getting a little frustrated at trying to make sense of it all. If we came off that way, I think I speak for both of us when I apologize for it.
04:08ibdknoxthat's an official record for me: over 12 hours on the HN front page
04:08ibdknox /win
04:08RaynesGood work./
04:08ejacksonibdknox: nice one !
04:09callenibdknox: what'd you post?
04:09ibdknoxcallen: korma
04:09callenibdknox: oh god I am excited about that one!
04:09Rayneshttp://news.ycombinator.com/item?id=3188609
04:09ibdknoxthough in terms of points, http://iwbyp.chris-granger.com got more
04:09ibdknoxamusingly noir was lower than both
04:10callenRaynes: part of the problem is that I am a bit of a lone-wolf and can end up uh... waldeinsamkeit.
04:10RaynesGod, Noir is so great.
04:10ibdknoxlol forrest loneliness?
04:10callenRaynes: so I come to weird conclusions and misunderstandings that can require a lot of stack-unrolling to get to the bottom of.
04:10RaynesHah. I found a new word.
04:10callenibdknox: lost in the woods.
04:11Raynes$trans gr en waldeinsamkeit
04:11lazybotLanguages not recognized.
04:11RaynesOh yeah, that's broken anyway.
04:11ibdknoxcallen: I know, I speak German :)
04:11callenibdknox: it expresses how I've approach programming, to my chagrin, very well.
04:11callenapproached*
04:12callenI'm quite envious of people that can speak of this or that mentor they had in uni.
04:12ibdknoxnow I kind of feel like I should go buy the programming clojure book
04:12RaynesI've never had a mentor.
04:12ibdknoxneither have I
04:12ibdknoxI never had a formal CS education
04:12callenibdknox: you mean the book that failed to save me from my own bizarre conceptions?
04:12RaynesAs a matter of fact, the only time I've ever met another programmer was at a conference.
04:12RaynesLast year, no less.
04:12callenibdknox: ditto. most of my CS background is pirated bibliographies and OCW.
04:13ibdknoxcallen: apparently noir is in the 2nd edition
04:13callenibdknox: been working as a programmer for 5, nearly 6 years.
04:13callenibdknox: whoa @ noir
04:13callenRaynes: conj?
04:13RaynesYes
04:13callenwell I have the log-structured data I wanted now.
04:13callennow I can start loading this into a database.
04:14callenI might have to write a parser first though.
04:14callenyeah, parser first. balls.
04:14ibdknoxit dawned on me the other day that I'd been programming professionally for just shy of 8 years
04:14callenRaynes ibdknox thanks again, I can rest well now. Goodnight.
04:15ibdknoxwhich is a bit ridiculous
04:15RaynesNight.
04:15callenibdknox: tell that to the junior below me who is one year younger than me and has been working professionally for a few months.
04:15callenibdknox: he finds me bewildering
04:15callenibdknox: I was explaining b-trees and database indexes to him the other day
04:15callenibdknox: said junior has two masters degrees.
04:15RaynesI'd hate to see him meet me.
04:16ibdknoxhaha Raynes would eat him for breakfast
04:16callenessprain?
04:16ibdknoxI'm 24.. and I'm old ;)
04:16callenI'm 23, and old, and tired.
04:16RaynesI'm 17, and mostly just hungry.
04:16callenI'm positive the motorcycle is making me older.
04:17ibdknoxhah and I'm apparently a beowulf cluster lol
04:17ibdknoxI'm excited to actually meet fogus
04:18ibdknoxhe strikes me as a fun guy
04:18RaynesMet him. He's short.
04:18RaynesFun, but short.
04:18ibdknoxhaha
04:18callenlol whut
04:18RaynesShorter than I expected in any case.
04:18ejacksonold ? you kids.
04:18callen<--- audibly cracking up
04:18ibdknoxejackson: I meant it sarcastically
04:18callenejackson: I know plenty of 50 year old unabomber types that love Forth.
04:18ibdknoxejackson: though compared to Raynes...
04:18ejacksonwell, yes.
04:19RaynesI expected some big guy with sunglasses until I nearly stepped on him on my way to my room.
04:19ibdknoxlol
04:19ibdknoxhe's that short?
04:19ibdknoxI'm only 5'7"
04:19RaynesWell, he is about as short as I am.
04:19callen5' 9" here.
04:19callenwhich is?
04:19RaynesProbably around the same height, I think.
04:19Raynes5'5 or so.
04:19RaynesMaybe 5'4.
04:19callenthat's short
04:19ejacksonI thought he was a giant green Minotaur...
04:19ibdknoxhuh, you're right, I expected him to be much taller
04:20callenditto.
04:20ibdknoxalright.. I've been up way too damn long
04:20callenme too.
04:20callenit's pacific time, but still bad enough.
04:20callenI have work tomorrow as always.
04:20callenlkgnmdsklfhmdfgh
04:20ejacksonibdknox: hehe, I'm just waking up here England time.
04:20callencheers all. It'll be a two-gallon coffee mug day.
04:20calleng'night
04:21RaynesIt is precisely 3:17AM right now.
04:21ibdknoxejackson: haha well then, all day to play with Korma ;)
04:21RaynesNight boys and girls.
04:21ejacksoncheers kids :P
04:21callenRaynes: That's 1320308288 to you, heathen!
04:22Raynesejackson: Night gramps.
04:22ibdknoxlol
04:23ejacksonget off my damn lawn !
04:23ibdknoxin case anyone is interested: HN/twitter brought in about 5000 viewers to sqlkorma.com
04:23ejacksonnice stat indee.
04:23ibdknoxI like looking at where they're from, it always ends up surprising me some
04:24ibdknoxmore than half were outside the US
04:24ejacksonthat's promising
04:25ibdknoxthe UK was the top of the european countries actually
04:25ibdknoxejackson: well done
04:25ejacksonoh, that was me with some perl
04:25ibdknoxhaha user-agent: curl
04:26ibdknoxdamn :p
04:26ibdknoxalright. I'm outta here. Catch you folks later
04:26ejacksonlater
05:03Blktgood morning everyone
08:10jscott1989hey, if i want a linked list, so i can maintain an arbitrary order (specifically where i can insert and element at any position) how would i go about that?
08:13jscott1989ignore my stupid question
08:13jscott1989:)
08:13jscott1989solved it
09:11bpris there a way to explore java packages? I'm thinking something like a cross between clojure.contrib.repl-utils/show and clojure.core/ns-*
09:16scottjwell you can inspect packages in Slime but it doesn't give much that's useful
09:50clgvIs there any documentation support for functions with options in clojure yet?
09:50clgvThis is often annoying when you have several layers where the options are passed through.
09:55dpritchettRaynes: Really dug the tryclojure on heroku post. Well done.
09:55cemerickclgv: beyond enumerating the options in a docstring, you mean?
09:56clgvcemerick: that is one good thing. I would go further and try some transitive analysis on the options for function calls that have options as well
09:57cemerickclgv: If you enumerate the options in a keyword destructuring form, they'll also show up in (:arglists (meta #'foo))
09:58cemerickFYI: The official unofficial homes of 'Clojure Programming', coming soon from O'Reilly: http://twitter.com/ClojureBook and http://clojurebook.com
09:58clgvcemerick: nice url you captured there^^
09:59cemerickI also got clojure-book.com and clojureprogramming.com, but I decided to go simple. :-)
10:02davidruppcemerick: Looking forward to buying the ebook. Any idea why it's not available through the normal (non-Safari) Rough Cuts?
10:03clgvoh, I didnt know that you shortcut it like that (defn f[x & {:keys [bla blubb]}] ...) to not have to create a hashmap yourself
10:04clgvbut it seems to work on 1.3
10:04cemerickdavidrupp: No idea, sorry. Are you talking about their direct early access thing? I heard something about it, but have no control/visibility into those sorts of things.
10:05cemerickI can try to beat the bushes on that…
10:05davidruppYeah, most of their ebooks are available for direct download, no Safari required, even in Rough Cuts.
10:05davidruppNot a huge concern.
10:06cemerickYou can download it through safari AFAIK…
10:19clgvI think about this syntax: (defn+opts f [x] [opt1 [opt2 10]] ...) is this idiomatic or is there a better way to specify the optional params with default values?
10:22cgrayhi, where do macros go so that the clojurescript compiler can find them?
10:23kephaleclgv: i'm a little confused by opt1 not having something after it but what about (defn f [x & {:keys [opt1 opt2] :or {opt1 blah opt2 10}}] …)
10:23clgvkephale: no, I try to improve that defn statement to something more useful
10:24clgvkephale: I aim for specifying default values but also being able to omit them
10:25kephaleclgv: aha cool… one of my complaints about the current approach (although it isn't exactly relevant to this situation) is that the value of :keys is technically implied by the value of :or since everything must have a default
10:26clgvhmm but maybe I have to separate it as well
10:29kephaleor have a single map where you explicitly specify nil for things that don't have defaults, which wouldn't be pretty
10:30neotykGood morning everyone!
10:30licenserhas anyone managed to get clojure-jack-in work with cake?
10:31kephalei think i like the syntax you suggest, but maybe making a bit more uniform with the existing approach: (defn+opts f [x & [opt1 [opt2 10] …] body)
10:31kephaleoops, missing a ]
10:34clgvkephale: I dont like the & ^^
10:34clgvit suggest the other semantic I think
10:34clgvmaybe I introduce a sign for it. should be possible. lets check
10:35kephalemaybe a pipe
10:35clgvor a question mark since they are optional
10:36kephalehrm perhaps, though in the case where x is some function predicate that could get confusing
10:36clgvkephale: example?
10:36TimMc,(let [| 5] (* | 2))
10:36clojurebot10
10:37clgv(defn+opts f [x ? {opt1 9, opt2 10}] ... ) and (defn+opts f [x ? [opt1, [opt2 10]] ... ) looks well
10:38clgvok I'll note question mark and pipe
10:38kephale(defn+opts f [float? ? options] …)
10:39clgvhmm the pipe has more visual impact. thats true
10:39clgvis it used for anything yet?
10:40kephalewell apparently TimMc wants to use it as a variable
10:40clgvlol, that's no harm - he can continue to do that^^
10:41clgvmy implementation can ignore that^^
10:41clgvlike defrecord uses '& as variable name ;)
10:45carkclgv: so you're going to make your own destructuring too ?
10:45carkthrowing away the good work of our language developers for estetics only ?
10:47clgvcark: no I do not. I improve optional parameter handling for my project
10:51carkthat's a whole cnan of worm you're opening here
10:51carkconsider this :
10:51cark,(let [f (fn [& {[a1 a2] :a}] [a1 a2])] (f :a [1 2]))
10:51clojurebot[1 2]
10:52carkthere is destructuring going on
10:52clgvcark: I do not have to consider this. I guess you did not get my intentions ;)
10:52carkrecursive destructuring should i say
10:53carkohwell ok =)
10:56clgvyou recheck when it's ready and I found it stable enough to put it on github ;)
10:58cgrayhas anyone successfully used macros with clojurescript? i'm having trouble getting the compiler to find them...
10:59PPaulis there a function that is like project, but returns a set of hash-maps with with all the keys but the ones project was given?
11:00PPaulor do i have to do something like project, and difference?
11:05ChousukePPaul: sounds like you could just use dissoc to remove the keys
11:06PPaulyeah, but project works over a set of hashes
11:06PPaulsticking to set stuff while working with sets seems like the right thing to do
11:10PPauli think i don't need it anyway, oh well
11:10PPaul^_^
11:20PPaulhow do i map over a hash-map... (map first/second {}) works, but when i do (map (fn [key val] val) {}) i get errors related to the num of args passed to the function
11:20PPaulis it because i'm not destructuring?
11:20PPaul(fn [[key val]] val) is what i should use?
11:21PPaulwoo, answered my own question
11:28TimMcPPaul: Why not use val?
11:29TimMc,(map val {:a 1, :b 2})
11:29clojurebot(1 2)
11:29PPauli want to use both
11:29TimMcOK.
11:30PPauli projected, and i want to create a new hash with the projection (it's a compression alg)
11:30cgrayis there a way to get cljsc to tell me what its classpath is?
11:30cgray,(vals {:a 1, :b 2})
11:30clojurebot(1 2)
11:31PPauli have a static method that takes in 2 Str args... is this the right sig for it?
11:31PPaul(:gen-class
11:31PPaul :methods [#^{:static true}[statsTransform [String String] void]]))
11:32PPaulalso, can i use void return even if it does return something (i'm guessing i can because all clojure functions return)
11:33licenserRaynes: you're there mate?
11:47ljosWhat is best practice for writing to file in Cljoure? I
11:48licenserljos: depends on what you want, spit is a very easy way :)
11:48ljosI only need easy. Nothing fancy :)
11:49licenserthat spit is your friend
11:49licenser,(doc spit)
11:49clojurebot"([f content & options]); Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/writer."
11:50ljosThank you :)
11:50licenseryou're more then welcome :)
11:51ljosAnother question. I know this is not excactly best practice, and it sounds like I'm doing things I shouldn't, but is there a way I can capture global variables?
11:52ljosSo if I have (def a 1) (defn retra [] a) (let [a 3] (retra)) I want that to return 3, but let doesn't capture globals.
11:53dnolenljos: you want binding.
11:53dnolenljsos: and you need to declare a to be dynamic
11:53dnolen(def ^:dynamic a 1)
11:54dnolenljos: I'm assuming you're using 1.3.0
11:54ljosok. Sweet! And yes I am.
11:55ljosThank you.
11:57PPaul (:gen-class
11:57PPaul :methods [#^{:static true}[statsTransform [String String] bool]]))
11:57PPaulbool is throwing a compile error
11:57ljosbinding will only work inside it's own lexical scope right? It won't do stupids things like actually changing the variable for functions outside of the scope that might be running at the same time under other scopes?
11:57PPaulwhat should i use instead (i can't find what options i have in docs or gen-class help sites)
11:58ljosits*
11:58dnolenljos: it's dynamic binding. It will change that vars value until it exits.
11:58dnolenany code that is code called within it will see the new value.
11:59PPaulnm i have to use boolean (really not familiar with java anymore)
11:59ljosdnolen: yes, but if I have code running in parallel, will it see it?
11:59ljosThat is not within the binding.
12:00dnolenljos: dynamic binding is thread local. however threads spawned by the current will also see the new value.
12:01hugodassuming those threads are spawned by a clojure core function…
12:01ljosdnolen: That was what I asked. So the change won't be global, only within the lexical scope of the binding, right?
12:01dnolenljos: dynamic scope
12:03ljosdnolen: ah. I read on what dynamic is vs lexical, I had some missconception of what lexical meant. Thank you for the help. That answered everything really..
12:04dnolenljos: np
12:14ThreeCupsI'd like to take this map {:a [[0 0] [0 1]], :b [[1 0] [2 0]]} and transform it to this vector [[[[0 0] :a] [[0 1] :a]] [[[1 0] :b] [[2 0] :b]]]. I'm sure there's an elegant way to do it, but I'm stumped
12:20halfprogrammer,((apply map vector ((juxt vals keys) {:key1 1 :key2 2})))
12:20clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>
12:21halfprogrammerThreeCups: think something like this should work
12:21halfprogrammer,((apply map vector ((juxt vals keys) {:key1 1 :key2 2}))
12:21clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
12:21halfprogrammer,(apply map vector ((juxt vals keys) {:key1 1 :key2 2}))
12:21clojurebot([2 :key2] [1 :key1])
12:22halfprogrammergot it as expected this time :)
12:22halfprogrammerdoes this serve your purpose?
12:22ThreeCupshalfprogrammer: Thanks! I think this'll work. Let me give it a try
12:26ThreeCupsNever used juxt before... reading the docs to understand it
12:31amalloy~juxt
12:31clojurebotjuxt is usually the right answer
12:34jodaroi love juxt
12:34jodaroused it for the first time the other day
12:37technomancythe biggest problem with juxt is that it's too awesome
12:37technomancyyou're always tempted to use it where you shouldn't
12:37ejacksona
12:37ejacksonspiderman function
12:37jodaroyou mean like when i go
12:37jodaro(ns ...
12:37jodaro(juxt ....
12:38scottjanyone know other lisp dialects that have juxt builtin?
12:38jodaro500 lines
12:38jodaro)
12:38technomancyscottj: liskell? =)
12:38halfprogrammer,(mapcat (fn [m] (let [k (key m) vx (val m)] (zipmap vx (repeat k)))) {:a [1 2 3] :b [4 5 6]})
12:38clojurebot([3 :a] [2 :a] [1 :a] [6 :b] [5 :b] ...)
12:39halfprogrammerThreeCups: even this seems to work :)
12:39ThreeCupshalfprogrammer: thanks again! still trying to wrap my mind around juxt :)
12:40ThreeCupsAll functions passed to juxt have to have the same arity, correct?
12:41halfprogrammerthink the arity is also fixed to 1
12:42ThreeCups,(doc juxt)
12:42clojurebot"([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
12:42halfprogrammer,((juxt + - *) 1 2 3)
12:42clojurebot[6 -4 6]
12:42halfprogrammeri was wrong :)
12:44ljosIs there a way to use relative paths in spit? I want to do this: (spit "~/newfile" "content of new file") .
12:45kephalehurrah for the triumvirate: juxt, comp, partial
12:45ThreeCupshalfprogrammer: in your first solution, you has this: (juxt vals keys), is that gauranteed to return the vals and keys in the same order?
12:45technomancyThreeCups: it's guaranteed, yes
12:46pdkzipmap yo
12:46halfprogrammertechnomancy: even if the map does not give the guarantee?
12:46technomancyhalfprogrammer: right, it's deterministic for a single map
12:48amalloyljos: that's not relative, it's absolute with $HOME expansion
12:49ljosamalloy: oh.. yeah ofc.
12:49ljosI'm getting tired.
12:50amalloyanyway, you can do it by hand with (System/getProperty "user.home"), or i'm sure there are some libraries out there to make java pretend it's posix
12:50amalloybut normally your shell expands ~, not your filesystem, so java doesn't do it
12:51TimMc,(doc sort-by)
12:51clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
12:51TimMc,(sort-by #(do (pr %) %) '[5 4 3 2 1])
12:51clojurebot54534352423251413121
12:51clojurebot(1 2 3 4 5)
12:52TimMcThat's disappointing.
12:53TimMcIn Ruby you can apparently define shuffle as array.sort_by { rand } because the keyfn (rand) is only called once per index.
12:53hiredmanclojurebot: what?
12:53clojurebotwhat is moustache
12:53amalloyTimMc: it's a tradeoff
12:53ljosamalloy: that worked. Thank you.
12:53TimMchrm
12:54amalloysuppose the predicate is super-cheap, such as identity. you want to double your storage costs and increase complexity in order to save calling this function?
12:54amalloywhereas clojure makes it trivial to get ruby's behavior
12:54bobnodesoh hi
12:54bobnodesanyone know of a sandbar replacement?
12:55amalloy&(let [f #(do (pr %) %)] (map second (sort-by first (map f ['5 4 3 2 1]))))
12:55lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
12:55scottjbobnodes: noir
12:55technomancy,(sort-by (memoize #(do (pr %) %)) '[5 4 3 2 1])
12:55clojurebot54321
12:55amalloy&(let [f #(do (pr %) %)] (map second (sort-by first (map (juxt f identity) ['5 4 3 2 1]))))
12:55clojurebot(1 2 3 4 5)
12:55lazybot⇒ 54321(1 2 3 4 5)
12:55bobnodesI've spent the last 8 hours trying to make it authorize a simple login form. But this seems completely broken in any recent version
12:55technomancyamalloy: beat ya =P
12:56TimMctechnomancy: Beat me, too. :-/
12:57amalloytechnomancy: yours doesn't call f at all for duplicate items, which doesn't seem to actually align with the ruby behavior he wanted
12:57technomancyhm; yeah I could go either way on that
12:59amalloyi guess i could go super-efficient by using pop instead of second :P
13:03TimMcamalloy: annotate!
13:03amalloygive the man a prize
13:04TimMcTimMc: botsnack
13:04TimMcTimMc: Thanks! Om nom nom!!
13:09TimMcpandeiro: ^ amalloy made a much nicer version of my shuffle-by-sort.
13:10pandeiroTimMc: i already modified your version to work with cljs but i'd like to take a look, link?
13:10amalloyTimMc: i read somewhere that using sort-by rand to shuffle leads to not-very-good shuffling
13:10amalloyso i'm not sure you'd want to do this
13:10TimMcamalloy: We were discussing that yesterday.
13:10TimMcamalloy: pandeiro is working in cljs, where shuffle isn't defined.
13:11TimMcpandeiro: (map second (sort-by first (map (juxt rand identity) [5 4 3 2 1])))
13:11amalloyTimMc, pandeiro: https://gist.github.com/805546
13:11TimMcBut use Fisher Yates or Knuth instead.
13:11amalloya functional impl of Fisher-Yates
13:12amalloywith the nice side benefit that it's lazy - you can take only N items out of the front and the rest won't be shuffled
13:14amalloylooking at it again it seems like it would be nicer to implement using lazy-seq directly instead of mapping first over an iterate
13:25amalloyTimMc, pandeiro: updated gist with an impl that is probably more performant
13:28TimMcI see a shuffle in there.
13:28amalloyTimMc: (fn shuffle ...)
13:28TimMcOh!
13:28TimMcshadowed, got it
13:28amalloy$mail fliebel remember back when we were looking at various lazy-shuffle implementations? i finally realized i should be using a transient vector and it's about four times faster than my last impl
13:28lazybotMessage saved.
13:32amalloy$mail fliebel forgot the link! https://gist.github.com/805546
13:32lazybotMessage saved.
13:35ThreeCups,(into [] {:a 1, :b 2})
13:35clojurebot[[:a 1] [:b 2]]
13:35ThreeCupsIs there a better way to do this?
13:36duck1123Is there anything easier than set/difference for removing a value from a set, or better yet, something like a dissoc-in that will work on maps containing sets?
13:36duck1123ThreeCups: ,(vec {:a 1 :b 2})
13:37technomancyduck1123: update-in plus disj?
13:37duck1123technomancy: disj is what I was missing
13:37technomancyyeah. I was a little confused as to why dissoc didn't work on sets at first.
13:38technomancyI think it makes sense since sets aren't associative, but it's a bit surprising at first.
13:39duck1123much nicer, thanks
13:45TimMcamalloy: Having trouble understanding lazy-shuffle. The innermost "coll" is the remaining elements, right?
13:45amalloyyeah
13:45TimMcThe last line of shuffle... are you doing an exchange?
13:45amalloyright
13:46TimMcOh, I get it! You add a random element to the lazy seq, and put the top element in its place.
13:46amalloyyes
13:46TimMcthen pop the duplicate
13:46TimMcCute.
13:47ThreeCupsHow do I flatten [[1 2] [3 4]] to [1 2 3 4]? (reduce concat [[1 2] [3 4]])?
13:47chouseryes, or apply concat or mapcat seq
13:47amalloyThreeCups: strongly prefer not producing [[1 2] [3 4]] in the first place
13:48gfredericksamalloy: :D
13:48ThreeCupsamalloy: one thing at a time :). Thanks for the advice
13:48amalloyeg, much nicer to ##(mapcat (fn [[x y]] [(inc x) y]) {1 2 3 4 5 6}) than to ##(apply concat (map (fn [[x y]] [(inc x) y]) {1 2 3 4 5 6})
13:48lazybot⇒ (2 2 4 4 6 6)
13:48TimMcfor for for
13:48amalloy&(apply concat (map (fn [[x y]] [(inc x) y]) {1 2 3 4 5 6}))
13:48lazybot⇒ (2 2 4 4 6 6)
13:49amalloyindeed. i always find the for version of the latter somewhat unpalatable though, and it's slower as well
13:50amalloy&(for [[x y] {1 2 3 4 5 6}, item [(inc x) y]] item) ; yuck
13:50lazybot⇒ (2 2 4 4 6 6)
13:54TimMcI thought you were all for & juxt these days
13:56amalloyit's true
13:59chouser'for' rocks for golfing
14:03hiredmanI just wish there was something like mapcat for for, you can kind of hack it in, but it's not pretty
14:04fdaoud,(flatten [[1 2] [3 4]])
14:04clojurebot(1 2 3 4)
14:05amalloy~flatten
14:05clojurebotflatten is clojure.contrib.seq-utils/flatten
14:05amalloyugh
14:05amalloyclojurebot: forget flatten |is| clojure.contrib.seq-utils/flatten
14:05clojurebotI forgot that flatten is clojure.contrib.seq-utils/flatten
14:05raek,(flatten [[[1 2] [3 4]] [[5 6] [7 8]]])
14:05clojurebot(1 2 3 4 5 ...)
14:06ibdknoxflatten is one of those scary functions
14:06raek,(apply concat [[[1 2] [3 4]] [[5 6] [7 8]]])
14:06clojurebot([1 2] [3 4] [5 6] [7 8])
14:06amalloyclojurebot: flatten |is| rarely the right answer. What if your "base type" is a list? Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
14:06clojurebotIn Ordnung
14:06ibdknoxyou'll use it, not think about needing to retain a nested collection and then you're screwed
14:07amalloy~flatten
14:07clojurebotNo entiendo
14:07ibdknoxlol
14:07amalloyhiredman: haallllp
14:08hiredman:(
14:10chouseramalloy, ibdknox: correct.
14:10chouseraren't you happy you have my approval? :-P
14:10amalloyhiredman: seriously though what did i get wrong there? i know he sometimes gets confused when the factoid has an "is" in there, so i wrapped the first one with pipes to get his attention
14:10amalloybut i'd like to make sure he knows this fact so i can stop crusading
14:11hiredmanyeah
14:11ibdknoxchouser: I'm checking that box on my list of things I need before I die :p
14:11chouserheh, I bet.
14:11hiredmanmy guess would be you need to escape the following is'es (\is) but the real answer is clojurebot's parser needs an overhaul
14:11amalloyibdknox: chouser will never give you approval to die. you'll be kept alive in a vat, inventing useful new tools
14:12amalloyclojurebot: flatten is rarely the right answer. What if you need to use a list as your "base type"? Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
14:12clojurebotc'est bon!
14:13amalloyin the meantime, i'll just rephrase without "is" :P
14:13TimMcflatten?
14:13clojurebotflatten is rarely the right answer. What if you need to use a list as your "base type"
14:13ibdknoxhahaha
14:13amalloy~botsmack
14:13clojurebotclojurebot evades successfully!
14:13ibdknox~botsmack
14:13clojurebotOwww!
14:14amalloy~flatten
14:14clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
14:14chouser~for
14:14clojurebotfor is a loop...in Java
14:15chouser~for
14:15clojurebotfor is not a loop
14:15ibdknox...
14:15ibdknoxlol
14:15chouserclojurebot: for is complected
14:15clojurebotYou don't have to tell me twice.
14:15ibdknoxthat seems to be the new word these days :p
14:15amalloychouser: oh boy, tell us about LOOP
14:16dnolenclojurebot: LOOP is complect complected
14:16clojurebotYou don't have to tell me twice.
14:17chouserthough interestingly, 'for' creates a lexical space in which some things can be simpler (not to mention easier) than outside the 'for'
14:18cgrayamalloy: heh, i was just about to guiltily use flatten before i thought "i'll just have a look at #clojure for a second"
14:18ibdknoxchouser: hm?
14:19amalloycgray: have you repented?
14:19amalloyaccept mapcat into your heart
14:19cgrayamalloy: indeed, mapcat is really what i wanted
14:20ibdknoxI've wanted flatten exactly once
14:20ibdknoxand it was actually the right thing to use
14:20technomancyit's pretty trivial to flatten with tree-seq if that's what you really want
14:21technomancykind of surprised when that got promoted
14:21ibdknoxit was for my version of that music as data thing: https://github.com/ibdknox/music-as-data
14:21amalloyagreed. my guess was that flatten is something that's taught sometimes as an interesting problem and someone wanted to show off that it's easy in clojure
14:22technomancyI dunno; for showing off purposes implementing it with tree-seq gets more wows
14:23lobotomywrote another blog post on clojure: http://lobotomys.blogspot.com/2011/11/chess-problem-solver.html
14:23lobotomythis one's a bit long. executive summary: straightforward dfs is straightforward
14:24technomancyflatten is literally (partial tree-seq coll? seq), right?
14:24Raynestechnomancy: Heh, we actually realized we needed to do that in clojail last night. Flatten wasn't flattening maps, so you could bad stuff.
14:24technomancyoh, sequential? instead of coll?
14:24Raynes&{:foo (eval '(+ 3 3))}
14:24ibdknox,(doc tree-seq)
14:24lazybot⇒ {:foo 6}
14:24tolstoyI saw in the Joy of Clojure free chapter something like: (defn [& (keys :foo 1 :bar 2)] …). Is that documented anywhere?
14:24clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
14:25Raynescould do bad stuff*
14:25amalloytechnomancy: right
14:25pjstadigtechnomancy: wow, you're right that is more readable than flatten :-p
14:25technomancywait, filter complement of sequential? ? dude.
14:25technomancyas pjstadig would say: remove, man.
14:25technomancy=)
14:25Raynestolstoy: http://stackoverflow.com/questions/3337888/clojure-named-arguments
14:27tolstoyRaynes: Thanks. I guess it's not a canonical technique?
14:27RaynesSure it is. Why wouldn't it be?
14:27tolstoyThere's not a page on clojure.org. ;)
14:27ibdknoxhah
14:28RaynesI guess it just isn't officially documented. It has been possible for a couple of Clojure versions now.
14:28tolstoyI see there's a contrib.
14:28RaynesBut there are plenty of stuff like that SO post to learn about it.
14:28tolstoyYep.
14:28ibdknoxhuh, I'm surprised there isn't a heading for destructuring
14:28amalloytolstoy: i don't think there's a page on clojure.org documenting that if you want to multiply a number by three you should use (* 3 x), but that's got to be the canonical technique
14:29ibdknoxit's probably one of most useful, yet least used by new people, things in clojure
14:29mdeboardI want destructuring in Python.
14:29mdeboardSo bad.
14:29tolstoySometimes I see techniques here and there, and I wonder how I could have found out about them if not randomly searching for something completely different. So, I was hoping there was some secret page I had missed….
14:30ibdknoxtolstoy: at some level it's a matter of building things on top of the concepts that you know already exist
14:30amalloythat's how programming works though. you read source and notice people doing neat stuff that you want to steal
14:30mdeboardtolstoy: Reading a couple of good books on the topic is the best way to learn things about new technologies
14:30tolstoyamalloy: Ah, come on. I'll not bite. I was just curious if there was a page somewhere that kind of had interesting idioms for typical kinds of things. That's all. I didn't mean to complain or criticize.
14:30ibdknoxmdeboard: eh, I didn't read any books. I read code.
14:30mdeboardamalloy: Eh some techniques are sufficiently advanced that you dont' even know where to begin.
14:30mdeboardibdknox: How long have you been programming with lisps?
14:30amalloymdeboard: for sure, books are good
14:30ibdknoxmdeboard: this is my first
14:31amalloymdeboard: mine too. started last summer
14:31ibdknoxsoooo, 8ish months?
14:31ibdknoxno
14:31technomancyoh, wait did you say "lisps"?
14:31ibdknox10 months
14:31mdeboardlithpth
14:31ibdknoxlol
14:31technomancyit's like in the Three Amigos. "We could go for a walk and you could kiss me on the veranda." / "Oh, uh... Lips would be fine."
14:32mdeboardibdknox: It was hard for me to find good projects written with Clojure that provided grokkable examples.
14:32mdeboardbut I'm a newb to programming in general
14:32ibdknoxmdeboard: I've been working on that ;)
14:32mdeboardtechnomancy: I program with my face. 1. slam face into keyboard 2. roll 3. ??? 4. Push to github
14:32mdeboardibdknox: I've noticed.
14:32ibdknoxI have a fun idea that I might try to convince Raynes to help me with
14:33ibdknoxI want to use Clojail to create a "trynoir"
14:33amalloyibdknox: you should try perl, eh?
14:33ibdknoxoh god
14:33ibdknoxI hate perl... even more than I hate PHP
14:33ibdknoxwhich is saying something
14:33Raynesibdknox: Sounds like fun.
14:33RaynesPerl 6 is interesting.
14:34mdeboardWhat was the Clojure project that was just on HN a couple days ago? I think cemerick authored?
14:34mdeboardNot the SQL DSL
14:34callenas a fan of Indian food, I find the nomenclature of that SQL DSL to be pleasing.
14:35mdeboardOh, wait, Python DOES have destructuring, of a sort.
14:36mdeboard*args, **kwargs
14:36mdeboardAnyway, sorry.
14:37amalloymdeboard: it has tuples and splatting, which does get you a fair chunk of the way there
14:38mdeboardamalloy: I'm only familiar with "splatting" in the context of references in C
14:39mdeboardNever heard it applied to (not '(C, C++))
14:39ThreeCupsI have a fn that takes a map and a keyword (fn [m k] ...). I want to either create a new set containing k or conj k into a set that already exists as a value in the map. How could I do this? Or is my old nature imperative style still creeping up?
14:39amalloymdeboard: as i understand it that's what ruby calls the *args construct, and possibly also python? i've never heard of it in C
14:39sdboDoes anyone know a particularly good Resque-like backgrounding library for Clojure?
14:39amalloyhttp://stackoverflow.com/questions/2322355/proper-name-for-python-operator
14:39mdeboardamalloy: May haev just been a former CS professor's word for it
14:40technomancysdbo: there's this: https://github.com/technomancy/die-roboter
14:40technomancyhasn't seen much real-world usage yet, but it's really simple; only about 100 LOC
14:40mdeboarddie-bart-die
14:40technomancymdeboard: http://www.cul.de/images/autotoolscg.jpg
14:41fdaoudmdeboard: "no one german could be harmful!" ?
14:41tolstoyRaynes: Thanks for your pointer. I guess I'm after "restructuring", which led me to: http://blog.jayfields.com/2010/07/clojure-destructuring.html
14:41mdeboardfdaoud: nailed it
14:41fdaoud:)
14:41tolstoyRaynes: I guess I should dip in to Joy of Clojure soonish. ;)
14:42mdeboardtolstoy: it's really a great book, only tech book I've ever read straight through like a novel. I mean, until the agents/refs/etc part.
14:42sdbotechnomancy: that's pretty close to what I was hacking around on building— you just set up the execution context in the worker before calling roboter/work?
14:43tolstoymdeboard: The free chapter pretty much backs up what you say. I've got some pressing problems I'm using Clojure for, but it'll be nice to go back and see how to improve.
14:43technomancysdbo: the execution context meaning database connections, etc?
14:43fdaoudmdeboard: +1. It really is tremendously well-written. I wonder who used the word "propensity".. chouser, fogus, or the editor?
14:44sdbotechnomancy: database connections, namespaces, etc
14:44technomancysdbo: right, pretty much
14:44mdeboardtolstoy: I wish I had some problems that were of a nature to warrant solving them with Clojure.
14:45mdeboardfdaoud: I don't follow
14:45technomancysdbo: I'm actually working on adding a -main function that you can pass the number of workers you want to set up and things like that
14:46fdaoudmdeboard: I was just impressed by the vocabulary. Like in chapter 9, "Newcomers to Clojure have a propensity to hack away at namespace declarations until they appear to work." I admit having to look up "propensity".
14:46tolstoymdeboard: Well, I don't have that. I just do stuff like query mongo, shove data into file, upload, etc, or web apps, or web services.
14:46mdeboardtolstoy: Oh, i think I'd get a shoe shoved into inappropriate places if I wrote production code in anything but Python. :P
14:46tolstoymdeboard: But I would really like to see if I can see these tasks in a completely new way.
14:47mdeboardfdaoud: Ah
14:47sdbotechnomancy: this is basically perfect, I think, haha
14:47tolstoymdeboard: Like incoming rabbitmq messages as an infinite sequence, etc.
14:47mdeboardtolstoy: Even utilities. Plus it wouldn't be fair. If I got hit by a truck, maintainability of the code base shouldnt' be impacted
14:48tolstoymdeboard: I'm doing our production code in Scala, and all the side-issues (monitoring, etc) in Clojure.
14:49fdaoudclojurebot: scala
14:49clojurebot{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
14:49technomancysdbo: the error handling still needs a bit of help, but I think the rest of it is pretty solid
14:49tolstoyHah!
14:49mdeboardtolstoy: Ah that's a little more reasonable.
14:50mdeboardI think eyes would pop at anythign but Python here.
14:50tolstoyI find I really like the type system stuff in Scala (esp. what I can use of Algebraic types). But when I work in Clojure, I don't miss it.
14:50fdaoudmdeboard: if you get hit by a truck, don't worry about the maintainability of your code..
14:50tolstoyI do miss "linked" actors, though, as a way to manage resources (not necessarily concurrency).
14:50mdeboardfdaoud: :P
14:51sdbotechnomancy: ohhh, does wabbitmq connect to other AMPQ servers? I can't seem to get RabbitMQ running on my cluster
14:51tolstoymaintainability: I figure if you can document the interfaces, and keep your apps to single-purpose functionality, someone could just rewrite the thing if they need to.
14:51technomancysdbo: probably, but I haven't tried it
14:52tolstoy(But then I'm not writing trading software.)
14:54sdbotechnomancy: need to run atm, but I'll definitely try this out—perfecto
14:54technomancysdbo: definitely interested in feedback
14:54kzarIs there a way to split a decimal number into it's component parts? So for 1.5 I need to get 1 and 5
14:56amalloykzar: uhm. what result do you want from 1.49?
14:56amalloy(my point here is that 1.5 is the same as 1.50000000000)
14:56kzaramalloy: Hmm I'm not sure, thing is I need to handle a timezone in decimal. The function I use expects two parameters, hours offset and minutes offset
14:57mdeboardkzar: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/mod
14:57mdeboardoh.
14:59kzarOh hang on, how does this sound (int (* 60 (rem offset 1)))
14:59TimMc~XY
14:59clojurebotxy is http://mywiki.wooledge.org/XyProblem
14:59TimMchah
15:00TimMckzar: What are you trying to accomplish?
15:00jodaroshot in the dark here, but is anyone using zeromq and clojure?
15:00kzarTimMc: Pretty sure I solved it, just tried it out
15:00amalloy~anyone
15:00clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
15:00technomancyjodaro: IIRC it's doable but annoying since you have to use some native libs that aren't packaged up nicely
15:01jodaroyeah
15:01jodaroi'm through all of that pain, fortunately
15:01jodarobut now i've got new pain
15:01Raynesamalloy: Don't be mean. jodaro is mah buddy. <3
15:01kzarTimMc: Say 1.5 hours is 1 hour and 30 minutes, so if I do (int 1.5) I get 1 hour and (int (* 60 (rem 1.5 1))) gives me minutes
15:01TimMckzar: Right, but what is this in service of?
15:02endformCan anyone tell me the differences between anonymous functions defined with #() and (fn [] ())?
15:02kzarI explained above, that's what a function I use needs
15:02jodarosorry, anyone currently active and willing to share
15:02amalloyendform: those are the same
15:02TimMckzar: OK. I won't try to dig any deeper.
15:02amalloy&'#()
15:02lazybot⇒ (fn* [] ())
15:03endformamalloy: I have heard that before, but I get different behavior from them, also when I run `(#()) and `((fn [] ())) the output differs
15:03amalloy&(#())
15:03lazybot⇒ ()
15:03hiredman() is the empty list
15:03amalloy&((fn [] ()))
15:03lazybot⇒ ()
15:03kzarTimMc: Javascript offset is given as decimal clj-time offset functions need minutes and hours
15:03endform#((Thread/sleep 1000) (+ 1 %)) returns a null pointer exception for me, but the same function written with fn, does not
15:04amalloyendform: that's not the same function
15:05amalloy&'#((Thread/sleep 1000) (+ 1 %))
15:05lazybot⇒ (fn* [p1__8621#] ((Thread/sleep 1000) (+ 1 p1__8621#)))
15:05TimMcendform: You're trying to call the result of Thread/sleep
15:05TimMcendform: Count your parens.
15:06endformTimMc: right, okay,
15:06endformTimMc: thanks!
15:06TimMcThrow a do in there.
15:06endformthey differ in that the do is implied then in using the fn form
15:07TimMcSort of...
15:07endformi'm not sure if that is the right way of saying that
15:07TimMcIt's more that a fn accepts multiple forms (and wraps them in a do.)
15:07amalloyendform: the () is implied by the #() form
15:07amalloyis how i would describe it
15:07hugodjodaro: storm uses zeromq - not sure whether from clojure or from java
15:07TimMc&'#(fn [x] x)
15:07lazybot⇒ (fn* [] (fn [x] x))
15:08TimMc&'#(fn [x] x x)
15:08lazybot⇒ (fn* [] (fn [x] x x))
15:08drewrhugod: from clojure (zilch lib)
15:08TimMchmmph
15:08licenserHi, I have some odd problems with swank/slime lately they refuse to connect and jack-in only gives strange errors like this: http://pastie.org/2805988
15:08TimMcUrgh, I see what I was doing.
15:08TimMc&'(fn [x] x x)
15:08lazybot⇒ (fn [x] x x)
15:09TimMcOK, right. Quote only reveals reader expansion.
15:09jodarohugod: thanks, looked there (and nathanmarz gave me some tips yesterday)
15:11tolstoylicenser: Maybe try 'lein plugin install swank-clojure 1.3.3' on the command line?
15:11endformTimMc: do you know where #() is documented? I cannot find it for the life of me on clojure.org
15:12licensertolstoy: so I usually use cake :P that does not make things better I know
15:12licenseroh at least a longer struck trace :D
15:13greghendform: http://clojure.org/reader under Macro Characters
15:13jodaroendform: http://clojure.org/reader#The Reader--Reader forms
15:13jodarowoops
15:13jodarorepost
15:13endformradical
15:13devn_cowabunga dude.
15:14licensertolstoy: thanks that really got me a step ahead :)
15:14tolstoylicenser: The other day I had the problem of starting Emacs via the OSX Doc, and it couldn't find lein in /usr/local, so had to add some stuff to my .emacs file. It all seems simple *after* technomancy helps you. ;)
15:15devnAnyone going to the conj smart enough to reserve a hotel for the 9th want to split the cost?
15:15licenserteehee
15:15devnI just reviewed my reservation and for some reason I thought it'd be a great idea to get a room for the 10th and 11th.
15:15devn*facepalm*
15:17licenserjava.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (internal.clj:1) isn't exactly good right?
15:17callendevn: I dunno man, that kind of stupid might be infectious.
15:17callendevn: what if I catch something? :\
15:18amalloylicenser: mismatched binary versions usually
15:18licenseroi mismatched binary version? How does that happen o.O?
15:19amalloycompile against 1.2 and run against 1.3?
15:19licenserahha sneakuy
15:23devncallen: haha
15:24devncallen: if the worst kind of stupid I can pass on is sucky calendaring I think I'm in pretty good shape
15:25gfredericksokay, I'm sitting down and trying to tackle this 'unbound fn' problem now
15:27licenserI start to think clojure hates me because I betrayed it with erlang :(*
15:27gfrederickserlang: finally a syntax everyone can agree on.
15:27Bronsais it normal for lein uberjar to take likely a minute to complete?
15:28Bronsa*like
15:28gfredericksBronsa: sounds typical to me. Something about cramming all the jars together.
15:28Bronsaok
15:28gfrederickslein jar is usually much faster
15:28Bronsalet's try
15:28Bronsaindeed you're right
15:29gfredericksI've just learned to not want to make uberjars every 5 minutes
15:30gfredericksmaven usually has better ways to do things
15:30amalloygfredericks, Bronsa: uberjar AOT-compiles all your dependencies
15:30Bronsawoah,.
15:31Bronsathat explains a lot
15:31licenseroh it really does, lein swank crashes, cake swank hangs when emacs connects
15:31amalloybecause your main ns needs to be aot-compiled, which means its dependencies do too
15:32gfredericksamalloy: now I know!
15:33zerokarmaleftgfredericks: wrt erlang => http://i.imgur.com/eXSQf.png
15:34gfrederickszerokarmaleft: :) classic
15:34jodaroheh
15:35licenseraha found the crulpit
15:36licenserclojure-contrib is version 1.1.0 and clojrue 1.2.0
15:38Rayneslicenser: If you're using cake from the develop branch, it also supports clojure-jack-in now.
15:38devnAnyone here play with protoge?
15:38devnprotege*
15:39gfredericksdevn: yes.
15:40gfrederickss/~anyone~/~anyone"
15:40licenserRaynes: that is good to know :)
15:40gfredericks(dvorak-type)
15:40gfrederickss/type/typo
15:45cemerickmdeboard: did you find what you were looking for?
15:46mdeboardcemerick: I was just trying to remember what the project was (of yours?) that was on HN a couple/few days ago. Not the SQL DSL
15:47cemerickmdeboard: all my public open source stuff is at https://github.com/cemerick FWIW
15:47mdeboardMaybe I'm misremembering
15:49licenseris there a way to do a soft dependence with maven? like saying "If you have clojure contrib, please take 1.2.0"?
15:54cemericklicenser: that's an optional dependency
15:55licensercemerick: then clojure should have clojure contrib in the right version as a optional dependencie
15:56cemerickhrm, that's a fair point
15:56hiredmanmeh
15:56licenseryup
15:56hiredmanclojure doesn't depend on contrib in anyway
15:57cemerickit's water under the bridge at this point anyway
15:57licenserhiredman: but it crashes if something else does :P
15:57cemerickhiredman: but there's nothing wrong with libs limiting minimum versions of known downstream dependents
15:57cemericklicenser: there is no "clojure-contrib" anymore, anyway
15:58hiredmanlicenser: right, if you do the wrong thing, it crashes
15:58hiredmanso just stop doing that
15:58licenserhiredman: not me, someone else did
15:58hiredmanwhoever
15:59licenserwhat happened is that one dependencey required clojure-contrib and meven/lein figured to get 1.1.0 while the project uses 1.2.0 of clojure
15:59hiredmanI understand
15:59licenserso if there are optional dependencies and it is known that clojure 1.2.0 does not work with contrib < 1.2.0 why not put it in
15:59licenserthey are from the same 'distributor' in the end
16:00TimMcI don't see how it could hurt.
16:00cemerickit doesn't, but it also isn't relevant anymore
16:00licenserI mean I understand that you don't put a random library like that
16:00licensercemerick: yes it is a lot of libraries require old versions
16:00TimMccemerick: Wishful thinking.
16:01licenserit isn't if you have SOTA clojure and all your libs do the same ;)
16:01cemerickWell, we can't go re-release clojure 1.2.0 with different dependency info.
16:01TimMcWhy not?
16:01licenserof cause but perhaps 1.2.1 ^^
16:01TimMcOh, I see -- not that exact version.
16:01licenseror 1.3.1 then
16:01hiredmanSOTA?
16:01cemerick1.3.x has nothing to do with clojure-contrib at all
16:01licenserState Of The Art :)
16:03TimMccemerick: ...and everything that uses 1.2 probably explicitly asks for 1.2.0 or 1.2.1, instead of the awkward [1.2.0,1.3.0)
16:03licensercemerick: still it cranes if a old version of c.c is present
16:04licenserwell the point of it is c.c 1.1.0 seems to be incompatible with 1.2.0+ since a lot of old libs require 1.1.0 it would be nice to have clojure be aware of this and block it :)
16:04cemericklicenser: except that would require changing your clojure version to, what, 1.2.2? Might as well require c.c [1.2.0] and be done with it?
16:05TimMctechnomancy: Can we have leiningen turn 1.2.* into [1.2.0,1.3.0) in deps? :-)
16:05cemerick:-O
16:05licensercemerick: for me yes I did that already and am fine I just expect that I am not the only one that runs into this problem and learns the hard way what the cryptic error message java throws on you means
16:05TimMcI'm guessing the latter syntax is a Maven-ism.
16:06gfredericksare there any common gotchas with maven and SNAPSHOTs?
16:06licenseralso c.c 1.2 does the same with clojure 1.3
16:06licenseras in crash
16:06hiredmansnapdon't
16:06cemerickTimMc: also a lein-ism as long as no one attempts to reinvent dependency resolution and repositories
16:06licenserso I think binding the contrib version within clojure is a bad idea
16:07licenserat least I don't see any reason why it would do any harm
16:07gfrederickshiredman: so when you work on several maven projects simultaneously, you just version-bump every time?
16:07licenserI mean about 10 second of work on the pom of clojure, saves generations of clojuruans the trouble to learn that including libraries means better double check that they don't depend on a old version of contrib
16:07hiredmangfredericks: I think I would just cry a lot
16:08TimMchiredman: That's reassuring.
16:08hiredmanmove to lein, use checkout dependencies
16:08cemerickbleh
16:08cemerickonly helpful if you own the world
16:08gfredericksI'm not sure that'd go very well with this java project
16:08licenserhiredman: I use lein, it downloaded the wrong c.c happily and crashed in my face with 200 lines of java excpetions
16:08gfrederickswhich depends on my clojure project
16:08cemerickgfredericks: what problem are you having in particular?
16:09hiredmanlicenser: wah wah wah
16:09TimMclicenser: He was responding to gfredericks re: lein
16:09hiredmancemerick: how so?
16:09gfrederickscemerick: I keep doing "lein deploy" with my snapshotted project, but my java project keeps building with the same old jar
16:09licenserhiredman: You failed to produce any argument just play nay-sayer, mind to explain why?
16:09gfrederickscemerick: I can even see in my ~/.m2 that the new jars are comming in with their timestamped names, but the generic jar is still the old version
16:09licenserTimMc: ah sneaky :) sorry hiredman
16:10cemerickgfredericks: is the Java project using maven?
16:10gfrederickscemerick: yeah
16:10cemerickIt'd try running `mvn -U …` (which will update all snapshot versions).
16:10gfrederickscemerick: it's building a war, so I can easily crack it open to see what it included
16:10gfrederickscemerick: will try that now
16:10cemerickif that doesn't work, nuke the relevant subdirectory in ~/.m2/repository/whatever, and try again
16:11cemerickhiredman: checkout dependencies require…a checkout
16:11hiredmanlicenser: because clojure doesn't depend on contrib? so why would marking it as a dependency make any kind of sense? it is semantically incorrect, you are trying to hack around a problem without solving it by smashing a square peg into a round hole
16:11hiredmancemerick: right, which if you are hacking on several projects at once you have
16:11cemerickif I want to use head of some library I'm not working on, then I need to go clone its repo. Not fun.
16:11gfrederickscemerick: yeah, that's definitely my backup plan. I'd like it to work properly though, not hackily.
16:12licenserhiredman: I see that point that is why I suggested a (how I now learned it is called) optional dependencie
16:12cemerickhiredman: right, if *I'm* hacking on the projects in question. Doesn't help if someone else is hacking, and I want to benefit from the hacking without futzing with having their repo.
16:12hiredmancemerick: right, but you can then commit and push your changes
16:13cemerickgfredericks: it is unfortunately a fact of life that .m2/repository needs flushing every now and then. That's gotten quite a bit better now that aether is maturing, FWIW.
16:13hiredmanlicenser: "dependency" clojure does not depend on clojure-contrib, so even if the result is the effect you want, a solution that ends up marking it as so is incorrect
16:14cemerickhiredman: commit to what? If I'm following foo's HEAD, and I'm not involved in the development of foo, then using snapshots I don't have to have a clone of foo (and update my clone of foo, and bar, and baz, whenever they have changes).
16:14gfrederickscemerick: the -U seems to have made a difference. I'll add that in, thanks.
16:15cemerickcheckout deps are a great solution for a single developer, but hardly a general solution
16:15hiredmancemerick: hacking on several projects at once implies making changes to several at once
16:15licenserhiredman: sorry that is just words that you argue, having named it 'things-that-are-relavant-for-this' just would have not sounded so good as dependencies
16:15cemerickhiredman: that's not the only use case of snapshots
16:15hiredmancemerick: correct, but is the case gfredericks asked about
16:15hugodgfredericks: zi can do checkout dependencies for maven projects, but unfortunately relies on fixes in maven post 3.0.3
16:15cemerickgfredericks: should only be necessary when you see things not updating properly; using it all the time will not do friendly things to your build time :-)
16:16gfrederickscemerick: :/ I'd hate to have to always check
16:16gfredericksmy goal here is to automate everything
16:16gfredericksI prefer slow to inconsistent
16:17licenseranyway since it won't happy anyway I just give it up
16:19sridcan (fn [a [o b]] (o a b)) be shortened any further?
16:20mdeboard.
16:21chousersrid: in some contexts you could almost replace that with ->
16:21srida and b are numbers, and o is one of the math operators
16:22sridthis is http://www.4clojure.com/problem/135 btw
16:22hiredmanbleh
16:22chouserIs this new?
16:22sridyea
16:22hiredmanisn't there a #clojure-golf channel or something?
16:22chouserheh
16:23TimMcit's called #4clojure
16:24amalloy~rimshot
16:24TimMcSANBOX DENIED
16:25TimMclicenser: I suppose it should really be that clojure-contrib 1.2 declares a dependency on clojure 1.2.
16:25TimMcWhat was I thinking...
16:26licenserTimMc: so that would mean that when releasing c.c 1.2 you already know that 1.3 will be incompatible but yes that would be the better way
16:27cemerickIf only we had a time machine?
16:27hiredmanI do
16:27hiredmanbut I get messages about corrupt backups at least once a month and have to start over, drives me nuts
16:28licenseron a bigger scale libraries requiering outdated things can be pretty scary especially if they are not explicit about it what would be the best way to handle this?
16:28TimMccemerick: When you were saying something about "lein-ism", were you saying that that syntax is native to leiningen, or that notion of version ranges is?
16:28hiredmanavoid those libraries
16:28TimMcugh
16:28cemerickTimMc: lein inherits nearly all of the dependency resolution semantics of maven (necessarily so), including version ranges.
16:28brehauthiredman: my time machine did the same for about 3 months, and then the disk died completely
16:29hiredman:(
16:29licenserthat is a rather harsh way but yes it would solve the problem
16:29TimMccemerick: Semantics, OK. But not syntax, surely!
16:29cemerickTimMc: insofar as version numbers are strings, yes
16:29TimMcHrm.
16:29cemerickThe syntax is not really problematic. The semantics are more questionable.
16:30cemerick[5,12) isn't exactly unprecedented, etc
16:30srid,(-> 3 (- 1))
16:30srid,(#(-> % %2) 3 '(- 1)) ;; fail
16:30TimMccemerick: I was sure that Maven would represent it as <version><lower include="true">1.2.0</lower><upper include="false">1.3.0</upper></version>
16:30cemerickheh
16:30TimMcbut I gues even the XMLers have a limit.
16:31hiredmanlicenser: you are saying "I want to use library x, but it's dependecies are outdated" and I am saying "well then you cannot use it" and you are responding with "but I really want to"
16:31licenserhiredman: nah I say is there a way to make it better
16:31brehautTimMc: youd think so would you…
16:31sridchouser: how would you wrap -> that in anonymous function?
16:32licenserhiredman: I mean it might be that there is a super simple way I just don't know about :P
16:32TimMcsrid: -> is a macro, it is a syntax transformer
16:32TimMche comes, etc.
16:33licenserbut since none went "oh that again, just do lein show-me-where-the-outdated-contrib-comes-from I guess something else is wrong
16:33hiredmanthe only real correct answer is the library needs to be brought up to date in it's dependencies, or you need to log yourself to its dependencies
16:33hiredmaneither of which can have large repercussions
16:34TimMc,(println "You OK, clojurebot?")
16:35licenserI really want the result to be "No."
16:35chousersrid: yeah, I don't see how.
16:35sridin general, ` (fn [a [o b]] (o a b)) ` can't be shortened using anonymous functions?
16:36TimMcsrid: Which 4clojure problem?
16:36srid135
16:36licenserhiredman: okay perhaps my approach was wrong. How about making it easier to find those problems or prevent them from crashing in a strange java stack trace that no normal person understand (save for those who had the problem themselves or wrote clojure ;)
16:36TimMclicenser: The exceptions are a problem for sure.
16:37TimMcOr maybe there should be a lein troubleshoot plugin!
16:37hiredmanlicenser: a. don't aot unless you are absolutely required b. educate your self, java stack traces are very informative, learn to read them
16:37TimMc"It looks like you have incompatible versions of those libs."
16:37TimMchiredman: Nonsense, there's some crazy shit in those traces, you're just used to it.
16:37hiredmanb. is really a must for anything
16:38licensereven so I figured out how to get me a dependence tree I don't see where contrib 1.1 comes from
16:38TimMcThey may have gotten better, but they're still mystifying on many occasions. Especially certain syntax errors.
16:38hiredmanlanguages are just another abstraction, they can an do break, and you depend on them, so treating them as a black box is dumb
16:38amalloychouser: hah, what a funny way to solve that problem
16:39srid? you stalking people's solutions?
16:39hiredmanlicenser: I don't recall the intermediate debugging steps you went through, but the first cause you mentioned does not indicate that something is pulling in contrib 1.1
16:39dakroneb
16:39amalloysrid: http://www.4clojure.com/problem/solutions/135
16:39sridhmm. not looking, until i compress my solution
16:39hiredmanit means that some library was aot compiled against some other version of clojure, that was not abi compatible
16:40arohnerlicenser: lein pom && mvn dependency:tree | less
16:40licenserhiredman: I know but someone here explained that, the stack trace: http://pastie.org/2806452 indicates that I use clojure 1.3 with something that is compiled for clojure 1.2
16:40licenserwhich was pretty close, I use clojure 1.2 for something - that for some reason is compiled with clojure 1.1 namely clojure-contrib 1.1.0
16:41amalloysrid: want a hint?
16:41licensernow I don't require contrib at all but something does so I went to put 1.2.0 in fixed - solved the crash
16:42licensernow I did more or les what arohner said to trace down which library is the one that requires 1.1.0 - answer is, none - my core project does
16:42arohneris there a function for 'or'ing a bunch of predicates together? #(or (foo? %s) (bar? %s)) -> (magic-fn foo? bar?)
16:43hiredmansome
16:43licenserhttp://pastie.org/2806467 would be the dependence tree
16:44amalloyclojure 1.3 adds every-pred or something like that
16:45ThreeCupsI'm trying to write a function that take a 2-d matrix of maps and updates a particular map. The function takes a matrix, coords (two ints in a vector), a fn that takes a map and other args, and the other args that are passed to fn. The definition is like this:
16:45ThreeCups(defn update-cell [matrix coords f & args] (update-in matrix coords f args))
16:45amalloy&(#(list % %&) 1 2 3 4) ; sric
16:45lazybot⇒ (1 (2 3 4))
16:45ThreeCupsBut I'm having trouble with args and getting them through to the fn call. I get this error: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: user$eval137$fn (NO_SOURCE_FILE:0).
16:45ThreeCupsIf I take out args, then everything works fine, but I want to be able to pass in optional args. Any tips?
16:45amalloyThreeCups: (apply update-in ...)
16:45TimMcchouser: Nice! (looking at solution)
16:46brehauti was going to be productive today, and now you all have me trying to solve 4clj problems.
16:46licenseraha found the bugger
16:46ThreeCupsamalloy: Thanks! it worked great
16:49sridamalloy: btw, is that (% %&) that hint? i didn't know of this implicit destructuring before. (don't need hint yet)
16:49amalloysrid: yes, that was all
16:49chouserTimMc: heh, thanks.
16:49sridoh ok. and recur is allowed in anonmy functions?
16:49amalloysrid: try it and see?
16:50cgrayin clojurescript, it appears that you can't have a function with the same name as the namespace. is this a bug?
16:50srid&#(if % (recur (dec %)) %) 5)
16:50lazybot⇒ #<sandbox6471$eval8674$fn__8675 sandbox6471$eval8674$fn__8675@17019f7>
16:50sridthat hung my repl; restartring ..
16:50ibdknoxcgray: it is an issue that has come up before, but I thought someone fixed it
16:51srid,(#(if (pos? %) (recur (dec %)) %) 5)
16:51cgrayibdknox: ok
16:51amalloysrid: clojurebot is down for the count atm, i think
16:51devn:(
16:51devnI can play clojurebot...
16:51TimMchaha
16:51TimMcdevn: ~botsmack
16:52TimMcslowbot
16:52devn=> 0
16:52devnsrid: ^
16:52TimMcsrid: ##(#(if (pos? %) (recur (dec %)) %) 5)
16:52lazybot⇒ 0
16:53sriddevn: ,(loop [x 1] (recur x)
16:53TimMclazybot is alive
16:54TimMcamalloy: Did you change something about lazybot's eval responses? I get a "?" now instead of an arrow.
16:54ibdknoxTimMc: utf?
16:55hiredmanamalloy: did someone do something that locked up clojurebot? down for the coutn how?
16:55cgrayibdknox: it looks like the issue is still there... i just updated to the latest github version
16:55TimMcibdknox: Shouldn't have changed since like last week, at least not on this computer.
16:55RaynesTimMc: Nothing has changed.
16:55Raynes&(+ 3 3)
16:55lazybot⇒ 6
16:56TimMchrmf
16:57Raynes,(+ 3 3)
16:57clojurebot6
16:57Raynes~botsnack
16:57clojurebotThanks! Can I have chocolate next time
16:57RaynesSure.
16:58TimMcThe last sign of life had been 14:57 < amalloy> ~anyone
16:58devnsrid: Still working on your query...
16:58sridbuggy bot. that's a syntax error!
16:58TimMcsrid: Not for lazybot.
16:59TimMc&(+ 1 2
16:59lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
16:59TimMco\__/o
16:59RaynesTimMc: We got rid of that.
16:59TimMcOK.
16:59TimMcWhy?
16:59clojurebotTimMc: because you can't handle the truth!
16:59RaynesIt used fnparse which is a bit of an abandoned project and we needed to update to 1.3.
16:59RaynesOr, I wanted to update to 1.3 in any case.
17:00TimMcAha.
17:00RaynesBut I absolutely want it back if someone wants to do it in some other way.
17:00TimMcAre there any cljs eval bots around?
17:00TimMcRaynes: (while EOF (add-parens))
17:00Rayneshttp://github.com/flatland/lazybot <-- src/lazybot/plugins/clojure.clj if anybody wants to give it a shot.
17:01Rayneslazybot can do Haskell, Clojure, and JRuby.
17:01RaynesNo cljs.
17:01amalloyTimMc: well, it used to handle (let [x (inc y] x)
17:01srid(eval (-> a b)) --- is it possible to resolve `a` and `b` before the the form is passed to `eval`?
17:01amalloywhich your strategy is not so good on
17:01RaynesAnd the jruby isn't allowed at the moment because I haven't bothered adding JVM sandboxing (which I can do fairly easily with clojail).
17:01RaynesBut Haskell certainly works.
17:02Raynes$he 2 + 2
17:02lazybot⇒ 4
17:02TimMcsrid: For-kludge-er won't take eval.
17:02sridhmm
17:04TimMcunless you're clever about it
17:04TimMcNot golf-friendly-though.
17:05TimMc s/y-/y /
17:07devnbahaha, srid: You are a jerk. I forgot about that REPL and my computer just started to get awfully loud.
17:10cemerickFYI: http://mostlylazy.wordpress.com/2011/11/03/coming-soon/
17:11licenserRaynes: :D long time no see
17:11RaynesIndeed.
17:11RaynesHow have you been?
17:12licensergood good :) got a new server, lots of fun and experience in setting stuff up, a actual work related clojure project which is darn awesome to have and my gf is spending a month with me :D
17:12licenserhow about you?
17:12TimMcwhelp
17:12RaynesI'm fantastic. :)
17:12TimMcdevn: It turns out that (loop [] (future (loop [] (recur))) (recur)) is a terrible idea.
17:13licenserglad to hear ^^
17:13devnhaha
17:13TimMcI'm on another computer now...
17:13devnlicenser: yeah, where have you been?
17:13licenserI read your blog and noticed that you moved try-clojure to heroku, should I changed to try-clojure.org domain?
17:13RaynesNaw, I've got a redirect up.
17:13licenserdevn: hiding under a pile of Hardware related work and some erlang coding
17:13RaynesIt's all good.
17:14licenser:)
17:14RaynesThe primary domain is tryclj.com now anyway.
17:14licenserkk
17:14TimMcMy computer is now a space heater.
17:14licensersweet TimMc :)
17:15RaynesTimMc: I take of my pants, fold my legs, and sit with my laptop in my lap to keep warm in the winter.
17:15Raynesoff*
17:15TimMcRaynes: And run a linear fork bomb?
17:15RaynesRight, yes.
17:15licenserheh
17:15TimMc'cause that's what I just did.
17:15TimMcAnd I have 8GB of RAM, so fuck me. Stupid Java process won't die for a while.
17:16licenserTimMc: neat, I tried that once to see if OSX fixed the "bug" in bash :P
17:16licenserfor the record, they didn't
17:16devnlicenser: cool, I just started working on the Manning Erlang and OTP book
17:16licenseryea that got me hooked, it is really good
17:16licenserif you ever are interested to look at some code, I've a darn interesting project in erlang
17:16devnthe guy was like "that is not a beginner book, but it is a great book"
17:17devnso i immediately purchased it. beginner books are a bummer.
17:17devn90 pages of what an array is.
17:17devnlicenser: I would be delighted to. :)
17:17devnbrb
17:17licensercool cool
17:20ibdknoxtechnomancy: ping?
17:21technomancyibdknox: what are the haps
17:22ibdknoxtechnomancy: would you be interested in version of lein new that used a lib designed to spit out project structures?
17:22technomancyibdknox: yeah, there's a "lein spawn" plugin that does that
17:23callenanybody going to the clojure meetup in SF tonight?
17:23technomancyI'd be interested in mainlining it or (something like it; I haven't looked at it much) for 2.0
17:23technomancyoops, paredit slurp that or in
17:23ibdknoxtechnomancy: excellent. There's a good chance Raynes or I might build such a lib.
17:24technomancyhave you evaluated spawn?
17:24ibdknoxif that one doesn't look good
17:24ibdknoxwas supposed to be on that sentence
17:24RaynesI'm looking at it now.
17:25RaynesI think we'll have to put some work into taking the Leiningen stuff out.
17:25RaynesI need this to work for both cake and leiningen.
17:25RaynesBut it looks good so far.
17:25cgrayis there an equivalent to the int function in cljs?
17:26ibdknoxcgray: (js/parseInt)
17:26licenserRaynes: out of curiosity how does the cake dev version handle jack-in?
17:26Rayneslicenser: The same way leiningen does, for the most part.
17:28licenserwhat I mean is if I do clojure-jack-in how does it decide weather to use cake or lein?
17:35callenwhether
17:36Rayneslicenser: Ah, you have to set the command it uses.
17:36Raynes(setq clojure-swank-command "cake jack-in %s")
17:36RaynesThat ought to do it.
17:38technomancyany seattle folk are welcome to swing by early =)
17:38licenserRaynes: sneaky :) thanks.
17:39RaynesThat isn't documented yet because the next version of clojure-mode will define clojure-swank-command as a defcustom so that it can be edited using the Emacs customization interface. Also, cake jack-in isn't in a release yet, so I didn't want to confuse people.
17:40replacacallen: I'll be there. You?
17:40licenserRaynes: I see I see :)
17:40callenreplaca: it was between clojure and django, I'm going to the clojure one instead. so yeah, I'll be there. I work nearby weatherbill.
17:41licenseralso reading your blog I found it curiose that you dived into the topic of media servers as well :)
17:41technomancyis weatherbill hosting?
17:41callenda.
17:41technomancycool
17:41ThreeCupsIs there a way to get around reduce's need for it's fn argument to take 2 args? I'd like to pass in more than 2.
17:41technomancyone of their Seattle employees is a regular up here
17:42callenthey seem to be prolific in general.
17:42cgrayThreeCups: just put them in a vector and destructure it in your fn
17:43ThreeCupscgray: Thanks, was hoping for a different solution, but that will work. I don't really like it because the optional arg is required.
17:44ThreeCupsThat means I have to write my function like (defn [a b & c] ...) and c is required by the fn
17:44cgrayThreeCups: no, i meant something like (defn foo [[a b] c] ...)
17:45cgrayand it should return a vector of two values
17:45replacacallen: cool. I work close too, so it's a great location.
17:45ThreeCupscgray: okay, that makes sense. let me give it a try...
17:46replacacallen: see you there
17:46callenreplaca: indeed. My name's Chris btw.
17:46replacacallen: And I'm Tom
17:46ThreeCupscgray: I don't understand the the "and it should return a vector of two values"
17:47ThreeCupsI'll have a look at the reduce source and that will prolly answer my confustion
17:47cgrayThreeCups: reduce calls the fn repeatedly with the last thing you return and the next thing in the list...
17:50technomancyso, any ideas why I can access a postgres db just fine on the command line but not via jdbc? the DB is owned by a postgres user with the same name as my unix user, which means I shouldn't need a password, but c.j.jdbc freaks out claiming the server requires a password.
17:50technomancy(side note: this is why people are nuts about nosql)
17:50clojurebot'Sea, mhuise.
17:50technomancy~botsmack
17:50clojurebotclojurebot evades successfully!
17:50technomancy...
17:50technomancyclojurebot: forget (side note: this |is| why people are nuts about nosql)
17:50clojurebotI forgot that (side note: this is why people are nuts about nosql)
17:51hiredmanpostgres somtimes decides to be whacky and do auth via identd
17:52gfredericksokay, I have now ceased getting unbound fn errors and am now getting an error about one of the generated fn classes not being found
17:52gfredericksthe exception relates to a class ending in "$iter__94__98$fn__99", while when I examine the jar the relevant class has slightly different numbers
17:52hiredmansounds like you are mixing aot and classloader wonkyness
17:53gfredericksI bet so :/
17:53hiredmanoh, no
17:53technomancyoh ffs
17:53technomancyident sameuser only works using unix domain sockets
17:53hiredmanthats not it, you should clean out your classfiles
17:53technomancythat's it. mongodb here I come.
17:53hiredmantechnomancy: well, it makes sense, other wise how can you tell it is the same user?
17:55technomancyhiredman: sure, but the point is that this is a waste of time.
17:55amalloyThreeCups: what would it mean for reduce to take three args? what args would it pass?
17:56technomancysetting up a postgres DB that you can actually access takes in excess of seventeen steps if you count all the times you have to create the DB, realize you've done something subtly wrong, dropping it, and recreating it.
17:56hiredmantechnomancy: you could just allow anyone to use the db without a password, just like most nosql dbs
17:58gfrederickshiredman: does "clean out your classfiles" imply anything more than `lein clean`? :/
17:58seancorfieldi must admit, on the (two) occasions i've setup postgres, i've found it to be crazy fussy to install / configure / use and i can't understand why anyone raves over it :(
17:59hiredmangfredericks: rm -rf classes
17:59ThreeCupsamalloy: it would take an accumulator, the next value to add to the accumulator, and any other args needed to calculate the addition of value to the accumulator
17:59duck1123There used to be a library that had a fn for shelling out that I can't seem to find anymore. Does anyone know of any good ones?
17:59hiredmanand make sure the jar you end up using was generated after you did the rm -rf
17:59duck1123I've got pallet.stevedore, but that only seems to generate the scripts
18:00technomancyseancorfield: "GRANT ALL ON db.* TO $USER" is 90% of the reason mysql is widely used
18:00hugodduck1123: clojure.java.shell
18:01amalloyThreeCups: but how would that work? either the "other args" are part of the next value (and you need only two args), or they're part of the accumulator (same thing), or they're the same every time. if they're the same every time, you can just make them part of the reducer function
18:01duck1123hugod: Well there it is. thanks
18:02seancorfieldtechnomancy: and the fact that for dev work you don't need to create an o/s level user for mysql etc etc etc
18:02gfrederickshiredman: did everything over quite carefully. It looks like the jar for my project contains in itself a reference to the class, even though the class it contains has the slightly different numbers
18:03gfredericks(i.e., when I `grep <classname> <jarfile>`, grep says it matches)
18:04gfredericksI'm using a macro that emits a deftype...would this make sense if it was somehow running twice during compilation?
18:04hiredmanpossibly
18:05hiredmanthe differing numebrs tends to mean something got compiled twice
18:05hiredmanalso, if you are emitting a deftype inside a let or something
18:05gfredericksthey all differ by one, which is odd, as it doesn't make sense if there's a global incremented variable for the unique IDs
18:07gfredericksthe deftype is at the top level. The weirdest thing going on is that I'm doing (require ...) a couple times in the body of the only function of my deftype, just to make sure the ns's are loaded.
18:07hiredmanugh, yeah, no
18:07hiredmandon't do that
18:07ThreeCupsamalloy: I think I understand what you're saying. I'm thinking about it a little differently. I'm updating a 2-d vector using reduce. I have a sequence of coordinate, value pairs e.g. ([[0 0] :value]...) and I have a fn that I use to update a matrix
18:07ThreeCups(defn update-matrix-cell [matrix coords f & args] (apply update-in matrix coords f args))
18:07gfredericksokay, then I don't know how to make sure my class works
18:07ThreeCupsI also have an intermediate fn between reduce and update-matrix-cell that takes 3 args
18:07ThreeCups(defn update-matrix-cell-for-specific-data [matrix coords data] ... (update-matrix-cell ...))
18:08ThreeCupsIt's this update-matrix-cell-for-specific-data that I'd like to call from reduce. I've "solved" this in the meantime by doing destructuring.
18:08gfrederickshiredman: without that I get unbound fn errors
18:08hiredmangfredericks: ok, add it, but use resolve
18:09hiredmanor, have the java side load the required namespaces
18:09amalloyThreeCups: (reduce (fn [acc x] (update-matrix-cell acc (do-stuff-with-x))) cells) or something?
18:09gfrederickshiredman: the latter would be clunky, as I'd rather not edit the java (different project). My macro is emitting symbols for the require statements
18:09gfrederickse.g., (require '~(-> *ns* str symbol))
18:10hiredmanuse ns-name
18:10hiredmanand use resolve
18:10gfredericksso (require (resolve '~(ns-name *ns*)))?
18:10hiredmanno
18:11hiredmanwhen you go to use something from the required ns, use resolve
18:11hiredman(reuire x) ((deref (resolve 'x/y)) 1)
18:11gfredericksoh wow
18:11gfredericksthe only thing I have after the require is ~@body
18:11gfredericksso I guess anytime I call the macro I need to resolve everything?
18:13gfredericksI had no idea interop from clojure was so hairy
18:14gfredericksam I doing something wrong? Is it really not possible to supply a class to a java proj via a jar without adding java code to bootstrap it?
18:16srid,((first '(+ x x)) 2 3) ;; strange result
18:16clojurebot3
18:16sridshouldn't that be 5?
18:16amalloyno
18:16gfredericks,('+ 2 3)
18:16clojurebot3
18:16amalloy&(= + '+)
18:16lazybot⇒ false
18:16amalloy&(:+ 1 20) ; same as this
18:16lazybot⇒ 20
18:16srid%('whatever 1 2)
18:17sridmembership lookup? returns 2nd arg as default.
18:17gfrederickshave symbols always done that?
18:17amalloy&('+ '{* 1} 4)
18:17lazybot⇒ 4
18:17srid,((resolve (first '(+ x x))) 2 3) ;; works n ow
18:17clojurebot5
18:18amalloy&('+ '{* 1 + 8} 4)
18:18lazybot⇒ 8
18:18amalloygfredericks: for as long as anyone can remember, anyway. probably for as long as keywords have done it
18:18srid4clojure refuses resolve.
18:19amalloy&(resolve (symbol "eval"))
18:19lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
18:20amalloythat's why - with resolve you can get eval, from which you can get anything you want
18:20sridproblem 121 - close to lowest code golf ...
18:20brehautamalloy: does it really ;)
18:20gfredericks,(list (symbol "eval"))
18:20clojurebot(eval)
18:24gfredericksis require idempotent?
18:24ThreeCupsamalloy: that will work, and I think it's what I've done but removing the "middle man". I want to think about updating my matrix with the fn
18:24ThreeCups(defn update-matrix-cell [matrix coords f & args]
18:24ThreeCupsThis seems to be a pretty clean/clear fn. And it makes sense that I'd have another function that update the matrix for a specific "data type" at a specific coordinate, hence the fn
18:24ThreeCups(defn update-matrix-cell-for-specific-data [matrix coords data] ... (update-matrix-cell ...))
18:24ThreeCupsNow I have a matrix and a sequence of coordinate/data pairs and want to call my handy function to update the matrix for this type of data. But I can't because reduce takes a fn that takes 2 args.
18:24ThreeCupsI've got around this by creating an intermediate fn
18:24ThreeCups(defn intermediate [matrix [coords data]] (update-matrix-cell-for-specific-data matrix coords data)
18:24ThreeCupsIt'd be nice if I could hide this fn somewhere, i.e. make it anonymous or something (I'm too new to clojure so I don't know how to do this)
18:25brehautThreeCups: let + fn or letfn ?
18:26ThreeCupsbrehaut: will give it a try. I've used it once and forgot about it :)
18:26technomancygfredericks: yeah
18:32ThreeCupsbrehaut: Thanks! worked like a charm
18:32gfredericksoh, I was wrong about my jar containing a reference to the non-existing class. apparently I used grep poorly.
18:36gfredericksoh man, I think it's a serialized object
18:37gfredericksare clojure datatypes not safely serializable in the java-sense? or maybe just lazy seqs?
18:44gfredericksI can imagine if java tries to serialize a lazy seq it couldn't do anything other than serialize the internal fn itself
19:02hiredmangfredericks: the other thing is java serializing requires the classes to be present at both ends, dones't play well with dynamic byte code generation
19:04gfrederickshiredman: are non-lazy datatypes safer? or do they have hidden references to fns?
19:05hiredmanthey are safer, you really should be able to serialize a lazy-seq
19:08gfredericksI think I finally got the example-of-a-use-case working, though I'm not sure if serialization will come up later. Will try it out.
19:08gfrederickshiredman: thanks for the help.
19:09hiredmannp
19:42scottj"There are several upcoming books on Clojure from multiple publishers. I think there's been more books on Clojure in 2 yrs than Lisp in 20 ;)"
19:42scottjno way, no matter how you pick the two years (since programming clojure is already over two years old).
19:43scottjlet over lambda, land of lisp, practical common lisp, lisp small pieces, ansi common lisp, on lisp, paip, plai, little schemer, seasoned schemer, reasoned schemer. and if you go 22 years or so you get horn and cltl2
19:43callenPC is the one I have.
19:43callenI can't wait for v2.0
19:43callenI want some Noir.
19:44scottjof course the tweet suffers from the same flaw as people who complain that the US isn't building as many bridges as China.
19:50technomancydon't forget the art of the metaobject protocol
19:51scottjoh wow I thought that was older so I didn't bother checking
19:52technomancynot really fair to count both CL and Scheme though
19:53scottjactually I bet if you just do 89-91 CL beats any three year pear of clojure
19:56scottjoopcl, amop, cltl2, paip, horn3
19:59tolstoyHow long until "Clojure & Spring"?
20:00tolstoyHeh. ;)
20:00TimMc$kill
20:00lazybotKILL IT WITH FIRE!
20:01tolstoyMovie: The Spring. A group of hackers go down to Antartica to uncover an old architecture, when...
20:03ThreeCupsHow would I get the x/y coordinate pairs from a 2-d matrix? E.g. (coord-pairs (->> (repeat 2 {}) vec (repeat 2) vec)) would return [[0 0] [0 1] [1 0] [1 1]]
20:05gfredericksThreeCups: I'd get the dimensions and do something like ##(for [x (range 3) y (range 2)] [x y])
20:05lazybot⇒ ([0 0] [0 1] [1 0] [1 1] [2 0] [2 1])
20:12technomancydakrone: how do you feel about accepting a string for :basic-auth?
20:12technomancyit would make for easier round-tripping via java.net.URI since that class exposes user/password only via .getUserInfo as a single colon-separated string.
20:12technomancy(as well as continuing to accept a seq of course)
20:13technomancyalso: why do I always come up with these questions for dakrone _after_ 6pm mountain time?
20:14hiredman:/
20:14mdeboardSo, question. I was just reading http://blog.factual.com/clojure-on-hadoop-a-new-hope and he has several variables preceded by `?`. Is this some convention or does it have a syntactic meaning I'm missing
20:15mdeboardor is it just something he likes doing
20:15hiredmanit's a cascalog/datalog/logic programming thing/convention
20:16nathanmarzit distinguishes variables from regular variables
20:16hiredmandoesn't have a meaning in clojure outside of those domains
20:16nathanmarzerrr
20:16nathanmarzfrom regular values
20:16nathanmarze.g., if you did this: (<- [?a ?b] (source ?a) (+ val ?a :> ?b))
20:16nathanmarzthen "val" is just a normal Clojure variable, and its value is substituted into the query
20:16nathanmarzwhereas ?a and ?b are part of the query
20:17mdeboardoh hey nathan
20:17mdeboardmarz
20:17mdeboardI was just looking at Cascalog
20:17mdeboardI se
20:17mdeboarde
20:17mdeboardI have a need for such functionality at work.
20:18mdeboardI've got this colossal "cities.txt" file that is a csv of every city in the world, with its country and lat/long
20:18mdeboard1.5 mil lines or something
20:18mdeboardcool story bro
20:19nathanmarzcool
20:19nathanmarzyou could certainly query that with cascalog
20:19gfredericksthe '.txt' makes me imagine opening it in notepad
20:20mdeboardgfredericks: Worse. Iterating over every line, creating a Django ORM object out of the line, then saving it to the database.
20:21mdeboardgfredericks: It is unbelievably slow.
20:21hiredman(didn't go over well)
20:21gfredericksmdeboard: I'm not sure what you just said but I'm pretty sure it was offensive
20:21mdeboardgfredericks: I threw up.
20:21hiredmanat least he didn't call you a cfmljure
20:22gfredericks:)
20:23mdeboardI'm frustrated just thinking about it.
20:26mdeboardIt's stovepiping part of a bigger project, actually. I wish I hadn't brought itup.
20:27TimMcstovepiping!
20:27mdeboardindeed
20:27TimMcI first heard that phrase in a Charlie Stross book, re: gov't projects.
20:28TimMcOr is that even the same term?
20:29mdeboardTimMc: I spent a decade+ in the USMC, common metaphor :P I'm sure it was explained in the book but literal stovepiping is when a spent cartridge is incompletely ejected from the chamber, and gets caught between the bolt and ejection port
20:29mdeboardSo it's just sticking straight up, preventing the weapon from completing its firing cycle
20:29mdeboardit being the spent casing
20:29TimMcWhy does it get that name?
20:29mdeboardIt looks like a stovepipe
20:29TimMcThat's like a 4th meaning...
20:30mdeboardhttp://images.google.com/imgres?q=stovepipe&amp;hl=en&amp;biw=1600&amp;bih=746&amp;gbv=2&amp;tbm=isch&amp;tbnid=O_5jgmm1b31ftM:&amp;imgrefurl=http://4photos.net/en/image:142-47576-Glock_23_stovepipe_images&amp;docid=BW6DcnkfZoGYgM&amp;imgurl=http://4photos.net/photosv2/130428_glock_23_stovepipe.jpg&amp;w=300&amp;h=200&amp;ei=QDGzTqLoNvG42QXsjMHMDQ&amp;zoom=1
20:30mdeboardwow, nice link
20:30mdeboardyou're right, I used"literally" and shouldn't have
20:30mdeboardLiterally a stovepipe: http://www.daviddarling.info/images/stove_pipe.jpg
20:30mdeboardMetaphorical weapon-related stovepipe, whence the term originates: http://4photos.net/photosv2/130428_glock_23_stovepipe.jpg
20:30TimMcNow *that*'s a stovepipe.
20:31TimMcWikipedia has two definitions: https://secure.wikimedia.org/wikipedia/en/wiki/Stovepiping
20:31mdeboardSo by stovepiping the project I mean something that is between me and project completion
20:32mdeboardwow
20:32mdeboardANd knowing is half the battle
20:32technomancy(defn getenv [x] ({} x (System/getenv x)))
20:33technomancy^ because no System/setenv exists
20:33TimMcmdeboard: And here I thought you meant you had some spaghetti... stovepipes...
20:33TimMcpiping data from one component to another, but haphazardly.
20:36mdeboardTimMc: Interesting, I've really never heard of that. Can tell I wasn't an intel bubba.
20:38mdeboardTimMc: Thanks, actually.
20:39TimMcI still don't really get the gov't/intel sense of the phrase.
20:39TimMcI mean, at a gut level for what it means organizationally.
20:43mdeboardTimMc: AFAICT it uses the meaning of stovepipe i.e. "isolated vertical conduit" that vents material outside the building, to mean an isolated vertical conduit that vents "material" (information) outside the organization
20:43mdeboardLike when a colonel has the ear of a senator
20:43mdeboardand passes his information to influence policy
20:43mdeboardwithout distributing it through the proper channels to reach the same destination.
20:44TimMcI get that one.
20:44TimMctechnomancy: What's the context?
20:45technomancyTimMc: you want to change an environment variable without restarting the whole JVM
20:45technomancyso you just slap it in the map in getenv
20:48TimMc{} is a placeholder for a ref of a map?
20:48technomancyit's just something you can edit inside the function at dev time
20:48carkis there a one liner that transforms :a to ([:a] [:a :a] [:a :a :a] ....) ?
20:49carkvectors not required,
20:49TimMctechnomancy: Oh, some defaults.
20:49hiredman,(for [i (range 10)] (repeat i :a))
20:50clojurebot(() (:a) (:a :a) (:a :a :a) (:a :a :a :a) ...)
20:50TimMc,((partial iterate conj []) :a)
20:50clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$iterate>
20:50carkhiredman: ah thanks, i was looking at reductions
20:50TimMcurg
20:50carkbut good enough !
20:50ibdknox,(map #(repeat % :a) (range 1 10))
20:50clojurebot((:a) (:a :a) (:a :a :a) (:a :a :a :a) (:a :a :a :a :a) ...)
20:52amalloy&(rest (iterate #(conj % :a) []))
20:52TimMc,(take 3 (drop 1 (iterate #(conj % :a) []))) ; cark
20:52clojurebot([:a] [:a :a] [:a :a :a])
20:52lazybotjava.lang.OutOfMemoryError: Java heap space
20:52ibdknoxlol
20:52amalloyhaha sorry lazybot
20:52amalloy(dec amalloy)
20:52lazybotYou can't adjust your own karma.
20:53gfredericks(inc amalloy)
20:53lazybot⇒ 19
20:53gfredericksserves you right
20:53gfredericksfor trying to dec yourself
20:53ibdknoxlol
20:54carkthanks all !
20:54gfrederickswhen I try to create a future in the body of an aleph channel-receiving function, I get a java.util.concurrent.RejectedExecutionException
20:54TimMctechnomancy: http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java/496849#496849
20:55TimMc:-P
20:55TimMccark: Pyramid scheme of some sort.
20:55technomancyTimMc: my eyes!
20:55TimMchaha
20:56gfredericksIt's not a real function if you haven't typed "Map<String, String>" at least four times.
20:56technomancyTimMc: that is a serious hack though, wow
20:56technomancyi wonder how many lines of clojure that would be
20:57ibdknoxthat is all kinds of evil
20:57hiredman,(let [[Map<String, String>] [1 2]] [Map<String, String>])
20:57clojurebot[1 2]
20:57TimMcahaha
20:58hiredmanclojurebot: symbols |are| kind of fun
20:58TimMcgfredericks: Map<LanguageCode, Map<String, Map<String, Set<Integer>>>>
20:58clojurebotIn Ordnung
20:58gfredericksclojurebot: symbols?
20:58clojurebotsymbols are kind of fun
20:58carkah for completeness here is the reductions version :
20:58cark,(take 3 (reductions conj [] (repeat :a)))
20:58clojurebot([] [:a] [:a :a])
20:58carkbut i'll take hiredman's version which is the most readable
20:59cark(for me)
20:59TimMccark: but but but it doesn't share structure!
20:59carkah indeed !
21:00amalloytechnomancy: not as much, anyway
21:00amalloyer, TimMc
21:01gfredericksto share the most structure wouldn't we want to use cons instead of conj?
21:01TimMctechnomancy: Farther down the page is a crossplatform hack.
21:01hiredmandepends
21:02carkcurse you TimMc, now i have to think about structure sharing =P
21:02hiredmancons is really only for constructing seqs
21:02hiredmanconj is fine for sharing structure among vectors
21:02carkone can conj on a list
21:03technomancyhttp://p.hagelb.org/setenv.clj.html <= 7 lines, could be golfed further
21:03gfredericks,(map type [(cons 7 ()) (conj 7 ())])
21:03clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
21:04gfredericks,(map type [(cons 7 ()) (conj () 7)])
21:04clojurebot(clojure.lang.Cons clojure.lang.PersistentList)
21:04gfredericksokay so I meant conjing onto a list I guess
21:04technomancyI'll stick with my crappy defn getenv workaround for now
21:07TimMctechnomancy: I was just writing that! `lein new hurk`, (defn ohgod [...] ...)
21:09jcromartiefor some reason, the bozo that wrote this code thought that a singleton object which operates as a state machine was somehow thread safe
21:09jcromartieand the words "thread safe single object for foo repository" are all over
21:10TimMcjcromartie: It is threadsafe because he used the @threadsafe Javadoc annotation.
21:10jcromartienot even
21:10jcromartiebut dear god
21:10jcromartieI just realized this crap is all over
21:10jcromartieit's a wonder it works at all
21:11amalloyjcromartie: but there's only one! how could that be unsafe!!!!
21:11TimMcjcromartie: Ah, the mystery of life.
21:12gfredericksat work I've been using the Activiti BPMN engine, and in one of their webapps they have a 500 line custom implementation of a prefix trie. AND it's buggy. I rewrote it in clojure and it worked fine.
21:13gfredericksI thought of that because I'm pretty sure it's not threadsafe either, but of course my clojure replacement was.
21:13jcromartie:)
21:13TimMcOK, evangelism question. I want to start converting bits of a large multi-component Java project at work into Clojure. How can I do it incrementally?
21:13TimMcEverything is managed with Maven.
21:14jcromartiethis is in 14 classes
21:14jcromartiethey are all race conditions
21:14jcromartiethey are all used unsynchronized
21:14jcromartieby multiple users on the web site
21:14jcromartieand they all say "Thread Safe"
21:14gfredericksjcromartie: if something doesn't work they just click the button again?
21:14TimMcMaybe it is a brand name.
21:14jcromartieand even among those classes there are OTHER race conditions
21:15jcromartielike where they copied temporary files to a file using new Guid() in .NET
21:15jcromartiewhich creates an *empty* GUID
21:15jcromartieevery time
21:15TimMcahaha
21:15jcromartiethe same file, 00000000-0000-0000-0000-000000000000
21:15jcromartieis used for every concurrent user
21:15jcromartieI mean dear god
21:16jcromartieI knew concurrency was not always easy
21:16TimMc"Well, when I tested it, it worked!"
21:16jcromartiebut this...
21:16jcromartiethis is inexcusable
21:16gfredericksjcromartie: it's okay if they're all the same as long as they're globally unique
21:16carkindubitably one unique guid you got there
21:17jcromartiethankfully our user activity is measured in hits per minute
21:18gfredericksIUID: Initially Unique Identifier
21:18TimMcI figured.
21:18TimMcjcromartie: Why does that constructor even exist? Attractive nuisance.
21:19jcromartieTimMc: it's a .net struct
21:19jcromartiemeaning it defaults all of the fields to a default (0) values
21:20jcromartieand, of course, since the geniuses copied and pasted all of this crap, it's the same race condition duplicated separately 14 times
21:20jcromartieused in slightly different ways
21:20TimMchahaha
21:20jcromartieI mean
21:20jcromartiecan we sue?
21:20TimMclazybot: Can we sue???
21:20lazybotTimMc: Yes, 100% for sure.
21:20gfredericksjcromartie: for a better-than-average job? :)
21:22TimMc,(= java.lang.String (.getClass ""))
21:22clojurebottrue
21:22TimMctechnomancy: Why not (= c java.util.Collections$UnmodifiableMap)
21:23technomancyTimMc: sure, why not?
21:23TimMcsince you kind of asked for golfing
21:23TimMcAlso, prettier.
21:25amalloy(some #{j.u.C$UM} all-the-classes)
21:25TimMcWhy does it even bother iterating?
21:27technomancyprobably because it's java =P
21:27TimMc(let [c java.util.Collections$UnmodifiableMap ... ) works
21:29TimMcSeriously, WTF.
21:31TimMcI wonder if the author didn't know you could directly reference stuff like that.
21:32jlftechnomancy: what's the recommended package to get clojure-jack-in working in a vanilla emacs 24?
21:32technomancyjlf: clojure-mode and lein plugin install swank-clojure 1.3.3 should do it
21:32technomancyjlf: clojure-mode either from marmalade or github
21:32jlfthanks
21:40technomancyah cool; say hi to everyone for me
21:41darevayhi 4clojurers. For problem 86 (http://www.4clojure.com/problem/86) I have a solution (http://www.4clojure.com/problem/86) that causes ClassNotFoundException:clojure.core. Works fine locally. What have I done?
21:41gfrederickshow does 1.3 handle vars in (future)?
21:41darevay... oops that solution link should be https://gist.github.com/1338452
21:46TimMcdarevay: Yeah, WORKSFORME locally.
21:47amalloydarevay: something seems to be wrong with the set literal. i don't know how that can be, really
21:48amalloyie, if i replace your #{} with [] and use (some #{n} ns), it works. obviously that shouldn't matter
21:51darevayamalloy: thanks. weird.
22:00darevay... and now I see how I was working way too hard to get the digits of a number. geesh :)
22:07gfredericksoh man. an hour of debugging and it turns out ztellman implemented his own map type. o_o
22:17gfredericksis there not an interface or protocol for conj?
22:19cark,(conj {} [:a 1])
22:19clojurebot{:a 1}
22:20amalloygfredericks: IPersistentCollection.cons
22:23gfredericksamalloy: ah ha. Indeed that method is left out. thanks.
22:45mdeboardexport JAVA_OPTS=-Xmx768m
22:45mdeboardoop
22:55brehautibdknox: ping?
23:02leo2007can M-. in slime jump to definition of `def'?
23:21tali713leo2007: i can't, here.
23:21leo2007tali713: thanks for the confirmatino.
23:22leo2007confirmation*
23:28technomancyleo2007: it should actually
23:29leo2007a bug?
23:29technomancycould be
23:45technomancyseancorfield: fixed that bug in clojure-jack-in that was causing issues with warn-on-reflection
23:45technomancyreleased a new clojure-mode version with the fix
23:47aperiodicis there a way to exit from a repl inside a repl?
23:47aperiodicwithout also exiting from the enclosing repl, that is
23:55technomancysending an EOF should do it