#clojure logs

2010-04-01

00:00hiredmantela: delay is the same, but synchronous
00:02telaI'm trying to evaluate a tree structure where each node is a stochastic function of the children. The children might be shared sometimes, though, and I want to only run the shared children once even if two evaluation paths simultaneously request it. The tree gets evaluated over and over though so delay is worrisome. I'll have to try it out though.
00:02hiredmanI don't think you understand delay
00:03hiredman,(let [a (delay (println :foo) 1)] [@a @a])
00:03clojurebot[1 1]
00:03clojurebot:foo
00:05telayes, but I want to be able to call @a later and have it redo the computation. I'm thinking I'll just have to keep a step counter and generate a new delay if the step isn't in uptodate.
00:07telahiredman, but yes, I think those are the semantics I was looking for. Thanks :)
00:36Crowb4rheh, youtube aprilfools jokes you never get old
00:37shadowsparI only wish this was real; I wouldn't have to make 4 trips for coffee every morning =) http://bit.ly/Plenta
00:37cp2heh
00:39alexykhow do you efficiently supply the f to merge-with here instead of conj:
00:39alexyk, (merge-with conj {:a 1 :b 2} {:a 2 :c 3})
00:39clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection
00:40alexykto achieve {:a [1 2] :b [2] :c [3]}
00:44telaalexyk, best I can do would be #(if (seq? %1) (conj %1 %2) (list %1 %2))
00:44alexykyeah, seems like we'll have to check type always
00:45noidi,(seq? [])
00:45clojurebotfalse
00:46noidiso you might want to use coll? instead
00:46alexykI want a vector anyways
00:46noidiI have this in my util.clj
00:46noidi(defn ensure-coll [x] (cond (coll? x) x (nil? x) [] :default [x]))
00:48cheezeyso uhh.. im new to this. does clojure have pattern matching of some sort? O_o
00:48telanoidi, yeah, that's a good one to keep around
00:48noidicheezey, not built-in, but there are libraries for that
00:51telacheezey, well, there's some built in on sequences
00:51alexyknoidi: thx
00:51tomojhmm
00:51tomojwe can do this more efficiently I think
00:51alexyktomoj: how?
00:51defnhow do I do a println but suppress nil?
00:52tela,(let [[x [a & os]] (list 10 (range 3))] (* x (+ a (apply / os))))
00:52clojurebot5
00:52tomojfmap over the Maybe monad?
00:52tomojdefn: ^ ;)
00:52defnheh
00:53defnfor some reason i remember there being a println which suppressed newline
00:53defni can always just write my own i guess
00:53defnerr not suppressed newline, but didn't return nil
00:54defnmaybe im thinking of something i read in stuart's book...
00:54hiredman,(doto :x prn)
00:54clojurebot:x
00:54clojurebot:x
00:56noididefn, what do you want to return, if not nil
00:56defnnothing, i just want it to be blank
00:56defnso i get a println, but no nil at the end
00:56defnis that possible?
00:56noidinil is the blank return value :)
00:56noidiyou only see it in the REPL because it prints all return values
00:56defnyeah nvm, im reading the source and yes that makes sense
00:57defnthanks noidi && hiredman
00:58telaalexyk, if you know the keys how about
00:58tela,(merge-with conj {:a () :b () :c ()} {:a 1 :b 2} {:a 3 :c 1} {:a 5 :b 3})
00:58clojurebot{:a (5 3 1), :b (3 2), :c (1)}
00:58noidibut you are right, it would make sense for the REPL to not print nil return values
00:58noidior nil's at all
00:58defnim just building this thing: http://github.com/defn/walton
00:58noidithat's what Python's REPL does, and I don't remember it ever causing any trouble
00:58defnand id like to print an example without the trailing nil, it just looks better
00:59tomojtela: genius!
00:59noidimaybe you could write your own read-eval-print loop?
01:00tomojoh, but you have to know the keys
01:00tomojhrmm
01:00tomojmaybe you could make an Associative that always gave ()
01:00telatomoj, I'm trying to find a way to have (constantly nil) fit the associative interface
01:00tomojand use that as a starting point
01:00tomojwith deftype I was thinking
01:01telahm, deftype I have not touched
01:01alexyktomoj: simple, we prepend a map like the first with []'s
01:01tomojbut the first might not have all the keys
01:01alexykyeah... argh
01:05tomojnoidi: well, my try was (defn ensure-coll [x] (case (empty x) (()) x [x])) but this turns out over twice as slow
01:07tomojalso doesn't work with sets
01:08tela,(merge-with conj {:a #{} :b #{} :c #{}} {:a 1 :b 2} {:a 3 :c 1} {:a 5 :b 3})
01:08clojurebot{:a #{1 3 5}, :b #{2 3}, :c #{1}}
01:08telahaha
01:09tomojso what you need is a generator for constant assocatives
01:09telaor just bakedin defaulting, a la Ruby (iirc)
01:11tomojhttps://www.assembla.com/spaces/clojure/tickets/231-deftype-cons-doesn-t-support-maps-
01:11telatomoj, wait, no. A generator wouldn't work because it would still have to know the names of all the keys that will be visited to prime the pump. Really just need a conj that wraps atoms if it's called on one.
01:12tomojno, that's what I'm saying
01:12tomojthe generator will give you something that acts like an Associative but returns the constant no matter what you give it
01:12tomoje.g. (get (the-generator []) x) will always return [] no matter what x is
01:13tomojbut it looks like that bug prevents you from doing this with a deftype
01:13telayeah, but the way merge-with works it'll think the generator is empty and not start off the reduction with the empty sequences. You still need to know all the keys upfront.
01:13tomojit was set to "Approval" like yesterday
01:13tomojno, you don't
01:14tomojhmm
01:14tomojthere is a problem, though
01:14tela,(merge-with conj {:a ()} {:a 1 :b 2})
01:14clojurebot{:b 2, :a (1)}
01:15tomojright
01:15tomojbut it won't be {:a ()}
01:15telaexactly
01:15tomojit'll be a deftype which always returns ()
01:15tomojso when it's asked what it's value for the key :b is, it'll return ()
01:15telawhat does (keys <generator>) return though?
01:15tomojsome bogus value
01:16tomojthe problem is that when conj does support deftypes, it probably won't mysteriously change the deftype into a hashmap
01:18tomojactually, why can't we just implement cons in IPersistentCollection and have it return a hash-map?
01:18telatomoj, no, no, I don't think so. Even given a generator that behaves the way we're thinking, unless the generator can provide a decent respose to (first <generator>) it won't work. That's the problem I see. You can't reduce over this generator.
01:19tomojyou don't need to reduce over it
01:19tomojyou only need to reduce over the maps you pass to merge, the first of which being the generator
01:19tomojmerge only calls conj on the generator
01:20telatomoj, ugh, I read it backwards. You're right.
01:21tomojhmm, wait, I don't have my head on straight
01:21tomoj(partial merge) is not (partial merge-with conj)
01:24miltondsilvaany ideias how to condense this? [(.nextFloat s) (.nextFloat s) (.nextFloat s)]
01:24tela,(merge-with conj {:a ()} {:a 1 :b 2})
01:24clojurebot{:b 2, :a (1)}
01:24telatomoj, that's the clincher: the first hash doesn't "know about" b so it doesn't get wrapped.
01:25tomojmiltondsilva: (take 3 (repeatedly #(.nextFloat s)))
01:25tomojtela: you're not being liberal enough
01:25tomojthis is a deftype
01:25tomojit can do whatever the hell it wants
01:25tomojit can say it contains every key
01:27miltondsilvatomoj: thanks.. I was using repeat.. (of course it wasn't working)
01:29telatomoj, okay, yeah, it only needs to define [contains? (constantly true) get (constantly nil)]]. I need to not do this so late at night.
01:30cp2alexyk: not sure if this is still relevant, but
01:30cp2,(reduce (fn [m [k v]] (assoc m k (conj (m k []) v))) {} [[:a 1] [:a 2] [:b 1] [:b 7]])
01:30clojurebot{:b [1 7], :a [1 2]}
01:30cp2might be of use to you
01:31cp2im sure i ripped that off of chouser or someone =P
01:34tomojhmm, I've never been around when Peer reset my connection before
01:35alexykcp2: interesting
01:36tomojtela: you were right
01:36tomojthere's a problem
01:37tomoj(merge-with conj (ConstantAss []) {:a 1 :b 2} {:c 4 :d 3})
01:37tomoj{:d 3, :c 4, :b 2, :a [1]}
01:38tomojoh, and if there's a duplicate key, it just explodes
01:38tomojhaha, check this out
01:38tomoj,(merge-with conj {:a [] :a 3})
01:38clojurebot{:a [], :a 3}
01:39tomoj,(merge-with conj nil {:a [] :a 3})
01:39clojurebot{:a [3]}
01:39cp2hehe
01:39tomoj,(merge-with + {:x 1} {:y 1 :y 2 :y 3})
01:39clojurebot{:y 6, :x 1}
01:40cp2alexyk: i have a gift for you :D
01:40hiredman,(doc merge-with)
01:40clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
01:41cp2alexyk: http://gist.github.com/351421
01:41cp2forgive me, it's pretty nasty
01:41cp2=P
01:42alexykoy
01:42alexykhiredman: what are you implying?
01:43tomojto get this generator to work, it needs to stay around until the end
01:43tomojso you'd need to also have a function to convert back to normal
01:44tomojotherwise you will still have its weird behavior at the end
01:44tomojbut it can build up an internal hash-map which it always checks and returns the constant if the internal map doesn't contain a key
01:45tomojthen the function just pulls that internal hash-map out
01:46tomojhmm.. I have a 'scratch' project for miscellaneous stuff, so this namespace is scratch.constant-ass
01:46hiredmanthe behavior of map literals with duplicate keys is undefined, so what you are seeing is that undefined behavior contaminate everything it passes through
01:47tomojyeah
01:47tomojI'm fine with that since it's only literals..
01:47tomojjust funny
01:47hiredmanso don't use map literals with duplicate keys
01:47hiredmanit's annoying
01:47hiredmanarraymap should really throw an exception
01:48tomojyeah, and that would be fine since it's never going to happen after you've verified the program works
01:48tomojunless you're dynamically evaling some code which contains a bad literal map
01:49tomojbut it would be like a compiler error
01:54tomojoh shit
01:55tomojI just realized that NEAT historical markings can just go into metadata in clojure
01:55tomojmaybe they're not meta enough
02:12miltondsilvawill clojure in clojure help with the cryptic java msgs?
02:19defnAnyone have any suggestions for an arg parsing library?
02:19tomojhmm
02:19Raynesdefn: Make it parse arguments. ;P
02:19tomojif you find something, let me know
02:19defnI mean it's not totally needed
02:19defnbut something more robust would be nice
02:19tomojhow hard is arg parsing, anyway?
02:20defnnot very...
02:20defnbut there are some fancier things i think one could do to make things a bit more clean and sane
02:20tomojI gots an idea
02:22tomojdefn: staying up late?
02:23defntomoj: ill be here for oh, another... 6-7 hours
02:23defntomoj: what's your idea?
02:24tomojit's actually sortof an idea I've had for a while now
02:24tomojbut your mention of option parsing made something click in my head
02:24defndo tell! :)
02:24defnyou can PM me if youd like
02:24tomojhmm
02:25tomojthe original idea was just to automatically generate developer tools from clojure code
02:25defn"generate"?
02:26defnlike what sort of tools
02:26tomojjust write plain clojure functions, or maybe use some macros, and you get a tool
02:26tomojthe original idea was irb like consoles
02:26tomojin which, of course, you'd have access to a full clojure repl
02:27tomojbut option parsing makes me think of generating command line tools
02:28tomojif you look at the example from http://docs.python.org/library/optparse.html
02:28omakasehow do i cast a string to an int/long?
02:28tomojwho really gives a fuck which letter is picked for the option
02:28tomojwe can just use the argument names to the function
02:29tomojonly need a way to provide defaults and documentation, perhaps with a special syntax in the docstring
02:29tomojor metadata maybe? dunno
02:29Raynesdefn: Licenser is making me make a Walton plugin, which in turn means I had to look at Walton. Cool stuff, bro. :D
02:29RaynesWalton plugin for my bot, even.
02:29tomojwalton?
02:30tomojgoogling seems futile
02:30TheBusbyOmakase: Integer.parseInt I think
02:30Rayneshttp://github.com/defn/walton
02:30defnhttp://github.com/defn/walton
02:30defnoops
02:30tomojah
02:30defnRaynes: Yeah I'm excited to get it into a bot
02:30defnthe latest version should be a lot closer to "working"
02:30defnalthough it is still a bit shaky at times
02:30Raynes,(Integer/parseInt "3")
02:30clojurebot3
02:30Raynesomakase:
02:30tomojthat is a great idea
02:31defnLicenser has done a ton to help me get it working how I wanted it to. It's slowly getting there I guess.
02:31Raynesomakase: Also, there is read-string, but it reads /anything/.
02:31Raynes,(read-string "3")
02:31clojurebot3
02:31TheBusbywould be great if that got added to core somewhere. Kind of strange to have to go out to java just to transform an a string into an int value
02:31Raynes,(read-string "{:a 3}")
02:31clojurebot{:a 3}
02:32RaynesTheBusby: No, it's not strange. Direct interop with Java is idiomatic.
02:32defnRaynes: I was thinking about a couple things for bot integration... 1.) Have the bot point to examples which exist on the website I'd like to generate using the current data. 2.) Have the bot intelligently give examples in a PM, since sometimes they can be very bad examples, even though they work in the sandbox.
02:33Raynesdefn: I need to take off, but I'll read that in a few hours.
02:33tomojRaynes: what bot are you using?
02:33defnRaynes: Licenser had a great idea wherein the bot would actually parse new sexps as they come in, reducing all of the extra up front processing.
02:34tomojwell, you still have to do up front processing to get at the history, don't you?
02:34tomojjust the running bot doesn't have to go fetch logs?
02:35TheBusbyRaynes: java interop isn't necessarily appreciated for such simple operations though. It implies you can't use clojure without knowing java first.
02:37defntomoj: what happens is that the sexps which run in the sandbox are tagged as :good, and the ones that dont are tagged as :bad in a ref
02:38defntomoj: there's a cool addition today to walton where you can (background-init-walton), which parses and runs the sexps in the background, so you can search almost immediately
02:39defntomoj: it would be ideal if the bot could just continue to add to the ref as the channel moves on
02:39defnperhaps serialize a daily snapshot or something?
02:40defnbtw, does anyone have good #clojure irc logs? I'm missing some days, from 03-09 to 03-16
02:41tomojdefn: ah, I see
02:41defnim sure chouser does, but id like to setup a crontask to update a tar.bz2 on my server to have a constant daily update of logging, a snapshot, if you
02:41defnwill
02:41tomojI was probably here but I don't stay around all the time
02:41defnnod
02:41tomojer, and my logging setup actually sucks
02:42defnI need to really have two sessions in here, one at this location, and one at the other, to make sure I don't miss anything
02:42defnand then diff
02:42defni also need to quit jabbering in here so much so I don't flood my app with a bunch of useless data. :)
02:44defnAnother fun idea, if anyone is interested -- I have had some emails back and forth with someone who has been discussing indexing stackoverflow's clojure questions, the mailing list, irc, disclojure, planet.clojure.in, etc. -- and make a full syntax search engine for clojure syntax
02:45defntomoj: also, @optparse, i still guess i do not see exactly what you mean, i think being able to make handy command line tools for clojure would be really nice -- i was thinking about something similar where you'd just have a sort of modular repository which is added to your PATH, and you could just drop .clj files into it and have them be executable
02:46tomojthat would be nice, but doesn't handle option parsing, does it?
02:46defnperhaps some sort of dynamic way of updating the project.clj, running lein deps automatically, etc.
02:47defntomoj: not really :X :)
02:47tomojhow could you possibly update project.clj?
02:47tomojI mean, how could you determine which deps need to be added?
02:48defntomoj: well it is just data, I was thinking you just parse the (ns) macro in the clj file which is added, and if it doesn't exist in the project.clj, you add it, you also add the file to the :namespaces
02:48defnsomething like that
02:48tomojbut 'lein deps' is only for external maven deps
02:48tomojand you don't know where to find those based on just the ns, do you?
02:49defni guess not. maybe the best thing to do would be to have a little map in the file which tells us which deps it needs?
02:49tomojyeah, that doesn't sound bad
02:49tomojone of my initial ideas was that it should be doable without changing the source you're using to generate the tool
02:50tomojbut realistically, this will probably not work very well anyway unless the author wants it to
02:50tomojand being able to easily wrap an external library and take care of the problems with a little bit of code like you suggest would be nice
02:50defn*nod* -- however... I can see simple .clj files which do not rely on external libraries working just fine
02:51tomojmaybe you just need an installer
02:51defnif the map doesn't exist we just assume all it needs are clojure.*
02:51defnyeah that could work
02:51tomojwell, what about this
02:52tomojer, well, I was thinking you could just deploy to clojars and then "installing" this little bundle of tools is just adding it as a maven dep
02:52tomojbut that loses the simplicity of just writing a single .clj file
02:52defnyeah and i dont really want to deploy everything i want to use to clojars.org
02:52defnthat would make clojars.org very messy
02:52tomojwell, you could also just lein install locally, but, yeah
02:53tomojthe kinds of tools I was thinking of were pretty large suites
02:53defni still haven't learn how to build lein modules
02:53defn:\
02:53tomojlike a suite for managing cloud clusters
02:53defnerr add lein tasks
02:53defntomoj: ah
02:53tomojapparently you can define tasks in project.clj
02:53tomojbut I don't know how
02:53defnyeah -- no one does! :)
02:53tomojthere's just that one commit that says "it's possible now"
02:54defnheh
02:54tomojwith an obscure change
02:55defntomoj: let's make a repo!
02:56defntomoj: heh -- i can't guarantee ill work on it tbh, but i would like to make a handy little "make this .clj a command line tool" sort of thing
02:56defnthat's something id work on
02:57tomojmy boss apparently thinks the company owns this idea
02:58tomojbut I am sure he would allow me to open source any work I do on the general framework, if not the cluster management tool
02:58defntomoj: ive been meaning to ask someone more familiar with that...
02:58tomojalso, I'm pretty sure I've got the legal upper ground
02:59tomojin fact, they've only ever paid me a one-time bonus check, and I've signed nothing, so :P
02:59defnif i open source something before being allowed to do so
02:59defnas in, i just throw an epl on it
02:59defnis that binding?
02:59tomojif they really have a legal claim to it, I'd think not
02:59tomojjust like you can't take someone's GPL and slap a copyleft on it
02:59defnnod
03:00tomojbut I don't know what it takes for a company to acquire the copyright
03:00defnit makes me sort of worried about some of the things ive been working on at work
03:00tomojI do all my work at home, so it's even more worrisome
03:00defnive just been hacking around on clojure building little things for fun here and there
03:00defni get a couple hours per night to do that -- just messing around, but someone started using one of the tools, and i hope they do not try to claim it as their own
03:00tomoj(more worrisome that it would be if I had a clear separation I mean)
03:01defnnod
03:01tomoj"many software engineers can be independent contractors. Without a written agreement, they may own the software they created.."
03:03tomojI would like to read about how to determine whether some side project you made belongs to you or not, but don't know how to google it
03:03defni am not primarily employed to write code
03:03defni wonder if that factors into any of this
03:03ajatomoj: Most jurisdictions have the concept of "work-for-hire". If you were paid to generate something, it may default to ownership by the payer, even if there is no explicit transfer.
03:05defnat the very least i need to do it on a laptop that is not company owned -- all my tools and snippets are on this machine
03:05ajatomoj: Also, if you used company resources (time, bandwidth, pencils, etc.) in development, that may be sufficient, even if you weren't explicitly hired to develop the product.
03:06defnaja: what if i printed a book on a company printer to learn a language? is all of that knowledge then owned by the company i work for?
03:07tomojdamn, this connection sucks
03:08tomojbut what if the employer never told me to make it?
03:08ajadefn: No, because knowledge does not constitue property (cannot be owned), and consequently wouldn't be the subject of a contract.
03:08defnaja: ah, okay
03:08ajatomoj: Again, if you used resources owned by the company (including time they paid you for), they may have a claim on the product.
03:09defn*may* is the operative word
03:09defnthey would need a good reason to want it in the first place -- which in my case, given how scared they are of using clojure, is a non-issue
03:09ajadefn: Note that things like non-compete clauses may restrict what you can *do* with your knowledge, but those are often unenforceable.
03:09tomojthe problem is, of course, to distinguish between time they paid me for and time they didn't
03:09tomojis my whole life now being funded by the company?
03:09defntomoj: if you do time tracking you have records
03:09ajadefn: Of course, "may" is operative. But in cases like that, the issue is often won by whoever has more money for lawyers ...
03:09tomojif I arrange my breakfast cereal in a neat pattern and try to sell it as modern art, are they going to sue me?
03:10ajatomoj: It's not black-and-white. It's a gradient. THere's stuff that is clearly your IP, stuff that is clearly the company's, and a huge freaking swath of arguable in between.
03:11tomojyeah :(
03:12ajatomoj: In general, if developing stuff for yourself, do not do it at work, do not do it using company resources, and do not do it during work hours. Or, of course, make an explicit agreement with your employer, which is often best.
03:12tomojyeah, makes sense
03:12tomojand in my current case I am sure open-sourcing will be feasible, which is all I'd want to do at this point anyway
03:13tomojopen-sourcing stuff seems to be very popular for cool web shops
03:13nvoorhiesif you're not an employee then it's not work for hire unless you explicitly say so in writing, btw
03:13tomojhah
03:14tomojI can't go sell all their trade secrets to a competitor, though, can I?
03:14nvoorhiesNot that that matters if it's the choice between paying a few thousand $ for a lawyer over something you don't care that much about
03:14ajanvoorhies: Depends on the jurisdiction and case law.
03:14tomoj(not that I would... this is an awesome job)
03:14tomojs/is an/will be/
03:14nvoorhiesI'm just going by federal law tho
03:16sparievdefn: hello, re: search engine for clojure code - it would be very cool and useful project, do you know about it's current status ?
03:19sparievdefn: doing smthg with clojure examples seems to be a trend - I wrote http://github.com/spariev/find-example last weekend, only to realize in Monday that it's basically a copy of your cljex :)
03:20tomojhmm, I wonder if I can round-trip clojure code in a source file -> emacs -> pass through a clojure fn -> back to emacs -> pretty print with proper indentation and replace in source file
03:20tomojso you can program your editor in clojure
03:21RaynesTheBusby: I don't believe it implies that you need to know Java. It implies you need to be able to google "parse int from string java", maybe. :p
03:22TheBusbyRTFM works great when it's mentioned in teh documentation
03:22TheBusbythe fact that it doesn't appear in clojure books though...
03:22tomojsome day in the future, we will want to move all this stuff into clojure, no?
03:23tomojotherwise code will be more incompatible across various implementations
03:23TheBusbyit would be great if we just had an alias for it in core
03:23tomojI think rhickey had mentioned some kind of implementation-independent numbers classes before
03:23tomojthose would presumably come with handy fns
03:23TheBusbyyou'd think this kind of thing would drive the CLR guys nuts
03:24tomojyeah
03:24tomojmy boss sent me a link about using memory-mapped files for IPC in .NET 4.0 and mentioned this would have interesting implications for clojure
03:25TheBusbyI haven't had any luck with mmap and java/clojure yet, still using C unfortunately
03:27tomojI don't yet understand what the benefit is
03:27defnspariev: my cljex is not so good, so feel free :)
03:27TheBusbybeyond offering blinding IO speed, two processes can mmap the same file to essentially share memory in some cases
03:28defnspariev: i have not worked on a search engine for clojure code (yet)
03:28TheBusbyI just use threads if I need to share memory, but I could see where you could pull off some interesting tricks using mmap for IPC
03:28defnspariev: i am not a search guru, so I'm not sure how to approach such an operation
03:29defnspariev: also check out my walton project
03:29sparievdefn: I'm thinking about piggybanking on walton for find-example - running through irc logs and carefully handpicking the best examples, benefiting from your hard work :)
03:29defnhehe, that's what i planned on doing
03:29defncljex has sort of been abandoned, and one of my TODOs for walton is to generate a website of examples :)
03:30defnspariev: consider maybe forking walton and adding something like that?
03:30defnspariev: either way feel free -- it's great to see people working on the same types of stuff
03:32defnspariev: it would be nice if we could, on the website, vote on the quality of an example
03:32defnadd a new example, etc.
03:32sparievdefn: yep, that's something I'm thinking about
03:34sparievdefn: would be nice to have a) some handpicked examples, b) indexed irc logs and blog posts from planet clojure, wikibooks and stuff in one place, with web-interface and some means to access it from repl
03:34sparievi wish i had 48 hours in a day :)
03:35tomojTheBusby: ooh, I get it
03:35defnhaha -- well perhaps some modularity would be nice
03:35tomojI was thinking that IPC meant multiple threads
03:35tomojeven though I knew what it stands for
03:35tomojdefn: and the protocol?
03:35tomojor just combine them in clojure?
03:36defntomoj: havent decided on that yet...any thoughts?
03:36tomojdunno, I don't have a good understanding of what would be required for your project
03:36tomojI kinda like json, though :)
03:38defnspariev: i do own getclojure.org btw, that's a good place for something like this IMO, but there are plenty of other catchy names :)
03:39defntomoj: i really have no preference -- json would likely work just fine
03:39sparievdefn: I've got clj-examples.appspot.com already :)
03:40sparievanyway, I should code somthing first, then talk on site names )
03:44defnspariev: hehe -- well, if you'd like to not duplicate work, consider forking walton -- im very open to changes
03:47Raynesdefn: I don't know about the up front parsing, at least not initially, but I suppose the website pointing stuff would be simple.
03:47RaynesWhen will there be such a website?
03:48sparievdefn: yep, definitely, I'm thinking of merging find-example functionality into walton, or something like this
04:07defnRaynes: within a week hopefully
04:08defnmy goal is to have the whole basic functionality of web front end + irc bot by that point
04:08defnit likely wont be pretty, but should be close...
04:09defnspariev: any interest in using enlive and moustache?
04:11sparievdefn: I've used only compojure so far, but enlive/moustache will do
04:12defnspariev: compojure is fine also -- it's been around longer so it has that going for it
04:35tomojI am also thinking of switching to moustache
04:40Raynesdefn: Yeah, I was going to point out that somebody might want to develop a bot specifically for the purpose of walton, because my bot does all sorts of stuff, and likely wouldn't be welcomed in here since clojurebot runs the house. ;)
04:40RaynesHowever, I'll still work walton into my bot just for awesomeness.
04:45bsteuberraynes: I don't think anyone would mind another bot around - if it gets us sth. new
04:46RaynesJust saying. Some channels are picky when it comes to bots. Of course, mine doesn't do anything disrupting unless you make it.
04:46Raynes;P
04:46LauJensenMorning team
04:47RaynesMorning.
04:47LauJensenRaynes: What does your bot do, that clojurebot doesnt ?
04:47RaynesLauJensen: Google Translate and quote-like stuff. :p
04:47LauJensenOh
04:47RaynesNaw, I'm not really sure. I don't keep track of what it can do.
04:48LauJensenThen ehm. I'm sure he'll have fun in #casual
04:48RaynesIt does lots of stuff that clojurebot doesn't do, but most of it isn't very useful for the purposes of this channel.
04:48RaynesI believe he was considering the possibility of me adding walton to the bot.
04:48RaynesWhich would give the channel something new.
04:49LauJensenwalton being?
04:49Rayneshttp://github.com/defn/walton
04:49RaynesOnly the coolest thing ever.
04:50LauJensenah nice
04:50LauJensenThat is cool
04:50LauJensenDoes it take in account all the failed examples?
04:50RaynesYou'd have to ask defn about that.
04:51LauJensendefn: Does it take in account all the failed examples?
04:52RaynesI don't guess it really matters.
04:52RaynesBut at 4:00am, it's a difficult decision.
04:52LauJensenproperties
04:53RaynesAny specific reason? To be honest, I don't really know what property files are for.
04:54RaynesExcept storing information.
04:54RaynesThat's obvious. It's the general use case I'm not sure of.
04:54LauJensenAnd what is JSON for ?
04:54RaynesAll sorts of stuff.
04:55RaynesIt's for keeping me from having to use XML.
04:55Raynes:D
04:55LauJensenhehe
04:56LauJensenOk, I guess you're right in saying that is has several purposes, specially storing data is not one of its design objectives, but properties are - does that help you make a decision? :)
04:56RaynesI suppose, but I use JSON to store data in other parts of the bot anyways.
04:57LauJensenI guess if its important to repeat mistakes then you should go with JSon :)
04:58RaynesI didn't use properties because they didn't seem to fit with the quote-like stuff.
04:59LauJensenI guess what matters most is, do you need to pass it along again, via some webservice or is it for internal use
05:00RaynesIt's for internal use.
05:00Raynesinb4propertiesidiot
05:01RaynesBut, aren't properties mainly just for outside configuration and such? It seems silly to use them to dynamically store quotes and such. Of course, that is probably something a database should be used for, but it feels like overkill.
05:04bsteuberRaynes: why not clojure data structures?
05:05Raynesbsteuber: Indeed, I could just as easy use a map in place of the JSON in general.
05:05bsteuberyou just get problems if you need to reed the stuff from outside clojure
05:06RaynesWhich would never happen.
05:06Raynes,(read-string "{\"hai\" \"thar\"})
05:06clojurebotEOF while reading string
05:06Raynes,(read-string "{\"hai\" \"thar\"}")
05:06clojurebot{"hai" "thar"}
05:07LauJensenRaynes: I'll side with bsteuber - Go with a native struct
05:08Raynesbsteuber, LauJensen: thanks for the input. I'll rewrite existing code to use plain ol' clojure files with maps and such.
05:09LauJensenOh and Raynes - Maybe you should stop coding at 4am :)
05:09RaynesLauJensen: I'm considering not sleeping tonight.
05:10LauJensenIn an attempt to get back to a normal routine?
05:10RaynesWell, that and I have to go to the bank in around 5 hours anyway.
05:10LauJensenOk
05:11RaynesSlurp is my friend.
05:11LauJensenIts annoying, I have this fn, everything is primitives, profiled and optimized. And its still slow
05:14Raynes(doc spit)
05:14clojurebot"([f content]); Opposite of slurp. Opens f with writer, writes content, then closes f."
05:17RaynesAw man.
05:18RaynesLoud noise outside. Probably burglars. I don't have any shells handy. :(
05:20RaynesLauJensen: Don't you love it when stuff works the first time?
05:20LauJensenI sure do
05:20RaynesI actually didn't have to change much code. In fact, it make it made it smaller.
05:20Raynes:D
05:20LauJensenit make it made it smaller? thats great :)
05:21RaynesLauJensen: No json/decode-from-writer and such.
05:21RaynesI'm just read-stringing a map.
05:21RaynesClojure maps make for a great configuration format as well, imo. Readable if indented right and such.
05:21BorkdudeFrom Twitter: ghoseb: Planet Clojure [http://planet.clojure.in] will now redirect to Planet Scala. That's because Scala is my current favorite language.
05:22LauJensenAprils fools :)
05:22Borkdudeomg
05:22Borkdudehahaha
05:22RaynesMan, I haven't heard a decent april fools joke all day. :(
05:22RaynesFrom Twitter: greenrd: I've had it up to here with Linux. From now on it's going to be Vista and Visual Studio all the way. Also, I'm joining UKIP.
05:26LauJensenLinux is for freetards anyway
05:35ambienthi, anyone having trouble with Counterclockwise (Eclipse plugin)? "java.lang.NoClassDefFoundError: clojure/contrib/repl_ln" I got JDK 1.6 installed and in path, installing CCW through Eclipse doesn't just seem to work
05:36BorkdudeI have seen that error before in Eclipse, but I don't remember what it was
05:36LauJensenInstalled without any problems a couple of weeks ago
05:36ambientmy version is 0.0.52.STABLE
05:37ambientEclipse 20100218-1602
05:39Rayneslpetit might be of assistance.
05:40LauJensenambient: I used 20090917-0800 from Ubuntu repos
05:40LauJensenAnd just installed like lpetit shows in the video - Had to retry once due to some server thing, but then it worked
05:40ambientyeah, it might be best to also mention that I'm on Windows
05:40lpetitambient: let's try see exactly what your problem is
05:41lpetitambient: I guess you have this problem when you try to launch a REPL, right ?
05:41ambientrun as > clojure repl, yes
05:41lpetitambient: so it's not an installation problem, for one :-)
05:41ambienti got simple test.clj that has "(print "foo")"
05:42ambientinside a clojure project and java perspective
05:43ambientoh dam. *foreheadsmack*
05:43lpetitI'm thinking more of something along those lines: the clojure-contrib.jar your project is currently referencing does not have repl_ln precompiled. Since ccw makes the (only) hypothesis that your project has clojure-contrib correclty AOT compiled in your classpath, this may explain the problem.
05:43ambienti had an ancient clojure project from earlier and i tried using new CCW
05:43clojurebotclojure is a language to use if you want to up your game
05:44ambientit put clojure-src.jar and clojure-contrib-src.jar on different places (i dont think they even existed back then)
05:44ambientexcuse me for the hassle
05:44lpetitambient: np
05:45lpetitambient: everything back to normal now ?
05:45ambientyes
05:45lpetitgood :)
05:45lpetitpoll: do you appreciate the recent paredit-like additions ?
05:46ambienti'll get back to you on that
05:47ambientalthough i think i just crashed it
05:48ambient(slurp "foobar.txt") > error: wrong path bla bla => *me fixes right path* => crash
05:48ambientyep, eclipse hangs and nothing happens
05:49ambient:D
05:51Rayneslpetit: I see you added auto-indentation.
05:51RaynesGood show, frenchman.
05:51lpetitthx :)
05:52lpetitambiant: maybe this is totally unrelated to the new version. Calling slurp on *big* files on the console/repl can cause it to haaaannnngg
05:52ambientyeah, its about 10 meg
05:52ambientnot a big fil per se imo
05:53lpetitRaynes: yes, and paredit-like functionalities: wrap round, auto-paren inserting. Still missing some, working on it these days by night
05:53RaynesNeato.
05:54lpetitambient: but you called (slurp "foobar.txt") in the REPL directly, without placing it in a variable and preventing it from being printing via the classical (do (def foo (slurp "foo")) nil) kind-of trick ?
05:54lpetityour console is currently trying to display at once 10 meg of textual content !
05:54ambientmy bag of tricks is a bit limited when it comes to clojure
05:54ambienti havent written that much with it
05:54ambientaaa
05:55ambientit doesnt have the environment variable set to something sensible?
05:55ambient*text-length-print-something*
05:55lpetitdefault one. So no, not set to sensible, I guess :-(
05:55ambienti see
05:56ambientfunny, that i can still shoot myself in foot with this high level language ;)
05:57RaynesYou can shoot yourself in the foot with a snorkel if you try hard enough.
05:58ambientpython has proven itself to be fairly idiot proof so far
05:59LauJensen:)
05:59Borkdude,(/ 1 .999)
05:59clojurebotjava.lang.Exception: Unable to resolve symbol: .999 in this context
05:59Borkdude,(/ 1 0.999)
05:59clojurebot1.001001001001001
06:04ambientlpetit ok the paredit type functionality is already confusing me
06:05ambienti cant get other parenthesis to go inside my other ones
06:06BorkdudeI also think inserting parens inside existing sexps is confusing in CC
06:07Borkdudebut maybe I'm not doing it right
06:07ambientits just something i have to learn i guess
06:07Borkdudeambient: you can select the portion which you want to wrap with new parens and then type (, [, or {
06:08ambientyeah, that doesnt really work at all
06:08Borkdudeit works here, but I have to get used to it
06:10ambientit just marks )'s with red and when i try to type "(" anywhere it just creates ()
06:11Borkdudecan you give the code you're editing?
06:11Borkdudeit might be explainable
06:11ambient(first (split-with '\n filu))
06:12ambientthat newline might be very wrong
06:13Borkdude(doc split-with)
06:13clojurebot"([pred coll]); Returns a vector of [(take-while pred coll) (drop-while pred coll)]"
06:14ambientthe issue was with paredit like functionality though
06:15ambienttrying to type ( at the beginning creates (), trying to paint the whole thing and type ( again does nothing
06:15Borkdudedeleting parens is something I'm fighting with in CC
06:15tomojwhy not M-( ?
06:15ambientits not emacs
06:15tomojM-( is not bindable?
06:16ambientseems that it is not
06:18ambientlooks like it wont work for top level s-exps
06:23ambientdeleting double parentheses like ((+ 1 1)) seems to be impossible
06:24Borkdudeyes exactly
06:24BorkdudeI use Ctrl-x for it, but that's a bit clumsy...
06:26ambientcorrection to my previous statement: its only the bottom top-level s-exp that is bugged
06:28Borkdudeambient, sorry, what was bugged exactly?
06:29ambientput cursor inside the bottom top-level s-exp, press shift + alt + up-arrow, press (
06:29ambientnothing happens
06:31Borkdudewhat should happen?
06:31ambient(+ 1 1) => ((+ 1 1))
06:31ambientthat's what happens everywhere else
06:32Borkdudeyou're right
06:32Borkdudethere was also an earlier bug with the last line
06:33Borkdudethat got solved in this version, but apparently they still haven't got the edge cases very well handled ;)
06:33Borkdudemost irritating thing for me is deleting parens though, if anyone has a good tip
06:39maaclWhat is the recommended way of getting a correct result from (- 2.0 1.1) in Clojure? Do I have to resort to BigDecimal?
06:39ambienti dont think you can get correct results with floating points in general
06:40ambientbut then again i dont know that much
06:40Borkdude(doc rationalize)
06:40clojurebot"([num]); returns the rational value of num"
06:42Borkdude(float (- (rationalize 2.0) (rationalize 1.1)))
06:42Borkdude,(float (- (rationalize 2.0) (rationalize 1.1)))
06:42clojurebot0.9
06:43maaclBorkdude: thanks but yikes not pretty
06:43ambient,(- 2 11/10)
06:43clojurebot9/10
06:44Licensermorning
06:44maacl,(- (BigDecimal. "2.0") (BigDecimal. "1.1"))
06:44clojurebot0.9M
06:48maacl,(- 2.0M 1.1M)
06:48clojurebot0.9M
06:48Borkdudemaacl: please read section 4.3 of The Joy of Clojure
06:48maaclThat's better.
06:48Borkdudecalled "Try to be rational"
06:48BorkdudeBigDecimals are also due to precision problems
06:49maaclBorkdude: Due to? prone to?
06:49ambientor if you have fixed point arithmetic you could just use integers everywhere
06:50Borkdudeprone, sorry
06:51maaclBorkdude: really? I thought it was really solid - a lot of banks use it...but that of course does not say much these days
06:51ambientbanks?
06:51ambientuse integers
06:52Borkdudesorry I might be wrong
06:52maaclambient: well, not all numbers are integers, not in banks either
06:53ambienti wonder what values in money transactions are not integers
06:54maaclambient: interest rates
06:54ambientbut if you have 17.34% interest rate thats just 1734
06:54ambienti digress
06:55Borkdude,(/ 1 3M)
06:55clojurebotjava.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
06:55cemerickno sane person in a financial inst would use anything other than integers
06:55Borkdudethat's where you are going to run in trouble maybe
06:55maaclcemerick: apparently they do
06:56cemerickSure, that's doesn't mean it doesn't happen, but there are very real consequences.
06:56ambientone would ask oneself how long will that bank stay afloat
06:59maaclambient: a lot of them don't for very long
06:59maaclhttp://bit.ly/cGf6ln
07:00ambienti've seen some really crappy programming in some banks that are still alive, after 5 years
07:00maaclStory about Groovy at Mutual of Omaha highlighting BigDecimal
07:01LauJensencemerick? 5 AM already?
07:02ambienthmm, enclojure latest release is 2009-08-25. trouble?
07:02cemerickLauJensen: nah, it's 7 :-)
07:03cemerickambient: you're looking at a stale page somewhere: http://github.com/EricThorsen/enclojure/downloads
07:03ambientok, thanks
07:03cemerickambient: where were you looking?
07:04ambienttoo tired, too much caffeine equals too much typing on irc much nonsense, apologies
07:04ambientcemerick enclojure home page
07:05cemerickah, the download link redirects properly, but that headline isn't helpful, is it? :-/
07:05ambienti suppose that was a rhetoric question, but no, it isn't
07:12lpetitBorkdude: yes, there is a trick for removing parens = add a space, and kill paren+space all at once
07:12lpetitI note the problem with the bottom sexpr, will correct it tonight hopefully
07:14lpetitWhen more of paredit is ported, those problems will hopefully have a more decent solution. I intend to provide the "Escape" touch as a way to disable paredit for a while, for example
07:18Borkdudewhy won't it let me just remove a paren if I want to?
07:23RaynesBorkdude: Because mismatched parens make paredit cry.
07:24BorkdudeRaynes: what about the inverse of typing ( with a selection?
07:25RaynesSay what?
07:25BorkdudeRaynes, for example: ((foo)), remove the inner or outermost matches
07:26RaynesM-s
07:28BorkdudeRaynes: doesn't work here
07:28RaynesIt works in Emacs.
07:29BorkdudeI'm in Eclipse + CC
07:29RaynesIs there any tools for line number analysis for Clojure?
07:32BorkdudeWhat is this about in core.clj?
07:33Borkdude(defn rationalize "returns the rational value of num" [num] (. clojure.lang.Numbers (rationalize num)))
07:33Borkduderationalize calls itself or what?
07:33hoeckBorkdude: place your point after the opening paren you want to remove and then press M-<up>
07:34hoeckBorkdude: no, it calls the rationalize static method of c.l.Numbers
07:34Borkdudehoeck: are you talking Eclipse here?
07:34hoeckBorkdude: sorry, you're in Eclipse
07:35Borkdude(doc .)
07:35clojurebotI don't understand.
07:35Borkdudehm
07:35hoeck. is a special symbol
07:35Borkdudeit's hard to search for in Google ;)
07:36hoeck,(clojure.lang.Numbers/rationalize 1)
07:36clojurebot1
07:36Borkdude,(clojure.lang.Numbers/rationalize 0.9)
07:36clojurebot9/10
07:37hoeck(. bla bah) is non-idiomatic syntax, only suitable when writing macros
07:38BorkdudeI used it once to write a macro yes
07:38Borkdudebut I didn't know you could do (. bla (bah foo bar))
07:39Borkdudeat first sight I would think it would first evaluate (bah foo bar) and then continue, but it's more like mimicing java syntax?
07:42hoeckyes, its a strange way of calling java methods, see http://clojure.org/java_interop
07:43hoeckit took a while for the .method syntax to emerge
07:45SynrGso Programming Clojure is dated and doesn't teach current idiomatic clojure?
07:45Borkdude(. Clojure.lang.Number (rationalize 1))
07:45Borkdude,(. Clojure.lang.Number (rationalize 1))
07:45clojurebotjava.lang.ClassNotFoundException: Clojure.lang.Number
07:45Borkdude,(. clojure.lang.Number (rationalize 1))
07:45clojurebotjava.lang.ClassNotFoundException: clojure.lang.Number
07:46Borkdude,(. Clojure.lang.Numbers (rationalize 1))
07:46clojurebotjava.lang.ClassNotFoundException: Clojure.lang.Numbers
07:46Borkdudedamn
07:46hoeck:)
07:49ambientthere was an easy way to split a string into substrings from newline?
07:51Borkdudeambient: http://richhickey.github.com/clojure-contrib/string-api.html#clojure.contrib.string/split-lines
07:51SynrG,(. clojure.lang.Numbers rationalize 1)
07:51clojurebot1
07:51Borkdude,(. clojure.lang.Numbers (rationalize 1))
07:51clojurebot1
07:52Borkdude(doc split-lines)
07:52clojurebotPardon?
07:53ambientlooks like that one came after 10.
07:53ambient1.0
07:53Licenser~ns
07:53clojurebotamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
07:53Borkdude(find-doc "split")
07:53Licenser~defmacro ns
07:53clojurebothttp://clojure.org/transients
07:54Borkdude,(find-doc "split")
07:54Licenserhmm I fail
07:54clojurebot------------------------- clojure.contrib.seq-utils/partition-by ([f coll]) Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of lazy seqs. ------------------------- clojure.core/split-at ([n coll]) Returns a vector of [(take n coll) (drop n coll)] ------------------------- clojure.core/split-with ([pred coll]) Returns a vector of [(take-while pred coll) (drop-while pred coll
07:54Borkdude,(doc split-lines)
07:54clojurebotExcuse me?
07:55Borkdudehmm, this comma in front of sexps is a bit annoying, is there a reason why ( is not simply the character that clojurebot listens to?
07:55Licenser,(doc clojure.contrib.seq-utils/split-lines)
07:55clojurebotNo entiendo
07:55Licenserah does not work :P
07:55Licenser(comment) becase he might get confused :P
07:56Licenser~defn split-at
07:56clojurebotTitim gan éirí ort.
07:56Borkdude(comment (+ 1 1 )) ; really?
07:56LicenserBorkdude: I think that is the reason
07:56Licenserbut on the other hand it might come handy
07:56RaynesMorning Licenser
07:56Licenserhi Raynes
07:57Borkdudewell I don't usually start a new sentence with (
07:57Borkdude, but also not with comma very often. ;)
07:57clojurebotjava.lang.Exception: Unable to resolve symbol: but in this context
07:59Borkdudegtg
07:59Borkdudelater
08:00lpetitBorkdude: expect M-s to be available in a future version of paredit. It's planned.
08:21opqdonutwhat's the easiest way to turn a java.lang.HashMap into a clojure map
08:22opqdonuterr, java.util.HashMap
08:25SynrGopqdonut: hmm. i think http://stackoverflow.com/questions/1665103/clojure-working-with-a-java-util-hashmap-in-an-idomatic-clojure-fashion gives the answer (accidentally? :)
08:25bsteuber,(into {} (doto (java.util.HashMap.) (.put 4 6)))
08:25clojurebot{4 6}
08:27bsteuberopqdonut: (into {} hm) seems most simple to me
08:27Fossiinto {} is nice
08:27SynrGoh! there is an FAQ that gives the same answer: http://en.wikibooks.org/wiki/Clojure_Programming/FAQ#Q:_How_can_I_convert_a_Java_HashMap_to_a_clojure_map.3F
08:28SynrGnot a very big FAQ :p
08:30lpetitAll: the current way of splitting an sexpr in emacs paredit is M+S . We (cgrand & me) intend to use another scheme for this command in ccw. It could just be hitting the closing kind of paren : e.g. "(a | b)" -> hit ")" -> "(a )|( b)". Reactions ?
08:33Fossiwould work for )}], but not really for "
08:33bsteuberlpetit: in emacs I sometimes use ) to navigate to the end of my expression
08:33bsteuberbut I guess it's all a matter of getting used
08:33Fossiexcept if you do something else to insert \"
08:34bsteuberon the long run, I hope all clojure modes converge to more or less the same bindings
08:34bsteuberbut now is still time for experiments, I would say :)
08:35bsteuberlpetit: best way would be allowing for different profiles, maybe
08:35bsteuberso you can have one paredit-compliant mode, a CC-default-mode and a user-custom mode
08:36bsteuberbut doesn't eclipse already do so?
08:36hoecklpetit: sounds quite useful, I do not like the paredit behaviour for ")" - its pretty useless for me
08:37lpetitFossi: yes, introducing "insertion modes" (like string insertion mode) could help, but I guess it could complefy the thing,too
08:37lpetitbsteuber: yes, sort of.
08:37bsteuberI guess splitting a string happens more often than inserting \"
08:38defnAnyone play with mustache at all?
08:38defnmoustache, sorry
08:38bsteuberso I would happily lose the latter if I get the former :)
08:39lpetitbsteuber: so inserting \" would just fall back to ... inserting \" (with \ being a dead-letter, maybe)
08:39lpetitbsteuber: I didn't know M-s would not work in strings in paredit;el
08:39defnI have something like (def myapp (app ["test" [text #".*"]] {:get (my-function-which-returns-html-as-a-string text)}))
08:39lpetitthanks guy, interesting stuff to think about.
08:40Licenserhmm how can I let in a macro? I kind of fail here :(
08:40tomojbsteuber: it does...
08:40defnunfortunately this isn't working -- so i tried encapsulating: [(my-function-which...)], still nothing -- so i append an empty string... ["" (my-function-which...)] -- this gets me the actual string printed on the page, but not rendered as html
08:40defnany ideas?
08:41tomojdefn: I ran into some problems like that as well
08:41defntomoj: hmmm -- am i missing something or is that just something you haven't figured out?
08:42tomojwell, I think there are just some problems with the way those values are interpreted
08:42tomojif the first thing isn't a string, it tries to do crazy stuff
08:42tomojand it's a macro, so
08:42tomojI think what you put there needs to just be the name of a handler for best results
08:42tomojbut I haven't done much with it yet
08:43hoeckLicenser: (defmacro m [] (let [a 1] `(list ~a))) ??
08:43Licenserhoeck: just figured I failed because I forgot to ~ some var :P
08:43Licenserthank you!
08:43bsteuberlpetit,tomoj: I get this error: paredit-kill-surrounding-sexps-for-splice: Splicing illegal in strings.
08:43hoecknp :)
08:43FossiM-s works in strings doesn't it?
08:44bsteuberbut maybe my version's too old
08:44bsteuberor I need an extra line in my .emacs
08:44tomojneed 23 beta
08:44tomojer, 22 beta
08:45dnolendefn: that won't work, the argument to get needs to be a function. it will be passed the request.
08:45bsteuberM-x emacs-version gives GNU Emacs 23.1.1
08:45bsteuberand paredit from elpa
08:45defndnolen: how do you mean?
08:45tomojand yet, the walkthrough has examples like (app ["hi"] "hello world!")
08:45bsteuberfrom the start, it also didn't work with {}, but I fixed that in my .emacs
08:46tomojbut we didn't understand that that only worked for literal strings
08:46dnolentomoj: yes moustache handles literal string as a special case.
08:46dnolen(def myapp (app ["test" [text #".*"]] {:get fn-which-returns-html-as-a-string)}))
08:46tomojbsteuber: yeah, 22 beta fixes that too
08:46bsteuberso 22 beta is better than 23?
08:46tomojbut you have to add M-[ and M-{ or whatever for wrapping them
08:47defndnolen: how do i give fn-which-returns-html-as-a-string the argument text?
08:47dnolen(defn fn-which-returns-htmls-as-astring [req] (ring.utils.response/response ...))
08:47tomojthere is no 23, I believe
08:47defndnolen: ahhhh
08:47defndnolen: thank you
08:47dnolendefn your function will always be passed the html request
08:47bsteubertomoj: but it happens to be installed on my machine - or do the ubuntu versions lie?
08:48tomojbsteuber: C-h v paredit-version
08:49bsteuberparedit-version is a variable defined in `paredit.el'. Its value is 20
08:49bsteuberoh
08:49bsteubernow I get it
08:49tomojhttp://mumble.net/~campbell/emacs/paredit-beta.el
08:49defnwhich ring version is everyone using -- the one from clojars?
08:50bsteuberI thought you were talking bout emacs versions lol
08:50dnolendefn: yeah 0.2 from clojars
08:50defndnolen: cool, thank you again
09:12defndnolen: still no luck :\
09:12dnolendefn: ?
09:12dnolendefn: paste?
09:12defnI wrapped the html output in a (response (html-tree [:html [:head ...]]))
09:13dnolendoes html-tree produce strings?
09:13defnand have (app ["test" [input #".*"]] {:get function}))
09:13defndnolen: ive checked and yes im just getting a long html string back
09:14dnolendo you have a simple case all in one file that you can paste?
09:14defnyeah let me whip something up since this is across a few files
09:17defndnolen: http://gist.github.com/351781
09:18dnolendefn: that won't work. your handle gets passed the html request *not* the matching text from the route.
09:19dnolenlooking over moustache cgrand doesn't put the matching part anywhere, I think he assumes you'll use it in a closure or something.
09:20dnolendefn: http://gist.github.com/351783, this should work.
09:21defnahhhh!
09:24defndnolen: still nothing :\ hmmm
09:24dnolendefn: can you add your server code to my gist?
09:25defnsure
09:26defndnolen: http://gist.github.com/351783#comments
09:27defndnolen: maybe the way im planning on accessing this is wrong?
09:27defnhttp://localhost:8080/examples/anything
09:28defnwhere anything is the string arg to the test-fn*
09:31dnolendefn where is defhtml from?
09:32defnclj-html
09:32defnim going to use enlive -- but i was just testing since im already more familiar with it
09:32defnit is definitely a string
09:33defni can see the response body {:status 200, :headers {}, :body "<html><head>...."}
09:34dnolenso perhaps the route is just wrong?
09:36defni dont see the catch-all route though, but i do elsewhere
09:36dnoleni see the catchall route
09:36dnolenpasting my code
09:37defnyou see the catch all route at localhost:8080/examples/foo?
09:39dnolendefn: gist updated. the example route doesn't work because it's just wrong from what I can tell.
09:42defndnolen: wrong in what sense?
09:44dnolendefn: sorry perhaps I'm wrong. it looks like the html logic is off now that I'm debugging.
09:44dnolendefn: (application text (code-list (code-block text)))
09:45dnolendefn: (code-block "foo") doesn't work for me at all.
09:45defndnolen: http://gist.github.com/351817
09:45defnthat works -- im not sure what changed -- but it works now...
09:46dnolendefn: you stopped matching text with the regex #".*"
09:46defnoh duh -- yeah ["examples" blah]
09:46defnyou were right, the #".*" is bad
09:47defni guess i just wonder why -- /me peers at the code
09:49defndnolen: anyway dnolen, thanks for the help
09:49dnolendefn: fwiw, this works for me ["examples" [text #".*"]] (fn [req] (response (str "examples" text)))
09:50dnolendefn: to be perfectly clear that matches /examples/anything NOT /examples/anything/
10:17defndnolen: ahhh, good to know, thank you
10:31defnIs it possible to combine two maps when doing destructuring
10:31defnlike: [[x y] (map first coll) (map second coll)]
10:31defnto combine those maps somehow?
10:32chouserdo you want zipmap?
10:32chouserhm, maybe not. is "coll" there a map already?
10:33defnmaybe i do...no it's a list of vectors
10:43chouserso coll is like [[:x 1] [:y 2]] and you want something that ends up like (let [x 1 y 2] ...) ?
10:44cgranddefn, dnolen: http://gist.github.com/351783#gistcomment-120
10:45dnolencgrand: nice. so do you plan on providing any sort of helper to pass the destructured bits to a fn? Right now you have to (fn [req] (handler x y req)) or something like that.
10:47defnchouser: hmmm, yes
10:47defncgrand: thanks for that
10:47chouserdefn: (let [{:keys [x y]} (into {} coll)] ...)
10:50cgranddnolen: I like closures :-) but I think that (defn give-me-a-name [f & args] #(apply f % args)) could be useful both with moustache and enlive
10:51cgrand(fn [req] (handler req x y)) would be (delegate handler x y)
10:51dnolencgrand: great!
10:52dnolennow moustache will be 151LOC instead of 150LOC
10:53cgrandso, delegate? partial1? another idea?
10:55dnolenI like delegate.
10:56dnolenit is partial1, but delegate give it's contextual meaning in moustache.
10:56dnolengive it's -> gives it
10:59cgrandI must confess that the special case of strings in handler position is only there for demo and tweet purposes :-)
11:00cgranddnolen: so delegate?
11:00dnolencgrand: well I like it. I suppose the moustache is crew is fairly small so I don
11:00dnolen't think we'll hear many other opinions :)
11:02SynrGbeen thinking. DENIED is rather harsh. maybe change it to "I'm sorry <nick>, I'm afraid I can't do that."
11:03hiredmanDENIED
11:03SynrG:p
11:04SynrGi guess the joke would get old fast
11:04hiredmanwell, you'd want a list of similar responses to pick from at random
11:04cgranddnolen: I know you'll spread the good word :-)
11:05hiredmanclojurebot: bleep bloop blop
11:05clojurebotPardon?
11:05hiredmanclojurebot: bleep bloop blop
11:05clojurebotI don't understand.
11:06dnolencgrand: I'll try. I want to do something that shows how moustache let's you always build services that are api ready. If you want HTML decorate with enlive, if you want data, just call the fn directly.
11:06dnolenmiddleware with enlive rather.
11:07cgrandor have a higher-order middleware which select the better rendering-middleware based on content negotiation
11:08dnolencgrand: hmm, i see where you're going. do you have a specific example you have in mind?
11:22stuartsierraI'm confused by behavior of the "extends?" function http://paste.lisp.org/+2301
11:22stuartsierraIs this a bug?
11:31qbgYou will get true from extends? if the type was extended using extend-type
11:32stuartsierraBut not if the protocol was extended inline in the deftype?
11:33qbgI'm not sure extends in the right word for what happens in deftype
11:33stuartsierrahmm, ok
11:33qbgeither that or deftype implicitly extends a protocol
11:44webwandererCan someone help me set up clj-processing with emacs and slime? I've got the clojure repl via emacs starter kit and ELPA. What do I do next?
11:48webwandererAnybody?
11:51stuartsierrawebwanderer: start simpler
11:51webwandererstuartsierra: what do you mean?
11:51dnolenwebwanderer make a lein project from the command line: "lein new my-p5-app"
11:51stuartsierraFigure out the command-line REPL first, then EMACS inferior-lisp mode, *then* try to configure SLIME
11:51webwandererdnolen: and then?
11:51dnolenchange your project clj to include clj-processing from clojars to your project.clj :dev-dependencies
11:52dnolenthen in Emasc run swank-clojure-project, and select your projects directory
11:52dnolenprofit
11:52stuartsierra:)
11:52dnolentaht
11:52dnolenwebwanderer: oops, that M-x swank-clojure-project
11:53webwandererdnolen: so should I not need to install lein?
11:53dnolenwebwanderer: lein is fairly easy to install if you're comfy with the commandline. instructions on github
11:54webwanderercool. but should i for getting clj-processing running?
11:54dnolenwell it makes it easier to have different processing sketches without futzing around with your classpath every time.
11:55webwandererare you sure this leads to profit?
11:55webwanderer:)
11:56webwandererI'll try anyhow.
11:56dnolenif you just want to run examples, go with stuartsierra suggestion
11:57webwandererdnolen: I need to clj-processing. Whatever leads to that is profit.
11:59stuartsierrawebwanderer: You need to start Java with a classpath that includes: 1) clojure.jar, 2) the clj-processing source files, 3) any JARs that clj-processing depends on
12:00stuartsierralein/maven will help you with that, assuming clj-processing is on clojars.org
12:00defnhttp://gist.github.com/351984 :: Any advice on this fn? Is this too terse? Too long?
12:01defnI realize the docstring is a little iffy, pay no attention to the :a :b, just assume they're "a" and "b". :)
12:01webwandererstuartsierra: I read that. It says something about 'the proper way to set up CLASSPATH' etc.. I'm sure that's up to no good for me.
12:01webwandererAs i don't know anything about Java.
12:02stuartsierrawebwanderer: well, start learning :)
12:02stuartsierraThe classpath is the -cp argument to the "java" command line.
12:02stuartsierraIt consists of directories and .jar files.
12:02webwandererstuartsierra: I thought the whole idea of clojure was to get the L away from Java.
12:02stuartsierraNo
12:02stuartsierraThe idea of clojure is to leverage Java.
12:03defnalso, clojure makes java suck a lot less
12:03defnan order of magnitude or more IMO
12:03dnolenwebwanderer: or not. I never use Java unless I have to. I prefer using wrappers around Java.
12:03bozhidardefn: java doesn't suck that much
12:03Borkdudeit all compiles to jvm class files in the end
12:03bozhidarthe language is certainly primitive
12:03bozhidarbut the platform has always been great
12:04defnright, we're talking about the JVM versus Java -- two different things
12:04fogusdefn: So Clojure is O(tehcool) and Java is O(meh)?
12:04bozhidarfogus: Clojure + JVM = Cosmic Synergy ;-)
12:04webwandererIsn't it implied that it's Java the language that people refer to when they say Java sucks?
12:05bozhidarI have no idea how clojure fares on the CLR
12:05BorkdudeClojure is intended as a hosted language. Hosted on JVM, CLR and what's to come?
12:05webwandererParrot?
12:05stuartsierrato-be-determined inside-every-web-browser VM
12:05webwandererJavascript is very good.
12:06webwandererNo need for clojure there IMHO.
12:06webwandererI don't know clojure but still..
12:06BorkdudeI would like to use Clojure instead of Javascript
12:06stuartsierraThere's an (incomplete) port of Clojure to Javascript.
12:06cheezeycan i use a "dynamic" regular expression pattern? i can't seem to do something like #(str ..)
12:07stuartsierracheezey: You need (Regexp/compile "...")
12:07stuartsierrasorry, java.util.regex.Pattern/compile
12:08foguswebwanderer: js is very good, but it has its flaws that can be addressed by alternative languages in the browser
12:09cheezeystuartsierra: thanks, i'll check it out
12:09Borkdudeyou did an asynchronous call in clojurescript?
12:10webwandererfogus: Not very pressing as many other concerns are.
12:10foguswebwanderer: I'm sorry, but I don't follow
12:11webwandererfor one thing, the browser is a very primitive environment.
12:12chousercheezey, stuartsierra: or re-pattern
12:12webwandererThere's not much gain with having multiple languages hosted on the browser.
12:13Borkdudewebwandered, but there is gain knowing one language very well and able to use it on different hosts
12:13bozhidarbtw a quick question about swank-clojure-project
12:13bozhidarwhat might be causing this to happen
12:13bozhidarPolling "/tmp/slime.25499".. (Abort with `M-x slime-abort-connection'.) [57 times]
12:13bozhidar
12:13BorkdudewebwandereR, sorry
12:13foguswebwanderer: Maybe, but I think that is a matter of debate
12:13bozhidarindefinately...
12:13webwandereryes.
12:13webwanderer.....
12:13stuartsierrabozhidar: Look at the *inferior-lisp* buffer, it's probably showing an error.
12:13naeuI just started reading the clojure version of SPEL
12:14dnolenwebwanderer: that is unless you're tired of current situation. I like JS and know it well, but apps are getting more and more complicated. Thus the existence of monstrosities such as GWT
12:14naeuand noticed: `(there is a ~(second path) going ~(first path) from here -))
12:14naeuthis doesn't seem like idiomatic Clojure
12:14webwandererBut you don't need GWT. I think it's misguided.
12:14webwandererI would recommend all of Douglas Crockfords recommendations.
12:15cheezeystuartsierra: thanks it worked, chouser: that's even easier loL :D
12:15naeubut it did remind of of Ruby string interpolation: "there is a #{path.second} going #{path.first} from here -"
12:15naeuwhat would be the most idiomatic way of representing string interpolation like this in Clojure?
12:15dnolenwebwanderer: you need something like GWT for sufficiently complex apps. Thus Cappucino. Douglas Crockford be damned. He says the same thing over and over. He's a smart dude but not the only smart dude doing JS stuff.
12:15brandonwdo you think there would be a way to re-use the optimizations of javascript in a secondary (or tertiary) language?
12:15bozhidarstuartsierra: you're correct and I'm absent-minded
12:16brandonwi know a lot of work is being done to get javascript highly optimized, and if you had several languages to choose from, it seems like it would detract from overall web usability
12:16brandonwnot that i am defending javascript; i would love to use something like clojure instead
12:16webwandererdnolen: But why is GWT like Java of all things? I think that it is pathological or some mental infection.
12:16chousernaeu: http://muckandbrass.com/web/display/~cemerick/2009/12/04/String+Interpolation+in+Clojure
12:16brandonwbut realistically, there is so much work being done specifically for javascript, it would be an absolutely huge undertaking to start using alternatives
12:16cemerickas I said earlier, the only thing js has going for it is distribution
12:17chousercemerick: js isn't *that* bad.
12:17defn11:04 < fogus> defn: So Clojure is O(tehcool) and Java is O(meh)?
12:17naeuchouser: thanks a lot
12:17webwanderercemerick: you've obviously not used javascript.
12:18chouserfor pages that have a little js sprinkled on them, up through smallish "web 2.0" sites, js with something like jquery is probably just fine.
12:18cemerickchouser: That's a tired response, IMO. If distribution weren't the key issue, you wouldn't use js for anything.
12:18defnfogus: I'm not trying to come across like that
12:18fogusI don't think the best path is providing multiple language interpreters in the browser, but rather multiple languages targeting js
12:18chousercemerick: that's true, but I guess I didn't see it as an equivalent statement
12:18chouserstuartsierra: wise. :-)
12:19cemerickchouser: Sure, I should've been more precise.
12:19cemerickstuartsierra: but what else is there to do during lunchtime? :-P
12:19brandonwthat sounds like an interesting goal, except that you either have to dynamically compile it into javascript, adding an overhead to using an alternative, or you have to pre-compile it and you effectively have a code generator (and everyone loves those)
12:19naeuchouser: that looks nice - are there any plans to include something like that in clojure or contrib?
12:19dnolenwebwanderer: I could go on but won't. GWT exists because _sometimes_ (not all) you need to write complex apps. You would prefer to have the illusion of a single codebase instead of two different codebases front and back because as application complexity increases, interop front/back complexity increases. /done
12:19chouserI've worked on apps with a few thousand lines of javascript, and at that scale I'd much prefer something else. Probably not Java (GWT) though. :-)
12:21fogusdnolen: inc
12:22chousernaeu: not sure. I think rhickey has been cold on the idea, but apparently it showed up at his and Halloway's pragmatic studio training session. So who knows. :-)
12:22cemericknaeu: I'm hoping, very much, tho I suppose I'm biased.
12:22chousernaeu: if you like it, use it.
12:23naeui love string interpolation in ruby
12:23cemerickit's one of the few things I :use everywhere
12:23chouserit won't be called << I bet, since rhickey wants that for cells
12:23naeui just wondered whether i was missing an idiomatic approach for clojure
12:23cemerick...and I *so* liked << for that :-(
12:24chouserthe ~{n} is the ugliest bit afaic
12:24cemericknaeu: language extension via macros *is* the idiomatic approach for many things in clojure :-)
12:24naeuchouser: it's similar to #{n} from Ruby, and the ~ matches the macro flop
12:24chouserbut I've failed to come up with better alternatives, so I should keep my mouth shut.
12:24cemerickchouser: yeah, I'm not so hot on that either, but I don't have any better ideas
12:24chouserI think you told me why ~n wouldn't work
12:25cemerickbecause you wouldn't know when to stop glomming the symbol
12:25chouseroh, right "~n."
12:25naeuyou'd also want to substitute whole sexps
12:25cemerickthat's ~(:blah foo)
12:25chouser"right, ~(:foo bar) is beautiful"
12:26chouser~(identity n) heh
12:26clojurebotandroid is http://github.com/Nafai77/helloandroid/tree/master
12:26chouserok, lunch
12:26naeuchouser: cheerio
12:35underdevi wonder why maps don't return seqs against seq functions
12:36underdevbecause thier inherently pairs?
12:37stuartsierrathey do return seqs
12:37stuartsierra,(seq? (map identity {:a 1 :b 2}))
12:37clojurebottrue
12:38underdev,(class (first {:a :b :c :d}))
12:38clojurebotclojure.lang.MapEntry
12:38underdev,(seq (first {:a :b :c :d}))
12:38clojurebot(:a :b)
12:38underdev,(seq? (first {:a :b :c :d}))
12:38clojurebotfalse
12:39underdevokay, so sometimes they do, and sometimes they don't?
12:40underdev,(seq? (first [a b c]))
12:40clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
12:40underdev,(seq? (first [:a :b :c]))
12:40clojurebotfalse
12:41underdevokay, so it's a "first" thing
12:41fogusunderdev: seq returns a seq, maps are built from mapentries. mapentries are vectors. vectors are not seqs
12:42fogus(first '[a b c]) is a symbol
12:42underdevfogus: thanks
12:42fogus,(isa? clojure.lang.MapEntry clojure.lang.IPersistentVector)
12:42clojurebottrue
12:42fogus,(seq? [])
12:42clojurebotfalse
12:45fogus,(seq? (seq [1]))
12:45clojurebottrue
12:48underdevokay, that may be handy
12:55BorkdudeCan one compare a Clojure symbol with a Common Lisp symbol in that it has a propertly list etc?
12:56joshua-choiI'm looking for a tutorial for using Swing to create a syntax-highlighting text editor.
12:56joshua-choiThe best I could find is at http://ostermiller.org/syntax/editor.html, but the source is gone missing.
12:56bsteuberborkdude: not really - but they can have meta data attached
12:56joshua-choiAnyone have any good websites?
12:57bsteuberwhich is somewhat comparable to property-lists
12:57dpritchettToday I'm going to read Ch. 4 of Joy of Clojure... I hope the next MEAP update is ready soon!
12:57bsteuberjochua-choi: Are you gonna write clojuremacs, finally? :)
12:58Borkdudedpritchett: me2!
12:58joshua-choibsteuder: Eh heh heh. Maybe, but probably not.
12:59dpritchettI can't read Alex Comfort at work so I'm counting on you two.
12:59mfexjochua-choi: the zip seems to contain the source files @ http://www.gjt.org/servlets/JCVSlet/list/gjt/com/Ostermiller/Syntax/Syntax.zip
12:59joshua-choimfex: I get a server error page. :(
13:00joshua-choiI'm not quite sure what's up with the Giant Java Tree.
13:01mfexjochua-choi: then click download between documentation and checkout latest at the top of the listing here: http://www.gjt.org/servlets/JCVSlet/list/gjt/com/Ostermiller/Syntax
13:02joshua-choimfex: That gives me another error, "Failed to open '2401@cvs.gjt.org'."
13:02mfexmsg me an email address then and I'll send it over
13:02joshua-choiOh, really? Thank you very much!
13:05brian_as a newbie, I'm trying to clarify "map", ie this works: (map vector a), but this doesn't (map (re-seq #"b") a), for that I need to include an argument like this (map #(re-seq #"b" %1 ) a) , whats the difference between "vector" and "re-seq" ?
13:07Borkdudebsteuber, tnx
13:09chouserbrian_: vector is a function, (re-seq #"b") is not
13:10chouserbrian_: (vector) is also not a function. Both (vector) and (re-seq #"b") are attempts to *call* a function, and whatever they would return would be passed as the first arg to map
13:11chouserbut (re-seq #"b") doesn't return anything because re-seq requires 2 args
13:11chouserso it throws an exception instead.
13:11chouserparens matter. anyone who says that the parens "disappear" after a while must mean something else.
13:12brian_thx chouser,i need to think about it
13:12defnhttp://thinkslate.com:8080/examples/concat
13:12defnif you refresh you can see it build in real time :)
13:12chouser,(map #(vector %) [1 2 3])
13:12clojurebot([1] [2] [3])
13:12chouser,(map #(vector :a %) [1 2 3])
13:12clojurebot([:a 1] [:a 2] [:a 3])
13:13wooby,(map (partial vector :a) [1 2 3])
13:13clojurebot([:a 1] [:a 2] [:a 3])
13:13defnhttp://getclojure.org/examples/partial
13:13Borkdude(doc ->>)
13:13clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
13:13defnoh no
13:13defnhttp://getclojure.org:8080/examples/partial
13:13defnthere we go
13:14defnhttp://getclojure.org:8080/examples/insert-your-fn-here
13:14defnanyway, off to bed -- gnight
13:15Borkdudegnight defn
13:15woobyneato
13:24alexykwhat's ret in amap? someone has a good example of amap?
13:40stuartsierraret is the array that will be returned, same size as the input array
13:49BorkdudeIs there an idiomatic way to do (?? x '(f1 f2 f3)) -> (f3 (f2 (f1 x))... compose or smth?
13:50danlarkin(doc comp)
13:50clojurebot"([f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
13:53Borkdudetnx
13:53mattreplBorkdude: do you need to programmatically compose them? otherwise there's ->
13:58BorkdudeI have a list of anonymous functions, I have to (apply comp l) them to make it one function
13:59foguscomp returns a function and ->/->> return "results"
14:06alexykare amap/areduce intended only for Java arrays?
14:06Chousukedo they even work on anything else?
14:07alexyknope...
14:08alexykso no equivalent reduce on a clojure vector, with index?
14:09Chousukeindex? I guess not
14:09stuartsierraeasy enough to write; there's "indexed" in contrib seq-utils
14:10Borkdudehttp://stackoverflow.com/questions/2553668/how-to-remove-list-of-words-from-strings/2556696#2556696 <-- I used comp for this
14:10alexykstuartsierra: thx
14:11alexykis there an update-in for array?
14:12alexykmeaning, for vector?
14:12tomojalexyk: update-in?
14:12alexyktomoj: how do you set a vector at position i?
14:13tomoj,(update-in [[1 2 3] [4 5 6]] [1 2] inc)
14:13clojurebot[[1 2 3] [4 5 7]]
14:13alexykah
14:13alexyk!
14:14tomojmatrices I guess
14:22alexykcute how update-in applies to maps and vectors alike
14:26naeuOK, so here's my proposal for a string interpolation syntax, it would be implemented with a reader macro using the magic # as follows: (let [bar "quux"] #"foo ~bar ~(+ 2 3)")
14:26alexyk,(update-in {:a [1 2]} [:a 1] #(+ % 3))
14:26clojurebot{:a [1 5]}
14:26alexyknow scala do that
14:27bsteubernaeu: #" is used for regexps
14:33Borkdudethat looks pretty cool
14:33Borkdude(update-in {:a [{:b 1} 2]} [:a 0 :b] #(+ % 3))
14:33Borkdude,(update-in {:a [{:b 1} 2]} [:a 0 :b] #(+ % 3))
14:33clojurebot{:a [{:b 4} 2]}
14:34BorkdudeI think I'll use it for my daily example on Twitter :)
14:40alexykBorkdude: I'm @khrabrov there :)
14:40alexykhow do you typehint a clojure vector?
14:41ChousukeIPersistentVector
14:41alexykkk
14:41Chousukeor hm
14:41Chousukewell, something like that :P
14:41Borkdudealexyk, great
14:44alexykor, should I use a precondition to make sure a parameter is a vector?
14:45stuartsierraType hints are not type assertions.
14:46stuartsierraSo if you want a check, us a precondition.
14:47alexykah right
14:48woobyor you can (vec arg) and hope for the best :)
14:48woobyi've done that in some functions to make seqs out of sets
14:53cemerickwooby: vectors are not seqs
14:53woobyerr to turn into vectors i mean :)
15:19alexykis clojure-contrib supposed to be compatible with clojure proper, both 1.2.0-master-SNAPSHOT github heads?
15:24tomojyeah
15:27alexykwell it barfs for me :(
15:28alexykthe dreaded java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
15:32hiredmanclojurebot: suddenly!
15:32clojurebotGabh mo leithscéal?
15:32danlarkinnooooooooooo
15:32pjstadig~suddenly
15:32clojurebotCLABANGO!
15:32danlarkinyesssssss
15:33pjstadigclojurebot: suddenly
15:33clojurebotCLABANGO!
15:33pjstadigno exclamation point
15:34alexyk~carramba!
15:34clojurebotI don't understand.
15:34alexyk~привет, клоужербот!
15:34clojurebotexcusez-moi
15:34alexyk~what's your relationship with one hiredman?
15:34clojurebothiredman <3 XeLaTeX
15:38alexykclojurebot: does it mean hiredman doesn't <3 you anymore?
15:38clojurebothiredman is slightly retarded
15:39slyphonis there an interactive debugger for clojure?
15:39slyphoni.e. where you can set breakpoints, etc?
15:39alexykprintln
15:39slyphonnot quite
15:47duncanmif i want to write a Java method that can work in Clojure as something that returns multiple values, the return type to my Java method should return an ISeq, right?
15:47duncanmis there a better interface?
15:47ChousukeYou can return a sequence or a vector
15:48ChousukeIPersistentCollection might be the best
15:48duncanmif i return an object [], that will work too?
15:48Chousukeyes, but it will be a mutable array :/
15:48Borkdudeaaaah, mutable, it hurts... nooooo
15:52chouserslyphon: many (most) java debuggers work with clojure code. jswat and netbeans at the very least.
15:53slyphonjswat, hm
15:53slyphonchouser: ok, i'll have a look
15:53slyphonchouser: do you know if slime/swank provide that kind of functionality?
15:54chouserslyphon: I don't use either, but I've heard recent chatter about a debug-repl. I don't know if that's based on the &env stuff or on the real java debugging api.
15:54slyphonah
15:54slyphonmm'kay
15:54slyphonthanks
15:54slyphon:)
16:08alexykso I build clojure proper from git, contrib with it, and get the dreaded java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (NO_SOURCE_FILE:0) trying to (use 'clojure.contrib.str-utils2). ?
16:09chouseralexyk: built contrib using mvn?
16:09alexykyep
16:09alexykinstalls as clojure-contrib-1.2.0-SNAPSHOT
16:09alexykwhich was confusing as I clojure proper is clojure-1.2.0-master-SNAPSHOT
16:09chouserhm, I was under the vague impression that did a clean first, but perhaps you should try mvn clean manually?
16:10alexykchouser: did clean I think, but will again
16:10chouserhm...
16:11alexykI wonder why "they" name them differently
16:11alexykalso the readme files are named: readme.txt in proper and README.txt in contrib -- decide on a case already!
16:16alexykhmm, still the same...
16:18alexykhmm -- no duck-streanms in that contrib! is it still there?
16:19alexykor renamed?
16:20dnolenalexyk: renamed to io
16:21alexykdnolen: so they killed 'e, ducks
16:21alexyk'em
16:21alexykpoor ducks!
16:21alexykwhat about str-utils2?
16:22alexykI guess I was picking those from some old crappy jar, they're no longer in contrib either
16:22alexykor, where's split now?
16:23chouserclojure.contrib.string
16:23alexykyeah, grepped that
16:24alexykso, is there a big huge danger sign, all your legacy imports will fail, crap will be picked off classpath, and you'll pull your hair rebuilding contrib? :)
16:25alexykperhaps those legacy things should be left with asserts which fail and croak
16:25chouserI'm sure it'll be in the release notes for 1.2 when that's released. :-)
16:25alexykchouser: pfft, who reads release notes :)
16:25alexykhow 'bout pre-release notes?
16:25alexykor, release prenotes?
16:26slyphonalexyk: i think that's called "the dev mailing list"
16:26chouseralso available as: #clojure
16:26alexykslyphon: see, I suddenly want to partake of the named arguments goodness, change my project.clj, rebuild from git, and expect immediate nirvana!
16:27alexykwhich is the usual way of clojure
16:27alexyknow I have to stare at the RestFn not found. This is not joyful!
16:27chousernote that the arugment order and some var names in string have changed against since str-utils2
16:28alexykkk
16:28LeNsTRhhhhhhhhhhhhhhhhhh
16:28LeNsTRops
16:30candellerhi how can a function that takes a single argument be called for every element in a collection? Lets say I wrote a function that takes a number and sees if its a prime number and I want to iterate through a collection
16:31Borkdudecandeller: map
16:31Borkdude,(doc map)
16:31clojurebot"([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. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
16:31candeller(map myfunc [collection]) would work?
16:31Borkdudeyes
16:32chouser,(map odd? [0 1 2 3 4 5])
16:32clojurebot(false true false true false true)
16:32Borkdude,(map (fn [x] (+ x 1)) [1 2 3])
16:32clojurebot(2 3 4)
16:32candelleroh indeed it does, i swear i tried it and it didnt:
16:32candellerthanks a lot:D
16:32Borkdudethat's what we are waiting here all day for
16:34erikcw1I have a map that uses strings as keys (the data comes from JSON). {"country" "US" ...}. Is it possible to use destrucuring with a dictionary like this? Or does the key have to be a :key?
16:36alexykwhy do they still insist on having a repeat in string which prevents a simple use suck-all names?
16:36alexykshouldn't they all at least not conflict with the core?
16:37Borkdude,(let [{a "country"} {"country" "US"}] a)
16:37clojurebot"US"
16:38Borkdudeerikcw1, seems to work
16:38alexykand what's seq-utils now?
16:38alexykI guess seq?
16:39chouser,(let [{:strs [country]} {"country" "US"}] country)
16:39clojurebot"US"
16:39erikcw1cool! thanks!
16:41Borkdudechouser, even better
16:41ipostelnikchouser, is :strs destructuring new in 1.2?
16:41chouseripostelnik: nope, been there as long as :keys
16:41bsteuberbut this is new:
16:42chouserBorkdude: well, you need both, especially for strings
16:42bsteuber,((fn [& {:strs [a b]}] [a b]) "a" 42 "b" 77)
16:42clojurebot[nil nil]
16:42cemerickheh, I never knew about that
16:42bsteuberhmpf
16:42alexykwhere can I read on the essence of the named arguments?
16:42chouserbsteuber: clojurebot's running old clojure
16:42bsteuberyeah, I just realized :)
16:42bsteuberI get [42 77]
16:43Borkdudewhat's the new thing, I don't know what the old thing is
16:43Borkdudeeverything is new to me ;)
16:43astoddardI am trying to understand "future-cancel". The doc says it will cancel the future "if possible". Is there some definition of possible?
16:44bsteuberBorkdude: map destructuring on &-arguments
16:45candellerhmm, regarding the map function: I wrote something like this: http://ideone.com/v6lNwBbu and it doesnt print anything, although I suppose it should. Is there anything I got wrong ?
16:45chouserastoddard: the vague definitions is "most blocking things" -- locks, IO and such will be interrupted
16:46bsteubercandeller: welcome to lazy sequences :)
16:46chouserastoddard: a simple compute loop like (loop [] (recur)) will not be interrupted.
16:46candellerbsteuber: whats that? I guess I will still need to read up :P
16:47bsteuberthe sequence doesn't actually evaluate until needed
16:47Borkdudecandeller, I think in ideone you need to call prn or some thing that causes side effects
16:47bsteuberbut you can force it
16:48Borkdudecandeller: http://ideone.com/mlytuebr
16:48Borkdudecandeller: oh wait, you already called println... didn't even notice that hehe
16:49Borkdudecandeller: maybe it only shows the result of the last expression
16:49astoddardWhat about the case where a future calls a includes "inner" functions mapped across a big list of file names, doing IO on the files, would the "outer" map be interruptable?
16:50bsteubercandeller: on a normal repl this should still print
16:50astoddardIt seems that a lot of IO continued after I called future cancel.
16:50candellerhmm, it prints on the repl, just checked, I had it compiled in netbeans and it didnt
16:51candellerby the way, as I had just begun learning clojure, what do you mean by 'side-effects?'
16:52bsteuber,(let [x (map print [1 2 3 4 5 6 7])] nil)
16:52clojurebotnil
16:52Borkdudea side effect is something that affects the outer world, like printing to a screen, writing to a file, etc
16:52bsteuber,(let [x (doall (map print [1 2 3 4 5 6 7]))] nil)
16:52joshua-choicandeller: A side-effect is something like modifying a file, printing a message, or mutating a mutable object, as opposed to just calculating something.
16:52clojurebot1234567
16:52joshua-choiPurely mathematical functions lack side-effects.
16:52candellerah i see
16:52bsteubercandeller: a doall might do the job for you
16:53bsteuber,(doc doall)
16:53clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
16:53bsteuber,(doc dorun)
16:53clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
16:54candellerhmm, ok i guess i will need to read up a little, as i had been exploring on my own browsing the api, will probably make it clearer, either way thanks a lot :)
16:55bsteubercandeller: yeah, there's really a lot of new stoff for post people - so a guided tour might be helpful
16:56Borkdude,(doc map)
16:56clojurebot"([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. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
16:56Borkdudeah map returns a lazy sequence
16:56bsteuberhm, the "post" was not supposed to be there :)
16:57Borkdudebsteuber: post people, is that something like "ubermensch" but then different? ;)
16:57Borkdudeso dorun is like force in other fp languages?
16:57alexykwhy cannot do this:
16:58alexyk,(let [points [1 2 3]] (map #([points %]) [1 2]))
16:58clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector
16:58alexykbut can do this:
16:58alexyk,(let [points [1 2 3]] (map #(get points %) [1 2]))
16:58clojurebot(2 3)
16:59ipostelnikalexyk, (let [points [1 2 3]] (map #(points %) [1 2]))
16:59ipostelnik,(let [points [1 2 3]] (map points [1 2]))
16:59clojurebot(2 3)
17:00ipostelnikalexyk, vectors is an IFn with index as the arg
17:00Borkdude,([1 2 3] 1)
17:00clojurebot2
17:00Borkdudeah I see
17:00alexykah right
17:04erikcw1Is it possible to do destrucuting in a multimethod? Basically I want to pass a dict to the multimethod, but then do some destructuring inside the methods...
17:05Borkdudeerikcw1, why don't you just try and see?
17:06dnolenerikcw1: you can.
17:06erikcw1I've been playing with it and I keep getting errors
17:07erikcw1http://pastebin.com/V9tnk1XL
17:10dnolenerikcw1: that works for me
17:10dnolenwhat errors are you getting?
17:11erikcw1Yeah -- that works -- but I'm trying to figure out how to move the let into the arg list and do the destrucutring there.
17:13dnolenerikcw1: http://pastebin.com/8aWbMNE0 should work
17:14erikcw1dnolen: that's what I was after! Thanks -- I'm still trying to get up to speed obviously...
18:53nteonhow can I expose a clojure function (in a :gen-class file which is implementing an interface) as a static function to java?
18:58nteonn/m should have read the docs
18:58nteonI can do it iwth :methods
19:52dnolenis it possible to type hint arguments to the methods of deftype?
19:57alexykhow do you get clojure version from repl?
19:58dnolen*clojure-version*
19:58dnolen,*clojure-version*
19:58clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
20:04dnolenalso how do you type-hint deftype'd instances?
20:08alexykdnolen: this is Chouser-Level Question, or CLQ :)
20:08alexykthx for the version
20:08dnolenheh, yeah I was hoping more people had played around with deftype and typehinting
20:14RaynesTurtles all the way down.
20:14RaynesOops, wrong channel. :|
20:14chouserdnolen: the type hint would go on the interface that the deftype is implementing
20:15chouserRaynes: yeah, that doesn't apply here. Here we have turles all the way down to the JVM.
20:15chouserturtles
20:15dnolenchouser: but how do you type-hint a deftype'd thing?
20:16chouseryou can put type metadata on the fields, but all the method signatures are defined elsewhere.
20:16chouseryou can't add a new method in a deftype
20:17chouseroh, the instance, I'm sorry.
20:17chouserhang on
20:17dnolenchouser: thx
20:17chouserlet's see -- you shouldn't need to. Again, hint using the interface that's being implemented
20:19dnolenchouser: so hint the protocol? or the actual method?
20:19dnolenhere's what I'm trying to do. I'm trying implement a simple vector math lib with deftype.
20:20chouserprotocol method calls don't need hinting
20:20dnolena method needs to take a another vec3 instance. don't I need to type hint this for perf?
20:20chouserahhh
20:21chouseryou want to do a field lookup on a datatype instance -- so just use (:fieldname vec3)
20:29dnolenchouser: hmm, deftype is fast, creation, access. but I guess no matter what you do mutable math is just going to be faster (you don't have the overhead of object creation?)
20:30chouserhm... changing a value in a mutable array will be faster than creating a new datatype instance with an update value.
20:30chouserthe math itself should be the same speed as java, as long as you're using primitives.
20:31dnolensadly more than an order of magnitude faster it seems.
20:31chouserthe way to avoid that I think is to move the boundary on mutability up higher.
20:32dnolenchouser: this is what my code looks like http://gist.github.com/352580
20:32chouserhm...
20:33chouserprotocols don't yet support primitives
20:33chouseroh, I see you don't need it to
20:34chouseryes, I'd bet (:x other) is still boxing the return value
20:34chouserhmmm
20:36dnolenchouser: some perf numbers from my machine
20:37dnolenI know getting close to mutable math is pointless. but I'd like to get close to mutable math+clone
20:37dnolenor maybe this is a silly exercise and I just to all this stuff in a cell :)
20:37chouserif you AOT compile that, the deftype will actually produce a your.namespace.vec2 class -- you can hint that
20:37chouser(.x #^vec2 other)
20:40dnolenchouser: so you don't think the fact that "other" in the method definition is not a problem?
20:40chouserheh, can't parse that question
20:40chouserbut this is interesting, from the deftype docstring:
20:40dnolenI don't see how the JVM get fast dispatch w/o (add [#^vec3 other] ...) in the deftype
20:40chouser"In the method bodies, the (unqualified) name can be used to name the class (for calls to new, instance? etc)."
20:41chouserdid you try that?
20:41chouserfrom that quote I just pasted, it might work
20:41dnolen"Can't find matching method: add, leave off hints for auto match."
20:41dnolen:)
20:41chouserthen you'd do (.x other) instead of (:x other). This is about primitives, not type hinting.
20:41chouserah!
20:41chouserok, try hinting it when it's used instead
20:41chouser(.x #^vec2 other)
20:42dnolenHOLY MOLY
20:42dnolenchouser: you're the man.
20:43dnolenas fast as mutable math + clone
20:45chouserwell, good. :-)
20:46chouserit's weird but usually if you see a 30-40x slowdown it's because of reflection, 8-10x is usually boxing
20:46chouserdnolen: that worked without AOT compilation?
20:46RaynesLauJensen: Let's write a chouserbot in J.
20:47chouserwill I be replaced by a very small J script?
20:48dnolenchouser: yes! rhickey is a genious and you're the messenger :) I updated the gist.
20:48dnolenthe body of add needs to look like this (vec2. (+ x (.x #^vec2 other)) (+ y (.y #^vec2 other)))
20:48chouserok. that's interesting -- inside the deftype, vec2 can be used as a classname even though there may be no class by that name.
20:49dnolen1000000 vectors added in 27ms.
20:49Rayneschouser: A very, very small J script. :D
20:49chouserRaynes: not sure there's eny such thing as a large J script.
20:49Rayneschouser: Indeed.
20:52defnRaynes: don't know if you saw this but: http://getclojure.org:8080/examples/function-name-goes-here
20:52defni dont have it auto-updating from #clojure yet, and it's still pretty ugly as far as formatting goes, but...
20:53chouserdefn: are the examples getting pulled from some manual list? or is it somehow automatic?
20:54defnit parses all of the logfiles in a background thread at first, and then (eventually) will just add to that ref as people write into the channel
20:54chouseroh, it's pulling from #clojure?
20:54defn*nod*
20:54defnnot yet, but it will be
20:54chouserdoes it compute it's own return value, or use clojurebot's?
20:54defni mean, all the logfiles are from #clojure, but it's not doing up-to-the-moment parsing
20:55Raynesdefn: That's great. I'll slap something in my bot asap.
20:55defnchouser: it computes it's own return value using Licenser's clojure sandbox
20:55chouserdefn: that's a really clever idea
20:55defnchouser: still pretty rough around the edges but it's getting there -- Licenser helped a lot
20:55RaynesSomething like $example func -> http://getclojure.org:8080/examples/func
20:56RaynesLicenser is awesome.
20:56chouserhttp://getclojure.org:8080/examples/ref is taking a while
20:56LicenserYea I agre Licenser is totally awsome
20:56Licenser:P
20:56defnhaha
20:56defnchouser: yeah that doesn't look good :)
20:57Raynes;)
20:57Licenseris that web walton?
20:57defnLicenser: yeah, sort of :)
20:57RaynesLicenser: Made any progress on that . bug?
20:57Licenserneat
20:57LicenserNah sorry, my brother demands some of my awsomness :P (just kidding, he's staying over easter)
20:58defnchouser: yeah something is broken site-wide it looks like
21:02defnuh oh... :)
21:02defnokay try now
21:03defnif you refresh you can see them being added in real team
21:03defnwhich is sort of neat
21:05chouserso it caches the results? starting when you first ask?
21:05chousermaybe "ref" breaks it
21:06defnit just starts searching log files, finding sexps, and then it tests them in a try/catch -- it adds things to a *sexps* ref by tagging them with :good or :bad depending on if it runs or not
21:06defnif none are returned, it will show you :bad tag results
21:07defnchouser: it seems like it happens over time
21:07defnthis was running all day and had no problems but then it just went unresponsive like you saw a minute ago
21:07chouserI saw it earlier, but it seems broken again.
21:07defnnoo!
21:07defnugh
21:08defnyeah my repl is hung
21:09defnand here i was feeling all proud of myself
21:09chouserit's a really fantastic idea
21:09Licenserref isn't in the whitelist I think
21:10defnLicenser: how do we know if something is in the whitelist?
21:13Licenserdefn: well you can look in it
21:13Licenseror you can try to run it it will tell you which functions fail the whitelist
21:21Licenserdefn: http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox/safe_fns.clj
21:24RaynesWhich is my doing. :D
21:24LicenserRaynes: yap
21:25RaynesJ is confusing. :(
21:30Licenserdefn: you can esaiely extend yor own matcher :) also you can send either me or Raynes functions that we forgot
21:34Raynesdefn: You might want to send them to me. I never sleep. :|
21:34Raynes:p
21:35LicenserRaynes: yes you do but in a different timezone: p
21:35RaynesHehe.
21:37defnRaynes: I don't think any of us sleep
21:38crowbar7nope
21:38defnI think I slept for 4 hours yesterday and I was able get a response from Licenser within 15min the whole time
21:38defn:)
21:39defnWhen I get done with work I go home and code (I get less done, but it is a nice way to relax)
21:39Crowb4rdefn: Yeah, same here
21:41Crowb4rDon't need my other account online at the moment
22:00brian__what is the covention java booleans ,ie it seems java returns 0 when true and -1 when false, ie
22:01nteonbrian__: ugh, what java does that? i though java programmers hated c-style int return types
22:02brian__(.compareTo "A" "A") 0
22:02brian__0
22:02brian__(.compareTo "A" "A")
22:02brian__0
22:02brian__(.compareTo "A" "A")
22:02brian__0
22:02brian__(.compareTo "A" "A")
22:02brian__0
22:02brian__(.compareTo "A" "A")
22:02brian__sorry about that
22:03nteonbrian__: oh, thats because its a tri-state. it returns -1, 0 or 1
22:03brian__(.compareTo "A" "B")
22:03brian__-1
22:03brian__(.compareTo "A" "B")
22:03brian__-1
22:03brian__(.compareTo "A" "B")
22:03brian__-1
22:03brian__when is it 1?
22:04cemerickbrian__: that's sort order, not equality
22:04nteon,(.compareTo "B" "A")
22:04clojurebot1
22:04nteon:)
22:04brian__ok
22:04nteon-1 is <, 0 is ==, 1 is >
22:04cemerickbrian__: see java.lang.Comparable
22:04cemerickjavadocs are your friend
22:05brian__yea but in clojure, how do you deal with java boolean, to be "idiomatic"
22:06cemerickclojure boolean are java booleans
22:06cemerickto generalize, all of clojure scalars are java scalars
22:07nteon,(= "a" (.toLowerCase "A"))
22:07clojurebottrue
22:07nteon,(= "b" "a")
22:07clojurebotfalse
22:07brian__ok, thanks
22:07nteon,(doc =)
22:07clojurebot"([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison."
22:09brian__i was using (if (java boolean)), which is true for -1 and 0
22:09cemerickbrian__: that's...unadvisable
22:10brian__yea, actally compareTo, as you said, is not a boolean, oops
22:10JonSmithis there a fleetdb version that runs in clojure 1.2?
22:14brian__i dont understand this though "Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison.""
22:15cemerickbrian__: I would suggest picking up Halloway's book to start, "Programming Clojure"
22:15cemerickit provides a very solid and gentle introduction
22:15brian__yea, i have it
22:15JonSmithis like, lets say you have 2 strings "foo" and "foo"
22:16JonSmithor like (let [f "foo", g "foo"] (= f g))
22:16JonSmithif it is value that's true
22:16JonSmithif it is identity that is false
22:16JonSmithso pretty much, it works the way you would expect it to
22:17brian__ok , i think i get it
22:17brian__f ang g are different identities with equal values
22:17cemerickPut another way, persistent data structures allow you to treat maps, lists, vectors, etc. as values more similar to numbers than the mutable objects that are common elsewhere.
22:18JonSmithyup
22:18alexykin lein-swank, how do you specify the clojure version for the repl?
22:18brian__however Im still trying to grasp that kind of mystical idea
22:19JonSmithwell it also ties into that every time you do an operation on an immutable datastructure, you get a 'new' datastructure
22:20JonSmithso using identity comparison doesn't make a lot of sense, as most of the time you will be getting something with a different identity
22:21cemerickbrian__: e.g. if you perform addition -- (+ 1 1) -- you're not changing either of the 1's, and the result you get is a particular value that will itself remain unchanged forever. Same thing with (merge {:a 5} {:b 6})
22:23Licenserwell I go to nap, see you later
22:23Raynescemerick: <p>How's it going?</b>
22:24Raynesp*
22:24Raynes/fail
22:24cemerickRaynes: good, you?
22:24RaynesOh, forget it now. Smartassery doesn't work when you screw up a closing tag.
22:25brian__yes, i understand that, its seems more concrete than "data and programs are one and the same"
22:25cemerickoh, I see. That was an XML pun. Clever. 9.9
22:25RaynesIt was supposed to be. :x
22:25cemerickbrian__: homoiconicity is a higher-level topic, I'd say. Very worthwhile tho
22:26brian__ok, i will follow the path
22:26cemerickbrian__: welcome :-)
22:32alexykso, how do I defn split depending on the version of clojure, form c.c.str-utils2 or c.c.string, with opposite order of regexp strarg? is it a job for a macro?
22:33defnalexyk: is there a back story to this?
22:33defni just walked in
22:33alexykdefn: that's the whole story
22:34alexykdefn is used in generic sense :)
22:34alexykin 1.2.x things a-changing'
22:34cemerickI guess we're starting to need those ifdef-esque things from CL
22:36alexykhmm, this just works: (if 1 (defn f [x] (inc x)) (defn f [x] (dec x)))
22:36alexykso I guess this will serve for the toplevel...
22:36defnalexyk: haha trust me i removed that nick highlight ages ago :)
22:37defnalexyk: in my own defense i had this nick pre-clojure
22:37alexykdefn: my client on Mac shows a pop-up via Growl on my nick... so it's unfortunate :)
22:38defnheh -- i use irssi so i have a hilight window, i pick very generic nicknames it would seem
22:38defnim "code" on another network
22:40cemerickalexyk: here's what we'll need in clojure eventually: http://www.faqs.org/faqs/lisp-faq/part2/section-17.html
22:41alexyk"The nascent Common Lisp standard" :)
22:41alexykthe young Simula-67...
22:41cemerickindeed! :-)
22:45alexykhere's my reader conditionalization: http://paste.pocoo.org/show/196610/
22:45alexykhorrible kludgilization
22:46alexyk(+ bgs000 100)
22:46defnI think I write clojure code in a very weird way. I use many many newlines, the indentation helps me. Is that "wrong"?
22:46cemerickyeouch
22:47cemerickalexyk: do you really need to support 1.1 and 1.2?
22:47alexykdefn: it's treason. leave immediately
22:47cemerickdefn: you'll get people flinching at you forever :-)
22:47alexykcemerick: I'm writing a code for a job interview. It must no matter where :)
22:47alexykrun it must
22:47alexykon Mars in a jar of acid lava
22:48cemerickalexyk: can't just pack clojure into your jar, and ship it in one shot?
22:48defn^
22:48cemerickRegardless, I certainly don't mind getting samples that have particular requirements.
22:48defncemerick: flinching in fear of how awesome I am?
22:49alexykcemerick: hmm... I describe how to get things with lein... but reviewers may have their own idiosynracies
22:49cemerickThose sorts of things are totally orthogonal to what actually goes into a hiring decision.
22:49cemerickdefn: likely no, but you can think whatever you like ;-)
22:49alexykcemerick: true, but I just like to overdo it
22:49defnhttp://mumble.net/~campbell/scheme/style.txt
22:49defnI often wonder if that's relevant for clojure
22:50cemerickalexyk: personally, I'd find what you pasted to be a distraction if I were evaluating interview samples, etc.
22:50alexykhow long you guys think before some IronSteel Clojure compiles into x64_86 and runs at the speed of light
22:50cemerickdefn: a lot of it is very sensible. I don't agree with the indentation mentioned there, but that's minor.
22:51alexykcemerick: that's just a support piece of code. I might think is shows a concern for legacy software :)
22:51alexykor general production-cycle awareness
22:51alexykor whatnot
22:51alexykwhen people start talking identation, the language moves too slow
22:51alexykwait 5 years and come back
22:52alexykby then, there will be a Steve Jobs Tab, self-identing and iPad-compatible
22:52alexykwith embedded AI
22:54riddochcI'm having a heck of a time with some classpath issues. Not a java person... On trying to :use or :require things from jars, I get NoClassDefFoundErrors...
22:55riddochcThis is with current master on clojure and clojure-contrib. I'm trying to hunt down a bug in another library that's a result of changes in clojure, by bisecting clojure itself, and for the life of me, I'm having an impossible time scripting runs of building clojure & contrib and running the result with some existing jars.
22:57cemerickriddochc: that sounds painful in general
22:58cemerickWhat class is it failing to find?
22:58defnalexyk: :)
22:58defnit is a terrible difficult bit of "standardization" to be concerned with (indentation and style)
22:59alexykdefn: imaging the glee of a Clojure Style Nazi, beating a new unruly hire into tabulation
23:00alexykthe Company White Space and Parentheses Policy (sign here)
23:00defnheh -- although there are some things which i sort of prefer that IMO increase readability
23:01alexykdefn -- see, I may hide the IRC window, but Growl will show a pop-up if you mention me! the power of Growl is immence. True, I think uniformity is most important in big teams (more than one person)
23:01alexykso uniformity is what matters, as readability is subjective
23:01defnspecifically when you do something like (reduce (fn [x] (comment a very long and complicated function)) {})
23:01riddochcInteresting. It seems to be a problem with *recent* versions of clojure. My 1.1.0-master-SNAPSHOT from January works fine. Garg.
23:01alexykand the Style Nazi is whoever got there first in a company, and has sadistic inclinations
23:02defnbeing able to have that {} on the same level as the initial reduce is nice
23:02defnat the end of a line it makes me think a bit harder
23:02alexykthat's all subjective IMHO
23:02defnyeah im not trying to tell anyone this is the right way
23:02defnjust something ive noticed about the way i read clojure
23:02alexykI write 200 character one-liners in REPL and then unroll them in the editor once they work
23:03alexykkinda all one big line to me :)
23:03alexykheck, 500 characters sometimes
23:03alexykrlwrap works wonders
23:03defnalexyk: same here
23:03defnwhat's rlwrap?
23:03alexykthe thing which is better than jline
23:03alexykC-r in slime
23:04alexykstandalone GNU readline for commandline anything
23:04defnhmm, never used C-r
23:04defnit's not like C-j is it?
23:04alexykdefn: now that's inexcusable
23:04defn:X
23:04alexykC-r is the basis of history! :)
23:05alexykincremental backward search
23:05alexykthrough commandline history
23:05defnoh duh
23:05alexykin emacs-like thingies
23:05defnim sorry about that -- i wasnt putting 2 and 2 together
23:05defn(which equals 5 btw)
23:05alexyknp, kidding
23:06alexykcemerick: when's the next New England Clojure meetup at your place again?
23:07cemerickalexyk: Not sure -- it's been a while! You mean the wmassdevs group, or a clojure-specific meetup at the Snowtide offices?
23:08alexykcemerick: I guess I saw some mentions of a latter! I'm on the VT/NH border so guess you cannot be too far from a Dartmouth-Boston line can you?
23:09defncool: http://github.com/swannodette/macros-tutorial/
23:09defn<--still has no clue about macros
23:09riddochcGreat, check this out. With master on clojure and clojure-contrib:
23:09riddochc(ns bughunt (:require [clojure.contrib [duck-streams :as ds]]))
23:10cemerickalexyk: we had Rich up for a talk almost exactly two years ago, which was great http://muckandbrass.com/web/pages/viewpage.action?pageId=2752684
23:10riddochcjava.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:3)
23:10alexykcemerick: well perhaps it can be a bi-annual tradition! :)
23:10alexykevery even minor version
23:11cemerickwe haven't had anything clojure-specific since then. You can certainly come down for a wmassdevs meetup, which is a lot more informal.
23:11cemerickClojure folk scattered through there, too.
23:11alexykScala people got the Boston Area Scala Enthusiasts going monthly at the Boston Google HQ
23:11riddochccontrib *is* on my classpath, is what's weird about this.
23:12cemerickalexyk: http://wmassdevs.com/ although most of the action (FWIW) is on the list @ http://groups.google.com/group/wmassdevs
23:12alexykriddochc: The ducks are dead. (use 'c.c.io) instead
23:12cemerickriddochc: there's been a significant reorg of contrib
23:12cemerickthere's a thread about it on the clojure-dev list
23:12defn(ns sort-of-funny (:require [clojure.contrib.duck-streams :as dick-streams]))
23:13riddochccemerick: Evidently. So much for easily bisecting contrib...
23:14alexykheadius you don't know what was one line above you
23:14headiusoh yeah?
23:15alexykcemerick: now what "e strip mall with the Wal-Mart and the Barnes and Noble" is meant there, out of 1,000,000,000 in the US? :)
23:15cemerickfeh, what a bad description :-P
23:15alexykheadius: defn can tell you! :)
23:16cemerickalexyk: In Hadley; it's the only Panera around
23:16defnhaha no thanks -- while parsing all the clojure logs i found someone did that awhile back and juvenile as it was, I chuckled
23:16defnbtw -- when are we switching to clojure.contrib.io*
23:16riddochcSo, the bug I *intended* to be hunting down was in a library, clj-peg. Two different runs, the only difference being which version of clojure I'm loading in the classpath. With 1.1.0 from early january, (ns bughunt (:use (com.lithinos.clj-peg core string-wrapper))) gives me nil, conveniently. With master, it gives me this: java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:1)
23:17alexykcemerick: ha, I can take Amtrack to Amherst!
23:17riddochcSame classpath, *except* for the pointers to clojure and clojure-contrib.
23:17alexykalmost a straight line from Dartmouth
23:18cemerickalexyk: how far is that?
23:18alexyk2 hours
23:18cemerickriddochc: yeah, I got one of those a while back. They're buggers to track down.
23:18alexykbut I love Amtrak and have people to visit at U Amherst
23:18alexykso may be one day
23:18cemerickAmherst or UMass?
23:19alexykUMass
23:19riddochccemerick: Guess I'll be bisecting clojure for a couple reasons...
23:19alexykcemerick: so you're practically at Amherst right
23:19cemerickriddochc: bisecting seems like a long path to take. I'd trace the dependencies of the libs in that :use and find the root of the problem.
23:20cemerickalexyk: about 30 min away, yeah
23:20alexykgogole maps shows Hadley almost in Amherst
23:20alexykgoogle maps
23:20slyphonoh man
23:20cemerickriddochc: it's not like you'll want to patch clojure
23:20slyphonhadley!
23:20slyphonwikkid awesome!
23:20cemerickalexyk: we're not in Hadley, but the wmassdevs meetings are
23:20alexykah ok
23:20cemerickslyphon: another local-yocal?
23:21slyphoncemerick: former UMass student
23:21alexykI wonder why not in Amherst than in a nice academic cafe...
23:21slyphoncemerick: used to live in Butterfield
23:21cemerickalexyk: amherst doesn't have any good spaces for a meetup
23:21slyphoncemerick: from what i can remember, it was nice :)
23:21cemerickslyphon: it is :-) Where are you now?
23:21slyphonNoo Yawk
23:21alexykcemerick: academics must gather somewhere! just open the laptops and scare them away!
23:22slyphoncemerick: you a student?
23:22slyphonfaculty member?
23:22slyphonPioneer Valley townie?
23:22cemerickslyphon: ugh, ouch :-)
23:22cemericksmall software company owner
23:22slyphonhahahahaha
23:22slyphonooooh
23:22slyphoncool!
23:23cemerickalexyk: ech, regardless, I try to stay out of amherst for the most part. Hadley and Northampton are more my style.
23:23slyphonnorthampton is the shit
23:23cemerickslyphon: where are you working?
23:23alexykcemerick: yeah, need to visit to see. Only read "An Arsonist's Guide to New England Writer's Houses" set in Amherst so far, but get the idea :)
23:24slyphoncemerick: I'm working for a startup in NY, strangely enough, right across the street from Goldman Sachs
23:24slyphonmotionbox.com is the site
23:24alexykslyphon: did you see the new mural described in the New Yorker then?
23:24cemerickdowntown is the new hip spot for small co's these days I guess
23:24riddochccemerick: Though it sounds like clojure is the issue, since it's not loading things consistently with :require between 1.1.0 and master.
23:24slyphonalexyk: hah, that's behind the bulletproof glass and the bomb-sniffing dogs
23:25alexykslyphon: but still can you see it at all?
23:25slyphoncemerick: yeah, well, the real estate prices down there are stupid cheap (after GS totally ruined the world economy)
23:25slyphonalexyk: i'll have to take a look next time i go by
23:26cemerickriddochc: Certainly possible, but I'd bet on some code you control not tracking changes in clojure that aren't going to be reverted. Either way, you know your codebase better than clojure's, and it's likely simpler and smaller.
23:26slyphoni usually try to avoid it, i have some phobia that i'm going to run into Darth Vader coming out of a meeting
23:26alexykslyphon: are you using clojure for work?
23:26slyphonalexyk: yeah, I'm the systems architect, so i'm using it as part of a little beta project
23:26cemerickalexyk: Interesting-looking book, I'll have to check it out.
23:27slyphontrying to make our encoding queue a little smarter
23:27alexykcemerick: I think if you disprefer Amherst you'll enjoy it :)
23:27slyphonwe're mainly a rails shop, which gets you so far
23:27cemerickalexyk: nice :-D
23:28alexykslyphon: interesting, thought clojure startups are only in the Bay Area
23:28slyphonwell, i'm adventurous
23:28slyphon:)
23:28cemerickwe looked at rails before jumping in bed with compojure...and *wow* there's a lot there. Way, way too complex and magical for me.
23:28slyphonrails is good for what it does
23:28slyphonit's not quite as magical as people think, and a lot of the time you're trying to un-magic it
23:28cemerickThat's what I hear. It seemed like too much to grok, especially given that we're fully committed to clojure otherwise.
23:29riddochcrails is okay until you actually need something beyond what it's designed to make easy.
23:29slyphonyeah
23:29slyphonwe've gone pretty far with it
23:29slyphonand it does scale, despite what people think
23:29slyphonit's just that scaling is hard, no matter what language you're using
23:30riddochcSo long as you don't need anything the rails people haven't already thought of, you're fine with rails.
23:30slyphonehh
23:30slyphonthat's not exactly true
23:30slyphonwe've plugged in MongoDB and a lot of other stuff
23:30slyphonour encoding queue is based in rails
23:31slyphonit's not a *good* choice, but it's served us allright for the last 2 years or so
23:31riddochcOkay, it might not be completely true. I gave up on rails long enough ago that things have likely changed a lot in the meantime.
23:31slyphonriddochc: yeah, i mean
23:31slyphonlook, rails is better than PHP
23:32slyphon(j)ruby is a good language that I've found covers 90% of the cases i need it to cover
23:32slyphonjruby actually lets you scale horizontally more easily
23:32albinowhat 10% are you missing?
23:32defnjruby is exceedingly awesome
23:32riddochcOh, absolutely. You won't hear me advocating PHP over pretty much anything... though I suppose I might consider it before doing a web app in forth, I suppose.
23:32slyphonalbino: macros?
23:32slyphonriddochc: HAH
23:33slyphonalbino: i dunno, it's more the fact that we have a large legacy codebase
23:33slyphonthat's stuck in rails-2.1 and on c-ruby 1.8.7
23:33albinoslyphon: ugh
23:33slyphonthat makes it difficult to scale without "throwing hardware at the problem"
23:33slyphonso we've had to get creative
23:33riddochcHm. Then again, forth might actually have a stronger tendency to stylistic consistency than PHP. I might reconsider that...
23:33albinothrowing hardware is fun if you have the budget to do so
23:33slyphonand try to chip away at the hairball (to mix metaphors)
23:33slyphonindeed
23:34defnphp is i think without a doubt the ugliest mixture of language i've ever seen
23:34defni have to write some of that at work in the next few days -- and i am absolutely dreading it
23:34slyphoni'm using clojure for a specific case where i need JTA/2PC
23:35slyphonand i didn't dig Scala, and I got tired of doing stuff in jruby
23:35riddochcOkay, I might use PHP for a web app before hand-coding assembly for the same... ;)
23:35slyphonriddochc: heh
23:35albinoriddochc: what about coding a webapp in C, would you take php over that?
23:35slyphonor classic C cgi with embedded HTML
23:35defnpoor PHP'ers -- I sort of feel bad for them
23:35defnall this hatred
23:35slyphondefn: it's hard being dumb
23:35albinowell deserved
23:36riddochcalbino: That's a tough question. I dislike C rather strongly, too. Though I probably shouldn't say that *too* loud...
23:36defnsome of them just dont know any better -- lisp is a scary thing to many people unfortunately
23:36slyphonis there a way of seeding the random number generator that 'shuffle' uses?
23:36defni just got my friend started on clojure -- he has been watching me for 4-5 months over my shoulder. at first he thought it was "weird", and then it was "kind of interesting", and now it's "wow"
23:36slyphonthat's why i like clojure, it's like CL without the bullshit
23:36slyphonplus the JVM
23:37defnhe's doing project euler and im critiquing his code -- he started things off with a loop/recur -- i said NO! MUST NOT LOOP!
23:37slyphon:)
23:37defnit's fun to see it from the other angle, knowing a tiny bit about clojure now
23:37defni immediately was like "okay where's my for loop"
23:38_ato,(java.util.Collections/shuffle [1 2 3] (java.util.Random. 57))
23:38clojurebotjava.lang.UnsupportedOperationException
23:39_ato,(seq (doto (java.util.ArrayList. [1 2 3]) (java.util.Collections/shuffle (java.util.Random. 57))))
23:39clojurebot(1 3 2)
23:39slyphonoh
23:39slyphonright on
23:39slyphonso that's totally not lazy
23:43_atoshuffle would be tricky to do efficiently and lazy, I think
23:43slyphon_ato: oh, i don't doubt it
23:43slyphonkind of sucks you can't set up a random-number generator specifically for clojure's core though
23:43cemerickshuffle is by definition not lazy, no?
23:44_atoyeah :(
23:44slyphoni mean
23:44_atocemerick: ah yes, you're right, since you need all the elements in RAM to do it
23:44slyphonmonkey-patching it would work, but that's really...nasty
23:44slyphon_ato: wouldn't you need only the list of indexes of a vector?
23:44slyphonoh, wait, i see your point
23:44_atobut suppose the first index is the last element ;-)
23:44slyphonyeah, totally
23:48riddochcSo, I'm curious. I'm still really new to clojure, but I'm more familiar with CL than scheme. Which would you say it's closer to, in general?
23:50alexykhow do I obliterate a symbol from a namespace again?
23:50cemerickriddochc: strong elements of both, really
23:51cemerickit feels more like a scheme in general usage because of the lisp-1 heritage
23:51cemerickbut it has CL-style macros
23:51cemerickbut they're hygenic
23:51cemerick+ reader macros
23:51_atoalexyk: ns-unmap?
23:51cemerickso, it's a mix
23:51alexyk_ato: o!
23:53alexyk_ato: say I have a symbol aliased to another namespace. Can I still ns-unmap it, or is there an unalias?
23:54_atoalexyk: there's a ns-unalias
23:55riddochccemerick: That makes sense. I only really started looking at scheme around the same time as I discovered clojure, for other reasons...
23:55alexyk_ato: will it do the same thing for an alias?
23:55riddochccemerick: Though I've used CL for a few years.
23:57_atoalexyk: not sure what you mean. If you do (require '[clojure.contrib.seq-utils as foo]) you can do foo/partition-by, but then (ns-unalias *ns* 'foo) and you can't do it anymore
23:57_atos/as/:as/
23:58alexyk_ato: right; say I do (ns-unmap *ns* 'foo) instead -- same effect? foo still alive in c.c.seq-utils?
23:59_atoah, no. foo and foo/* are totally different. By creating an alias you're not mapping the symbol
23:59_atoeg you can alias foo to seq-utils and then define foo be a function, and both will work
23:59_atothey're independent