#clojure logs

2010-01-27

00:09alexykwhat is (not equals)?
00:09alexyki.e. how do we check x /= 0?
00:27alexyknot=, sleepy people
01:18cschepis using maven to build the latest clojure-contrib required?
01:19dnolencschep no
01:19dnolenyou just need the clojure.jar itself
01:21cschepdnolen: do i need to write my own build.xml? does it matter if i used "mvn package" instead to build it?
01:22dnolencschep: I doubt that. but someone who uses maven more frequently will need to chime in here.
01:23cschepmost of the stuff online says to just git pull and type ant
01:23cschepin the clojure-contrib dir, but build.xml isn't there anymore..
01:23cschepha ha
01:23dnolencschep: that works for clojure
01:24dnolento build clojure-contrib, ant -Dclojure.jar=path/to/clojure.jar
01:24cschepoh, alright.
01:24cschepdnolen: it still needs a build.xml file doesn't it?
01:25dnolencschep: probably, if you checked it from source you should definitely have that.
01:25dnolencschep: oh hmm, you're right it's not a part of contrib anymore.
01:26dnolenand I see the github page has maven instructions, and that doesn't work for you?
01:26cschepdnolen: i think it got it built by just running "mvn package" but i was just kinda making sure that's right...there must be a bunch of old blog posts online all saying to use ant
01:27dnolencshep: i'm pretty sure github is up-to-date. I was clearly behind the times.
01:28cschepdnolen: that's cool, I appreciate the response, it's not very lively around here!
01:28dnolencschep: well it's a bit late. usually it's hoppin'
01:28cschepdnolen:
01:28cschepdnolen: yeah that's what i figured.
02:56RaynesWow. Clojars search is useless.
03:03RaynesI have got to get a new mouse. I can't use the scroll wheel without the middle mouse button firing. Does all sorts of uncool stuff on Ubuntu.
03:04vu3rddIs the slime/swank working with the current master git repo of clojure?
03:05vu3rddLooks like commit 277f02 (jan 14) broke it.
03:11RaynesYay! I fixed my mouse wheel.
03:11RaynesTurns out I just needed to clean out about 2 years of caked on grime out from underneath it.
03:14simplechatouch
03:16RaynesThere is a message here, kids: don't forget to clean behind your mousewheels. ;)
03:19RaynesI really need a better way to test this email stuff I'm doing. Sending myself a message every time I need to test the get-emails function is really killing my mood. :|
03:20RaynesI should write a function that sends myself the email!
06:20AWizzArd~seen kotarak
06:20clojurebotkotarak was last seen quiting IRC, 2170 minutes ago
06:28Raynes~haskell
06:28clojurebot"you have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work." -- ayrnieu
06:30nubaheh
06:31Raynes~ocaml
06:31clojurebotHuh?
06:31RaynesAw.
06:31nuba~java
06:31clojurebot
06:31RaynesThat's the most awesome one.
06:32nubaits good
06:47lypanovlol. i did not know my console could display that.
06:48cemerickcgrand: I remember you putting together an alternative to seque / fill-queue a while back -- where did that go?
06:50esjthis ? http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
06:52cemerickesj: yes, thanks!
06:58cemerickhrm, now to decide between pipe, seque, and fill-queue
07:10opqdonutwhy is there a not-any? but no any?
07:12opqdonutoh, it's some?
08:16vu3rddI am tryint to learn compojure.. have a simple app from Programming Clojure book.
08:17vu3rddwhen I :reload the namespace, I get a java.net.BindException
08:17vu3rddsaying address already in use.
08:19cgrandcemerick: don't use that! it's just a PoC.
08:19cemerickvu3rdd: you're the namespace you're loading is trying to start up another server
08:19cemerickcgrand: I won't be, the API isn't right for what I'm doing. Looks perfectly reasonable enough to use, though.
08:20vu3rddcemerick: yes. I thought :reload will stop and start the server bound to the same port?
08:21cemerickvu3rdd: no, :reload only controls the loading of code, and is entirely application independent (e.g. it won't stop and start servers for you as-is)
08:21cemerickjust move your server-init code out of the ns you're reloading, and you should be fine.
08:22cgrandcemerick: ok. Fyi there's a little memory leak (the last consumed item is retained) and I bet this API could be better implemented using a BlockingQueue.
08:24rhickeywow, tons of Clojure tweets in Japanese, as Stu's book is released in translation
08:24vu3rddcemerick: Ah! Thanks a lot.
08:25AWizzArdHi rhickey.
08:25rhickeyAWizzArd: hi
08:25AWizzArdHow was this dsw thing?
08:26cgrandcemerick: btw I added a pom.xml to enlive (generated by lein)
08:26cemerickcgrand: oh, very nice, thank you :-)
08:26esjIs this the idiomatic way to set defaults for arguments ? : (defn a ([] (a 3)) ([x] x))
08:26rhickeyAWizzArd: fine
08:26Chousukeesj: yes
08:27esjthanks
08:27chouserrhickey: fogus has been chatting them up in their native tongue a bit too
08:27rhickeychouser: cool
08:27AWizzArdOh btw, rhickey, would it be okay that I open a ticket or too regarding sorted sets, some feature requests?
08:28rhickeyAWizzArd: which features
08:28rhickey?
08:28ChousukeI need to learn Japanese programming vocabulary :P
08:28esjooh sorted-sets: working with them this very moment.
08:29esjwas wondering if there was a (merge ) ?
08:29chouseresj: into
08:29AWizzArdrhickey: Currently the TreeMaps don't implement SortedSet. So one can't call .subSet on them.
08:29AWizzArdsubseq only returns a seq
08:29chouserwell, merge works too I guess
08:30AWizzArdand subseq can't take indexes. For example, if I know that my sorted set has 500 elements, I can't ask for the elements 30 to 70
08:30esjthanks
08:31esjAWizzArd: that would be a great.
08:31rhickeyAWizzArd: subset is interesting, indexed subseq is an anti-pattern, non-efficient
08:31rhickeysets are not indexed
08:31AWizzArdI see
08:31alexottrhickey: there are also some twits about clojure in russian
08:31rhickeyso, ticket for subset welcome
08:32esjinteresting - I'm using a sorted-set-by to represent ordered maps of data (by one of the keys)
08:32esjit would be really useful to be able to say get me 5 before and after a particular key
08:32AWizzArdesj: yes, I am doing it too. Good set support is very interesting for my Clojure DB system.
08:32rhickeyalexott: yes, saw them too. Unfortunately the auto-translations of both Russian and Japanese are pretty bad - I really can't tell what is being said
08:32chouseresj: you can use subseq and rsubseq to do that
08:33esjindeed ?
08:33AWizzArdesj: you can give a start and end
08:33alexottrhickey: very strange - usually russian -> english is pretty good
08:33esjsplendid ! Thanks gents.
08:34AWizzArdAnother convenience thing could be to be able to tell clojure.set/intersection which order its result should have. When I input into intersection 5 sets and they are all differently ordered, then intersection will go through the shortest and see if its elements show up somewhere else.
08:35chouseresj: to get "5 before", you'll need rsubseq starting with the item whose value you know, then take 5 and reverse. I think.
08:35AWizzArdBut the returned set may be ordered differently, and currently I can't decide which of my inputs has the right order of the result
08:35AWizzArdchouser: is subseq lazy?
08:35AWizzArdif it would return a million entries, can I only take the first 200?
08:35esjchouser: thanks again - I'lll play around with this.
08:35chousersure, though all million are of course in your map or set already.
08:37hchbawrhickey: offical support page here :) http://practical-scheme.net/wiliki/wiliki.cgi?Shiro%3aProgrammingClojure
08:37AWizzArdchouser: do you know if rsubseq runs in O(1)?
08:37AWizzArdthe R part of it
08:37rhickeyAWizzArd: O(logN) like all sorted stuff
08:40rhickeyhchbaw: thanks!
08:46AWizzArdrhickey: when I try to add a new ticket it tells me that I must set a "type" for the ticket (such as "Enhancement"). Unfortunately there is no such field for me. My account name is "awizzard" in Assembla.
08:48rhickeyAWizzArd: are you using the support tab?
08:48AWizzArdyes
08:50rhickeyAWizzArd: try now
08:50AWizzArdgood, now the "type field" appeared
08:50AWizzArdthx
08:50rhickeynp, thanks for letting me know - I guess people haven't been using the support tab!
09:07AWizzArdrhickey: did you create your ca.pdf file with Open Office?
09:08rhickeyAWizzArd: no. I use a Mac and just print to pdf.
09:09AWizzArdOkay I see. I was looking for an editable file, so I can copy and modify it for my own use. Thought you may have it in an editable format.
09:13Chousukehm
09:13Chousukemy slime doesn't work :(
09:13vsteinHello first time here... It appears line-seq throws a RuntimeException when its BufferedReader throws a IOException. I'd like to catch a IOException. Any ideas?
09:14ChousukeI can't evaluate anything within the slime buffer
09:14Chousukehm
09:19rhickeyhttp://it-republik.de/jaxenter/quickvote/
09:20jcromartiewhat's the process for updating clojure-mode?
09:20jcromartiewith ELPA in Aquamacs?
09:28cemerickCan't believe groovy scores so high, in any poll.
09:28cemerickNo, wait, I *can* believe it.
09:38jcromartieswank-clojure/clojure-mode are kind of magicals
09:38jcromartiemagical
09:38jcromartieI wish I knew what swank-clojure means when it says clojure is not installed
09:38jcromartieI have clojure all over the place.
09:39vsteinIs it by intention that line-seq throws RuntimeException when its Buffere
09:39jcromartiesomething like "It appears clojure is not installed in <where it's looking> ... would you like to install it there? Or do you have it installed somewhere else""
09:39vsteinrader throws IOException
09:41Chousukehmh
09:41chouservstein: clojure has to wrap RuntimeExceptions around things at times to skirt Java's checked exception rules
09:41Chousukesomething is wrong with swank-clojure on recent slimes apparently
09:41ChousukeI wish I knew what.
09:42chouservstein: the best work-around is generally just to catch a broader set of exceptions (just Exception or perhaps Error) and then rethrow if you really don't want to handle it.
09:44rhickeyyes, it is the great conundrum of checked exceptions that they frequently force one to change the type of exceptions thrown in nested scopes, especially once closures come into play. Checked exceptions are horribly broken
09:44jcromartieChousuke: I just nuke my ~/.emacs.d/elpa and started over
09:45vsteinchouser: So I should check the cause, and then take actions, or just rethrow? Or is there some idiom people use?
09:45Chousukejcromartie: I have slime from git
09:46Chousukejcromartie: and I'd rather have swank-clojure fixed than use an old slime, but unfortunately I have no clue where to even begin looking :/
09:46wlrChousuke: don't know if it applies but see comments by vu3rdd 08:04-08:05 utc
09:49vsteinrhickey: I guess the checked exception issue will be blown away the day Clojure is in Clojure, Right? Since checked exceptions is a Java compiler detail, isn't it?
09:51rhickeyvstein: yes, it will be possible to flow more things up, although the question will remain - what should the interfaces generated by protocols declare tat they throw (matters when consumed by Java)?
10:00vsteinrhickey: True, thanks. Then I guess, that any core fn wont throw another kind of RTE when exposed to one, right?
10:01rhickeyvstein: depends on the signature to IFn
10:01vsteinrhickey: I see, thanks
10:09stuartsierrarhickey: did you see my compile-time multimethods yesterday?
10:15jasappdid we ever hear where DRW was?
10:16chouserjasapp: DRW Trading Group, a Clojure funder: http://clojure.org/funders
10:16chouserthat's my guess, anyway.
10:16chousertheir page says they have an offic in new york
10:17chouserI hope it was there and not in their Chicago HQ, or I'd have to give rhickey a little talking-to about not letting me know.
10:17angermanhmm JNA is giving me headaches
10:17jasappinteresting
10:26esjmy copy of van Roy and Haridi just turned up. Crumbs ! I'm too scared to even open it.
10:27alexottis anywhere a list of companies/projects, who are using Clojure? Couldn't find - i want to include several examples into my article
10:29woobyalexott: some companies using it are runa.com and flightcaster
10:30chouseralexott: one might assume the companies that are funding clojure are also using it.
10:30angermanwe (emendio.de) are using it too, though business hasn't picked up.
10:31alexottwooby: i already wrote about flightcaster ;-)
10:32jasappalexott: I'm sure you've got sonian too then?
10:32alexottjasapp: no, hadn't heard about it
10:32jasappI think they're the largest employer of clojure programmers
10:32jasapp5 currently
10:33alexottjasapp: thanks - I'll include link to them
10:33jasappor something like that, maybe one of them will correct me
10:42jcromartiethis is bizarre
10:42jcromartiewhen I load a file on my machine it's fine
10:42jcromartiebut when I load it on another I get an EOF
10:42jcromartiein the middle of the file
10:43jcromartiethe whole file is there
10:43jcromartieI've got Clojure 1.1.0 on both
10:44the-kennyEncoding issues?
10:44jcromartiemaybe
10:44jcromartieI'm sending over rsync
10:47jcromartieI'm using OpenJDK on the server with the problem
10:47jcromartieand the only new ingredient in the equation is clojure-mode
10:48jcromartiealso why does clojure-mode give me INSANE indentation on comments
10:48jcromartie?
10:48jcromartieis that some kind of convention?
10:48angermansomething seems broken on your end.
10:48jcromartieyeah really
10:48jcromartieyay clojure-mode
10:49angermanhmpf. Now I'm going to write a JNA testcase :(
10:50Chousukejcromartie: what kind of comments are you using? (how many semicolons)
10:50jcromartieone semicolon
10:51Chousukeone semicolon comments get indented all the way to the right by default IIRC.
10:51Chousukethey're meant for end-of-the-line comments
10:52jcromartiehmm, interesting
10:52Chousuketwo semicolons get aligned with the code immediately below the comment
10:52jcromartieso it's probably some weird stuff getting inserted
10:52jcromartiethat OpenJDK does not like
10:53Chousukeand three semicolons are meant for commenting functions and other top-level stuff.
10:53jcromartiehmm
10:53jcromartieI didn't know this
10:53jcromartiemaybe http://clojure.org/reader needs to be updated
10:53jcromartieit lists Comment (;) Single-line comment ...
10:54Chousukeit's not a reader thing
10:54Chousukeit's just an indentation convention
10:54Chousukeie. you're only supposed to use one semicolon if you do (somecode) ; comment
10:55jcromartieI feel like I have to break out a hex editor here
10:55Chousukewhereas two semicolons are for ;; comment \n (somecode)
10:55jcromartiehmm
10:55chouserjava.lang.Exception: EOF while reading, starting at line 8 (bad.clj:15)
10:56chouserthat's kinda handy
10:56jcromartiestarting at line X would be really nice
10:56chouserI've got it working here
10:56jcromartieI just get java.lang.RuntimeException: java.lang.Exception: EOF while reading (venues.clj:34)
10:57chouserright, I just wrote a patch.
10:58jcromartieOK now every time I require this file the line number of the error keeps increasing
10:59jcromartie!?!?!!?!?
10:59Chousukethe repl is weird
11:06noidiis there a way to convert a map into a struct?
11:08noidiI merge several maps together to get the data of the struct, and it'd be nice if I could just cast it into a struct
11:08the-kenny,(doc struct-map)
11:08the-kennyNo clojurebot today?
11:08jasapphe's had trouble lately
11:08jasapps/he's
11:10noidithe-kenny, how should I use struct-map?
11:11noidi(apply struct-map (create-struct :foo :bar) {:foo 3 :bar 4})
11:11noidi{:foo nil, :bar nil, [:foo 3] [:bar 4]}
11:12Chousukenoidi: why do you need to make it a struct?
11:12chouser,(into (struct (create-struct :foo :bar)) {:foo 1, :bar 2})
11:13Chousukestruct-maps are maps and you can use a map anywhere you can use a struct, unless you use the accessor methods (which no-one does :P)
11:13noidiChousuke, yeah, you're right
11:16noidinow that I think of it, I don't really need to call my defstruct at all, since the map-merging function is the only one (so far) that generates my structs
11:17noidibut I need it just to have something to refer to when defining the expectations of functions dealing with the structs
11:18noidiI'm ashamed to admit that at the moment I quite miss static typing :P
11:18the-kennynoidi: You could use :pre and :post
11:20noidithe-kenny, I don't want runtime checks, I want to document what my functions expect, and it'd be nice to have compile-time checks against that documentation
11:21RaynesA la Haskell.
11:21noidiyup
11:22noidii.e. the compiler would tell me "the function expects key :foo of map m to be a seq of 3-item seqs" instead of the function just throwing a random exception at runtime
11:25RaynesLike chouser's pretty little gem: java.lang.Exception: EOF while reading, starting at line 8 (bad.clj:15)
11:25Raynes;)
11:25noidiyeah, I hate those
11:26noidiI have to document the types anyway (to help avoid gems like that), so not checking the calling code against the spec is just a missing feature, imho
11:26esjnoidi : i'm not sure you can. I believe the basis of a dynamically typed language is that type checking only occurs at runtime. I am not a CS guy though, so others may correct me.
11:27dnolennoidi: or just stop worrying about types. vectors and maps are just about all you need. it's just a different perspective (from what I know of Haskell i like it)
11:28dnolenalso macro-writing would be perhaps arduous with types?
11:31noidiI don't think it would have to change the way Clojure code is written
11:33ChousukeIf there ever will be static checking for Clojure, it'll likely be completely optional.
11:33chouserdnolen: yes -- I think you see that if you look at template haskell
11:34jcromartieI am having a hell of a time with permissions
11:34jcromartieI have a directory that is 777 owned by the same user running clojure
11:34AWizzArdcemerick: take Java into the poll and everything else would score around 0.4%
11:34jcromartiebut I can't seem to rename a temp file to a file in that directory
11:36cemerickAWizzArd: Yeah. Clearly, there needs to be some delineation between "building software" and "put tab A into slot B".
11:37noidimaybe I'm overestimating the usefulness of static typing right now, but writing "code" like this made me think that it'd be nice to be able to write in in a format that the compiler understands: http://gist.github.com/287978
11:38noidiand the only reason I created the struct was to be able to say "the argument foo should be a client-side-mesh"
11:39noidiso from my perspective right now, static typing would involve less typing (as I could use a formal language) and maybe even catch a mistake or two
11:40cemericknoidi: I presume you're looking for haskell + s-expressions, then?
11:41jcromartieshoot, it seems to be a problem with /tmp being on a different device
11:45noidicemerick, more like clojure with static typing + type inference :)
11:46esjif you do without S-exp maybe OCaml ?
11:46cemericknoidi: I'm not sure you could get there without making macros hugely painful, as chouser mentioned.
11:46AWizzArdnoidi: this was of course discussed several times in the past. Currently Clojure is making progress in being rewritten in Clojure. When this happens it may be easier to implement optional static typing, which would indeed be very nice.
11:46noidicemerick, yeah, that might be
11:46rhickeynoidi: how would it handle all of the heterogenous things Clojure supports? And Java inheritance? Both problems for type inference
11:46cemerickthere's qi, which apparently allows for very powerful static typing, but I know nothing about it
11:46AWizzArdAn optional system that finds as much it can would be most preferrable in my opinion.
11:47cemericknoidi: you might find factor interesting *shrug* But that's in a different world entirely.
11:47noidiand I'm not sure if static typing would even be useful, I just started pondering about this when writing the "code" above :P
11:47noidias it looked eerily like static type definitions
11:47chouserrhickey: you saw the quoted metadata bug?
11:48AWizzArdMany things can't get detected or are very difficult. But for other areas it is possible, and currently many of those we don't try to detect.
11:48rhickeychouser: no
11:51rhickeychouser: where?
11:51chouserso far failing to get a link, sorry...
11:54chouserrhickey: http://groups.google.com/group/clojure/msg/c457a36d7bacb7fe
11:55jcromartieanybody using Aquamacs: do you ever see the minibuffer getting "stuck" on something?
11:55jcromartielike no matter how much I hit C-g it doesn't go away
11:55jcromartie"Switch to buffer ..." or whatever it happens to get stuck on
11:55the-kennyjcromartie: Try Esc-Esc-Esc
11:55pjacksonjcromartie: try ESC-ESC-ESC if all else fails
11:56jcromartienice, thanks guys
11:56rhickeychouser: will look, thanks
11:56jcromartieEmacs is the "100 year editor" for more than one reason
11:57pjacksonthe-kenny beat me to it because I had to uppercase more letters.
11:57the-kennypjackson: heh
12:03chouserrhickey: I dug into it a bit, but made no headway beyond the high-level diagnostics in that message.
12:04chouserI don't have enough idea of what the compiler is doing or what it's supposed to be doing in the bytecode emitting parts.
12:19jlongsterHey guys, I'm using Compojure and trying to write a simple middleware which appends a trailing slash to the URL if the current URL 404'ed. I'm getting NullPointerException, though. Does anything look wrong with this?
12:19jlongsterhttp://paste.lisp.org/display/94001
12:19jlongsterI'm using the standard `decorate` function to install it
12:25cemerickjlongster: a lot depends on what's throwing the NPE
12:27jlongstercemerick: I just annotated the paste
12:27jlongsterhttp://paste.lisp.org/display/94001#1
12:28jlongsterStrangely enough, it doesn't throw this error if I simply use curl
12:28jlongsterInstead of hitting it in a browser
12:29cemerickjlongster: those line numbers don't correspond with the source I have. But if curl is working, and a browser isn't that's a little odd. Seems like it's worth a post to the list.
12:33jlongstercemerick: thanks. unfortunately, I don't have time to figure out the exact details, but this seems to work:
12:33jlongsternekk (n=jmb@208.66.67.16) has joined channel #clojure [12:33]
12:33jlongsterERC>
12:33jlongsterer, sorry
12:33jlongsterhttp://paste.lisp.org/display/94001#2
12:34jlongsterSeems like a bug.
12:36cemerickjlongster: ah, you're not getting the api right for redirect-to. It just takes a URL.
12:36cemericke.g. (redirect-to (str (:uri request) "/"))
12:37jlongstercemerick: That was a mistake, which I fixed after I posted it and I was still getting the error. Bad timing on my part.
12:37cemerickjlongster: FYI, compojure folk sometimes hang out over here ---> #compojure
12:37jlongsterI was reading the source code of another web app and they noted a bug about responses not containing a :body key
12:37jlongsteroh, thanks
12:38LauJensenDoes anyone know of a simple Java lib to generate sparklines ?
12:40LauJensen(will try sparkline.org then)
12:45esjLau: those look nice. Pls let me know if you succeed with them.
12:51BrandonWtechnomancy: i've looked more into lein and it makes me wonder something
12:51BrandonWi like how it handles projects, and it is great that it has an easy way to set up a repl with all the correct class paths set up for you
12:52BrandonWand that makes me curious, is it common among clojure developers to just use the clj shell script repl, as opposed to an integrated one a la enclojure, vimclojure or emacs + swank ?
12:56technomancyBrandonW: I don't thing many people use the CLI repl
12:56technomancyit's implicitly discouraged
13:00mtmtechnomancy: any chance of adding ivy dependency support to lein?
13:00maaclIs there a generic (as in not xml/html) templating lib for Clojure?
13:03technomancymtm: ivy uses the same dependency format as maven
13:03technomancy*repository format
13:04mtmah, okay. just need to point lein at ~/.ivy instead of ~/.m2 I suppose
13:08BrandonWdoes the swank clojure integration in emacs allow you to have to change how the repl startup works? so that you could start the integrated repl via 'lein repl'?
13:08technomancyBrandonW: what you want is probably M-x swank-clojure-project
13:08BrandonWwell yeah that's the hard part
13:09BrandonWi did really want to use emacs for clojure since it is so far ahead in terms of lisp-based development
13:09BrandonWbut i can't because of control key usage
13:09BrandonWi just wondered if it was standard to do stuff like that within emacs, so i know i could contribute something similar to vimclojure
13:12esjBrandonW: "lein swank" exists and allows you to connect to a repl. I can't make the classpaths work, but that's an issue with me.
13:13esjsorry, connect slime to a repl from emacs
13:14BrandonWthat's the hard part for me though-- i am using vim now just because it is easier on my fingers
13:15somniumBrandonW: you could map ctrl to menu or capslock or M-x "42" if thats the only thing stopping you from trying slime
13:15BrandonWi tried capslock, didnt really help cause it was still my pinky
13:15BrandonWi was thinking switch it with alt, but then i would still be using control a lot for meta-x which is a pretty common command
13:15Chousukeyou can remap the modifiers pretty freely
13:15BrandonWwhat is M-x "42" ?
13:16ChousukeI have caps-lock as meta and cmd as control in emacs
13:16somniumM-x "42" was a silly example of how you can make any key-press into pretty much whatever you want
13:17BrandonWoh right
13:17BrandonWi think i like the menu idea
13:17BrandonWi didn't try that
13:17BrandonWbind control to the windows key + the menu key so they are reachable by thumb
13:17BrandonWi wish you could rebind keys only inside of emacs :)
13:19somniumBrandonW: you can
13:19HunBrandonW: try binding execute-extended-command to C-x C-m and C-x m. works much better :)
13:21BrandonWwait
13:21BrandonWif i had known that
13:21BrandonWi would have continued using emacs a year ago when i switched to vim
13:22BrandonWhow come when you google for ideas in changing the control key, no one says anything about rebinding inside emacs, it's all changing your xmap and that kind of stuff :(
13:24BrandonWso it is possible to bind alt to the windows key + menu key, and bind control to the alt keys inside emacs? that would make me switch over instantly
13:26ChousukeBrandonW: yes
13:26ChousukeBrandonW: Excepting ridiculous demands, the answer to "is it possible?" is almost always affirmative in emacs. it just depends on how much elisp you're prepared to write.
13:27ChousukeBrandonW: swapping the modifiers is pretty easy
13:27BrandonWyeah that's what i figured
13:27Chousukethere's also a vi emulator for emacs, called viper
13:27BrandonWthat is what drew me back to emacs once i started playing with clojure (my first real experience with lisp, other than one course in college)
13:27Chousukebut it often doesn't work that well with other things :/
13:28Chousukelike paredit
13:28BrandonWbut i kept finding articles saying the only way to do it is binding keys differently in the operating system
13:28BrandonWyeah, i thought about trying viper mode
13:28chouserdoes paredit play along at all with viper mode?
13:29Chousukewell, typing things does work I think, but the viper deletion commands ignore paredit.
13:29somniumIf youre really determined you can hack the paredit bindings (I did)
13:29Chousukehmm, looks like the modifier swapping code I have in my emacs config is mac-specific :/
13:30Chousukehttp://github.com/Chousuke/emacs.d/blob/master/init-mac.el maybe something similar exists for Windows and Linux
13:31BrandonWi don't mind that so much, cause all the keyboards i use are not mac keyboards
13:32BrandonWwhether i'm on arch or vista or windows 7
13:32BrandonWthe best part of this news is that everything works everywhere- i don't have to unlearn all the typical OS commands of ctrl-c etc. because the bindings are inside of emacs
13:32BrandonWand because they are inside emacs, they (assumably) will work across ssh just as well as if you are right at your computer
13:33BrandonWso there are no double-mappings where you have to map keys in X and in virtual consoles
13:33BrandonWi should have talked to you guys years ago so i never switched :O
13:35BrandonWman, all i remember about emacs is ctrl-npfb, heh
13:37Chousukesometimes I wonder whether I should map some basic emacs movement commands to C-h/j/k/l
13:37ChousukeI use vimperator so my fingers are still very trained to use those keys. :P
13:37BrandonWis it uncommon or unheard of to remap C-npfb to M-npfb (or something else?)
13:38BrandonWi don't recall off the top of my head just how much CTRL is used, but if the primary movement keys used alt instead, that might allow me to keep meta where it is, and just move control one key close to the middle of the keyboard
13:38maaclIs there a generic (as in not xml/html) templating lib for Clojure?
13:38ChousukeI don't know. I suck at using the emacs movement commands
13:38ChousukeI use arrows.
13:38BrandonWhaha nice :)
13:38the-kennyme too, except for C-v and M-v
13:39BrandonWyeah that's what i'
13:39Hunbest moving commands in emacs are C-s and C-r
13:39Chousukebut paredit is just awesome
13:39BrandonWi've been realizing
13:39Chousukeand the latex mode too
13:39chouserChousuke: you've been corrupted. You used to use hjkl as one should.
13:39the-kennyUh and I use C-M-f an C-M-b a lot
13:39Hunjust look where you want to be, type the next 5 chars you see and you're there
13:39chouseror perhaps I'm assuming things incorrectly
13:39the-kenny(forward/backward-sexp)
13:39BrandonWis even ignoring the keyboard commands of emacs, the power you have (especially regarding dynamic and high level languages like clojure) is worth so much more
13:39jasappmove them around until your tendonitis goes away
13:39chousermaacl: you might look at StringTemplate (java lib) -- it's been generally recommended
13:39Chousukechouser: I was never very good with vim either
13:40jasappI left control in it's original spot, and eventually my left pinky stopped working correctly
13:40ChousukeThough I still use it for editing config files and such
13:40jasappthat wasn't very fun
13:40Chousukevim is awesome for quick edits.
13:41chouserah, shoot. I was drawn into an editor discussion. again.
13:41Chousukethis has the amusing consequence that I sometimes type vim init.el
13:43Hunalias vi="emacsclient -t"
13:43Hun:)
13:44Chousuke:p
13:44esjIt is widely known Knuth has a pipe organ in his house, upon which tend to think he plays Bach. This is of course untrue. The device is his emacs terminal, and the pedals his modifier keys.
13:46ChousukeI bet there are people who really do use pedals with emacs
13:47jasappThat actually isn't a bad idea
13:47Chousukeit's not, but it still sounds ridiculous
13:47jasappthat'd be kind of cool to hook up control and meta to foot pedals
13:47BrandonWin my googling
13:47bpsmi have pedals for my kinesis ergo keyboard, and I use emacs. I don't use the pedals much though. ;-)
13:47BrandonWi've seen people use both pedals
13:47BrandonWand a very funky looking keyboard where all the modifiers were reachable by your thumbs
13:48esjno ! I was totally taking the Mickey.
13:48jasappbpsm: you clearly need to map the pedals to control and meta
13:48jasapp:)
13:48bpsmjasapp: yea, I know, but my sense of timing just isn't good enough, so I end up syncopating my modifiers... and that's just bad.
13:48ChousukeI think emacs is actually designed to be used with keyboards where you can use your palms to press modifier keys, instead of fingers.
13:49jasappChousuke: which keyboard is that?
13:49Chousukeone with big enough modifier keys I guess.
13:50bpsmjasapp: "which keyboard?": this one: http://en.wikipedia.org/wiki/Space-cadet_keyboard
13:52BrandonWso basically to summarize, i should try binding execute-extended-command and/or viper mode
13:53BrandonWnow the rough part, is i have to relearn/remember emacs configuration enough so that i can set those up before i start learning it again..
13:53raeki'm thinking about representing URIs as clojure keywords, since I will keep a lot of them and compare them for equality very often. is this a good idea?
13:54stuartsierrano
13:54stuartsierrause String.intern
13:55raekah, I see...
13:55raekthis was most probably what I were looking for
13:55raekthanks!
14:10BrandonWsorry, but i'm still trying to google on how exactly to change modifier keys inside emacs only and i can't seem to find anything
14:11BrandonWi found on the emacs side it flat out says it is impossible to swap control + caps lock inside emacs, and a couple of other results saying they swapped alt + control outside of emacs because they didn't know if it was possible inside of emacs
14:11grammatidoes anyone here use leiningen on Windows?
14:12DeusExPikachuon cyclic definitions, its possible to write functions that depend on each other using 'declare, but is it possible to do that with local bindings?
14:13chouserDeusExPikachu: yes, with letfn
14:14DeusExPikachuchouser: what about with recursively defined sequences?
14:14chouserI'm not sure what you mean.
14:15robwolfegrammati: I use lein on Windows
14:15grammatiok, so it works? more-or-less?
14:16robwolfesure, I wrote simple "bat" file for this
14:16DeusExPikachuchouser: normally in a let form, you can't define new locals that depend on later defined locals. I'm making nested sequences that depends on later definitions of sequences that depend on the first sequence
14:17dnolenBrandonW: are you on a mac?
14:17BrandonWno
14:17BrandonWwindows/arch linux typically
14:18chouserDeusExPikachu: letfn allows you to define locally-named fns that can refer to each other in their bodies.
14:18BrandonWalthough my co-worker would probably be interested in the mac commands, he is also interested in trying out emacs again if you can rebind control and alt freely within emacs
14:18dnolenBrandonW: on mac you have two possibilities, OS Keyboard Prefs, or mac specific extensions to Carbon Emacs and Aquamancs.
14:19dnolen(setq mac-option-modifier 'meta) (setq mac-command-modifier 'ctrl)
14:19dnolen
14:19dnolenis what I do.
14:19DeusExPikachuchouser: maybe I can wrap the sequences in local functions that return sequences?
14:20BrandonWsee i don't mind having an OS specific extension, as long as it is contained within emacs
14:20chouserDeusExPikachu: possibly. I'm still not quite sure what you mean by defining a sequence.
14:20BrandonWis there something similar to mac-option-modifier except for non-mac keyboards?
14:22DeusExPikachuchouser: something like (let [foo (list :a 1 2 3 bar) bar (list 1 2 foo)])
14:22ChousukeBrandonW: it's not really for mac keyboards, but for the Mac OS :/
14:23BrandonWouch
14:23BrandonWso it isn't an api that is available in windows/*nix in a different form
14:23BrandonWit's just that apple allows their OS to rebind keys per app, and other OS don't? :(
14:24grammatirobwolf: I don't understand this part of your bat file: rem add jars found under "lib" directory to CLASSPATH
14:24grammatiwhat exactly is expected to be in lib?
14:24grammatido I need anything other than leiningen and clojure jars on the classpath?
14:25robwolfegrammati: all your dependencies after running "lein deps"
14:25DeusExPikachumy actual problem I'm trying to solve is there is this parsing expression grammar (PEG) I'm defining with s-expression like syntax, ie (:ordered-choice exp1 exp2), and normally these are bound to names, most PEG definitions have cycles though, and trying to solve that problem
14:25grammatiI'm still at the "self-install" stage
14:25grammatihaven't got that to work yet
14:25robwolfegrammati: self-install does not work on Windows
14:25chouserDeusExPikachu: not sure if this helps: (letfn [(foo [] (lazy-cat [:a 1 2 3] (bar))) (bar [] (lazy-cat [1 2] (foo)))] (foo))
14:25grammatioh, ok, I'll stop trying that then :)
14:26robwolfeyou need to download Leinigen by yourself
14:26grammatiok, thanks, I'll give that a try
14:26DeusExPikachuchouser: that might work, I'll try it out
14:29jcromartiechouser: you rock, man... thanks for the EOF fix :)
14:30chouserjcromartie: sure! I hope the line number it reports is actually helpful in real-world cases.
14:32jcromartieheh, at least it's a start
14:32jcromartie(P.S. my problem earlier was not encoding or parens-related after all... just an exception that I didn't realize was an inner exception)
14:33jcromartiemaybe I'll try my hand at improving the REPL :)
14:55stacktracerI have a Java codebase, and would like to use Clojure data structures (PersistentHashMap, et al.) from my Java code. Is there any reason that this wouldn't be a good idea?
14:56chouserstacktracer: because they're persistent and don't have generics, the code to use them will not be particularly idiomatic Java. But it should actually work just fine.
14:57stacktracerchouser: cool -- thanks!
15:09cemerickstacktracer: clojure's data structures have leaked into our java codebase quite a bit -- they're not the prettiest things to use, but they're handy and work as you'd expect.
15:10chouserhey, I only said "not particularly idiomatic" ;-)
15:10rhickeythat's fair
15:10stuartsierrai only said they need reindenting
15:10rhickeyheh
15:10the-kennyWe talk about pure Java. Everything is ugly in Java.
15:10rhickeyIdea did that for me once already
15:10the-kenny*hides under a desk*
15:11stuartsierraIdea has strange ideas about indentation then
15:11cemerickrhickey: not ugly, just sticking out like a sore thumb far from her native land ;-)
15:11stacktracerbeautiful on the inside
15:11chouser:set noexpandtab tabstop=4 cinoptions=j1>1s{1s
15:12rhickeyon an update they toggled reformat-on-checkin on me, and coupled it with an indentation bug
15:12stuartsierraah
15:12rhickeynot to say my indentation was that great
15:12chouserthat's what it takes to convince vim to indent like rhickey
15:13technomancyone of these days I'm going to steal everyones' laptops and covertly configure them to highlight lines over 80 columns long
15:13chousertechnomancy: yay! I'd help.
15:13the-kennyme too
15:13stuartsierratechnomancy: just auto-truncate long lines
15:14chouserthough realizing Clojure's java code only wants 4 spaces when it has a tab helps a bit
15:14stuartsierraand do it at 72 columns
15:15stuartsierraAnd make everyone write Literate Programs
15:15chouseruh
15:18dnolenauto-truncate +1 this isn't 1970
15:19stacktracercemerick: thanks
15:32arnihermannI'm doing a program which generates program code in erlang from another source program and been playing with it in clojure, so far only printing it to std. out
15:32arnihermanngot any tips on how to collect the generated source and pretty print it?
15:33jasapp,(doc with-out-str)
15:34jasappthat should help you collect it, not sure about making it pretty
15:34arnihermannmmm nice, it's a starting point anyways
15:34arnihermannthanks
15:35jasapp~seen clojurebot
15:35Chousukefor pretty-printing clojure code there's clojure.contrib.pprint at least.
15:35Chousukebut if you need to pretty-print erlang code you might need to parse it first.
15:38DeusExPikachufor the purpose of a certain macro, I need to iterate through some defined bindings and ideally I need to iterate two items in the sequence at a time.... map doesn't seem to fit here, any pointers?
15:38Chousukepartition the sequence?
15:38kotarak,(doc partition)
15:39hiredmanbah
15:39DeusExPikachuthat's it, thanks
15:43hiredmanclojurebot: ping?
15:43clojurebotPONG!
15:51rhickeyhiredman: why not?
15:53AWizzArdrhickey: did you protect the name Clojure?
15:53hiredmanrhickey: I don't know, I assume it's because I am not part of the "team" but I don't know. maybe I can but am unable to find the right place to do it in the ui
15:53AWizzArd~max people
15:53clojurebotmax people is 240
15:53AWizzArdthis is now :-)
15:53LaPingvinohello :)
15:53AWizzArdgrats LaPingvino :-)
15:54LauJensenBlogged a little about Global Warming from a Clojure perspective :) http://www.bestinclass.dk/index.php/2010/01/global-warming/
15:55rhickeyhiredman: if you are not a contributor, you can submit issues using the Support tab. If you are a contributor, you need to use your real name on Assembla and I'll make you a member
15:56hiredmanreal name as my login, or in the personal information thing?
15:56rhickeyhiredman: I don't think you need to change your login
16:00DeusExPikachuwow, I've reached the point where I need to use symbol macros, props to Konrad
16:01kotarakDeusExPikachu: scary
16:03DeusExPikachukotarak: its actually worse, I need to write a macro that takes forms and decorate it with symbol macros implicitly defined by the user and interpolates that into letfns ...
16:04DeusExPikachuI think its the most complicated macro I've tackled so far
16:04kotarakDeusExPikachu: scary++
16:04hiredmanrhickey: ok
16:04kotarakDeusExPikachu: I'm just moving away from macros.
16:04hiredmanDeusExPikachu: sounds pretty horible
16:05DeusExPikachuI'll post my code on github in a bit, I'm calling it simple-peg, will release under very open source friendly terms
16:05DeusExPikachuin contrast to clj-peg
16:09rhickeyhiredman: ok, you should be all set
16:09krumholti know i brought this up before, but if it is not too much of a terrible inconvenience could we get (apply foo) back (compared to (apply foo nil)? if there is no real need for that to go away
16:09hiredmanrhickey: thanks!
16:10AWizzArdwhat is different between (apply foo) and (foo)?
16:10krumholtAWizzArd, none
16:10AWizzArdah ok
16:10krumholtbut i use a lot of functions that produce functions to call them looks like ((foo))
16:10cemerickmake it easier for macro writers? *shrug*
16:11krumholtand (apply (foo)) is much clearer
16:11krumholtthat duplicate (( is hard to miss when you read the code again
16:11AWizzArdkrumholt: maybe (def äplei #(apply %1 nil))?
16:11cemerickkrumholt: eh, just get used to ((foo)) :-)
16:12krumholti could make a macro myself but why did that go away in the first place?
16:12AWizzArdcemerick: the real fun begins at level 5 :)
16:12rhickeykrumholt: when did it 'go away'? I'm not sure that was ever supported
16:12krumholtit was
16:12krumholtbefor i updatet to 1.1
16:12cemerickAWizzArd: sometimes there can be too many levels of indirection :-)
16:12AWizzArd*g*
16:12rhickeykrumholt: like, supported in the doc string?
16:13krumholtrhickey, hm i don't know like supported as in i used it a lot and after updating to 1.1 it didn't work anymore
16:15krumholtas i said if this is a big problem to change i don't care about it. but it seems natural for apply to support that
16:15krumholtit's just to make my code look more pretty
16:16DeusExPikachuwhat's the way to use a lib's private functions?
16:17AWizzArdbe in the right ns
16:17cemerickDeusExPikachu: (#'ns/private-var args...)
16:17AWizzArdand know what you are doing
16:18AWizzArda propos private.. defonce- would also be nice
16:23DeusExPikachuok, I think I'll not do that in this case, but then now need idiomatic way to pick every other item in seq
16:24hiredman,(doc take-nth)
16:24clojurebot"([n coll]); Returns a lazy seq of every nth item in coll."
16:24hiredman,(take-nth 2 (range 10))
16:24clojurebot(0 2 4 6 8)
16:24DeusExPikachuwhops, I assumed that did something different
16:24DeusExPikachuyeah thats it -_-
16:28jlongsterWhat's is Clojure's equivalent of Scheme's `cond` and `case` statements?
16:29AWizzArd,(doc cond)
16:29clojurebot"([& clauses]); Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate any of the other tests or exprs. (cond) returns nil."
16:29AWizzArd,(doc case)
16:29clojurebot"clojure.contrib.fcase/case;[[test-value & clauses]]; Like cond, but test-value is compared against the value of each test expression with =. If they are equal, executes the \"body\" expression. Optional last expression is executed if none of the test expressions match."
16:29chouserheh
16:30kotarak,(doc condp)
16:30clojurebot"([pred expr & clauses]); Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, its result-fn, which must
16:30jlongsterThanks. I didn't see it in their documentation.
16:31kotarak,(condp = 5 1 1 2 2 3 3 4 4 5 5 6)
16:31clojurebot5
16:31kotarak,(condp = 10 1 1 2 2 3 3 4 4 5 5 6)
16:31clojurebot6
16:36chouserLauJensen: you probably want to "lose" your head, not "loose" it
16:36LauJensenhehe
16:36LauJensenThanks
16:42DeusExPikachuhmm, trying to get this symbol macro to work, (symbol-macrolet [a (a)] a), I want something like (do a) to turn into (do (a)), something I'm missing?
16:43DeusExPikachusorry, the error is it turns into stack-overflow
16:45DeusExPikachuI think its expanding a into (a), and then recursively expanding (a)
16:45DeusExPikachuI kinda just need a one shot
16:47hiredmanmakes sense, macros do expand recursively
16:47DeusExPikachuexcept I need a one shot
16:48hiredmansounds horrible
16:51DeusExPikachuok, think I have a workaround
17:48krumholthow can i access a field that i defined in a deftype?
17:48hiredman:a
17:49krumholtoh thats nice. thank you
18:08DeusExPikachuwell finished that beast of a macro, but now I gotta debug a parser generator, yay
18:12krumholtcan i use still deftype with multimethods and without a protocol or is that obsolete?
18:13Chousukemultimethods are not obsolete
18:14Chousukeprotocols are a special case of multimethods, implemented more efficiently
18:15dnolenChousuke: "special case" might be a little bit misleading right? They are a separate system than multimethods.
18:15krumholthm ok so i can still use deftype and then dispatch on the type?
18:16Chousukeseparate system, yeah, but multimethods can do everything protocols can, as far as I know
18:16Chousukethey're just less efficient. :/
18:19krumholtok. thanks. i'll use multimethods
18:38alexykthe algorithmic fun problem of the day: implement the longest contiguous increasing subsequence in clojure! a very simple description is in http://stackoverflow.com/questions/655817/longest-contiguous-subsequence-algorithm. Basically you scan left to right and notice the length when not increasing anymore. Update to longer if found. The description is imperative; what's a good FP way?
18:54jlongsterHow do I case a string to a number?
18:54jlongster(int "3") doesn't work
18:55Chousuke,(Integer/valueOf "4")
18:55clojurebot4
18:56jlongsterthanks
19:11tomojis there a better way to do (update-in {} [k] #(if % (inc %) 1)) ?
19:11tomojI think I vaguely remember someone asking about this before in here
19:13tomojmaybe (assoc map key (inc (get map k 0))) ?
19:13DeusExPikachuok, http://github.com/bmillare/simple-peg/blob/master/core.clj is where my simple-peg code is, currently trying to debug the parser when you feed it PEGs defined with cycles, at least now others can look at it and tear it apart
19:17tomojin other words, is this ugly? https://gist.github.com/d959ec8067aab3be40b5
19:17tomojseems ugly to me
19:18mquander,(Integer/valueOf "notanumber")
19:18clojurebotjava.lang.NumberFormatException: For input string: "notanumber"
19:28Chousuketomoj: define the fnil function :/
19:29tomojfnil?
19:29Chousuketomoj: (defn fnil [f default] (fn [x] (if x (f x) default)))
19:30Chousukethen you can do ((fnil inc 0) nil) -> 0
19:30tomojoh, just found this http://groups.google.com/group/lawcommons-dev/browse_thread/thread/8b1172af9652c741
19:30tomojsame code there
19:30tomojah, good idea
19:31tomojis using update-in when [k & ks] is just a single key silly?
19:32Chousukenah.
19:32tomojI always feel like there is a missing function there
19:33tomojto parallel assoc/assoc-in
19:33Chousukeupdate, you mean? :)
19:33tomojyep
19:33tomojit doesn't exist, though, does it?
19:33Chousukenope
19:34ChousukeI don't think the update operation is so common that you'd need an analogy to assoc
19:34Chousukewhereas assoc is kind of fundamental
19:34tomojalso assoc takes arbitrarily many kv pairs
19:35Chousukehmm
19:35tomojand my update would be used in a reduce anyway so doesn't need that
19:35Chousuke(update-many k f k2 f2 ...) :P
19:35Chousukewould be silly.
19:35tomojyeah
19:39tomojso fnil is sortof a replacement for maybe from haskell, I guess
19:40alexykis there something like max-by to go together with sort-by?
19:42tomojc.c.accumulators looks interesting
19:43_ato,(doc max-key)
19:43clojurebot"([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."
19:43_atoalexyk: ^
19:43alexyknice
19:44alexyk_ato: you're the clojars guy, right?
19:44_atoalexyk: yep
19:44alexyk_ato: so why was search so bad? :)
19:45alexykjust askin' :)
19:46_atoyou mean why is search currently so buggy?
19:46_atocause I haven't spent enough time on it
19:46alexykah ok :)
19:47alexykso at least the root cause is under control
19:47_atoyeah. I'm working a new version that uses lucene instead of sqlite. Got a couple of migration issues to sort out. I haven't had much time to work on Clojure stuff in the last month or so
19:47_atonearly done though, hope to get it out in the next day or so
19:48_atooh, and yes, it'll have browse support finally
19:48_ato;-0
19:48alexykcool! then everything hidden will be revealed again!
19:48_ato;-)
19:48_atoyes
19:48alexyklucene rules
19:49_atoyes it does. :-)
19:52dnolen_ato: are you using couchdb-lucene?
19:53dnolenI've found it to be pretty slick, and quite easy to use (I thought clojars was on couchdb)
20:08alexykhow would you use max-key to find a pair among say [(1 2) (2 5)] where the second element is the greatest?
20:11Chousuke,(max-key second [1 2] [3 1])
20:11clojurebot[1 2]
20:11alexykright
20:17alexykhere's a version of the contiguous longest subsequence length: any improvements?
20:17alexyk,(->> [1 2 3 4 0 1 2 1 3 4 5 6 2 3 0] (partition 2 1) (partition-by (fn [[x y]] (< x y))) (map count) (apply max) (+ 1))
20:17clojurebotjava.lang.Exception: Unable to resolve symbol: partition-by in this context
20:17alexyk,(->> [1 2 3 4 0 1 2 1 3 4 5 6 2 3 0] (partition 2 1) (clojure.contrib.seq-utils/partition-by (fn [[x y]] (< x y))) (map count) (apply max) (+ 1))
20:17clojurebot5
20:44alexykand here's one with [position length]:
20:44alexyk,(->> [1 2 3 4 0 1 2 1 3 4 5 6 2 3 0] (partition 2 1) (clojure.contrib.seq-utils/partition-by (fn [[x y]] (< x y))) (map count) ((fn [v] [(clojure.contrib.seq-utils/reductions + 0 v) (map inc v)])) (apply zipmap) (apply max-key second))
20:44clojurebot[7 5]
20:45alexyknow here's some FP at work :)
21:01ohpauleezHey guys, is there a better shorthand: (reduce #(or %1 %2) (map odd? [ 2 4 6]))
21:03hiredman,(some odd? [2 4 6])
21:03clojurebotnil
21:03hiredman,(some odd? [2 5 6])
21:03clojurebottrue
21:03ohpauleezthanks hiredman
21:04ohpauleezI knew it felt way to drawn out
21:18alexykmy current repl didn't load the contrib, and has some important data in it. I can load-file seq_utils.clj, but still can't refer to e.g. partition-by. What should I do after load-file to make seq-utils available in the current namespace?
21:19RaynesEmail is confusing. :(
21:24alexykso -- the names do exist now in-ns 'clojure.contrib.seq-utils, how do I make them available without prefix in another namespace?
21:26alexykah, refer...
21:28alexykI tried to define reductions manually and now refer complains about it; how do I undefine it and refer again?
21:29alexykanybody?
21:35chouseralexyk: 'refer'
21:36alexykyep -- but I messed with a function, do I had to (def name ns/name) manually
21:36stuarthallowaywhat part of the new maven build for contrib produces the variant jars? (e.g. the "-slim" jar)?
21:41stuarthallowaychouser: maven won't bite just from a git pull :-)
21:42stuarthallowaybut I sure hope someone who already knows it can add the XML needed to build clojure-contrib-debug.jar for me. 15 minutes of googling has only confirmed that I don't really want to know how it works
21:44chouserheh
21:51alexykare we guaranteed to get keys and vals from sorted-map in the sorted order of keys?
22:01cemerickalexyk: almost certainly
22:02drewrso is &env sugar for getting locals?
22:02cemerickgotta love assurances :-)
22:02cemerickis there any reason that I should feel dirty about sending to *agent*?
22:02alexykcemerick: thx! I can sleep soundly now
22:02alexykcemerick: so long as it's not Smith
22:05chousercemerick: nope, it's good
22:08cemerickchouser: it's certainly more useful (w.r.t. reporting status, etc) than recurring in the sent fn, but there's something about the different flavor of circularity that tweaks me.
22:11alexykwhat's the absolutely shortest way to code this fn: inc if greater than 1?
22:12alexykmay check with not=
22:12drewr#(if (pos? x) (inc x) x)
22:12drewrer, #(if (pos? %) (inc %) %)
22:12alexykdrewr: 1 should not be inc'd
22:13drewrhm, yes
22:13drewr#(if (> % 1) (inc %) %)
22:14alexykyeah, that's kind of expected. I was hoping for some tricks :)
22:20krumholt_alexyk, can x be negative?
22:20alexyknope
22:33tomojso, with latest master including new, could I create a type which acts like a map (and so works with map functions like update-in), but caches subtree counts in individual nodes?
22:33tomojI ask because I don't understand the new stuff at all, and am not sure whether it would be worth trying to understand it tonight only to realize that it won't work for my problem
22:37alexykhow do we tke only odd members of a seq in a simplest way?
22:40krumholt_,(filter odd? [1 2 3 4 5])
22:40clojurebot(1 3 5)
22:40tomojdid you mean odd indexes or odd values?
22:42krumholt_in the index case
22:42krumholt_,(take-nth 2 [1 9 2 9 3 9 4])
22:42clojurebot(1 2 3 4)
22:43tomojoh, nice
22:43tomoj,(take-nth 2 (rest [0 1 2 3 4 5 6 7]))
22:43clojurebot(1 3 5 7)
22:44tomojI was thinking recursion/lazy-seqs :)
22:45krumholt_that will work too :)
22:48tomojI feel like I need a game which forces me to learn all the core and contrib functions
22:48tomojso that at least I know about them while writing my own functions to avoid recursion/lazy-seq ratholes
22:56tomojso I am thinking that maybe deftype can be used to make custom map-like types?
22:56tomojin this case, which interface to use?
22:56tomojAssociative?
22:57ohpauleezchouser: you brave soul
22:57chousertomoj: I think that's right.
22:57ohpauleezI already hacked the pom myself
22:58tomojwhy does the pom need hacking?
22:58tomojI just pulled
22:58chousertomoj: oh, probably ILookup and/or IPersistentMap instead.
22:58ohpauleezmake the build do interesting things, or build stuff into contrib
22:58ohpauleezI'm also running on JDK7, so sometimes it gets wonky
22:58tomojchouser: ok, thanks
22:59chouserI need it to build against my own patched version of clojure. Is this going to be a problem?
22:59tomojIPersistentMap I think since it needs to be "modifiable"
22:59chouseroh man, *everything* is renames.
23:01ohpauleezchouser: you might need to edit the dependencies in the pom, so it doesn't try to pull clojure in. You can do an offline build and drop your own clojure jar in your repo
23:02ohpauleezbut I don't know for sure
23:02chousergah
23:02chouser:-(
23:04chouserinstructions right in the readme, beginning with "Download the maven-ant-tasks JAR..."
23:05chouserheh. I don't even have maven installed.
23:06tomojhmm
23:07tomojwhen I deftype and define methods for IPersistentMap, should I be making implementations of e.g. .assoc, .assocEx, .without from IPersistentMap.java?
23:07tomojor implementations of clojure functions like assoc, get, etc?
23:09chouserthe Java method names
23:09tomojwithout the "." I guess?
23:09tomojunless the examples in (doc deftype) are focused on protocols
23:10tomojmaybe I will write "new branch for dummies" sometime
23:10chouser:-)
23:11chouserno dots, and the names as given in the interface, not the clojure fn that calls them.
23:11chousermaven is stunningly huge.
23:11tomojchouser: thanks for your help
23:13chouserwow. completely failure
23:13ohpauleezhas anyone written a nice tutorial on the new features yet? especially deftype?
23:14chouser[WARNING] JAR will be empty - no content was marked for inclusion! ... Total time: 2 minutes 2 seconds
23:14ohpauleezchouser: what's the issue, test failures?
23:14krumholt_is there anyway in clojure to create a structure in memory without making an object?
23:14chouserkrumholt_: what kind of structure is not an object?
23:15krumholt_chouser, three integers in a row
23:15chouserohpauleez: I shouldn't mess with this tonight. I'll try again tomorrow. Maybe Sierra will be here so I can verbally abuse him.
23:16chouserkrumholt_: about the lightest way I can think of to hold three integers would be an array, but an array is still an object.
23:16ohpauleezhaha, good point, ping me tomorrow if I can help out
23:16chouserohpauleez: great, thanks.
23:16krumholt_chouser, i am asking because i am writing a little graphics application and it is much too slow. the problem doesn't seem to be the math. it's pretty fast on the jvm but if i multiply to vectors i get a third. and all that object creating is costing me all the time
23:17chouserI *was* going to push these Clojure patches, but not without making sure they don't break contrib first.
23:17chouserI guess everyone will just have to wait...
23:17ohpauleezkrumholt_: transients maybe, or parallelize some of that
23:17ohpauleezyou'll have to run it through a profiler to confirm where the bottleneck is
23:18chouserkrumholt_: ah. well, math with primitive numbers is much faster than math with boxed numbers, and the only collection that supports primitives is the Java array.
23:18chouserok, to bed.
23:18krumholt_hm ok thanks
23:20qbgIf we shouldn't use single segment namespaces, what would be a good way to pick a multi-segment namespace?
23:27alexyktomoj: need odd indices. Is there an inverse of interleave, i.e. unzip?
23:28tomojodd indices was solved above
23:30tomojbut if you want n seqs, each containing all elements of the original seq with indices that are i modulo n, hmm
23:30tomojnot sure
23:31tomojis it impossible to use a deftype constructor within a method definition in the deftype?
23:33tomojoh, I see, within the method definition you need TypeName. rather than just TypeName
23:39alexyktomoj: my IRC gapped, didn't see any nice odd indices!
23:41alexykalso: how do we revert partition 2 1? I.e., glue back ((3 2) (2 1)) into (3 2 1), nicely?
23:42krumholt_<krumholt_> ,(take-nth 2 [1 9 2 9 3 9 4])
23:42krumholt_,(take-nth 2 [1 9 2 9 3 9 4])
23:42clojurebot(1 2 3 4)
23:42technomancy_ato: you're back!
23:45technomancyor not...
23:47alexykah! ok
23:57tomojor add a rest if you want odd zero-based indices
23:59krumholt_alexyk, and the anti-partitioning i think would be concat
23:59krumholt_,(apply concat (partition [1 2 3 4 5 6 7 8 9] 2))
23:59clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
23:59krumholt_,(apply concat (partition 2 [1 2 3 4 5 6 7 8 9]))