#clojure logs

2011-01-10

01:10TakeVHow well does the .NET port of Clojure work?
01:19cheezeydoes drop-last have some weird side effect
01:20cheezeycuz after i try to conj a list that's been drop-lasted, it conjs backwards :\
01:20cheezeyif that makes any sense
01:21amalloy&(doc drop-last)
01:21sexpbot⟹ "([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
01:21amalloycheezey: it conjs to the front of the list, just like it does to every list
01:22amalloy&(conj (drop-last 2 (range 10)) 1)
01:22sexpbot⟹ (1 0 1 2 3 4 5 6 7)
01:22cheezeywhoops, i meanet to say cons*
01:22amalloythe only thing that ever conjs to the end is a vector: ##(conj (vec (drop-last 2 (range 10))) 1)
01:22sexpbot⟹ [0 1 2 3 4 5 6 7 1]
01:23amalloycheezey: doesn't matter. cons glues onto the head too
01:23amalloy&(cons 10 (range 2))
01:23sexpbot⟹ (10 0 1)
01:27cheezeylet's see..
01:27cheezey&(conj [0 1] 2)
01:27sexpbot⟹ [0 1 2]
01:27cheezey&(conj (drop-last [0 1]) 2)
01:27sexpbot⟹ (2 0)
01:28cheezeyi guess i don't get it :|
01:28amalloycheezey: ##(class [0 1]) ##(class (drop-last [0 1]))
01:28sexpbot(class [0 1]) ⟹ clojure.lang.PersistentVector
01:28sexpbot(class (drop-last [0 1])) ⟹ clojure.lang.LazySeq
01:29amalloyvectors are the *only* thing that adds at the end, and once you do something lazy to it like drop-last, you don't have a vector anymore
01:30cheezeyoh ok.
01:31amalloy&(class (seq [0 1]))
01:31sexpbot⟹ clojure.lang.PersistentVector$ChunkedSeq
01:31amalloy&(conj (seq [0 1]) 2)
01:31sexpbot⟹ (2 0 1)
01:33TakeVSo, protocols are interfaces, and records are classes, essentially?
01:33cheezeyamalloy: is there a way to "revector" them o_O
01:34amalloycheezey: sure, but you're blowing your performance to hell if you do that
01:34amalloysee instead ##(doc subvec)
01:34sexpbot⟹ "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."
01:34amalloyTakeV: umm. more or less, but if you try to translate an OOP program using those rules you'll be in for pain and you'll be missing the point of clojure
01:36cheezeyhey amalloy the lists are going to be like a maximum of size 10
01:36cheezeyim ok right :P
01:37amalloycheezey: if you don't care about performance, just use concat
01:37cheezeyoh
01:38amalloyand it will probably be more efficient than going to and from vectors over and over
01:40amalloycheezey: the fact that this is getting complicated should make you reconsider whether you're doing it the right way
01:41cheezeyamalloy: i would like to drop the last element from a list and be able to append to it
01:41cheezeyi dunno how much simpler it could get.
01:42amalloycheezey: i mean, why it is you want to be able to do that. but hey, if that's what you need to do, then concat and (drop-last and/or take) are your friends
01:42cheezeyamalloy: i guess you can think of it as a stack O_o?
01:43cheezeyhonestly, it doesn't matter if it's the front or back as long as im adding/removing from the same side..
01:43amalloycheezey: so conj onto a subvec, or cons onto a sublist
01:48cheezeyahhh.. i just realized im doing other stuff with the list
01:48cheezeyi guess i need to get the first/last (again, only need to "modify" one side though)
01:48cheezeyand "rest" in both ways
01:49tufflax(assoc v i (inc (v i))) <- is this really the best way to increase an element in a vector by 1?
01:50amalloytufflax: update-in
01:50amalloy&(update-in [1 2 3] [1] inc)
01:50sexpbot⟹ [1 3 3]
01:51tufflaxthanks
01:53cheezeyanyway, thnx amalloy im not used to clojure obv
01:53cheezey=P
02:00TakeVamalloy: Oh yes. It seems like a good tool to have, not something one should pidgin hole everything into though.
02:01amalloyTakeV: protocols are largely for performance and interop. for general-purpose clojure code, multimethods are more flexible
02:01Clintegerno, please pigeonhole everything
03:02notsonerdysunnyCan I suppress the repl in slime printing the return value by default?
03:05LauJensenamalloy: Im thoroughly disappointed to see people in here asking questions about ClojureQL which you are unable to answer *frown*
03:06amalloyLauJensen: i'm a rebel
03:06LauJensenYou're incompetent
03:07LauJensen(crude joke, sorry, hope you're not weeping now)
03:08amalloyLauJensen: i'm running out of tissues
03:08LauJensenamalloy: So sorry - I'll make a blogpost flaming Scala if that'll cheer you up
03:08amalloy*laugh* that sounds fantastic
03:08notsonerdysunnyI remember the return values of expressions evaluated in the repl were automatically bound to some vars..
03:08amalloymaybe i'd learn something about scala
03:08notsonerdysunnywhat are those vars .. google isn't helping ..
03:08amalloy*1
03:09notsonerdysunnythanks amalloy
03:09notsonerdysunnycan I suppress the return values from being automatically printed ...
03:10LauJensennotsonerdysunny: (do (your form) nil)
03:10notsonerdysunnyright now I add a (def _ s-exp) to achieve that...
03:10amalloynotsonerdysunny: you just want to do a bunch of stuff with side effects?
03:10amalloy(= (whatever))
03:10notsonerdysunnyyes right .. I am just interested in the debug prints ..
03:11notsonerdysunnyprinting the return value is just flooding the repl ...
03:13notsonerdysunnywhy isn't *1 showing up when I do a (ns-publics *ns*)
03:13amalloyit's not an interned var
03:14amalloyit's a repl convenience
04:18rrc7czhow do you guys feel about translating http error responses (client 4XX or server 5XX) into typed RuntimeExceptions (e.g. BadGatewayException) for a REST client lib?
04:25AWizzArdrrc7cz: my first thought would be that this introduces unnecessary complexity.
04:26LauJensenrrc7cz: Would make some code easier, ie. assuming everything goes well and just catch exceptions instead of testing on the result
04:28rrc7czso I'm not considering it for Clojure clients of the lib. I use conditions and I like it
04:28rrc7czI throw a map like {:status 422, etc} and I can have my handle-case dispatch on :state instead of :type
04:29rrc7czbut I'm thinking about how Java clients should be supported by the library. And having them catch a single Condition type isn't very friendly
04:29rrc7czthinking of the Java code, i think it would be best to have something like "catch (BadGatewayException e)... catch (NotImplementedException e).."
04:30rrc7czright now I have an abstract HttpException which extends RuntimeException and contains a factory which accepts a status code and returns an instance of the correct exception.
04:31rrc7czBasically I'm thinking I'll have my core clojure code w/condition, then a sort of Java wrapper which translates those conditions to this set of exceptions
04:37AWizzArdrrc7cz: When you return a record or map that contains all data, then the users of your lib can just have a look into that record or map.
04:41Fossii think exceptions are ugly for http statuses
04:41Fossiafter all it's a valid outcome of a request
04:41Fossiwould hate to have to catch all of those
04:41Fossiespecially being RuntimeExceptions might screw up your program quite a lot
04:42Fossiloads of users will never catch those
04:43AWizzArdYes, in principle each request needs to be embedded in a try/catch where the catch will have to list all 60 return codes.
04:46Fossiwell, or just one class those extend from, but still
04:47AWizzArdA simple map or record could do well.
04:59rrc7cza map or record is fine for clojure clients, but I'd hate to have a Java client have to parse a map
04:59rrc7czno client would have to catch all of those exceptions; they're RuntimeExceptions for that very reason
05:00rrc7czjust catch what you care about, or catch a superclass like HttpException or ClientException (4XX)
05:00AWizzArdrrc7cz: It should be trivial to call get from Java on maps, or access public fields of a record.
05:00rrc7czAWizzArd: sure, but then every usage of the lib forces the client to code for error conditions
05:00rrc7czinstead of giving them the freedom to ignore it, or to handle it higher up in the call stack
05:01rrc7czI mean, I was thinking about error-as-return-type as well, like Maybe/Either in Haskell
05:01rrc7czbut what I don't like is that without pattern matching, it's kinda ugly forcing every client to check for these error conditions
05:03rrc7czFossi: it's a valid outcome for a request, but in a RESTful API it's also the mechanism by which to signal errors
05:05Fossiyeah, but you are trying to fix these problems (having to check for the error) in a non-java way
05:06rrc7czhere's a concrete example: POST to /user should create a new user at /users/1, where 1 is the PK of the user (just an example). But imagine POST is not actually allowed on /user because the API requires the client to specify a PK, so only PUT on /user/1 is supported. It will return a 405 Method Not Supported. That's useful and it's an invocation error. How would your client lib handle that?
05:06Fossithere simply is no maybe/either, there is (almost) no "handling it higher up the callstack" and there is no pattern matching
05:06Fossithose are not your/your library's faults, so don't try to cleverly fix em
05:07Fossiin your scenario the "user" would never try to invoke that
05:07Fossiand never handle that error
05:07rrc7czactually looking at my example, I think it's a bad one because it shows a problem with the client lib rather than the data supplied to the client lib
05:07rrc7czhm
05:07Fossibecause i assume they would have documentation and remove "flawed" calls
05:08Fossithen again, if something changed unnoticed, i want to get thrown a "hard"/typed error
05:08Fossiso i can deploy a new version
05:09Fossibut on a more realistic senario, the api may be down/overloaded for a while
05:09rrc7czit exception idea works in other contexts though. Look at JPA/Hibernate. If you try to persist() an entity whose PK already exists in the DB, you would get a RuntimeException
05:09Fossii don't want that to throw me out of some loop, because i "forgot" to catch runtimeexception
05:10Fossiyeah and that is *horrible* in practice
05:10rrc7cz?
05:10Fossii rarely know anybody who hasn't complained about it once
05:10Fossiit's such a bad pattern
05:10rrc7czhow would you have designed it?
05:10AWizzArdrrc7cz: the clients are forced to implement *something* anyway if they want to react to errors. In some cases they want to write into a log file, in the other case a little Swing window should pop up, etc.
05:11Fossithat we almost always wrap it either by rethrowing a checked exception or not binding to it/using sql
05:11Fossithen again, if the DB is down, *that* is a useful case for an exception
05:11rrc7czAWizzArd: correct, I'm just arguing that by making it a RuntimeException, you're giving the client the freedom to a) choose what to handle and what to ignore and b) where to handle it
05:11Fossias in, somebody has to do something about it
05:12Fossiruntime exceptions will almost never be caught from my experience
05:12Fossithey will just fall through and cause somebody to be called late night
05:12Fossijust to notice an enduser fiddeled with a url on your site somewhere
05:26rrc7czwell the good news is, I'm writing the Java client code as well. So I'll try both approaches and see which one feels better/less painful
05:27rrc7czI could end up with a compromise: just stick with clojure's condition lib and leave it to the Java code to catch a http error condition (4XX or 5XX) and parse the "status" field of the map themself if they care about handling a particular value
05:27rrc7czthat would save me from writing a big class hierarchy
05:30rrc7czit's pretty quiet in the EU timezone :-) It seems it's usually only AWizzArd and Lau. Fossi where you located?
05:31FossiHamburg, DE
05:32Fossigenerally picks up a few hours from now
05:32Fossibut lots of lurkers as well :)
05:32rrc7czI have good memories of the fish market at 5am
05:32Fossi(including me usually)
05:32rrc7czI miss currywurst :-(
05:33rrc7czthe best I ever had was in Hamburg, thought the smoked eel from the market was awesomet oo
05:33Fossiberlin is quite famous for currywurst
05:33Fossibut we have quite a few good ones here at well
05:33rrc7czI tried it there too, but it wasn't as good. I had a native Hamburger host though so he knew where to go
05:36mduerksen*lurk*
05:37rrc7czso it's up to 5 now :-)
05:40LauJensenGuys, you're making me sick with all this talk of German food :(
05:41Fossigerman food is awesome
05:41rrc7cz:-D sorry, but I thought Danish food was basically the same, especially in the sea-front Hamburg
05:41Fossiactually danish food is quite nice as well
05:41ejacksondon't complain - I have to eat English food.
05:42rrc7czI imagine pickled herrring
05:42rrc7czejackson: you win. Blood pudding cannot be beat, even by the Germans
05:42Fossiyeah, english food sucks mostly :o
05:43ejacksonjust as well the the girls are so pretty here, or there'd be no reason to stay...
05:43rrc7czejackson: I hope you're joking... English girls???
05:43rrc7czgood lord. You need to come here to the Czech Republic. I think you'd enjoy it :-)
05:43ejacksonoh yeah... I'm joking :)
05:49LauJensenrrc7cz: Yea I wasn't boasting about the danish food culture :( And AFAIK the only pretty girl in the UK is ejackson :((
05:50ejacksonLOL ! yes, she's a stunner
05:51rrc7czlol tragic
05:51ejacksonactually I was drinking Gemmeldansk on saturday night, you have nothing to boast about !
05:51ejacksonand that was after the bizarrely named Fishshot, also from your part of the world LauJensen
05:52LauJensenejackson: You mean Fishermans friend?
05:52rrc7czCarlsberg is also terrible.
05:52ejacksonwell, Fishermen's friend is the solid phase, this was a liquid that tasted identical
05:54LauJensenejackson: okay, I know which one you're talking about. Its very refreshing
05:54ejacksonlol, it claimed on the bottle to be the most popular shot in the world, which was highly commendable lying.
06:01krumholthi. i am looking for a function that retrives the first occurence of an element. i could use filter and first but i need the index and not the value
06:05raekkrumholt: an exact function for that is not in core, but how to make it is explained in the first chapter of Programming Clojure: http://media.pragprog.com/titles/shcloj/flow.pdf
06:05mrBliss,(.indexOf [1 2 3] 3)
06:05clojurebot2
06:05raekhrm
06:06raekthere's no function wrapping that, right??
06:06LauJensen,(letfn [(find-idx [k c] (reduce #(if (= %2 k) %1 (inc %1)) 0 c))] (find-idx :y [:x :y :z]))
06:06clojurebot2
06:07krumholtthanks all
06:08LauJensenkrumholt: wait, scratch that, reduce doesnt stop when it gets a hit
06:10LauJensengo with stu's
06:13raek(defn index-of [coll x] (some (fn [[idx val]] (when (= val x) idx)) (indexed coll)) ;; version using Stuart Halloway's indexed, but some instead of first + filter
06:14raeksome has the advantage here that it can check for one thing and return another
06:25LauJensenpepijndevos: whats with the nick ?
06:38pepijndevosLauJensen: I'm trying to change it.
06:39Raynespepijndevos: What trouble are you having doing so?
06:40pepijndevosRaynes: I'm not sure. It seems to work, but it still shows fliebel in some places
06:40Raynespepijndevos: I'm going to spend the next week or so trying to figure out how to pronounce your name.
06:41pepijndevosRaynes: harhar, both ie an ij er pretty much Dutch sounds. Thoug i and y are close in some ways.
06:41raekI like the dutch "ij"
06:43pepijndevosI wonder what the relation is between nickname and user name. Colloquy now shows my nick to be fliebel, and user to be pepijndevos.
06:44raekin irc?
06:44pepijndevosraek: yes
06:45raeknickname is basically the only thing that's used
06:45raekthe other fields (login and real name) is for /whois lookups
06:46raekcurrently, you are registered at nickserv as "fliebel". but that only affects channel admin stuff on freenode
06:47pepijndevosraek: So, I'm still registered as fliebel, but displayed as pepijndevos?
06:47raekyes
06:48pepijndevosokay, I can live with that :)
06:48raekI only saw the string "fliebel" in the whois lookup. nowhere else.
06:49raekpepijndevos: http://pastebin.com/hPyLFkuu
06:51pepijndevosraek: Thanks
07:45AWizzArdrhickey: Good morning.
08:00AWizzArdSwing users? When I grab the handles of my window and resize it manually to become bigger then my UI grows. But when I open a fresh JFrame with it and hit maximize then the components don't grow in x-direction. Any ideas? (.validate (.getContentPanel frame)) didn't help.
08:01AWizzArdnevermind
08:02pepijndevosAWizzArd: What was it?
08:02ChousukeSounds like OS X
08:04AWizzArdpepijndevos: was Windows XP with MigLayout. ML will only resize automatically in x direction if *all* column constraints contain a "[grow]".
08:05pepijndevosMigLayout... I've heard a bit about it, but never used it. Is it good?
08:07AWizzArdIt is indeed very good. It basically removes the need for all other Layouts that come with Swing.
08:11StartsWithKhttp://paste.pocoo.org/show/317723/ can some one tell me is this a bug in clojure? (if it was already anwsered, i'm sorry didn't see it)
08:14raekthe first one looks weird...
08:15raekas for the second exception: it seems like remove-ns does not remove used vars and aliases from other namespaces
08:16raek(those can be done manually with ns-unmap and ns-unalias)
08:16raekif that is intentional, I do not know
08:58pepijndevosWhat is the state of logic programming in Clojure? There are 2 mini kanrens and one hadoop lib, as far as I know.
08:59kumarshantanupepijndeos: Fogus is working on unification library, did you consider that already?
09:03pepijndevoskumarshantanu: No, where does it live?
09:06dakronepepijndevos: https://github.com/clojure/core.unify
09:07LauJensenpepijndevos: that link to my website you put on HN yesterday, just left the frontpage minutes ago :)
09:08pepijndevosLauJensen: ASCII version of your stats of the past day: /^^^^\__
09:08LauJensen(and generated about 15 - 16.000 hits)
09:08pepijndevosdakrone: I just arrived there as well, thanks :)
09:15pepijndevosBut, core.unify does not do the rule thing that datalog does, or does it?
09:18kumarshantanudatalog can go hit a data source (on the disk), which is interesting
09:19pepijndevoskumarshantanu: But, can I do the classic family relations in core.unify? I don't think I understand unification completely yet...
09:20kumarshantanucore.unify lets you only unify vars and values...it doesn't know about facts AFAICT
09:23LauJensenejackson: heads up! I think your blog has stalled :(
09:31pepijndevosWhoa, another one! http://clojure.github.com/clojure-contrib/datalog-api.html
10:08dsophmm how to check if an obj implements a certain type created with deftype?
10:08dsopah satisfies
10:08tonyl(type obj)
10:08tonylmaybe
10:12cemerickdsop: instance? is what you're looking for. satisfies? checks whether a type has been extended to a protocol
10:19markskilbeckIn the Programming Clojure book, it says "Avoid direct recursion." What's the difference between direct and indirect recursion?
10:20Chousukemarkskilbeck: indirect just means using recur
10:21ChousukeYou shouldn't do recursion "directly" by calling the function because that causes stack growth.
10:21dsopas clojure doesn't have a tail-call optimization
10:22ChousukeI think it actually depends on the JVM
10:22Chousukeif the JVM guaranteed TCO then Clojure wouldn't need recur, but it unfortunately doesn't :/
14:10mprenticeok, got it working now, thanks for the help qbg and technomancy
14:26BerengalTwo things: First, I love how many "magic" things are implemented using macros. Makes it very easy to see how they're implemented. Second, my very preliminary proxy-mocking code already feels like I'm not only dissecting objects, but removing most of the organs and replacing them with a very steampunk machinery of ratchets, coils and spring, including a cockpit for me to sit and drive in.
14:34pepijndevosBerengal: Have you figured out a default-proxy macro already? :)
14:35Berengalpepijndevos: just create an "empty" proxy, and use init-proxy to add functions to it
14:36pepijndevosBerengal: I mean, the abstract-subclass thing you asked for earlier.
14:37Berengalpepijndevos: As in create a subclass of an abstract class, not just an instance to it?
14:38markskilbeckWhat's the difference between when and if?
14:38qbgwhen has only a true branch and allow for multiple forms in it
14:38pepijndevosBerengal: I don't know. You asked about something for poking at Java and generating stub classes.
14:38Berengalpepijndevos: Ah, that's what I'm working on
14:39BerengalAnd init-proxy is how I create the stubs
14:40markskilbeckqbg: Ah! Bitte.
14:52pepijndevosCan I say I hate function - and macros even more - that take &rest arguments? Sure, I can use apply and reduce for most, but not with macros.
14:53qbgWhy don't you like & arguments on macros?
14:54qbgIf your writing a macro that expands to a macro usage, just use ~@
14:56amalloyand if you were writing a function that uses a macro with & args, you couldn't do it anyway - the arguments to the macro would have to be known at compile time as literals anyway
14:57pepijndevosamalloy: Exactly.
14:57amalloypepijndevos: i think you missed my point. macros can't really take a seq of arguments
14:58amalloytry rewriting a macro from (defmacro foo [a & more]) to (defmacro foo* [a more]) and you'll have the same problem
14:58amalloyso i don't see what you think would be an improvement
15:01pepijndevosamalloy: *rereads everything, again, and again* I don't get it...
15:01amalloypepijndevos: maybe i'm the one who doesn't get it
15:02amalloycould you give an example of a macro with a &rest argument that causes you problems?
15:02pepijndevosamalloy: Uuhm, let me thing, I think Enlive had a few.
15:04pepijndevosamalloy: There. They make me want to resort to (eval (macroexpand)) tricks sometimes. https://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L554
15:07amalloypepijndevos: and how would you propose improving this? (defmacro transformation [forms]) won't be any good. not knowing anything about this library, the sheer number of macros-instead-of-functions makes me nervous, but i don't think there's anything wrong with the macros themselves other than (possibly) the fact that they're macros
15:10pepijndevosamalloy: That is the solution, tell people to stop using macros, and tell them someone at the other end of the globe is going to hate them when he needs to jump through hoops to make their macro run with a seq of arguments.
15:11amalloypepijndevos: that's fine. it's just you're complaining about macros with & arguments, when really what's bothering you seems to be macros
15:14pepijndevosamalloy: Macros are fine it's just that sometimes I want to stuff a seq of arguments through one, and it can't be done. There is no solution to it, I just don;t like it.
15:16qbgI suspect that using what ever macro you are trying to use wouldn't really make sense at runtime anyways
15:17opqdonutI think it's good style to offer function versions of macros where possible
15:18qbgI think Enlive already has functional versions of a lot of things already
15:18qbgAfter all, it was used in CGrand's (not= DSL macros) talk IIRC
15:18pepijndevosI once had a mega-macro that did a lot and was very messy, but when I broke it up in functions, I could not get all the ends tied together, and resorted to this. It was temporarily, but then the project stalled. https://github.com/pepijndevos/utterson/blob/develop/src/utterson/compile.clj#L76
15:20pepijndevosqbg: iirc I had to dig deep down to find a function for what I did, but that was a looong time ago.
15:32mduerksenwhat could be the reason i need to use gen-class in 1.3, while i didn't need it in 1.2?
15:38mduerksenhmm, gen-class didn't work either - ClassNotFoundException during runtime
16:08mduerkseninteresting - when compiled with lein-stable, everything works fine.
16:12_na_ka_na_hellos, how do i create a non-top level var
16:14_na_ka_na_intern will create a top (ns) level var
16:14tonylyou can use let
16:15amalloy_na_ka_na_: do you actually mean var, as in like #'foo, or do you just want a local binding?
16:15_na_ka_na_amalloy: a var
16:15amalloy_na_ka_na_: i don't think you can do that
16:16amalloyand it's not really clear why you would want to. if you want a binding, you have let; if you want mutability, you have atoms/refs
16:17_na_ka_na_amalloy, i want to keep a var of my app's compojure routes, so i can change it dynamically, i would have gladly used an atom if it worked
16:18tonyljust rebind the symbol of the var to a new var
16:18amalloy_na_ka_na_: use a closure around an atom?
16:19amalloy(let [real-route (atom whatever)] (set-compojure-routes-function (fn [] (@real-route))))
16:19amalloynote that i don't know anything about compojure so the actual words i used there are nonsense, but i hope you get the idea
16:21_na_ka_na_amalloy, i dont understand what you mean
16:22amalloy_na_ka_na_: if you want something that you can rebind, but don't want to create a top-level var (which is the only kind of var), you can create an atom that stores the real data, and pass that around / modify it as needed
16:22_na_ka_na_so routes is just a function .. say. . (def *routes* (fn ...)) .. then here's how i'll start the server .. (start *routes*)
16:23_na_ka_na_and inside compojure will just call the function as (*routes* request)
16:23_na_ka_na_so if I start my server as : (start (var *routes*)) .. I can rebind it and changes will be reflected
16:24_na_ka_na_is is because ((var some-fn) ..) works ..
16:24_na_ka_na_,((var +) 1 2)
16:24clojurebot3
16:24amalloyyes, i'm aware
16:25amalloyaside from the fact that i don't know why you want to avoid creating a var, you can close around an atom and then swap/reset the atom
16:25_na_ka_na_but i'm not aware of any utility as 'set-compojure-routes-function'
16:26_na_ka_na_i'm just being fussy .. i want to avoid a top level name coz its not really required
16:26_na_ka_na_I'll just do (declare *routes*)
16:29_na_ka_na_aren't vars reference types like atoms/refs/agents, why can't we create them like we do the others?
16:31chouseryou can craete vars using with-local-vars
16:32amalloychouser: no kidding? neat
16:33_na_ka_na_chouser, but it works only if used from the same thread
16:33_na_ka_na_,(with-local-vars [a 10] (future (var-get a)))
16:33clojurebot#<core$future_call$reify__5500@1e60601: :pending>
16:33_na_ka_na_,(with-local-vars [a 10] @(future (var-get a)))
16:33clojurebotjava.util.concurrent.ExecutionException: java.lang.IllegalStateException: Var null/null is unbound.
16:36amalloy_na_ka_na_: what i'm talking about is this: https://gist.github.com/b4ff52ae5f0d50db15bd
16:36chouserworks in 1.3 :-)
16:36_na_ka_na_yeah i know :/ even binding is multithreaded in 1.3
16:37chouserbut of course it's unbound in another thread. That's how vars work.
16:37chouser,(with-local-vars [a 10] @(future (with-bindings {a 20} (var-get a))))
16:37clojurebot20
16:38_na_ka_na_amalloy, nice i understand now !
16:38_na_ka_na_thanks
16:38amalloyimo this is a disgusting solution and you should just use vars like god intended
16:38amalloybut if you don't want to, there's the answer
16:39_na_ka_na_hmm you're right, I'll just use a var, I was just curious about creating a var like other reference types
16:40chouserWell, this isn't Clojure-related, but it's what I was up to this weekend: http://blog.n01se.net/?p=237
16:41_na_ka_na_chouser, that-is-awesome
16:41chouser:-) thanks. Surely it's been done before, but it was fun to make myself.
16:45_na_ka_na_do we have a 1.3 clojure-bot ?
16:45_na_ka_na_i think it may be useful
16:45_na_ka_na_to have a bot running latest beta
16:45_na_ka_na_or alpha
16:46amalloy_na_ka_na_: we don't
16:47amalloychouser: fwiw, it works on my droid x, but only with one finger
16:47amalloyif i use two fingers, neither one draws anything
16:47_na_ka_na_amalloy, can i help create one in any way
16:48amalloy_na_ka_na_: http://github.com/Raynes/sexpbot - just change the dependencies to use whatever clojure version you want, and run it on your computer
16:49amalloyyou'll probably want to (surprise!) read the readme, which has a pretty good getting-started guide
16:52_na_ka_na_amalloy, I'll take a look
17:14RaynesAssuming sexpbot will run on 1.3
17:14RaynesNever actually tried.
17:15RaynesI intend to make it so we can evaluate code in both 1.2 and 1.3 from the same bot using classlojure.
18:06david`hi
18:06david`anyone here work at Relevance
18:06david`by chance
18:09redingerdavid`: Several of us do, what's up?
18:09david`oh, I was thinking of applying
18:10david`I was emailing with someone named Andrew but I don't see that person on the site
18:10redingerdavid`: Ah, cool; Yeah, we don't have Andrew up there
18:11david`oh ok
18:11david`thanks redinger
18:11david`are you going to the Ruby meetup on the 18th?
18:11redingerSure am
18:11david`nice!
18:12redingerWe also have the TriFunc meeting tomorrow in our office. Aaron's speaking
18:12david`oh really
18:12david`I've never heard of ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnkld+J8ySCvnjBPXcNpFlnI6TIZvLcdFgw0mdMNeW/rIdUNNQBQuC4QXv+P2WhnECS9m1tJV2SvvyvGnjOz1RkUTIucrolskhwxu2cr50eThb7vvH9xBVTIZ4nWoaorTAaThqN8KZYmRGyl3g9oP2ROipDBIR4qaHtutGj4vjXcRr9pG8GCDx0JUy8xZjGDGKa1fcbH65vUkytbRwIkZfHB0AI2XNejbaZ8lTOofXZ74eWpZVwsI15Fhn6AqOtjl1Df3PSoKVutWNY2ksXt0FlMOaC9Mp4MqqTAw/B8AyJ1bf4uD3ugDC4jDXhyATL9A5Xyt2LYpVRRSzL+HNK4Zww== david@darthmaul
18:12david`fuck
18:12david`TriFunc
18:12david`copy and paste on ubuntu sucks
18:13david`oh cool, aaron = incanter
18:14david`I was reading up on Incanter this past weekend
18:14redingerAaron's talking about incanter. David L = incanter
18:14david`oh ok
18:14redingerThe TriClojure group is also kicking off tomorrow (at TriFunc): http://www.meetup.com/TriClojure/calendar/15938227/
18:15david`awesome, I was thinking about how there was no Functional meetup group in the triangle
18:15Raynesredinger: Did you ever get my reply to your email?
18:15david`I was talking to one of my coworkers about starting one
18:16redingerRaynes: I did, thanks for getting back go me!
18:16redingers/go/to
18:16sexpbot<redinger> Raynes: I did, thanks for getting back to me!
18:16RaynesJust making sure my email client didn't decide he hated me.
18:18Raynesredinger: For the record, there is a new draft that you'll want to grab before reading it. Recently made a huge move to pandoc and fixed a lot of things in the earlier chapters. Read page 5 of that new draft before anything else, it'll give you a feel for the status of the book.
18:18RaynesSame link (always the same link).
18:18RaynesPrettier fonts. :>
18:18redingerCool, I'll take a look through it
18:19RaynesI have a friend who has agreed to copy edit it, so I'm doing well in the editing and review department.
18:56bytecolorhow would I bring java.lang.Math/cos into my namespace so I can (cos x, not (Math/cos x)? I've tried all manner of :use, :import, :require, etc.
18:57RaynesYou can't.
18:57bytecoloroh? well that's interesting
18:57RaynesWhat you want to do is create a function that wraps it.
18:57Raynes(defn cos [x] (Math/cos x))
18:57RaynesThen you can just call your own function.
18:57bytecoloraye, I see
18:58raekthis can be used too http://richhickey.github.com/clojure-contrib/import-static-api.html
18:58Raynesraek: Stop stealing my spotlight.
18:58Raynes;)
18:58raek:-)
18:58RaynesFirst time I've heard of import-static.
18:58bytecolorI thank you both equally ;)
18:59Raynes<3
18:59raek(inc Raynes)
18:59sexpbot⟹ 3
18:59Raynes(inc raek)
18:59sexpbot⟹ 3
18:59amalloyget a room, guys
19:00tonylimported as macros, wonder if there is an option for importing as fn
19:00raekimport-static could be updated to emit a definline instead
19:09rata_hi
19:09rata_how do you get a unique temporary file in clojure?
19:09amalloy&(java.io.File/createTempFile "pre" "suff")
19:09sexpbotjava.lang.SecurityException: Unable to create temporary file
19:10amalloy,(java.io.File/createTempFile "pre" "suff")
19:10clojurebotjava.lang.SecurityException: Unable to create temporary file
19:10amalloybah. but rata_, ^
19:10rata_thanks amalloy =)
19:11rata_do you use that with with-open?
19:12amalloyrata_: do whatever you want with the File object it gives you
19:13rata_I ask that because I don't know how to use a File object
19:14raekrata_: if you want to read text, create a Reader. if you want to read raw bytes, create a InputStream.
19:14raekrata_: you can use 'reader' and 'input-stream' from clojure.java.io to do that
19:14raekthey can both take a File object as argument
19:15raek(require '[clojure.java.io :as io]) (import 'java.io.File)
19:15rata_can I use c.c.duck-streams/write-lines?
19:15raek(with-open [rdr (io/reader (File/createTempFile ...))] ...read here...)
19:16raeksure
19:16raeksome of the stuff in c.c.duck-streams has migrated into c.j.io and core
19:17rata_I didn't know about c.j.io
19:17rata_is it in 1.3?
19:17raek1.2
19:18raek(if you want to write, you use a writer or a output-stream)
19:20rata_thanks
19:21rata_I just want to write-lines on it and then launch a command line program that reads it
19:22rata_how do I manually close a File object? I doesn't have a .close method
19:23raekthe "File" class name is a bit confusing. a File actually represents a file name, rather than an opened file
19:24raekcalling 'writer' on the File object will create a FileOutputStream under the hood, which will open the file
19:24raekWriters and OutputStreams have a .close method, though
19:27rata_oh, thanks raek =)
20:19Deranderraek: I swear your name is a nosql db or something
21:58cheezeyis it possible to apply map to a function with more than one variable
21:58cheezey(or somehow consolidate two lists together..)
21:59brehaut,(map (fn [a b] [a b]) [1 2 3] [:a :b :c])
21:59clojurebot([1 :a] [2 :b] [3 :c])
21:59brehautlike that?
21:59cheezeyoh my god that's totally not what the docs say LoL
21:59cheezeyi prolly should have just tried it out :\
22:00brehautthe docs are a wee bit obtuse, but they do say that to me?
22:00amalloycheezey: that is what the docs say
22:00amalloy&(doc map)
22:00sexpbot⟹ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. An... http://gist.github.com/773949
22:00cheezeyoh. i misread it fffuuu
22:00cheezeyi suck at reading guys.
22:00amalloybtw brehaut, ##(map vector [1 2 3] [:a :b :c]) is easier :P
22:00sexpbot⟹ ([1 :a] [2 :b] [3 :c])
22:01brehautamalloy: yeah i almost did that, but figured the explicity function is clearer
22:01amalloybrehaut: maybe so
22:25cemerickThere was a clojure lib floating about that automated (somewhat saner) microbenchmarking. Anyone remember the name?
22:37cmeierI just watched Rich Hickey's demo with the ant colony - it rocked my world
22:37cmeierLooking for the actual code ... does anyone know if it is available?
22:38brehautit used to be
22:39brehautit has been a very long time since i looked for it; its pre-1.0 code
22:39amalloycmeier: http://clojure.googlegroups.com/web/ants.clj
22:40brehaut(inc amalloy )
22:40sexpbot⟹ 1
22:41cmeieramalloy: thanks!
22:59cemerickI did a bit of irresponsible microbenchmarking, probably going to write up a blog post for fun. Does any of this look fishy to anyone? https://gist.github.com/d3e652e87d76796ab05c
23:00cemerickThe map v. HashMap result seems plausible, but the vector v. ArrayList result doesn't.
23:01qbgI wonder how ArrayList is implemented
23:01cemerickit's just a wrapper around an array, which is why I have to think the result is wrong
23:01cemerickAn array dereference can't be slower than a tree traversal, no matter how shallow.
23:02cemerickand yet…
23:03amalloy$source get
23:03qbgI wonder how they compare if you add the items to the ArrayList manually
23:03sexpbotget is http://is.gd/kwSz3
23:04amalloycemerick: the arraylist has to go through several more hoops in RT.get
23:07amalloyapparently because get is intended for associative things, which arraylist is not
23:07amalloycemerick: try replacing (get) in your benchmark with (.get) - that may be more viable
23:08cemerickI just did -- *much* more sensible.
23:08amalloygood!
23:09amalloytbh i don't see how (get) works at all on an arraylist, from reading Rt.java
23:09cemerickgood catch, thanks -- I wrote it for the map test, and just blindly reused it
23:10brehautcemerick: how much faster does it get?
23:10cemerickYeah, neither do I. It's got to get to nth somehow, but the second clause in the conditional surely is false for ArrayLists.
23:11amalloycemerick: yeah, i'm baffled
23:13cemerickbrehaut: using .get, (t _ 1e6) is 10.5s for the vector, 5.2s for the ArrayList.
23:14cemerickThat seems entirely plausible (and not damn bad for the vector IMO).
23:14brehautcemerick: cheers; i tried to run it but did something dumb and my repl died
23:17cemerickInterestingly, the same "benchmark" is consistently ~1s faster for the arraylist under 1.3.0-alpha4.
23:20cemerick,(get (java.util.ArrayList. (range 5)) 0)
23:20clojurebotnil
23:20cemerickamalloy: ha-ha! ^^ :-P
23:20amalloyah. it doesn't work :P
23:20amalloyi thought i'd tried that, but i see now that i didn't
23:20cemerickWe got tarred on that one.
23:20cemerickjeez, there since 2008! https://github.com/clojure/clojure/commit/1c9de854a30e116e502c2d0bebaadce8f80219fb
23:21cheezeyim doing (map f (map b l) l) where b is a buffer, f is some function and l is a list of numbers
23:21cheezeyand f seems to never be called ;x
23:21cheezeyer sorry
23:21cheezeyb is not a buffer
23:22cheezeyb is an associative array (integer -> string)
23:22qbgcheezey: map is lazy
23:22qbgIf you never use the result, nothing will be computed
23:23cheezeybut it looks like im using it :X (in f)
23:23Scriptorcheezey: what you need?
23:23qbgYou can use doall/dorun to force computation
23:24qbgIf this is for side effects only, doseq might be a better choice
23:28Raynescheezey: "lazy" means that none of the function calls that create the new sequence are evaluated until you actually use them. By use them, I mean try to get them out of the collection.
23:28cheezeyqbg: can i use doseq with multiple sequences
23:28cheezeybecause it does not seem like i can D:
23:28qbgIn a nested fashion yes; in a parallel fashion not as easily
23:28RaynesNot like you can with map.
23:29cheezeyRaynes: yea. i thought by passing it to a function, it would count but i guess not
23:29qbg,(doseq [[x y] (map list (range 10) (range 10 20))] [x y])
23:29clojurebotnil
23:29qbg,(for [[x y] (map list (range 10) (range 10 20))] [x y])
23:29clojurebot([0 10] [1 11] [2 12] [3 13] [4 14] [5 15] [6 16] [7 17] [8 18] [9 19])
23:29qbg^ That is just nasty though
23:29Scriptorsomewhat random question, does anyone know what rich hickey used to make his presentations? I need something that can embed code
23:31cemerickPretty sure he uses keynote.
23:31cemerickNot sure what's used to do the code highlighting. I doubt it's builtin.
23:31cheezeyqbg: what do you mean by nasty. inefficient?
23:32qbgNot very beautiful
23:32amalloydisgusting
23:32cheezeywell is it worse than (dorun (map ..
23:32cheezey?
23:34Scriptorargh, dammit my client lagged out
23:34Scriptorsorry to bother, but if there were any responses to my question, could someone repost them?
23:35cemerickPretty sure he uses keynote.
23:35cemerickNot sure what's used to do the code highlighting. I doubt it's builtin.
23:35Scriptorhmm
23:35qbgYou can also embed code in Beamer
23:36Scriptordon't have much experience with latext, unfortunately
23:37cemerick"and the LaTeX shall rise again" eh ;-)
23:37cheezeyScriptor: i think beamer makes the presentation pretty easy even if you don't know latex
23:38Scriptorcheezey: really? I'm trying to find some docs for it now
23:39qbgYou can cargo-cult it to a large degree
23:41Raynescemerick: I recently migrated my entire book to markdown. Using pandoc to generate the latex and pdfs. :D
23:41cheezeyScriptor: i only used beamer like twice before but i think so. you might get frustrated by fixing small details since you're new to latex..
23:41RaynesIt's pretty cool.
23:41cemerickRaynes: That sounds very sane. :-)
23:41cemerickWe're using asciidoc, which I've come to like quite a lot.
23:41qbgHopefully it is markdown -> latex -> pdf and not just markdown -> pdf
23:42RaynesOf course, I still had to touch some latex (just a template) to get it precisely how I want it.
23:42Raynesqbg: Of course.
23:42RaynesHow does that work out?
23:43RaynesSomeone else typeset it for you?
23:43cemerickIt's entirely automated. No latex in the process though, either.
23:43cemerickO'Reilly doesn't like latex much, AFAICT. They're big on semantic markup.
23:43Raynesasciidoc can, by itself, output that pretty?
23:44RaynesThat's insane.
23:44cemerickno
23:44cemerickit's asciidoc -
23:44cemerick.
23:44cemerickbah
23:44qbgDidn't they use a lot of troff in the past?
23:44cemerickit's asciidoc -> docbook -> ???? -> PDF
23:44RaynesOh, docbook.
23:44RaynesPandoc can generate docbook as well.
23:44RaynesBut, since I don't plan to publish with O'Reilly... LATEX!
23:45cemerickqbg: don't know about the history. The /Creator of our PDF proofs is "XSL Formatter", so I'll bet they're going from docbook -> FOP -> PDF
23:47RaynesI'm happy I found pandoc.
23:48Raynesmarkdown-mode + emacs + pandoc = Lyx being uninstalled.
23:48Scriptorhmm, I just found https://github.com/schacon/showoff
23:48Scriptormight just do the trick
23:48qbgI'm liking markdown a lot after using on the github wikis
23:49RaynesI have equally pretty (if not prettier) output and more control without the clunky and ugly Lyx WYSIWYG editor.
23:49Scriptorqbg: same here, it has pretty much everything you'd need to write some simple but good docs
23:50Scriptorusing it with github pages is a sweet combo
23:50amalloyyeah, i have to say i've barely used markdown but it's pretty convenient
23:50Raynesschacon's Progit book was written using pandoc and markdown.
23:50cemerickAs sad as it is, I can *never* remember the order of href/text in markdown links. Never.
23:51qbgThen again, I've always liked the simplicity of CLHS
23:51cemerickAnd if I get the order right, I mix up parens and brackets.
23:51technomancyit bothers me on some level that markdown is implementation-defined
23:51technomancywith an unmaintained implementation
23:51Scriptorcemerick: using it on reddit alot finally hammered it in :)
23:53cemericktechnomancy: implementation_s_ in the plural. Every impl has its own little extensions. :-(
23:54qbgI wonder if there is support for blinking in at least on implementation...
23:55Deranderqbg: doesn't markdown support arbitrary html?
23:56qbgI haven't used markdown much yet
23:56RaynesYes, there is.
23:56RaynesYou can embed HTML into it.
23:56Deranderqbg: then yes, there is blink support :-)
23:56RaynesI've used <div style="center">some text</div> to center text in markdown before.
23:56DeranderI wonder if there is a jquery plugin to add blink support to browsers that no longer include it
23:56Raynesalign: center, even
23:57DeranderI still use <center> occasionally
23:57Deranderwhen I'm feeling really lazy
23:57Derander:-9
23:57RaynesI was tempted, but figured I'd be better off to use the former. I only had to do it twice.