#clojure log - Jan 27 2010

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:09 alexyk: what is (not equals)?

0:09 i.e. how do we check x /= 0?

0:27 not=, sleepy people

1:18 cschep: is using maven to build the latest clojure-contrib required?

1:19 dnolen: cschep no

1:19 you just need the clojure.jar itself

1:21 cschep: dnolen: do i need to write my own build.xml? does it matter if i used "mvn package" instead to build it?

1:22 dnolen: cschep: I doubt that. but someone who uses maven more frequently will need to chime in here.

1:23 cschep: most of the stuff online says to just git pull and type ant

1:23 in the clojure-contrib dir, but build.xml isn't there anymore..

1:23 ha ha

1:23 dnolen: cschep: that works for clojure

1:24 to build clojure-contrib, ant -Dclojure.jar=path/to/clojure.jar

1:24 cschep: oh, alright.

1:24 dnolen: it still needs a build.xml file doesn't it?

1:25 dnolen: cschep: probably, if you checked it from source you should definitely have that.

1:25 cschep: oh hmm, you're right it's not a part of contrib anymore.

1:26 and I see the github page has maven instructions, and that doesn't work for you?

1:26 cschep: dnolen: 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

1:27 dnolen: cshep: i'm pretty sure github is up-to-date. I was clearly behind the times.

1:28 cschep: dnolen: that's cool, I appreciate the response, it's not very lively around here!

1:28 dnolen: cschep: well it's a bit late. usually it's hoppin'

1:28 cschep: dnolen:

1:28 dnolen: yeah that's what i figured.

2:56 Raynes: Wow. Clojars search is useless.

3:03 I 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.

3:04 vu3rdd: Is the slime/swank working with the current master git repo of clojure?

3:05 Looks like commit 277f02 (jan 14) broke it.

3:11 Raynes: Yay! I fixed my mouse wheel.

3:11 Turns out I just needed to clean out about 2 years of caked on grime out from underneath it.

3:14 simplechat: ouch

3:16 Raynes: There is a message here, kids: don't forget to clean behind your mousewheels. ;)

3:19 I 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. :|

3:20 I should write a function that sends myself the email!

3:20 * Raynes does that.

6:20 AWizzArd: ~seen kotarak

6:20 clojurebot: kotarak was last seen quiting IRC, 2170 minutes ago

6:28 Raynes: ~haskell

6:28 clojurebot: "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

6:30 nuba: heh

6:31 Raynes: ~ocaml

6:31 clojurebot: Huh?

6:31 Raynes: Aw.

6:31 nuba: ~java

6:31 clojurebot:

6:31 Raynes: That's the most awesome one.

6:32 nuba: its good

6:47 lypanov: lol. i did not know my console could display that.

6:48 cemerick: cgrand: I remember you putting together an alternative to seque / fill-queue a while back -- where did that go?

6:50 esj: this ? http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/

6:52 cemerick: esj: yes, thanks!

6:58 hrm, now to decide between pipe, seque, and fill-queue

7:10 opqdonut: why is there a not-any? but no any?

7:12 oh, it's some?

8:16 vu3rdd: I am tryint to learn compojure.. have a simple app from Programming Clojure book.

8:17 when I :reload the namespace, I get a java.net.BindException

8:17 saying address already in use.

8:19 cgrand: cemerick: don't use that! it's just a PoC.

8:19 cemerick: vu3rdd: you're the namespace you're loading is trying to start up another server

8:19 cgrand: I won't be, the API isn't right for what I'm doing. Looks perfectly reasonable enough to use, though.

8:20 vu3rdd: cemerick: yes. I thought :reload will stop and start the server bound to the same port?

8:21 cemerick: vu3rdd: 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)

8:21 just move your server-init code out of the ns you're reloading, and you should be fine.

8:22 cgrand: cemerick: 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.

8:24 rhickey: wow, tons of Clojure tweets in Japanese, as Stu's book is released in translation

8:24 vu3rdd: cemerick: Ah! Thanks a lot.

8:25 AWizzArd: Hi rhickey.

8:25 rhickey: AWizzArd: hi

8:25 AWizzArd: How was this dsw thing?

8:26 cgrand: cemerick: btw I added a pom.xml to enlive (generated by lein)

8:26 cemerick: cgrand: oh, very nice, thank you :-)

8:26 esj: Is this the idiomatic way to set defaults for arguments ? : (defn a ([] (a 3)) ([x] x))

8:26 rhickey: AWizzArd: fine

8:26 Chousuke: esj: yes

8:27 esj: thanks

8:27 chouser: rhickey: fogus has been chatting them up in their native tongue a bit too

8:27 rhickey: chouser: cool

8:27 AWizzArd: Oh btw, rhickey, would it be okay that I open a ticket or too regarding sorted sets, some feature requests?

8:28 rhickey: AWizzArd: which features

8:28 ?

8:28 Chousuke: I need to learn Japanese programming vocabulary :P

8:28 esj: ooh sorted-sets: working with them this very moment.

8:29 was wondering if there was a (merge ) ?

8:29 chouser: esj: into

8:29 AWizzArd: rhickey: Currently the TreeMaps don't implement SortedSet. So one can't call .subSet on them.

8:29 subseq only returns a seq

8:29 chouser: well, merge works too I guess

8:30 AWizzArd: and 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

8:30 esj: thanks

8:31 AWizzArd: that would be a great.

8:31 rhickey: AWizzArd: subset is interesting, indexed subseq is an anti-pattern, non-efficient

8:31 sets are not indexed

8:31 AWizzArd: I see

8:31 alexott: rhickey: there are also some twits about clojure in russian

8:31 rhickey: so, ticket for subset welcome

8:32 esj: interesting - I'm using a sorted-set-by to represent ordered maps of data (by one of the keys)

8:32 it would be really useful to be able to say get me 5 before and after a particular key

8:32 AWizzArd: esj: yes, I am doing it too. Good set support is very interesting for my Clojure DB system.

8:32 rhickey: alexott: 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

8:32 chouser: esj: you can use subseq and rsubseq to do that

8:33 esj: indeed ?

8:33 * esj runs to the repl

8:33 AWizzArd: esj: you can give a start and end

8:33 alexott: rhickey: very strange - usually russian -> english is pretty good

8:33 esj: splendid ! Thanks gents.

8:34 AWizzArd: Another 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.

8:35 chouser: esj: to get "5 before", you'll need rsubseq starting with the item whose value you know, then take 5 and reverse. I think.

8:35 AWizzArd: But the returned set may be ordered differently, and currently I can't decide which of my inputs has the right order of the result

8:35 chouser: is subseq lazy?

8:35 if it would return a million entries, can I only take the first 200?

8:35 esj: chouser: thanks again - I'lll play around with this.

8:35 chouser: sure, though all million are of course in your map or set already.

8:37 hchbaw: rhickey: offical support page here :) http://practical-scheme.net/wiliki/wiliki.cgi?Shiro%3aProgrammingClojure

8:37 AWizzArd: chouser: do you know if rsubseq runs in O(1)?

8:37 the R part of it

8:37 rhickey: AWizzArd: O(logN) like all sorted stuff

8:40 hchbaw: thanks!

8:46 AWizzArd: rhickey: 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.

8:48 rhickey: AWizzArd: are you using the support tab?

8:48 AWizzArd: yes

8:50 rhickey: AWizzArd: try now

8:50 AWizzArd: good, now the "type field" appeared

8:50 thx

8:50 rhickey: np, thanks for letting me know - I guess people haven't been using the support tab!

9:07 AWizzArd: rhickey: did you create your ca.pdf file with Open Office?

9:08 rhickey: AWizzArd: no. I use a Mac and just print to pdf.

9:09 AWizzArd: Okay 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.

9:13 Chousuke: hm

9:13 my slime doesn't work :(

9:13 vstein: Hello 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?

9:14 Chousuke: I can't evaluate anything within the slime buffer

9:14 hm

9:19 rhickey: http://it-republik.de/jaxenter/quickvote/

9:20 jcromartie: what's the process for updating clojure-mode?

9:20 with ELPA in Aquamacs?

9:28 cemerick: Can't believe groovy scores so high, in any poll.

9:28 No, wait, I *can* believe it.

9:38 jcromartie: swank-clojure/clojure-mode are kind of magicals

9:38 magical

9:38 I wish I knew what swank-clojure means when it says clojure is not installed

9:38 I have clojure all over the place.

9:39 vstein: Is it by intention that line-seq throws RuntimeException when its Buffere

9:39 jcromartie: something 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""

9:39 vstein: rader throws IOException

9:41 Chousuke: hmh

9:41 chouser: vstein: clojure has to wrap RuntimeExceptions around things at times to skirt Java's checked exception rules

9:41 Chousuke: something is wrong with swank-clojure on recent slimes apparently

9:41 I wish I knew what.

9:42 chouser: vstein: 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.

9:44 rhickey: yes, 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

9:44 jcromartie: Chousuke: I just nuke my ~/.emacs.d/elpa and started over

9:45 vstein: chouser: So I should check the cause, and then take actions, or just rethrow? Or is there some idiom people use?

9:45 Chousuke: jcromartie: I have slime from git

9:46 jcromartie: and I'd rather have swank-clojure fixed than use an old slime, but unfortunately I have no clue where to even begin looking :/

9:46 wlr: Chousuke: don't know if it applies but see comments by vu3rdd 08:04-08:05 utc

9:49 vstein: rhickey: 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?

9:51 rhickey: vstein: 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:00 vstein: rhickey: True, thanks. Then I guess, that any core fn wont throw another kind of RTE when exposed to one, right?

10:01 rhickey: vstein: depends on the signature to IFn

10:01 vstein: rhickey: I see, thanks

10:09 stuartsierra: rhickey: did you see my compile-time multimethods yesterday?

10:15 jasapp: did we ever hear where DRW was?

10:16 chouser: jasapp: DRW Trading Group, a Clojure funder: http://clojure.org/funders

10:16 that's my guess, anyway.

10:16 their page says they have an offic in new york

10:17 I 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:17 angerman: hmm JNA is giving me headaches

10:17 jasapp: interesting

10:26 esj: my copy of van Roy and Haridi just turned up. Crumbs ! I'm too scared to even open it.

10:27 alexott: is anywhere a list of companies/projects, who are using Clojure? Couldn't find - i want to include several examples into my article

10:29 wooby: alexott: some companies using it are runa.com and flightcaster

10:30 chouser: alexott: one might assume the companies that are funding clojure are also using it.

10:30 angerman: we (emendio.de) are using it too, though business hasn't picked up.

10:31 alexott: wooby: i already wrote about flightcaster ;-)

10:32 jasapp: alexott: I'm sure you've got sonian too then?

10:32 alexott: jasapp: no, hadn't heard about it

10:32 jasapp: I think they're the largest employer of clojure programmers

10:32 5 currently

10:33 alexott: jasapp: thanks - I'll include link to them

10:33 jasapp: or something like that, maybe one of them will correct me

10:42 jcromartie: this is bizarre

10:42 when I load a file on my machine it's fine

10:42 but when I load it on another I get an EOF

10:42 in the middle of the file

10:43 the whole file is there

10:43 I've got Clojure 1.1.0 on both

10:44 the-kenny: Encoding issues?

10:44 jcromartie: maybe

10:44 I'm sending over rsync

10:47 I'm using OpenJDK on the server with the problem

10:47 and the only new ingredient in the equation is clojure-mode

10:48 also why does clojure-mode give me INSANE indentation on comments

10:48 ?

10:48 is that some kind of convention?

10:48 angerman: something seems broken on your end.

10:48 jcromartie: yeah really

10:48 yay clojure-mode

10:49 angerman: hmpf. Now I'm going to write a JNA testcase :(

10:50 Chousuke: jcromartie: what kind of comments are you using? (how many semicolons)

10:50 jcromartie: one semicolon

10:51 Chousuke: one semicolon comments get indented all the way to the right by default IIRC.

10:51 they're meant for end-of-the-line comments

10:52 jcromartie: hmm, interesting

10:52 Chousuke: two semicolons get aligned with the code immediately below the comment

10:52 jcromartie: so it's probably some weird stuff getting inserted

10:52 that OpenJDK does not like

10:53 Chousuke: and three semicolons are meant for commenting functions and other top-level stuff.

10:53 jcromartie: hmm

10:53 I didn't know this

10:53 maybe http://clojure.org/reader needs to be updated

10:53 it lists Comment (;) Single-line comment ...

10:54 Chousuke: it's not a reader thing

10:54 it's just an indentation convention

10:54 ie. you're only supposed to use one semicolon if you do (somecode) ; comment

10:55 jcromartie: I feel like I have to break out a hex editor here

10:55 Chousuke: whereas two semicolons are for ;; comment \n (somecode)

10:55 jcromartie: hmm

10:55 chouser: java.lang.Exception: EOF while reading, starting at line 8 (bad.clj:15)

10:56 that's kinda handy

10:56 jcromartie: starting at line X would be really nice

10:56 chouser: I've got it working here

10:56 jcromartie: I just get java.lang.RuntimeException: java.lang.Exception: EOF while reading (venues.clj:34)

10:57 chouser: right, I just wrote a patch.

10:58 jcromartie: OK now every time I require this file the line number of the error keeps increasing

10:59 !?!?!!?!?

10:59 Chousuke: the repl is weird

11:06 noidi: is there a way to convert a map into a struct?

11:08 I 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:08 the-kenny: ,(doc struct-map)

11:08 No clojurebot today?

11:08 jasapp: he's had trouble lately

11:08 s/he's

11:10 noidi: the-kenny, how should I use struct-map?

11:11 (apply struct-map (create-struct :foo :bar) {:foo 3 :bar 4})

11:11 {:foo nil, :bar nil, [:foo 3] [:bar 4]}

11:12 Chousuke: noidi: why do you need to make it a struct?

11:12 chouser: ,(into (struct (create-struct :foo :bar)) {:foo 1, :bar 2})

11:13 Chousuke: struct-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:13 noidi: Chousuke, yeah, you're right

11:16 now 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:17 but I need it just to have something to refer to when defining the expectations of functions dealing with the structs

11:18 I'm ashamed to admit that at the moment I quite miss static typing :P

11:18 the-kenny: noidi: You could use :pre and :post

11:20 noidi: the-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:21 Raynes: A la Haskell.

11:21 noidi: yup

11:22 i.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:25 Raynes: Like chouser's pretty little gem: java.lang.Exception: EOF while reading, starting at line 8 (bad.clj:15)

11:25 ;)

11:25 noidi: yeah, I hate those

11:26 I 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:26 esj: noidi : 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:27 dnolen: noidi: 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:28 also macro-writing would be perhaps arduous with types?

11:31 noidi: I don't think it would have to change the way Clojure code is written

11:33 Chousuke: If there ever will be static checking for Clojure, it'll likely be completely optional.

11:33 chouser: dnolen: yes -- I think you see that if you look at template haskell

11:34 jcromartie: I am having a hell of a time with permissions

11:34 I have a directory that is 777 owned by the same user running clojure

11:34 AWizzArd: cemerick: take Java into the poll and everything else would score around 0.4%

11:34 jcromartie: but I can't seem to rename a temp file to a file in that directory

11:36 cemerick: AWizzArd: Yeah. Clearly, there needs to be some delineation between "building software" and "put tab A into slot B".

11:37 noidi: maybe 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:38 and the only reason I created the struct was to be able to say "the argument foo should be a client-side-mesh"

11:39 so 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:40 cemerick: noidi: I presume you're looking for haskell + s-expressions, then?

11:41 jcromartie: shoot, it seems to be a problem with /tmp being on a different device

11:45 noidi: cemerick, more like clojure with static typing + type inference :)

11:46 esj: if you do without S-exp maybe OCaml ?

11:46 cemerick: noidi: I'm not sure you could get there without making macros hugely painful, as chouser mentioned.

11:46 AWizzArd: noidi: 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:46 noidi: cemerick, yeah, that might be

11:46 rhickey: noidi: how would it handle all of the heterogenous things Clojure supports? And Java inheritance? Both problems for type inference

11:46 cemerick: there's qi, which apparently allows for very powerful static typing, but I know nothing about it

11:46 AWizzArd: An optional system that finds as much it can would be most preferrable in my opinion.

11:47 cemerick: noidi: you might find factor interesting *shrug* But that's in a different world entirely.

11:47 noidi: and I'm not sure if static typing would even be useful, I just started pondering about this when writing the "code" above :P

11:47 as it looked eerily like static type definitions

11:47 chouser: rhickey: you saw the quoted metadata bug?

11:48 AWizzArd: Many 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:48 rhickey: chouser: no

11:51 chouser: where?

11:51 chouser: so far failing to get a link, sorry...

11:54 rhickey: http://groups.google.com/group/clojure/msg/c457a36d7bacb7fe

11:55 jcromartie: anybody using Aquamacs: do you ever see the minibuffer getting "stuck" on something?

11:55 like no matter how much I hit C-g it doesn't go away

11:55 "Switch to buffer ..." or whatever it happens to get stuck on

11:55 the-kenny: jcromartie: Try Esc-Esc-Esc

11:55 pjackson: jcromartie: try ESC-ESC-ESC if all else fails

11:56 jcromartie: nice, thanks guys

11:56 rhickey: chouser: will look, thanks

11:56 jcromartie: Emacs is the "100 year editor" for more than one reason

11:57 pjackson: the-kenny beat me to it because I had to uppercase more letters.

11:57 the-kenny: pjackson: heh

12:03 chouser: rhickey: I dug into it a bit, but made no headway beyond the high-level diagnostics in that message.

12:04 I 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:19 jlongster: Hey 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:19 http://paste.lisp.org/display/94001

12:19 I'm using the standard `decorate` function to install it

12:25 cemerick: jlongster: a lot depends on what's throwing the NPE

12:27 jlongster: cemerick: I just annotated the paste

12:27 http://paste.lisp.org/display/94001#1

12:28 Strangely enough, it doesn't throw this error if I simply use curl

12:28 Instead of hitting it in a browser

12:29 cemerick: jlongster: 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:30 * cemerick is still in compojure noob territory

12:33 jlongster: cemerick: thanks. unfortunately, I don't have time to figure out the exact details, but this seems to work:

12:33 nekk (n=jmb@208.66.67.16) has joined channel #clojure [12:33]

12:33 ERC>

12:33 er, sorry

12:33 http://paste.lisp.org/display/94001#2

12:34 Seems like a bug.

12:36 cemerick: jlongster: ah, you're not getting the api right for redirect-to. It just takes a URL.

12:36 e.g. (redirect-to (str (:uri request) "/"))

12:37 jlongster: cemerick: That was a mistake, which I fixed after I posted it and I was still getting the error. Bad timing on my part.

12:37 cemerick: jlongster: FYI, compojure folk sometimes hang out over here ---> #compojure

12:37 jlongster: I was reading the source code of another web app and they noted a bug about responses not containing a :body key

12:37 oh, thanks

12:38 LauJensen: Does anyone know of a simple Java lib to generate sparklines ?

12:40 (will try sparkline.org then)

12:45 esj: Lau: those look nice. Pls let me know if you succeed with them.

12:51 BrandonW: technomancy: i've looked more into lein and it makes me wonder something

12:51 i 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:52 and 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:56 technomancy: BrandonW: I don't thing many people use the CLI repl

12:56 it's implicitly discouraged

13:00 mtm: technomancy: any chance of adding ivy dependency support to lein?

13:00 maacl: Is there a generic (as in not xml/html) templating lib for Clojure?

13:03 technomancy: mtm: ivy uses the same dependency format as maven

13:03 *repository format

13:04 mtm: ah, okay. just need to point lein at ~/.ivy instead of ~/.m2 I suppose

13:08 BrandonW: does 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:08 technomancy: BrandonW: what you want is probably M-x swank-clojure-project

13:08 BrandonW: well yeah that's the hard part

13:09 i did really want to use emacs for clojure since it is so far ahead in terms of lisp-based development

13:09 but i can't because of control key usage

13:09 i just wondered if it was standard to do stuff like that within emacs, so i know i could contribute something similar to vimclojure

13:12 esj: BrandonW: "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:13 sorry, connect slime to a repl from emacs

13:14 BrandonW: that's the hard part for me though-- i am using vim now just because it is easier on my fingers

13:15 somnium: BrandonW: you could map ctrl to menu or capslock or M-x "42" if thats the only thing stopping you from trying slime

13:15 BrandonW: i tried capslock, didnt really help cause it was still my pinky

13:15 i 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:15 Chousuke: you can remap the modifiers pretty freely

13:15 BrandonW: what is M-x "42" ?

13:16 Chousuke: I have caps-lock as meta and cmd as control in emacs

13:16 * esj is installing a footpedal

13:16 somnium: M-x "42" was a silly example of how you can make any key-press into pretty much whatever you want

13:17 BrandonW: oh right

13:17 i think i like the menu idea

13:17 i didn't try that

13:17 bind control to the windows key + the menu key so they are reachable by thumb

13:17 i wish you could rebind keys only inside of emacs :)

13:19 somnium: BrandonW: you can

13:19 Hun: BrandonW: try binding execute-extended-command to C-x C-m and C-x m. works much better :)

13:21 BrandonW: wait

13:21 if i had known that

13:21 i would have continued using emacs a year ago when i switched to vim

13:22 how 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:24 so 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:26 Chousuke: BrandonW: yes

13:26 BrandonW: 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:27 BrandonW: swapping the modifiers is pretty easy

13:27 BrandonW: yeah that's what i figured

13:27 Chousuke: there's also a vi emulator for emacs, called viper

13:27 BrandonW: that 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:27 Chousuke: but it often doesn't work that well with other things :/

13:28 like paredit

13:28 BrandonW: but i kept finding articles saying the only way to do it is binding keys differently in the operating system

13:28 yeah, i thought about trying viper mode

13:28 chouser: does paredit play along at all with viper mode?

13:29 Chousuke: well, typing things does work I think, but the viper deletion commands ignore paredit.

13:29 somnium: If youre really determined you can hack the paredit bindings (I did)

13:29 Chousuke: hmm, looks like the modifier swapping code I have in my emacs config is mac-specific :/

13:30 http://github.com/Chousuke/emacs.d/blob/master/init-mac.el maybe something similar exists for Windows and Linux

13:31 BrandonW: i don't mind that so much, cause all the keyboards i use are not mac keyboards

13:32 whether i'm on arch or vista or windows 7

13:32 the 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:32 and because they are inside emacs, they (assumably) will work across ssh just as well as if you are right at your computer

13:33 so there are no double-mappings where you have to map keys in X and in virtual consoles

13:33 i should have talked to you guys years ago so i never switched :O

13:35 man, all i remember about emacs is ctrl-npfb, heh

13:37 Chousuke: sometimes I wonder whether I should map some basic emacs movement commands to C-h/j/k/l

13:37 I use vimperator so my fingers are still very trained to use those keys. :P

13:37 BrandonW: is it uncommon or unheard of to remap C-npfb to M-npfb (or something else?)

13:38 i 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:38 maacl: Is there a generic (as in not xml/html) templating lib for Clojure?

13:38 Chousuke: I don't know. I suck at using the emacs movement commands

13:38 I use arrows.

13:38 BrandonW: haha nice :)

13:38 the-kenny: me too, except for C-v and M-v

13:39 BrandonW: yeah that's what i'

13:39 Hun: best moving commands in emacs are C-s and C-r

13:39 Chousuke: but paredit is just awesome

13:39 BrandonW: i've been realizing

13:39 Chousuke: and the latex mode too

13:39 chouser: Chousuke: you've been corrupted. You used to use hjkl as one should.

13:39 the-kenny: Uh and I use C-M-f an C-M-b a lot

13:39 Hun: just look where you want to be, type the next 5 chars you see and you're there

13:39 chouser: or perhaps I'm assuming things incorrectly

13:39 the-kenny: (forward/backward-sexp)

13:39 BrandonW: is 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:39 jasapp: move them around until your tendonitis goes away

13:39 chouser: maacl: you might look at StringTemplate (java lib) -- it's been generally recommended

13:39 Chousuke: chouser: I was never very good with vim either

13:40 jasapp: I left control in it's original spot, and eventually my left pinky stopped working correctly

13:40 Chousuke: Though I still use it for editing config files and such

13:40 jasapp: that wasn't very fun

13:40 Chousuke: vim is awesome for quick edits.

13:41 chouser: ah, shoot. I was drawn into an editor discussion. again.

13:41 * chouser tries to walk away.

13:41 Chousuke: this has the amusing consequence that I sometimes type vim init.el

13:43 Hun: alias vi="emacsclient -t"

13:43 :)

13:44 Chousuke: :p

13:44 esj: It 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:46 Chousuke: I bet there are people who really do use pedals with emacs

13:47 jasapp: That actually isn't a bad idea

13:47 Chousuke: it's not, but it still sounds ridiculous

13:47 jasapp: that'd be kind of cool to hook up control and meta to foot pedals

13:47 BrandonW: in my googling

13:47 bpsm: i have pedals for my kinesis ergo keyboard, and I use emacs. I don't use the pedals much though. ;-)

13:47 BrandonW: i've seen people use both pedals

13:47 and a very funky looking keyboard where all the modifiers were reachable by your thumbs

13:48 esj: no ! I was totally taking the Mickey.

13:48 jasapp: bpsm: you clearly need to map the pedals to control and meta

13:48 :)

13:48 bpsm: jasapp: 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:48 Chousuke: I think emacs is actually designed to be used with keyboards where you can use your palms to press modifier keys, instead of fingers.

13:49 jasapp: Chousuke: which keyboard is that?

13:49 Chousuke: one with big enough modifier keys I guess.

13:50 bpsm: jasapp: "which keyboard?": this one: http://en.wikipedia.org/wiki/Space-cadet_keyboard

13:51 * technomancy would use pedals if he didn't have a standing desk

13:52 BrandonW: so basically to summarize, i should try binding execute-extended-command and/or viper mode

13:53 now 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:53 raek: i'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:54 stuartsierra: no

13:54 use String.intern

13:55 raek: ah, I see...

13:55 this was most probably what I were looking for

13:55 thanks!

14:10 BrandonW: sorry, 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:11 i 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:11 grammati: does anyone here use leiningen on Windows?

14:12 DeusExPikachu: on 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:13 chouser: DeusExPikachu: yes, with letfn

14:14 DeusExPikachu: chouser: what about with recursively defined sequences?

14:14 chouser: I'm not sure what you mean.

14:15 robwolfe: grammati: I use lein on Windows

14:15 grammati: ok, so it works? more-or-less?

14:16 robwolfe: sure, I wrote simple "bat" file for this

14:16 DeusExPikachu: chouser: 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:17 dnolen: BrandonW: are you on a mac?

14:17 BrandonW: no

14:17 windows/arch linux typically

14:18 chouser: DeusExPikachu: letfn allows you to define locally-named fns that can refer to each other in their bodies.

14:18 BrandonW: although 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:18 dnolen: BrandonW: on mac you have two possibilities, OS Keyboard Prefs, or mac specific extensions to Carbon Emacs and Aquamancs.

14:19 (setq mac-option-modifier 'meta) (setq mac-command-modifier 'ctrl)

14:19

14:19 is what I do.

14:19 DeusExPikachu: chouser: maybe I can wrap the sequences in local functions that return sequences?

14:20 BrandonW: see i don't mind having an OS specific extension, as long as it is contained within emacs

14:20 chouser: DeusExPikachu: possibly. I'm still not quite sure what you mean by defining a sequence.

14:20 BrandonW: is there something similar to mac-option-modifier except for non-mac keyboards?

14:22 DeusExPikachu: chouser: something like (let [foo (list :a 1 2 3 bar) bar (list 1 2 foo)])

14:22 Chousuke: BrandonW: it's not really for mac keyboards, but for the Mac OS :/

14:23 BrandonW: ouch

14:23 so it isn't an api that is available in windows/*nix in a different form

14:23 it's just that apple allows their OS to rebind keys per app, and other OS don't? :(

14:24 grammati: robwolf: I don't understand this part of your bat file: rem add jars found under "lib" directory to CLASSPATH

14:24 what exactly is expected to be in lib?

14:24 do I need anything other than leiningen and clojure jars on the classpath?

14:25 robwolfe: grammati: all your dependencies after running "lein deps"

14:25 DeusExPikachu: my 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:25 grammati: I'm still at the "self-install" stage

14:25 haven't got that to work yet

14:25 robwolfe: grammati: self-install does not work on Windows

14:25 chouser: DeusExPikachu: not sure if this helps: (letfn [(foo [] (lazy-cat [:a 1 2 3] (bar))) (bar [] (lazy-cat [1 2] (foo)))] (foo))

14:25 grammati: oh, ok, I'll stop trying that then :)

14:26 robwolfe: you need to download Leinigen by yourself

14:26 grammati: ok, thanks, I'll give that a try

14:26 DeusExPikachu: chouser: that might work, I'll try it out

14:29 jcromartie: chouser: you rock, man... thanks for the EOF fix :)

14:30 chouser: jcromartie: sure! I hope the line number it reports is actually helpful in real-world cases.

14:32 jcromartie: heh, at least it's a start

14:32 (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:33 maybe I'll try my hand at improving the REPL :)

14:55 stacktracer: I 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:56 chouser: stacktracer: 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:57 stacktracer: chouser: cool -- thanks!

15:09 cemerick: stacktracer: 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:09 * rhickey hears someone calling his baby ugly...

15:10 chouser: hey, I only said "not particularly idiomatic" ;-)

15:10 rhickey: that's fair

15:10 stuartsierra: i only said they need reindenting

15:10 rhickey: heh

15:10 the-kenny: We talk about pure Java. Everything is ugly in Java.

15:10 rhickey: Idea did that for me once already

15:10 the-kenny: *hides under a desk*

15:11 stuartsierra: Idea has strange ideas about indentation then

15:11 cemerick: rhickey: not ugly, just sticking out like a sore thumb far from her native land ;-)

15:11 stacktracer: beautiful on the inside

15:11 chouser: :set noexpandtab tabstop=4 cinoptions=j1>1s{1s

15:12 rhickey: on an update they toggled reformat-on-checkin on me, and coupled it with an indentation bug

15:12 stuartsierra: ah

15:12 rhickey: not to say my indentation was that great

15:12 chouser: that's what it takes to convince vim to indent like rhickey

15:13 technomancy: one of these days I'm going to steal everyones' laptops and covertly configure them to highlight lines over 80 columns long

15:13 chouser: technomancy: yay! I'd help.

15:13 the-kenny: me too

15:13 stuartsierra: technomancy: just auto-truncate long lines

15:14 chouser: though realizing Clojure's java code only wants 4 spaces when it has a tab helps a bit

15:14 stuartsierra: and do it at 72 columns

15:15 And make everyone write Literate Programs

15:15 chouser: uh

15:15 * stuartsierra is in a sadistic mood today

15:18 dnolen: auto-truncate +1 this isn't 1970

15:19 stacktracer: cemerick: thanks

15:32 arnihermann: I'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:32 got any tips on how to collect the generated source and pretty print it?

15:33 jasapp: ,(doc with-out-str)

15:34 that should help you collect it, not sure about making it pretty

15:34 arnihermann: mmm nice, it's a starting point anyways

15:34 thanks

15:35 jasapp: ~seen clojurebot

15:35 Chousuke: for pretty-printing clojure code there's clojure.contrib.pprint at least.

15:35 but if you need to pretty-print erlang code you might need to parse it first.

15:38 DeusExPikachu: for 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:38 Chousuke: partition the sequence?

15:38 kotarak: ,(doc partition)

15:39 hiredman: bah

15:39 DeusExPikachu: that's it, thanks

15:43 hiredman: clojurebot: ping?

15:43 clojurebot: PONG!

15:48 * hiredman still can't post patches to assembla

15:51 rhickey: hiredman: why not?

15:53 AWizzArd: rhickey: did you protect the name Clojure?

15:53 hiredman: rhickey: 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:53 AWizzArd: ~max people

15:53 clojurebot: max people is 240

15:53 AWizzArd: this is now :-)

15:53 LaPingvino: hello :)

15:53 AWizzArd: grats LaPingvino :-)

15:54 LauJensen: Blogged a little about Global Warming from a Clojure perspective :) http://www.bestinclass.dk/index.php/2010/01/global-warming/

15:55 rhickey: hiredman: 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:56 hiredman: real name as my login, or in the personal information thing?

15:56 rhickey: hiredman: I don't think you need to change your login

16:00 DeusExPikachu: wow, I've reached the point where I need to use symbol macros, props to Konrad

16:01 kotarak: DeusExPikachu: scary

16:03 DeusExPikachu: kotarak: 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:04 I think its the most complicated macro I've tackled so far

16:04 kotarak: DeusExPikachu: scary++

16:04 hiredman: rhickey: ok

16:04 kotarak: DeusExPikachu: I'm just moving away from macros.

16:04 hiredman: DeusExPikachu: sounds pretty horible

16:05 DeusExPikachu: I'll post my code on github in a bit, I'm calling it simple-peg, will release under very open source friendly terms

16:05 in contrast to clj-peg

16:09 rhickey: hiredman: ok, you should be all set

16:09 krumholt: i 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:09 hiredman: rhickey: thanks!

16:10 AWizzArd: what is different between (apply foo) and (foo)?

16:10 krumholt: AWizzArd, none

16:10 AWizzArd: ah ok

16:10 krumholt: but i use a lot of functions that produce functions to call them looks like ((foo))

16:10 cemerick: make it easier for macro writers? *shrug*

16:11 krumholt: and (apply (foo)) is much clearer

16:11 that duplicate (( is hard to miss when you read the code again

16:11 AWizzArd: krumholt: maybe (def äplei #(apply %1 nil))?

16:11 cemerick: krumholt: eh, just get used to ((foo)) :-)

16:12 krumholt: i could make a macro myself but why did that go away in the first place?

16:12 AWizzArd: cemerick: the real fun begins at level 5 :)

16:12 rhickey: krumholt: when did it 'go away'? I'm not sure that was ever supported

16:12 krumholt: it was

16:12 befor i updatet to 1.1

16:12 cemerick: AWizzArd: sometimes there can be too many levels of indirection :-)

16:12 AWizzArd: *g*

16:12 rhickey: krumholt: like, supported in the doc string?

16:13 krumholt: rhickey, 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:15 as 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:15 it's just to make my code look more pretty

16:16 DeusExPikachu: what's the way to use a lib's private functions?

16:17 AWizzArd: be in the right ns

16:17 cemerick: DeusExPikachu: (#'ns/private-var args...)

16:17 AWizzArd: and know what you are doing

16:18 a propos private.. defonce- would also be nice

16:23 DeusExPikachu: ok, I think I'll not do that in this case, but then now need idiomatic way to pick every other item in seq

16:24 hiredman: ,(doc take-nth)

16:24 clojurebot: "([n coll]); Returns a lazy seq of every nth item in coll."

16:24 hiredman: ,(take-nth 2 (range 10))

16:24 clojurebot: (0 2 4 6 8)

16:24 DeusExPikachu: whops, I assumed that did something different

16:24 yeah thats it -_-

16:28 jlongster: What's is Clojure's equivalent of Scheme's `cond` and `case` statements?

16:29 AWizzArd: ,(doc cond)

16:29 clojurebot: "([& 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:29 AWizzArd: ,(doc case)

16:29 clojurebot: "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:29 chouser: heh

16:30 kotarak: ,(doc condp)

16:30 clojurebot: "([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:30 jlongster: Thanks. I didn't see it in their documentation.

16:31 kotarak: ,(condp = 5 1 1 2 2 3 3 4 4 5 5 6)

16:31 clojurebot: 5

16:31 kotarak: ,(condp = 10 1 1 2 2 3 3 4 4 5 5 6)

16:31 clojurebot: 6

16:36 chouser: LauJensen: you probably want to "lose" your head, not "loose" it

16:36 LauJensen: hehe

16:36 Thanks

16:42 DeusExPikachu: hmm, 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:43 sorry, the error is it turns into stack-overflow

16:45 I think its expanding a into (a), and then recursively expanding (a)

16:45 I kinda just need a one shot

16:47 hiredman: makes sense, macros do expand recursively

16:47 DeusExPikachu: except I need a one shot

16:48 hiredman: sounds horrible

16:51 DeusExPikachu: ok, think I have a workaround

17:48 krumholt: how can i access a field that i defined in a deftype?

17:48 hiredman: :a

17:49 krumholt: oh thats nice. thank you

18:08 DeusExPikachu: well finished that beast of a macro, but now I gotta debug a parser generator, yay

18:12 krumholt: can i use still deftype with multimethods and without a protocol or is that obsolete?

18:13 Chousuke: multimethods are not obsolete

18:14 protocols are a special case of multimethods, implemented more efficiently

18:15 dnolen: Chousuke: "special case" might be a little bit misleading right? They are a separate system than multimethods.

18:15 krumholt: hm ok so i can still use deftype and then dispatch on the type?

18:16 Chousuke: separate system, yeah, but multimethods can do everything protocols can, as far as I know

18:16 they're just less efficient. :/

18:19 krumholt: ok. thanks. i'll use multimethods

18:38 alexyk: the 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:54 jlongster: How do I case a string to a number?

18:54 (int "3") doesn't work

18:55 Chousuke: ,(Integer/valueOf "4")

18:55 clojurebot: 4

18:56 jlongster: thanks

19:11 tomoj: is there a better way to do (update-in {} [k] #(if % (inc %) 1)) ?

19:11 I think I vaguely remember someone asking about this before in here

19:13 maybe (assoc map key (inc (get map k 0))) ?

19:13 DeusExPikachu: ok, 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:17 tomoj: in other words, is this ugly? https://gist.github.com/d959ec8067aab3be40b5

19:17 seems ugly to me

19:18 mquander: ,(Integer/valueOf "notanumber")

19:18 clojurebot: java.lang.NumberFormatException: For input string: "notanumber"

19:28 Chousuke: tomoj: define the fnil function :/

19:29 tomoj: fnil?

19:29 Chousuke: tomoj: (defn fnil [f default] (fn [x] (if x (f x) default)))

19:30 then you can do ((fnil inc 0) nil) -> 0

19:30 tomoj: oh, just found this http://groups.google.com/group/lawcommons-dev/browse_thread/thread/8b1172af9652c741

19:30 same code there

19:30 ah, good idea

19:31 is using update-in when [k & ks] is just a single key silly?

19:32 Chousuke: nah.

19:32 tomoj: I always feel like there is a missing function there

19:33 to parallel assoc/assoc-in

19:33 Chousuke: update, you mean? :)

19:33 tomoj: yep

19:33 it doesn't exist, though, does it?

19:33 Chousuke: nope

19:34 I don't think the update operation is so common that you'd need an analogy to assoc

19:34 whereas assoc is kind of fundamental

19:34 tomoj: also assoc takes arbitrarily many kv pairs

19:35 Chousuke: hmm

19:35 tomoj: and my update would be used in a reduce anyway so doesn't need that

19:35 Chousuke: (update-many k f k2 f2 ...) :P

19:35 would be silly.

19:35 tomoj: yeah

19:39 so fnil is sortof a replacement for maybe from haskell, I guess

19:40 alexyk: is there something like max-by to go together with sort-by?

19:42 tomoj: c.c.accumulators looks interesting

19:43 _ato: ,(doc max-key)

19:43 clojurebot: "([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is greatest."

19:43 _ato: alexyk: ^

19:43 alexyk: nice

19:44 _ato: you're the clojars guy, right?

19:44 _ato: alexyk: yep

19:44 alexyk: _ato: so why was search so bad? :)

19:45 just askin' :)

19:46 _ato: you mean why is search currently so buggy?

19:46 cause I haven't spent enough time on it

19:46 alexyk: ah ok :)

19:47 so at least the root cause is under control

19:47 _ato: yeah. 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 nearly done though, hope to get it out in the next day or so

19:48 oh, and yes, it'll have browse support finally

19:48 ;-0

19:48 alexyk: cool! then everything hidden will be revealed again!

19:48 _ato: ;-)

19:48 yes

19:48 alexyk: lucene rules

19:49 _ato: yes it does. :-)

19:52 dnolen: _ato: are you using couchdb-lucene?

19:53 I've found it to be pretty slick, and quite easy to use (I thought clojars was on couchdb)

20:08 alexyk: how would you use max-key to find a pair among say [(1 2) (2 5)] where the second element is the greatest?

20:11 Chousuke: ,(max-key second [1 2] [3 1])

20:11 clojurebot: [1 2]

20:11 alexyk: right

20:17 here's a version of the contiguous longest subsequence length: any improvements?

20:17 ,(->> [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:17 clojurebot: java.lang.Exception: Unable to resolve symbol: partition-by in this context

20:17 alexyk: ,(->> [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:17 clojurebot: 5

20:44 alexyk: and here's one with [position length]:

20:44 ,(->> [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:44 clojurebot: [7 5]

20:45 alexyk: now here's some FP at work :)

21:01 ohpauleez: Hey guys, is there a better shorthand: (reduce #(or %1 %2) (map odd? [ 2 4 6]))

21:03 hiredman: ,(some odd? [2 4 6])

21:03 clojurebot: nil

21:03 hiredman: ,(some odd? [2 5 6])

21:03 clojurebot: true

21:03 ohpauleez: thanks hiredman

21:04 I knew it felt way to drawn out

21:18 alexyk: my 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:19 Raynes: Email is confusing. :(

21:24 alexyk: so -- the names do exist now in-ns 'clojure.contrib.seq-utils, how do I make them available without prefix in another namespace?

21:26 ah, refer...

21:28 I tried to define reductions manually and now refer complains about it; how do I undefine it and refer again?

21:29 anybody?

21:35 chouser: alexyk: 'refer'

21:36 alexyk: yep -- but I messed with a function, do I had to (def name ns/name) manually

21:36 stuarthalloway: what part of the new maven build for contrib produces the variant jars? (e.g. the "-slim" jar)?

21:39 * chouser has been scared to pull contrib

21:41 stuarthalloway: chouser: maven won't bite just from a git pull :-)

21:42 but 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:44 chouser: heh

21:51 alexyk: are we guaranteed to get keys and vals from sorted-map in the sorted order of keys?

22:01 cemerick: alexyk: almost certainly

22:02 drewr: so is &env sugar for getting locals?

22:02 cemerick: gotta love assurances :-)

22:02 is there any reason that I should feel dirty about sending to *agent*?

22:02 alexyk: cemerick: thx! I can sleep soundly now

22:02 cemerick: so long as it's not Smith

22:05 chouser: cemerick: nope, it's good

22:08 cemerick: chouser: 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:11 alexyk: what's the absolutely shortest way to code this fn: inc if greater than 1?

22:12 may check with not=

22:12 drewr: #(if (pos? x) (inc x) x)

22:12 er, #(if (pos? %) (inc %) %)

22:12 alexyk: drewr: 1 should not be inc'd

22:13 drewr: hm, yes

22:13 #(if (> % 1) (inc %) %)

22:14 alexyk: yeah, that's kind of expected. I was hoping for some tricks :)

22:20 krumholt_: alexyk, can x be negative?

22:20 alexyk: nope

22:33 tomoj: so, 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:33 I 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:37 alexyk: how do we tke only odd members of a seq in a simplest way?

22:40 krumholt_: ,(filter odd? [1 2 3 4 5])

22:40 clojurebot: (1 3 5)

22:40 tomoj: did you mean odd indexes or odd values?

22:42 krumholt_: in the index case

22:42 ,(take-nth 2 [1 9 2 9 3 9 4])

22:42 clojurebot: (1 2 3 4)

22:43 tomoj: oh, nice

22:43 ,(take-nth 2 (rest [0 1 2 3 4 5 6 7]))

22:43 clojurebot: (1 3 5 7)

22:44 tomoj: I was thinking recursion/lazy-seqs :)

22:45 krumholt_: that will work too :)

22:48 tomoj: I feel like I need a game which forces me to learn all the core and contrib functions

22:48 so that at least I know about them while writing my own functions to avoid recursion/lazy-seq ratholes

22:54 * chouser pulls contrib

22:56 tomoj: so I am thinking that maybe deftype can be used to make custom map-like types?

22:56 in this case, which interface to use?

22:56 Associative?

22:57 ohpauleez: chouser: you brave soul

22:57 chouser: tomoj: I think that's right.

22:57 ohpauleez: I already hacked the pom myself

22:58 tomoj: why does the pom need hacking?

22:58 I just pulled

22:58 chouser: tomoj: oh, probably ILookup and/or IPersistentMap instead.

22:58 ohpauleez: make the build do interesting things, or build stuff into contrib

22:58 I'm also running on JDK7, so sometimes it gets wonky

22:58 tomoj: chouser: ok, thanks

22:59 chouser: I need it to build against my own patched version of clojure. Is this going to be a problem?

22:59 tomoj: IPersistentMap I think since it needs to be "modifiable"

22:59 chouser: oh man, *everything* is renames.

23:01 ohpauleez: chouser: 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:02 but I don't know for sure

23:02 chouser: gah

23:02 :-(

23:04 instructions right in the readme, beginning with "Download the maven-ant-tasks JAR..."

23:05 heh. I don't even have maven installed.

23:06 tomoj: hmm

23:07 when I deftype and define methods for IPersistentMap, should I be making implementations of e.g. .assoc, .assocEx, .without from IPersistentMap.java?

23:07 or implementations of clojure functions like assoc, get, etc?

23:09 chouser: the Java method names

23:09 tomoj: without the "." I guess?

23:09 unless the examples in (doc deftype) are focused on protocols

23:10 maybe I will write "new branch for dummies" sometime

23:10 chouser: :-)

23:11 no dots, and the names as given in the interface, not the clojure fn that calls them.

23:11 maven is stunningly huge.

23:11 tomoj: chouser: thanks for your help

23:13 chouser: wow. completely failure

23:13 ohpauleez: has anyone written a nice tutorial on the new features yet? especially deftype?

23:14 chouser: [WARNING] JAR will be empty - no content was marked for inclusion! ... Total time: 2 minutes 2 seconds

23:14 ohpauleez: chouser: what's the issue, test failures?

23:14 krumholt_: is there anyway in clojure to create a structure in memory without making an object?

23:14 chouser: krumholt_: what kind of structure is not an object?

23:15 krumholt_: chouser, three integers in a row

23:15 chouser: ohpauleez: I shouldn't mess with this tonight. I'll try again tomorrow. Maybe Sierra will be here so I can verbally abuse him.

23:16 krumholt_: about the lightest way I can think of to hold three integers would be an array, but an array is still an object.

23:16 ohpauleez: haha, good point, ping me tomorrow if I can help out

23:16 chouser: ohpauleez: great, thanks.

23:16 krumholt_: 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:17 chouser: I *was* going to push these Clojure patches, but not without making sure they don't break contrib first.

23:17 I guess everyone will just have to wait...

23:17 ohpauleez: krumholt_: transients maybe, or parallelize some of that

23:17 you'll have to run it through a profiler to confirm where the bottleneck is

23:18 chouser: krumholt_: 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:18 ok, to bed.

23:18 krumholt_: hm ok thanks

23:20 qbg: If we shouldn't use single segment namespaces, what would be a good way to pick a multi-segment namespace?

23:27 alexyk: tomoj: need odd indices. Is there an inverse of interleave, i.e. unzip?

23:28 tomoj: odd indices was solved above

23:30 but if you want n seqs, each containing all elements of the original seq with indices that are i modulo n, hmm

23:30 not sure

23:31 is it impossible to use a deftype constructor within a method definition in the deftype?

23:33 oh, I see, within the method definition you need TypeName. rather than just TypeName

23:39 alexyk: tomoj: my IRC gapped, didn't see any nice odd indices!

23:41 also: how do we revert partition 2 1? I.e., glue back ((3 2) (2 1)) into (3 2 1), nicely?

23:42 krumholt_: <krumholt_> ,(take-nth 2 [1 9 2 9 3 9 4])

23:42 ,(take-nth 2 [1 9 2 9 3 9 4])

23:42 clojurebot: (1 2 3 4)

23:42 technomancy: _ato: you're back!

23:45 or not...

23:47 alexyk: ah! ok

23:57 tomoj: or add a rest if you want odd zero-based indices

23:59 krumholt_: alexyk, and the anti-partitioning i think would be concat

23:59 ,(apply concat (partition [1 2 3 4 5 6 7 8 9] 2))

23:59 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

23:59 krumholt_: ,(apply concat (partition 2 [1 2 3 4 5 6 7 8 9]))

Logging service provided by n01se.net