#clojure log - Aug 01 2010

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

0:04 defn: apparently i still suck at using zip-filter.xml/xml->

0:05 (def rss (zip/xml-zip (xml/parse ("url string))))

0:07 bah maybe i got it...

0:09 rhudson: defn: I'd be interested in seeing your solution. I haven't played with zippers much, and zip-filter not at all

0:13 technomancy: defn: rudel is great if you're just sharing a buffer or two

0:14 defn: but usually when pairing you want to share the whole frame; tmux is way better for that

1:17 http://www.everytopicintheuniverseexceptchickens.com/

1:17 good night, Internet.

1:18 lancepantz_: good night

2:21 notsonerdysunny: can I findout the version of clojure.jar from the repl?

2:21 brehaut: ,*clojure-version*

2:21 clojurebot: {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}

2:26 notsonerdysunny: thanks brehaut

2:26 brehaut: no worries

2:36 mister_m: what exactly is the emacs starter kit?

2:37 and does anyone know if I can run the clojure repl as an inferior emacs process?

2:37 brehaut: mister_m: its a set of .emacs stuff that gives you a well rounded initial set up with (i believe) a focus towards dynamic languages

2:38 notsonerdysunny: is the function "source" new in 1.2 or was it always there?

2:38 brehaut: been there since at least 1.1

2:38 notsonerdysunny: hmm

2:40 brehaut: at least, i recall using it prior to last week

2:40 and i only upgraded to 1.2 last week

2:40 http://clojuredocs.org/v/2445 tells me it was added in 1.0

2:42 though it might have migrated from contrib?

2:58 defn: mister_m: as far as an inferior process, you mean slime?

2:58 mister_m: this might be helpful to you:

2:59 http://gist.github.com/407543

3:02 mister_m: defn, with any luck I can get that working

3:02 flintf: mister_m swank_clojure is available as an emacs package, very easy to get started with

3:04 you just need to install ELPA then, the relevent packages in EMACS

3:09 defn: that's my recommendation

3:09 "but don't take /my word for it/." -Levar Burton

3:12 mister_m: I'm new to emacs, but I'll see if I can't work it out

5:16 Bahman: Hi all!

5:27 defn: hey Bahman

5:27 edbond: how force / to remove double, not ratio?

7:55 kiemdoder: has clojure/contrib/repl_utils.clj been dropped in 1.2?

7:55 or moved rather

8:38 raek: http://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/repl_utils.clj

8:38 seems to be there

9:04 Bahman: Hi all!

9:43 Bjering: Two questions, #1: this gives me null-pointer-exception, why? #2 : am I using refs all wrong, how should I think about this problem?

9:43 https://gist.github.com/1d2bde05e5a923154661

9:46 pastorn: hello

9:46 ok, so i'm messing in scheme, but this should apply here as well ;)

9:46 i have

9:46 (define xs (+ 10 5 1)) but i want with nifty usage of cdr and apply calculate (- 10 5 1)

9:46 is this possible?

9:49 silly me... it had to be (define xs '(+ 10 5 1))

9:53 fyuryu: pastorn: (eval (cons '- (next '(+ 10 5 1))))

9:54 pastorn: or better (apply - (next '(+ 10 5 1)))

9:54 pastorn: is next something clojure-specific?

9:54 oh, it's cdr

9:54 fyuryu: yes

9:54 I think it's cdr in scheme

9:55 Bjering: fyuryu: Do you have any clue what is wrong with my paste above?

9:56 pastorn: Can you run clojure code on android devices?

10:01 defn: http://www.mail-archive.com/clojure@googlegroups.com/msg07499.html

10:01 raek: car=first, cdr=rest/next

10:02 defn: raek: is that accurate to say cdr works like both rest and next?

10:02 raek: next always return nil if there are no more elements

10:02 well, clojure has a distinction that neither CL or Scheme have

10:02 defn: pastorn: http://riddell.us/ClojureAndAndroidWithEmacsOnUbuntu.html

10:03 pastorn: defn: emacs? who uses that?

10:03 defn: people who write code

10:04 pastorn: bah...

10:04 vi vi vi - the editor of the beast

10:04 defn: save your editor wars for another day, friend

10:04 pastorn: haha

10:04 defn: goal: to write code that works

10:04 mfex: Bjering, alter and commute follow the pattern (alter ref fn & args), so write (alter users conj {new-map})

10:05 raek: can't find the article about clojure editor usages

10:05 I saw a piechart on that once

10:05 defn: it was from rubylearning

10:05 but it doesn't matter

10:06 it's quite fragmented. people use what they use. it doesn't matter.

10:06 (although personally i dont think vim has anything comparable to slime)

10:06 ((nor does any other editor for that matter))

10:06 raek: ah, here it is: http://muckandbrass.com/web/display/~cemerick/2010/06/07/Results+from+the+State+of+Clojure%2C+Summer+2010+Survey

10:06 pastorn: defn: slime? you have a link?

10:07 raek: http://muckandbrass.com/web/download/temp/chart2996995522313431103.png

10:07 defn: http://common-lisp.net/project/slime/

10:07 raek: pastorn: http://github.com/technomancy/swank-clojure

10:07 slime is an emacs thing that lets you connect to a swank server

10:07 swank-clojure is a swank server for clojure

10:08 pastorn: cool stuff :)

10:08 defn: it's more than that really raek

10:08 raek: so, swank is the part that is clojure-specific

10:08 ok, but simplified

10:08 defn: yeah fair enough

10:08 Bjering: mfex: Thank you! as to my #2, is it good style? Or should I use 3 different refs inside users instead?

10:09 raek: anyway, the clojure-specifics are documented at technomancy's swank-clojure

10:09 defn: well, some of them

10:09 there are plenty of things undocumented in swank-clojure that slime does by virtue of the bridge that swank clojure creates

10:09 like M-. for instance

10:09 raek: and C-M-x I guess

10:10 defn: C-x C-e

10:10 etc.

10:10 raek: but with C-x C-e, you have to put the point at the end of the form to eval, right?

10:11 mfex: Bjering, for #2 I have no ideas or experience

10:11 defn: yeah but that's still part of slime more than it is a swank-clojure feature

10:11 that's just a fancy slime eval

10:11 raek: hrm, ok. I remembered seeing C-x C-e in the readme but not C-M-x

10:13 defn: yeah i dont know all the features tbqh

10:13 i just think it's worth mentioning that slime does a lot of automatic stuff by virtue of the bridge

10:13 sid3k: anyone knows what "no message" error is/

10:13 defn: that is not explicitly stated in the bridge (swank-clojure) documentation

10:14 Bjering: Rephrased question, what is the preferable way todo this, A or B? https://gist.github.com/7f8962c6e77d8784b296

10:14 defn: B

10:15 sid3k: http://paste.lisp.org/display/113042

10:15 this example raises "no message" exception, I couldn't understand the reason

10:16 Bjering: defn: Thank you, may I further ask why? :)

10:17 defn: Bjering: i dont have a very good reason

10:17 raek: Bjering: unless the parts change independently and very often, I would say B

10:17 defn: :D

10:18 Bjering: yeah, B just looks like it will be more performant

10:18 no need for the triple ref

10:18 also you might consider making :next-id an atom

10:18 raek: in the first case, would have to "asseble" a map with the three associations if you would need it as a single value

10:19 a rule of thumb might be don't put in more refs than you need

10:22 defn: Bjering: you raise an interesting question though, but like most things, it requires you explain exactly what you're trying to do

10:22 raek: if a transaction restart and you use atoms for next-id, you might get "gaps" in the numbering

10:22 kiemdoder: reak: thanks for the reply about clojure-contrib. I'm trying clojure for the first time and is working through some example and did not realise that clojure-contrib is actualy a separate project.

10:23 raek: if that is acceptable, then using atoms won't make transactions restart because two of them wanted a new id at the same time

10:23 Bjering: defn: A typical data-table with auto-increment IDs and index on both names and id, in RAM, transactional.

10:25 defn: Bjering: would an atom for next-id be out of the question?

10:25 kiemdoder: oops raek, got you name wrong :-0

10:25 defn: Bjering: how will you be accessing the data? like could you give an example of your total structure?

10:27 Bjering: your version A looks better in the create-user code, but B looks better in the ref creation code

10:27 and vice versa

10:27 Bjering: not out of the question, but strictly sequential (without gaps) is kind of nice when debugging I guess. Performance isn't critical for this particular scenario (but nice to learn you reasoning nevertheless), what I care about is correctness, readability, "conceptual clarity" and learning to be idiomatic in clojure.

10:28 defn: if we're talking conceptual clarity then i greatly prefer A after looking at it for a bit longer

10:28 Bjering: So, A until profiler says otherwise?

10:28 defn: im not the end-all be-all of clojure idioms here, so take my advice with a grain of salt

10:29 but A just seems a lot more clear to me

10:29 I like the @(users :next-id)

10:30 raek: hrm, when looking closer to that case, I'm starting to lean towards A, too

10:30 defn: yeah :\

10:31 it's a weird case -- i disagree with the multiple refs to represent what are essentially values in a hashmap

10:31 raek: an insert operation would alter next-id and commute-in the new row

10:31 defn: but there is no doubt that the dosync...alter feels more clojurish

10:32 raek: anyway, don't use a ref for every field for every row in the table :)

10:33 defn: it would seem that there will be more contention with A

10:33 raek: I started to make a db layer in one of my projects: http://github.com/raek/konserver/blob/master/src/konserver/db.clj

10:33 defn: does that seem like a fair guess?

10:33 raek: that file only contains the functional part, though

10:34 outside it, I used one ref for each table, and one ref for each auto-increment counter (for those tables that needed it)

10:36 Bjering: Usage is a very benchmark/prototype chat-like server. I am evaluating using Clojure for a 2d Strategy MMO-server (not twitch-based). Want to see how much complexety I get rid of comparted to a C++ boost::asio solution, and how much users per shard I give up.

10:36 very simple I meant to write...

10:37 raek: one very great thing you get with clojure: being able to do snapshots of the world, while it's still living

10:37 you won't have to pause the game 1h every day to store the state to disk

10:37 Bjering: yes, many things are awesome, I just want to learn the price of awesome before I embark 100% :)

10:37 raek: sure

10:38 I have a friend who's considering implementing a Ultime Online server in clojure

10:39 those problems he experienced with a C# based implementation is what clojure was made to solve

10:39 defn: no way

10:39 Bjering: raek: Has he settled on a network-lib? I am going to try this with Netty, from browsing the net alone it seems the best.

10:39 defn: ultima online?

10:39 that takes me back

10:39 wayyyyy back

10:39 raek: he is serp_, btw

10:40 defn: i wasted like 3 of my most formative years learning german on Ultima Online

10:40 by playing a euroshard

10:40 raek: Bjering: you might be interested in aleph

10:41 hrm, is Netty a http server or a general server?

10:41 defn: there's a ring adapter for netty

10:41 raek: or simply a asynchronous-anything lib?

10:41 Bjering: I wasnt planning on using http, I need push, I'll be using google protobufs over binary sockets I think. My client will be Flash.

10:42 raek: ok, aleph is a http server

10:44 Bjering: I don't think he has settled with any lib yet

10:45 Bjering: But I run ahead of myself, for this test, I will use simple strings and it is just a chat :) To learn what #users I can reach with that, and how it hits the wall. My C++ impl was CPU bound and that scares me a little. But it was also getting complex so I might have done something seriosly wrong in it.

10:46 And as you understand of my earlier questions, learning clojure along the way :)

10:47 raek: I hope I haven't confused you too much... :)

10:48 defn: for a chat impl I choose B

10:48 ..maybe.. lol

10:50 Bjering: Haha, I'll write the whole thing and put the source somewhere and then post the question again. Seems there is more to learn here.

10:51 I'll start with A though, it read easier to me. Thanks for the input.

10:52 defn: Bjering: would you mind if i wrote a post about your example?

10:52 id like to work on it later today and do some timing

10:53 Bjering: Not at all, especially if you post to me here if you learn anything interesting :)

11:07 pdk: ,(defmulti populate [chain content] (if (zero? 0) ::zero :: one))

11:07 clojurebot: Invalid token: ::

11:07 pdk: ,(defmulti populate [chain content] (if (zero? 0) ::zero ::one))

11:07 clojurebot: java.lang.Exception: The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)

11:08 defn: Bjering: ill look at it later and ping you when i come to a thoughtful position :)

11:08 ciao all

11:08 pdk: ok so what's wrong with this defmulti code here

11:09 Bjering: defn: Great, I'll shift to a more Sunday-appropriate problem of trying to get Starcraft 2 to play without burning up my GPU now.

11:09 defn: Bjering: haha! im in the process of downloading

11:09 maybe when i wake up it will be finished

11:09 "5 hours remaining"

11:09 anyway, night all

11:09 pdk: ,(defmulti populate (fn [chain content] (if (zero? 0) ::zero ::one)))

11:09 clojurebot: DENIED

11:20 slyrus: grumble grumble

11:20 java.lang.OutOfMemoryError: PermGen space (smiles2.clj:9)

11:20 again :(

11:34 Lajla: Clojure doesn't support using the continuation passing style, does it?

11:35 qbg: You could do it, if you really wanted to

11:37 Zeiris: Is learning Clojure likely to get me a job? :)

11:40 Chousuke: Zeiris: If you learn it well enough, it might.

11:43 sid3k: I don't get the function named "reduce", is there any easy tutorial or sth. explaining it?

11:44 qbg: (reduce + [1 2 3]) == (+ (+ 1 2) 3)

11:44 Chousuke: well, it reduces a collection of values into a single scalar value

11:46 there's not really much to explain. you have a collection of values of type A, a function that takes two values of type A and returns a value of type A. then you apply the function to your initial value and the first item in the collection, then again to the result of that and the second item in the collection, et cetera until you run out of values in the collection

11:46 sid3k: thanks, I guess I need to learn how problems can be solved using this function

11:47 qbg: reduce is essentially an accumulator

11:47 Chousuke: though clojure being dynamic "type A" here means "whatever works" :P

11:47 qbg: You can alternatively see it a state machine

11:48 Where the fn takes in the old state and the input and returns the new state

11:48 And the function returns the final state

11:48 sid3k: I've coded a little thing: (reduce #(str %1 %2) [\h \e \l \l \o])

11:49 Chousuke: sid3k: str already takes two arguments so the anonymous function is not necessary.

11:49 qbg: ,(reduce #(str %1 %2) [])

11:49 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: sandbox$eval501067$fn

11:50 qbg: ,(reduce str [])

11:50 clojurebot: ""

11:50 qbg: ,(reduce #(str %1 %2) "" [])

11:50 clojurebot: ""

11:50 sid3k: Chousuke: sure, I'm trying to find a killer usage example

11:51 qbg: ,(reduce + (range 10))

11:51 clojurebot: 45

11:51 Chousuke: sid3k: reduce is quite situational, so it's hard to think up examples that don't seem trivial

11:52 sid3k: ,(apply + (range 10))

11:52 clojurebot: 45

11:52 sid3k: when should we use reduce? is there any killer usage example?

11:52 qbg: (reduce conj () [1 2 3 4])

11:52 ,(reduce conj () [1 2 3 4])

11:52 clojurebot: (4 3 2 1)

11:52 Chousuke: sid3k: but whenever you have a collection of values and you need to produce a single value (or a bunch of stats, for example) out of them, consider reduce

11:53 sid3k: all right

11:54 tyvm

11:55 mfex: sid3k, what is called reduce is called fold in other functional programming languages, the first reference on the wikipedia page has a lot of examples

11:57 sid3k: mfex: you are right, thanks

11:59 raek: ,(reduce (fn [freqs elem] (assoc freqs elem (inc (get freqs elem 0)))) {} [:a :a :b :c :a :b])

11:59 clojurebot: {:c 1, :b 2, :a 3}

12:00 raek: ,(reduce (fn [freqs elem] (merge-with + freqs {elem 1})) {} [:a :a :b :c :a :b])

12:00 clojurebot: {:c 1, :b 2, :a 3}

12:00 sid3k: it's a very complicated example for a newbie like me :)

12:02 raek: the idea here was to count how many times each thing occurs in the vector

12:02 from the beginning, there are no counts at all

12:02 hence the empty map

12:02 after the first element, the partial result is {:a 1}

12:03 after the second, it has seen :a once more, so then it's {:a 2}

12:03 pdk: ,(doc rest)

12:03 clojurebot: "([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."

12:03 pdk: ,(doc drop)

12:03 clojurebot: "([n coll]); Returns a lazy sequence of all but the first n items in coll."

12:04 pdk: ,(cons 1 '())

12:04 clojurebot: (1)

12:04 pdk: ,(cons 1 nil)

12:04 clojurebot: (1)

12:06 sid3k: raek: thanks, I should check out docs of some functions in the example

12:06 here is the example I've written using reduce:

12:06 (defn factorial [number] (reduce * (reverse (range 1 (inc number)))))

12:06 pdk: (doc trampoline)

12:06 clojurebot: "([f] [f & args]); trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f with supplied args, if any. If f returns a fn, calls that fn with no arguments, and continues to repeat, until the return value is not a fn, then returns that non-fn value. Note that if you want to return a fn as a final value, you must wrap it in some data structure and unpack it after trampoline r

12:06 qbg: sid3k: Why reverse it?

12:07 raek: sid3k: well, there you have your killer usage example :)

12:07 sid3k: qbg: I dunno what I thought

12:07 raek: thanks :)

12:07 raek: reduce separates the iteration from what to do each step

12:08 sid3k: just like map and filter functions

12:08 raek: exactly :)

12:08 sid3k: tyvm

12:16 diracdelta: Hi, I've looked into clojure before, but the top google hit when I try to find information on they syntax of macros is the clojure macro page, which has a short example but no explanation of the syntax. Is the reference the source code, or is there a book which does a good job?

12:17 raek: some of it (mainly "syntax-quote", `) is documented on clojure.org/reader

12:17 qbg: There is the defmacro docstring

12:17 ,(doc defmacro)

12:17 clojurebot: "([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Like defn, but the resulting function name is declared as a macro and will be used as a macro by the compiler when it is called."

12:18 raek: but macros don't have to use syntax-quote

12:18 qbg: But that may not be too helpful

12:18 raek: macros are simply functions that get code as arguments and return code

12:19 the syntax of macros themselves are the same as ordinary functions

12:19 you can try the macro as if it was a function by using macroexpand-1

12:19 Chousuke: syntax-quote is just a convenient way to construct lists and vectors containing symbols, which is what most clojure code is.

12:20 diracdelta: Looking at /reader now, I think that is what I was looking for, thank you :)

12:20 raek: ,(macroexpand-1 '(when some-cond do-foo do-bar))

12:20 clojurebot: (if some-cond (do do-foo do-bar))

12:20 Chousuke: ,(@#'when 'some-cond '(doo foo bar)) you can also do this :P

12:20 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$when

12:20 Chousuke: hmm

12:20 oh, right, they take the implicit args.

12:21 that used to work :P

12:22 raek: as Chousuke said, syntax-quote is not restricted to macros

12:23 Chousuke: ,`(like this)

12:23 clojurebot: (sandbox/like sandbox/this)

12:24 raek: ,(let [x 1, y 2, z [3 4 5]] `(~x ~y ~z ~@z))

12:24 clojurebot: (1 2 [3 4 5] 3 4 5)

13:06 slyrus: any idea why I can't seem to map name onto a record that implements clojure.lang.Named?

13:06 http://gist.github.com/503538

13:14 raek: for some reason, it looks like it tries to call clojure.core/name on a map

13:14 ,(name {:a 1, :b 2)}

13:14 clojurebot: Unmatched delimiter: )

13:14 raek: ,(name {:a 1, :b 2})

13:14 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named

13:14 raek: slyrus: do you have a protocol method called name?

13:24 slyrus: no, but I have clojure.lang.Named (getName [atm] _name))

13:24 and a _name field

13:25 I can understand why this might not work, but then why would (map name (first q)) work?

13:29 oh, never mind...

13:30 one of the elements was a vector containing a map, not an Atom.

13:30 it would be nice if the slime debugger allowed me to inspect the stack

13:31 pdk: (doc every)

13:31 clojurebot: excusez-moi

13:31 pdk: you get the hell over here clojurebot

13:32 (doc every?)

13:32 clojurebot: "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."

13:44 raek: slyrus: I've heard about a "debug-repl" project

13:48 sid3k: is "coll" a lisp/clojure/java term or a general computing term?

13:48 I don't know what it means exactly but as I understand colls are a kind of sequences

13:49 raek: it's short for "collection" which is a very general term

13:49 a collection is a collection of things, that's pretty much it

13:49 in clojure, you can do seq on collections to get a sequence of its elements

13:50 java has a java.util.Collection interface too: http://download-llnw.oracle.com/javase/6/docs/api/java/util/Collection.html

13:51 most clojure functions that take a "coll" argument does (seq coll) and operate on that sequence

13:51 sid3k: raek: tyvm

13:53 LauJensen: Good morning gents (UGT)

13:53 raek: good morning! (UGT)

13:55 I guess one could define "coll" as anything implementing Seqable, or anything else the seq function knows how to turn into a sequence (e.g. java.util.Collection and java arrays)

13:56 rhudson: and strings, which are then treated as char seqs

14:01 pdk: sid3d when you read the arglists for functions and stuff coll is short for collection

14:02 sid3k: another thing I don't get is the "lazy" term, I'm reading ociweb's great guide and I couldn't understand the lazy sequences part

14:02 pdk: basically anything that contains multiple items in it like a map, sequence whatever so they can be treated alike most of the time

14:02 hm where is the ociweb guide

14:02 sid3k: here: http://java.ociweb.com/mark/clojure/article.html

14:03 pdk: the idea with lazy evaluation is to let you do things like generate an infinite sequence of items in a finite amount of space in a way that's still idiomatic for the language

14:03 so if i had a function that gave me an infinite sequence of (0 1 2 3 ...)

14:04 plain jane non-lazy version would try to generate and return this whole sequence at once and obv would crash and burn

14:04 raek: you could wrap reading from a file in a lazy sequence

14:04 pdk: lazy version instead would give me an object that contains code to generate the next item in the sequence up to as many as i ask for

14:05 raek: then only as much as the list that was traversed will be read from the file

14:05 pdk: so in effect it'd pass me an object i can use as if it's an actual infinite sequence in the code

14:05 raek: http://gist.github.com/480608

14:05 pdk: and internally it doesn't generate any part of the sequence until you actually ask for a certain part

14:05 say the 1000th item

14:05 raek: I made that example for playing with when the lazy sequences are realized

14:05 Scriptor: sid3k: for example, haskell uses lazy evaluation to implement fibonacci

14:06 sid3k: thanks for great explonations and the example guys, I get it too

14:06 pdk: it won't have that 1000th item generated anywhere in advance and instead waits until i ask for it to generate it

14:06 raek: (also, lazy sequences are thread safe and each "cons cell" is only realized once)

14:07 pdk: and can continue to go along this way infinitely all within a finite amount of space because generation of items in the sequence is deferred until you ask for them

14:07 obv you'll still get stuck if you do something dumb like try to ask for every item in an infinite lazy sequence

14:07 sid3k: the dialog example seems very interesting, I'm trying it now

14:08 pdk: practical clojure just gives few 1 line examples that demonstrate the difference between eager vs lazy evaluation with their own version of range

14:08 raek: try, for example, doing (take 3 ...) of the sequence

14:08 and the n doing it again on the same sequence

14:09 pdk: yeah if you want an item out of a lazy sequence you can pull it out with the same old functions as if it's any other type of sequence

14:09 though if the sequence is infinite and you try to get the whole of it by accident you can guess what happens

14:09 and instead of storing all the items of the sequence in advance you could ask for in advance it waits until you ask for a specific item to generate the sequence up to the point you want

14:10 then it throws away the stuff it had to generate in order to get up to the point you asked for

14:11 sid3k: wov, it's a really cool feature, as I see from the example

14:11 pdk: one book that would be helpful in learning how things are when you have lazy evaluation available vs when you don't would be purely functional data structures

14:12 raek: it lets you model many things as sequences, which traditionally would be imperative calls (like input from a file/socket/dialog)

14:12 pdk: all the code examples in the book are standard ml/haskell instead of lisp but it talks at length about the difference and shows you how it can affect things like runtime analysis on your code

14:13 aside from teaching you about those fancy pants data structures you didnt learn in cs 201 :p

14:15 for example they show you lots of variations on tree structures with properties that are useful in a functional environment

14:15 mister_m: hey I'm trying to follow this guide, http://wiki.unto.net/setting-up-clojure-and-slime , to get clojure set up with slime, and swank in emacs. but when I get to the end and try to M-x slime in emacs it just says [no match]

14:15 sid3k: pdk: I'm a physics student in Turkey, but I'm planning to watch MIT lectures, they would be helpful to get these stuff

14:15 pdk: shows you stuff like how the code for a red black tree looks in a functional vs traditional imperative environment and how the functional version is more concise and simpler to understand

14:16 raek: mister_m: the most simple way of starting swank is by strarting it outside emacs

14:16 sid3k: mister_m: try slime-connect after starting swank clojure

14:16 Scriptor: mister_m: try http://data-sorcery.org/2009/12/20/getting-started/

14:16 pdk: chris okasaki's phd thesis on functional data structures is basically the precursor to his book about them and the thesis is easy to find online

14:16 Scriptor: it's a more filled-out tutorial, so hopefully you'll be able to find any mistakes

14:17 pdk: how much better is the book than the thesis?

14:17 raek: "Previous versions of Swank Clojure bundled an Elisp library called swank-clojure.el that provided ways to launch your swank server from within your Emacs process. While swank-clojure is still distributed with the project, it's a much more error-prone way of doing things than the method outlined above." (technomancy's notes on: http://github.com/technomancy/swank-clojure)

14:18 pdk: i have the book on hand, i'll try to find the thesis real quick

14:18 Scriptor: I have a PDF of the thesis, so I'm just wondering if maybe I should invest in the book

14:18 pdk: i think it was around $30 on amazon and around 200 pages though the writing is pretty dense

14:19 sid3k: tyvm pdk, btw, do you guys blog? if yes, let me start to follow them

14:19 pdk: what do you mean by guy's blog

14:19 someone named guy or blogs from various people

14:20 Scriptor: pdk: no possessive in guy, just asking if you guys have a blog

14:20 pdk: oh i read "know" into there somehow haha

14:20 so at first glance "do you know guys blog?"

14:20 sid3k: pdk: sorry for my poor english, I mean, do you blog? (blog as a verb)

14:21 pdk: nah it was correct but i read it wrong the first time over

14:21 sid3k: :)

14:21 pdk: blog as a verb is proper form

14:21 i just read an extra word in there that wasnt there and misunderstood the first time around

14:21 sid3k: so, do you blog?

14:22 pdk: i wouldnt have enough to say if i did :p

14:22 i could swear i found a comparison of the thesis and book a while ago

14:23 Scriptor: sid3k: I just found this: http://twitter.com/planetclojure, you could give it a shot

14:23 sid3k: great, thanks

14:25 pdk: tumblr makes blogging very easy to start, I think you should let people to follow you

14:25 twitter counts btw

14:27 Scriptor: posterous is nice too

14:32 pdk: heh

14:35 also i managed to pull up the okasaki thesis now

14:35 * slyrus keeps forgetting that t is spelled "true"

14:41 pdk: im thumbing through to see what's in the book thats different from the thesis though right off the bat not counting the indices the book is about 50pg longer

14:43 hm there are two extra chapters that explain persistence and show a few common structures like red black trees done functionally

14:45 rubydiamond: Does anybody use irc bouncer like znc

14:49 bgs100: rubydiamond, I do

14:49 rubydiamond: bgs100: I have started using it recently.. znc

14:49 I have 200GB slice..

14:49 bgs100: ?

14:49 rubydiamond: in two days .. it says it has done 4GB of transfer

14:50 bgs100: so is this 4GB because of znc /

14:50 bgs100: ?

14:51 bgs100: rubydiamond, I dunno.

14:51 I don't really know much about ZNC; I just have an account on a certain server.

14:52 Ask on #znc ?

14:52 rubydiamond: bgs100: which server?

14:52 are there any free providers?

15:23 mister_m: what do I do if something already exists when installing things with ELPA, but is not listed as installed

15:24 can I force it to overwrite whatever file it's talking about

15:56 BobFunk: hey

15:56 trying to make a boring task interesting by learning clojure along the way, and am trying to do some log parsing with clojure

15:57 but am runing into out of memory problems

15:57 while doing quite basic stuff

15:58 just doing a count of the lines uses up my 3 gigs of memory it seems

15:58 doing it like this: http://gist.github.com/503695

15:58 guess there must be some better way of working with textfiles than this

15:59 raek: try (count (read-lines logfile))

15:59 when you bind the head of the sequence to a variable

15:59 the JVM cannot garbage collect any parts of it

16:00 thus, the whole file will be in memory

16:01 BobFunk: ok - makes sense

16:02 Derander: BobFunk: there is no escaping the nesting ;-)

16:03 BobFunk: hehe

16:04 hmm, doesn't seem to help though

16:04 trying just: (count (read-lines "path-to-my-log-file.log"))

16:04 but memory use still just groving and groving with no result coming

16:05 ahh - result came now

16:05 and guess the gc might just not have kicked in - gonna try with a lower memory limit on the jvm

16:13 raek: you can still do a .readLine on the reader manually and cound the number of times it returns non-nil

16:18 mister_m: any clojure reading recommendations for someone new to the language?

16:18 preferably the free kind of reading

16:20 qbg: Blogs are free

16:20 You could go to a library and try to get Programming Clojure

16:21 raek: there is some free pieces of The Joy of Clojure: http://manning.com/fogus/

16:21 http://planet.clojure.in/ http://disclojure.org/

16:22 also, some screencasts: http://clojure.blip.tv/

16:22 there are other video series around too

16:23 qbg: Some material relating to Scheme might be good also depending on new you are to FP

16:24 tomoj: anyone know why some planet clojure feed items have their links fucked up?

16:24 I wonder if it's planet clojure's fault or the feed author's faults?

16:40 LauJensen: Does anyone have an example of how Rings current session middleware is supposed to be used for memory storage?

16:41 dsop: y

16:42 LauJensen: mister_m: my blog on www.bestinclass.dk has quite a few articles that are new-comer friendly

16:42 (and also a couple that arent)

16:44 Bjering: Using counter-clockwise I have a problem adding the netty.jar, I have drag-dropt it into the IDE, copied it, and then added it to my build path (it is now among my referenced libraries). Yet when I import it I get ClassNotFoundException, the code used to work in Enclojure. Any hints as what I do wrong?

16:45 LauJensen: Bjering: Yea, from your description it sounds like you're not using Emacs

16:45 tomoj: (defn an-aleph-handler [ch r] (enqueue-and-close ch (a-ring-handler r))) sort of defeats the purpose, doesn't it?

16:49 fielcabral: #jering maybe you need to restart the repl to get the new class path? or maybe the (import ...) is mistyped? or the class path you changed is just for compilation and is not for Running

16:51 Bjering: fielcabral: Restarting the repl helped so that I could load it (ie it works) editor still highligt as error, restarting Eclipse now to see if that fixes that thing.

16:53 fielcabral: Nope, editor still show it as error even though it works now when loaded into the repl. As if the editor-code checking my syntax pre-evaluation isnt using the new build path.

16:55 fielcabral: Bjering sorry I'm not very familiar with counter-clockwise though I love eclipse. I would hunt for a dialog specific to counter clockwise that lets you change a classpath.

17:03 Bjering: fielcabral: Found this http://groups.google.com/group/clojuredev-users/browse_thread/thread/53716a0cb2d5e694# and that did it, that is, closing the REPL as you said and then also project->clean

17:03 thank you

17:04 fielcabral: welcome

17:04 Bjering i gotta try counter clockwise again one of these days

17:07 Bjering: I like it, but what do I know :) my problem is I am not only new to Clojure, I am new to Eclipse as well :) And haven't really programmed anything serious in a Java environment since 2002 or so... But I think I'll be ok, the namespace browser and the outline seems very nice.

17:11 fielcabral: Bjering yes I agree with you about the NS browser and outline. I'm hoping the eclipse debugger will let you step through code, set breakpoints, etc..

17:18 raek: which editor had that paredit-like thingy? ccw?

17:18 qbg: Yes

17:22 JoeyA: Quick question: I'm not familiar with Clojure (I've only done a little Scheme, which is different), but does Clojure predominantly use single application or multiple application?

17:22 In other words, if you apply an argument to, say, addition, does it yield a function which adds 3 (single applicative)?

17:22 Or do you have to apply all arguments up front? (or use a lambda or #(+ 3 %))

17:23 tomoj: are you asking if you can do ((+ 1) 2) to get 3?

17:23 JoeyA: yes

17:24 tomoj: no, you can't

17:24 ((partial + 1) 2) works

17:24 JoeyA: is partial a special operator that only works in that context?

17:24 tomoj: partial is just a function

17:24 JoeyA: oh

17:25 raek: it does something like (defn partial [f val] (fn [& args] (apply f (cons val args))))

17:25 ,(source partial)

17:25 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

17:25 raek: ~partial

17:26 clojurebot: It's greek to me.

17:26 tomoj: ([f arg1] (fn [& args] (apply f arg1 args)))

17:26 raek: (source partial)

17:26 hrm, yeah

17:27 JoeyA: Can you do this to create a partially applied function? #(function_of_5_args 1 2 %1 %2 5)

17:27 tomoj: sure

17:27 raek: yes, that will yield a 2-arg functoin

17:27 JoeyA: cool

17:29 I've been thinking about how to implement a sort of drag-and-drop programming facility for an application.

17:29 tomoj: so do we end up having to reimplement ring stuff for aleph?

17:30 JoeyA: One cool idea I'm thinking of applying to the project is that when you have a spot to drag a function, and you drag a function with too many arguments, it lets you go ahead and bind some of the parameters (rather than yell at the user for doing something wrong)

17:30 I'm not sure that idea would work so well in single-applicative style.

17:31 Anyway, thanks.

17:43 technomancy: JoeyA: single applicative functions like you're describing don't seem to be compatible with variable argument lists

17:44 I think the term is currying

17:46 Derander: technomancy: 'tis indeed

17:46 uncurried functions, currying, etc.

17:46 s/un//

17:46 sexpbot: curried fctions, currying, etc.

17:47 technomancy: sexpbot: I didn't see a g there...

17:49 JoeyA: right

18:17 pdk: [17:27] <JoeyA> Can you do this to create a partially applied function? #(function_of_5_args 1 2 %1 %2 5) <- yes, you can also curry the function with (partial function 1 2 3 ...) if you know you want the first X arguments predefined and the rest after those left to be filled in as the function is called

18:18 e.g. (partial * 2) would basically be equivalent to #(* 2 %1) though the curried version with partial would let me tack on as many extra arguments as * can take

18:31 tomoj: it's #(apply * 2 %&)

18:32 pdk: OR THAT

18:33 JoeyA: Thanks

18:33 tomoj: -> ((partial * 1))

18:33 sexpbot: => 1

18:33 tomoj: never thought about that

18:58 pdk: (doc ->)

18:58 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

19:09 lancepantz_: github should map anchor tags to line numbers

19:10 i should be able to do http://github.com/nablaone/slime/blob/master/slime.el#2214

19:10 and that go to 2214

19:11 tomoj: http://github.com/nablaone/slime/blob/master/slime.el#L2214

19:11 lancepantz_: nice!

19:11 you always come through for me tomoj :)

19:11 tomoj: you can click on the line numbers to get those links

19:11 lancepantz_: i see

19:27 pdk: (doc read-lines)

19:27 clojurebot: "clojure.contrib.duck-streams/read-lines;[[f]]; Like clojure.core/line-seq but opens f with reader. Automatically closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE."

19:27 pdk: (doc line-seq)

19:27 clojurebot: "([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."

19:28 wwmorgan: what's the preferred way to submit patches?

19:29 kencausey: http://www.assembla.com/wiki/show/clojure

20:47 lancepantz_: ,(let [x (filter odd? [2 4])] (when (first x) x))

20:47 clojurebot: nil

20:48 lancepantz_: ^ is there a cleaner way to do that?

20:48 making a filtered seq return nil if it's empty

20:48 wwmorgan: ,(seq (filter odd? [2 4]))

20:48 clojurebot: nil

20:50 lancepantz_: wwmorgan: ty

20:53 pdk: (doc when)

20:53 clojurebot: "([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."

21:08 * slyrus hates buggy specs

21:09 rhudson: don't we all

23:33 Bahman: Hi all!

23:55 gstamp: ,(clojure.stacktrace/root-cause (Exception.))

23:55 clojurebot: #<Exception java.lang.Exception>

Logging service provided by n01se.net