#clojure logs

2010-08-01

00:04defnapparently i still suck at using zip-filter.xml/xml->
00:05defn(def rss (zip/xml-zip (xml/parse ("url string))))
00:07defnbah maybe i got it...
00:09rhudsondefn: I'd be interested in seeing your solution. I haven't played with zippers much, and zip-filter not at all
00:13technomancydefn: rudel is great if you're just sharing a buffer or two
00:14technomancydefn: but usually when pairing you want to share the whole frame; tmux is way better for that
01:17technomancyhttp://www.everytopicintheuniverseexceptchickens.com/
01:17technomancygood night, Internet.
01:18lancepantz_good night
02:21notsonerdysunnycan I findout the version of clojure.jar from the repl?
02:21brehaut,*clojure-version*
02:21clojurebot{:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}
02:26notsonerdysunnythanks brehaut
02:26brehautno worries
02:36mister_mwhat exactly is the emacs starter kit?
02:37mister_mand does anyone know if I can run the clojure repl as an inferior emacs process?
02:37brehautmister_m: its a set of .emacs stuff that gives you a well rounded initial set up with (i believe) a focus towards dynamic languages
02:38notsonerdysunnyis the function "source" new in 1.2 or was it always there?
02:38brehautbeen there since at least 1.1
02:38notsonerdysunnyhmm
02:40brehautat least, i recall using it prior to last week
02:40brehautand i only upgraded to 1.2 last week
02:40brehauthttp://clojuredocs.org/v/2445 tells me it was added in 1.0
02:42brehautthough it might have migrated from contrib?
02:58defnmister_m: as far as an inferior process, you mean slime?
02:58defnmister_m: this might be helpful to you:
02:59defnhttp://gist.github.com/407543
03:02mister_mdefn, with any luck I can get that working
03:02flintfmister_m swank_clojure is available as an emacs package, very easy to get started with
03:04flintfyou just need to install ELPA then, the relevent packages in EMACS
03:09defnthat's my recommendation
03:09defn"but don't take /my word for it/." -Levar Burton
03:12mister_mI'm new to emacs, but I'll see if I can't work it out
05:16BahmanHi all!
05:27defnhey Bahman
05:27edbondhow force / to remove double, not ratio?
07:55kiemdoderhas clojure/contrib/repl_utils.clj been dropped in 1.2?
07:55kiemdoderor moved rather
08:38raekhttp://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/repl_utils.clj
08:38raekseems to be there
09:04BahmanHi all!
09:43BjeringTwo questions, #1: this gives me null-pointer-exception, why? #2 : am I using refs all wrong, how should I think about this problem?
09:43Bjeringhttps://gist.github.com/1d2bde05e5a923154661
09:46pastornhello
09:46pastornok, so i'm messing in scheme, but this should apply here as well ;)
09:46pastorni have
09:46pastorn(define xs (+ 10 5 1)) but i want with nifty usage of cdr and apply calculate (- 10 5 1)
09:46pastornis this possible?
09:49pastornsilly me... it had to be (define xs '(+ 10 5 1))
09:53fyuryupastorn: (eval (cons '- (next '(+ 10 5 1))))
09:54fyuryupastorn: or better (apply - (next '(+ 10 5 1)))
09:54pastornis next something clojure-specific?
09:54pastornoh, it's cdr
09:54fyuryuyes
09:54fyuryuI think it's cdr in scheme
09:55Bjeringfyuryu: Do you have any clue what is wrong with my paste above?
09:56pastornCan you run clojure code on android devices?
10:01defnhttp://www.mail-archive.com/clojure@googlegroups.com/msg07499.html
10:01raekcar=first, cdr=rest/next
10:02defnraek: is that accurate to say cdr works like both rest and next?
10:02raeknext always return nil if there are no more elements
10:02raekwell, clojure has a distinction that neither CL or Scheme have
10:02defnpastorn: http://riddell.us/ClojureAndAndroidWithEmacsOnUbuntu.html
10:03pastorndefn: emacs? who uses that?
10:03defnpeople who write code
10:04pastornbah...
10:04pastornvi vi vi - the editor of the beast
10:04defnsave your editor wars for another day, friend
10:04pastornhaha
10:04defngoal: to write code that works
10:04mfexBjering, alter and commute follow the pattern (alter ref fn & args), so write (alter users conj {new-map})
10:05raekcan't find the article about clojure editor usages
10:05raekI saw a piechart on that once
10:05defnit was from rubylearning
10:05defnbut it doesn't matter
10:06defnit's quite fragmented. people use what they use. it doesn't matter.
10:06defn(although personally i dont think vim has anything comparable to slime)
10:06defn((nor does any other editor for that matter))
10:06raekah, here it is: http://muckandbrass.com/web/display/~cemerick/2010/06/07/Results+from+the+State+of+Clojure%2C+Summer+2010+Survey
10:06pastorndefn: slime? you have a link?
10:07raekhttp://muckandbrass.com/web/download/temp/chart2996995522313431103.png
10:07defnhttp://common-lisp.net/project/slime/
10:07raekpastorn: http://github.com/technomancy/swank-clojure
10:07raekslime is an emacs thing that lets you connect to a swank server
10:07raekswank-clojure is a swank server for clojure
10:08pastorncool stuff :)
10:08defnit's more than that really raek
10:08raekso, swank is the part that is clojure-specific
10:08raekok, but simplified
10:08defnyeah fair enough
10:08Bjeringmfex: Thank you! as to my #2, is it good style? Or should I use 3 different refs inside users instead?
10:09raekanyway, the clojure-specifics are documented at technomancy's swank-clojure
10:09defnwell, some of them
10:09defnthere are plenty of things undocumented in swank-clojure that slime does by virtue of the bridge that swank clojure creates
10:09defnlike M-. for instance
10:09raekand C-M-x I guess
10:10defnC-x C-e
10:10defnetc.
10:10raekbut with C-x C-e, you have to put the point at the end of the form to eval, right?
10:11mfexBjering, for #2 I have no ideas or experience
10:11defnyeah but that's still part of slime more than it is a swank-clojure feature
10:11defnthat's just a fancy slime eval
10:11raekhrm, ok. I remembered seeing C-x C-e in the readme but not C-M-x
10:13defnyeah i dont know all the features tbqh
10:13defni just think it's worth mentioning that slime does a lot of automatic stuff by virtue of the bridge
10:13sid3kanyone knows what "no message" error is/
10:13defnthat is not explicitly stated in the bridge (swank-clojure) documentation
10:14BjeringRephrased question, what is the preferable way todo this, A or B? https://gist.github.com/7f8962c6e77d8784b296
10:14defnB
10:15sid3khttp://paste.lisp.org/display/113042
10:15sid3kthis example raises "no message" exception, I couldn't understand the reason
10:16Bjeringdefn: Thank you, may I further ask why? :)
10:17defnBjering: i dont have a very good reason
10:17raekBjering: unless the parts change independently and very often, I would say B
10:17defn:D
10:18defnBjering: yeah, B just looks like it will be more performant
10:18defnno need for the triple ref
10:18defnalso you might consider making :next-id an atom
10:18raekin the first case, would have to "asseble" a map with the three associations if you would need it as a single value
10:19raeka rule of thumb might be don't put in more refs than you need
10:22defnBjering: you raise an interesting question though, but like most things, it requires you explain exactly what you're trying to do
10:22raekif a transaction restart and you use atoms for next-id, you might get "gaps" in the numbering
10:22kiemdoderreak: 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:23raekif that is acceptable, then using atoms won't make transactions restart because two of them wanted a new id at the same time
10:23Bjeringdefn: A typical data-table with auto-increment IDs and index on both names and id, in RAM, transactional.
10:25defnBjering: would an atom for next-id be out of the question?
10:25kiemdoderoops raek, got you name wrong :-0
10:25defnBjering: how will you be accessing the data? like could you give an example of your total structure?
10:27defnBjering: your version A looks better in the create-user code, but B looks better in the ref creation code
10:27defnand vice versa
10:27Bjeringnot 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:28defnif we're talking conceptual clarity then i greatly prefer A after looking at it for a bit longer
10:28BjeringSo, A until profiler says otherwise?
10:28defnim not the end-all be-all of clojure idioms here, so take my advice with a grain of salt
10:29defnbut A just seems a lot more clear to me
10:29defnI like the @(users :next-id)
10:30raekhrm, when looking closer to that case, I'm starting to lean towards A, too
10:30defnyeah :\
10:31defnit's a weird case -- i disagree with the multiple refs to represent what are essentially values in a hashmap
10:31raekan insert operation would alter next-id and commute-in the new row
10:31defnbut there is no doubt that the dosync...alter feels more clojurish
10:32raekanyway, don't use a ref for every field for every row in the table :)
10:33defnit would seem that there will be more contention with A
10:33raekI started to make a db layer in one of my projects: http://github.com/raek/konserver/blob/master/src/konserver/db.clj
10:33defndoes that seem like a fair guess?
10:33raekthat file only contains the functional part, though
10:34raekoutside it, I used one ref for each table, and one ref for each auto-increment counter (for those tables that needed it)
10:36BjeringUsage 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:36Bjeringvery simple I meant to write...
10:37raekone very great thing you get with clojure: being able to do snapshots of the world, while it's still living
10:37raekyou won't have to pause the game 1h every day to store the state to disk
10:37Bjeringyes, many things are awesome, I just want to learn the price of awesome before I embark 100% :)
10:37raeksure
10:38raekI have a friend who's considering implementing a Ultime Online server in clojure
10:39raekthose problems he experienced with a C# based implementation is what clojure was made to solve
10:39defnno way
10:39Bjeringraek: 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:39defnultima online?
10:39defnthat takes me back
10:39defnwayyyyy back
10:39raekhe is serp_, btw
10:40defni wasted like 3 of my most formative years learning german on Ultima Online
10:40defnby playing a euroshard
10:40raekBjering: you might be interested in aleph
10:41raekhrm, is Netty a http server or a general server?
10:41defnthere's a ring adapter for netty
10:41raekor simply a asynchronous-anything lib?
10:41BjeringI 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:42raekok, aleph is a http server
10:44raekBjering: I don't think he has settled with any lib yet
10:45BjeringBut 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:46BjeringAnd as you understand of my earlier questions, learning clojure along the way :)
10:47raekI hope I haven't confused you too much... :)
10:48defnfor a chat impl I choose B
10:48defn..maybe.. lol
10:50BjeringHaha, 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:51BjeringI'll start with A though, it read easier to me. Thanks for the input.
10:52defnBjering: would you mind if i wrote a post about your example?
10:52defnid like to work on it later today and do some timing
10:53BjeringNot at all, especially if you post to me here if you learn anything interesting :)
11:07pdk,(defmulti populate [chain content] (if (zero? 0) ::zero :: one))
11:07clojurebotInvalid token: ::
11:07pdk,(defmulti populate [chain content] (if (zero? 0) ::zero ::one))
11:07clojurebotjava.lang.Exception: The syntax for defmulti has changed. Example: (defmulti name dispatch-fn :default dispatch-value)
11:08defnBjering: ill look at it later and ping you when i come to a thoughtful position :)
11:08defnciao all
11:08pdkok so what's wrong with this defmulti code here
11:09Bjeringdefn: 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:09defnBjering: haha! im in the process of downloading
11:09defnmaybe when i wake up it will be finished
11:09defn"5 hours remaining"
11:09defnanyway, night all
11:09pdk,(defmulti populate (fn [chain content] (if (zero? 0) ::zero ::one)))
11:09clojurebotDENIED
11:20slyrusgrumble grumble
11:20slyrusjava.lang.OutOfMemoryError: PermGen space (smiles2.clj:9)
11:20slyrusagain :(
11:34LajlaClojure doesn't support using the continuation passing style, does it?
11:35qbgYou could do it, if you really wanted to
11:37ZeirisIs learning Clojure likely to get me a job? :)
11:40ChousukeZeiris: If you learn it well enough, it might.
11:43sid3kI don't get the function named "reduce", is there any easy tutorial or sth. explaining it?
11:44qbg(reduce + [1 2 3]) == (+ (+ 1 2) 3)
11:44Chousukewell, it reduces a collection of values into a single scalar value
11:46Chousukethere'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:46sid3kthanks, I guess I need to learn how problems can be solved using this function
11:47qbgreduce is essentially an accumulator
11:47Chousukethough clojure being dynamic "type A" here means "whatever works" :P
11:47qbgYou can alternatively see it a state machine
11:48qbgWhere the fn takes in the old state and the input and returns the new state
11:48qbgAnd the function returns the final state
11:48sid3kI've coded a little thing: (reduce #(str %1 %2) [\h \e \l \l \o])
11:49Chousukesid3k: str already takes two arguments so the anonymous function is not necessary.
11:49qbg,(reduce #(str %1 %2) [])
11:49clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: sandbox$eval501067$fn
11:50qbg,(reduce str [])
11:50clojurebot""
11:50qbg,(reduce #(str %1 %2) "" [])
11:50clojurebot""
11:50sid3kChousuke: sure, I'm trying to find a killer usage example
11:51qbg,(reduce + (range 10))
11:51clojurebot45
11:51Chousukesid3k: reduce is quite situational, so it's hard to think up examples that don't seem trivial
11:52sid3k,(apply + (range 10))
11:52clojurebot45
11:52sid3kwhen should we use reduce? is there any killer usage example?
11:52qbg(reduce conj () [1 2 3 4])
11:52qbg,(reduce conj () [1 2 3 4])
11:52clojurebot(4 3 2 1)
11:52Chousukesid3k: 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:53sid3kall right
11:54sid3ktyvm
11:55mfexsid3k, 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:57sid3kmfex: you are right, thanks
11:59raek,(reduce (fn [freqs elem] (assoc freqs elem (inc (get freqs elem 0)))) {} [:a :a :b :c :a :b])
11:59clojurebot{:c 1, :b 2, :a 3}
12:00raek,(reduce (fn [freqs elem] (merge-with + freqs {elem 1})) {} [:a :a :b :c :a :b])
12:00clojurebot{:c 1, :b 2, :a 3}
12:00sid3kit's a very complicated example for a newbie like me :)
12:02raekthe idea here was to count how many times each thing occurs in the vector
12:02raekfrom the beginning, there are no counts at all
12:02raekhence the empty map
12:02raekafter the first element, the partial result is {:a 1}
12:03raekafter the second, it has seen :a once more, so then it's {:a 2}
12:03pdk,(doc rest)
12:03clojurebot"([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."
12:03pdk,(doc drop)
12:03clojurebot"([n coll]); Returns a lazy sequence of all but the first n items in coll."
12:04pdk,(cons 1 '())
12:04clojurebot(1)
12:04pdk,(cons 1 nil)
12:04clojurebot(1)
12:06sid3kraek: thanks, I should check out docs of some functions in the example
12:06sid3khere is the example I've written using reduce:
12:06sid3k(defn factorial [number] (reduce * (reverse (range 1 (inc number)))))
12:06pdk(doc trampoline)
12:06clojurebot"([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:06qbgsid3k: Why reverse it?
12:07raeksid3k: well, there you have your killer usage example :)
12:07sid3kqbg: I dunno what I thought
12:07sid3kraek: thanks :)
12:07raekreduce separates the iteration from what to do each step
12:08sid3kjust like map and filter functions
12:08raekexactly :)
12:08sid3ktyvm
12:16diracdeltaHi, 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:17raeksome of it (mainly "syntax-quote", `) is documented on clojure.org/reader
12:17qbgThere is the defmacro docstring
12:17qbg,(doc defmacro)
12:17clojurebot"([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:18raekbut macros don't have to use syntax-quote
12:18qbgBut that may not be too helpful
12:18raekmacros are simply functions that get code as arguments and return code
12:19raekthe syntax of macros themselves are the same as ordinary functions
12:19raekyou can try the macro as if it was a function by using macroexpand-1
12:19Chousukesyntax-quote is just a convenient way to construct lists and vectors containing symbols, which is what most clojure code is.
12:20diracdeltaLooking at /reader now, I think that is what I was looking for, thank you :)
12:20raek,(macroexpand-1 '(when some-cond do-foo do-bar))
12:20clojurebot(if some-cond (do do-foo do-bar))
12:20Chousuke,(@#'when 'some-cond '(doo foo bar)) you can also do this :P
12:20clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$when
12:20Chousukehmm
12:20Chousukeoh, right, they take the implicit args.
12:21Chousukethat used to work :P
12:22raekas Chousuke said, syntax-quote is not restricted to macros
12:23Chousuke,`(like this)
12:23clojurebot(sandbox/like sandbox/this)
12:24raek,(let [x 1, y 2, z [3 4 5]] `(~x ~y ~z ~@z))
12:24clojurebot(1 2 [3 4 5] 3 4 5)
13:06slyrusany idea why I can't seem to map name onto a record that implements clojure.lang.Named?
13:06slyrushttp://gist.github.com/503538
13:14raekfor some reason, it looks like it tries to call clojure.core/name on a map
13:14raek,(name {:a 1, :b 2)}
13:14clojurebotUnmatched delimiter: )
13:14raek,(name {:a 1, :b 2})
13:14clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named
13:14raekslyrus: do you have a protocol method called name?
13:24slyrusno, but I have clojure.lang.Named (getName [atm] _name))
13:24slyrusand a _name field
13:25slyrusI can understand why this might not work, but then why would (map name (first q)) work?
13:29slyrusoh, never mind...
13:30slyrusone of the elements was a vector containing a map, not an Atom.
13:30slyrusit would be nice if the slime debugger allowed me to inspect the stack
13:31pdk(doc every)
13:31clojurebotexcusez-moi
13:31pdkyou get the hell over here clojurebot
13:32pdk(doc every?)
13:32clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
13:44raekslyrus: I've heard about a "debug-repl" project
13:48sid3kis "coll" a lisp/clojure/java term or a general computing term?
13:48sid3kI don't know what it means exactly but as I understand colls are a kind of sequences
13:49raekit's short for "collection" which is a very general term
13:49raeka collection is a collection of things, that's pretty much it
13:49raekin clojure, you can do seq on collections to get a sequence of its elements
13:50raekjava has a java.util.Collection interface too: http://download-llnw.oracle.com/javase/6/docs/api/java/util/Collection.html
13:51raekmost clojure functions that take a "coll" argument does (seq coll) and operate on that sequence
13:51sid3kraek: tyvm
13:53LauJensenGood morning gents (UGT)
13:53raekgood morning! (UGT)
13:55raekI 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:56rhudsonand strings, which are then treated as char seqs
14:01pdksid3d when you read the arglists for functions and stuff coll is short for collection
14:02sid3kanother 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:02pdkbasically anything that contains multiple items in it like a map, sequence whatever so they can be treated alike most of the time
14:02pdkhm where is the ociweb guide
14:02sid3khere: http://java.ociweb.com/mark/clojure/article.html
14:03pdkthe 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:03pdkso if i had a function that gave me an infinite sequence of (0 1 2 3 ...)
14:04pdkplain jane non-lazy version would try to generate and return this whole sequence at once and obv would crash and burn
14:04raekyou could wrap reading from a file in a lazy sequence
14:04pdklazy 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:05raekthen only as much as the list that was traversed will be read from the file
14:05pdkso in effect it'd pass me an object i can use as if it's an actual infinite sequence in the code
14:05raekhttp://gist.github.com/480608
14:05pdkand internally it doesn't generate any part of the sequence until you actually ask for a certain part
14:05pdksay the 1000th item
14:05raekI made that example for playing with when the lazy sequences are realized
14:05Scriptorsid3k: for example, haskell uses lazy evaluation to implement fibonacci
14:06sid3kthanks for great explonations and the example guys, I get it too
14:06pdkit won't have that 1000th item generated anywhere in advance and instead waits until i ask for it to generate it
14:06raek(also, lazy sequences are thread safe and each "cons cell" is only realized once)
14:07pdkand 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:07pdkobv you'll still get stuck if you do something dumb like try to ask for every item in an infinite lazy sequence
14:07sid3kthe dialog example seems very interesting, I'm trying it now
14:08pdkpractical clojure just gives few 1 line examples that demonstrate the difference between eager vs lazy evaluation with their own version of range
14:08raektry, for example, doing (take 3 ...) of the sequence
14:08raekand the n doing it again on the same sequence
14:09pdkyeah 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:09pdkthough if the sequence is infinite and you try to get the whole of it by accident you can guess what happens
14:09pdkand 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:10pdkthen it throws away the stuff it had to generate in order to get up to the point you asked for
14:11sid3kwov, it's a really cool feature, as I see from the example
14:11pdkone 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:12raekit lets you model many things as sequences, which traditionally would be imperative calls (like input from a file/socket/dialog)
14:12pdkall 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:13pdkaside from teaching you about those fancy pants data structures you didnt learn in cs 201 :p
14:15pdkfor example they show you lots of variations on tree structures with properties that are useful in a functional environment
14:15mister_mhey 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:15sid3kpdk: I'm a physics student in Turkey, but I'm planning to watch MIT lectures, they would be helpful to get these stuff
14:15pdkshows 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:16raekmister_m: the most simple way of starting swank is by strarting it outside emacs
14:16sid3kmister_m: try slime-connect after starting swank clojure
14:16Scriptormister_m: try http://data-sorcery.org/2009/12/20/getting-started/
14:16pdkchris 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:16Scriptorit's a more filled-out tutorial, so hopefully you'll be able to find any mistakes
14:17Scriptorpdk: how much better is the book than the thesis?
14:17raek"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:18pdki have the book on hand, i'll try to find the thesis real quick
14:18ScriptorI have a PDF of the thesis, so I'm just wondering if maybe I should invest in the book
14:18pdki think it was around $30 on amazon and around 200 pages though the writing is pretty dense
14:19sid3ktyvm pdk, btw, do you guys blog? if yes, let me start to follow them
14:19pdkwhat do you mean by guy's blog
14:19pdksomeone named guy or blogs from various people
14:20Scriptorpdk: no possessive in guy, just asking if you guys have a blog
14:20pdkoh i read "know" into there somehow haha
14:20pdkso at first glance "do you know guys blog?"
14:20sid3kpdk: sorry for my poor english, I mean, do you blog? (blog as a verb)
14:21pdknah it was correct but i read it wrong the first time over
14:21sid3k:)
14:21pdkblog as a verb is proper form
14:21pdki just read an extra word in there that wasnt there and misunderstood the first time around
14:21sid3kso, do you blog?
14:22pdki wouldnt have enough to say if i did :p
14:22pdki could swear i found a comparison of the thesis and book a while ago
14:23Scriptorsid3k: I just found this: http://twitter.com/planetclojure, you could give it a shot
14:23sid3kgreat, thanks
14:25sid3kpdk: tumblr makes blogging very easy to start, I think you should let people to follow you
14:25sid3ktwitter counts btw
14:27Scriptorposterous is nice too
14:32pdkheh
14:35pdkalso i managed to pull up the okasaki thesis now
14:41pdkim 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:43pdkhm there are two extra chapters that explain persistence and show a few common structures like red black trees done functionally
14:45rubydiamondDoes anybody use irc bouncer like znc
14:49bgs100rubydiamond, I do
14:49rubydiamondbgs100: I have started using it recently.. znc
14:49rubydiamondI have 200GB slice..
14:49bgs100?
14:49rubydiamondin two days .. it says it has done 4GB of transfer
14:50rubydiamondbgs100: so is this 4GB because of znc /
14:50rubydiamondbgs100: ?
14:51bgs100rubydiamond, I dunno.
14:51bgs100I don't really know much about ZNC; I just have an account on a certain server.
14:52bgs100Ask on #znc ?
14:52rubydiamondbgs100: which server?
14:52rubydiamondare there any free providers?
15:23mister_mwhat do I do if something already exists when installing things with ELPA, but is not listed as installed
15:24mister_mcan I force it to overwrite whatever file it's talking about
15:56BobFunkhey
15:56BobFunktrying to make a boring task interesting by learning clojure along the way, and am trying to do some log parsing with clojure
15:57BobFunkbut am runing into out of memory problems
15:57BobFunkwhile doing quite basic stuff
15:58BobFunkjust doing a count of the lines uses up my 3 gigs of memory it seems
15:58BobFunkdoing it like this: http://gist.github.com/503695
15:58BobFunkguess there must be some better way of working with textfiles than this
15:59raektry (count (read-lines logfile))
15:59raekwhen you bind the head of the sequence to a variable
15:59raekthe JVM cannot garbage collect any parts of it
16:00raekthus, the whole file will be in memory
16:01BobFunkok - makes sense
16:02DeranderBobFunk: there is no escaping the nesting ;-)
16:03BobFunkhehe
16:04BobFunkhmm, doesn't seem to help though
16:04BobFunktrying just: (count (read-lines "path-to-my-log-file.log"))
16:04BobFunkbut memory use still just groving and groving with no result coming
16:05BobFunkahh - result came now
16:05BobFunkand guess the gc might just not have kicked in - gonna try with a lower memory limit on the jvm
16:13raekyou can still do a .readLine on the reader manually and cound the number of times it returns non-nil
16:18mister_many clojure reading recommendations for someone new to the language?
16:18mister_mpreferably the free kind of reading
16:20qbgBlogs are free
16:20qbgYou could go to a library and try to get Programming Clojure
16:21raekthere is some free pieces of The Joy of Clojure: http://manning.com/fogus/
16:21raekhttp://planet.clojure.in/ http://disclojure.org/
16:22raekalso, some screencasts: http://clojure.blip.tv/
16:22raekthere are other video series around too
16:23qbgSome material relating to Scheme might be good also depending on new you are to FP
16:24tomojanyone know why some planet clojure feed items have their links fucked up?
16:24tomojI wonder if it's planet clojure's fault or the feed author's faults?
16:40LauJensenDoes anyone have an example of how Rings current session middleware is supposed to be used for memory storage?
16:41dsopy
16:42LauJensenmister_m: my blog on www.bestinclass.dk has quite a few articles that are new-comer friendly
16:42LauJensen(and also a couple that arent)
16:44BjeringUsing 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:45LauJensenBjering: Yea, from your description it sounds like you're not using Emacs
16:45tomoj(defn an-aleph-handler [ch r] (enqueue-and-close ch (a-ring-handler r))) sort of defeats the purpose, doesn't it?
16:49fielcabral#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:51Bjeringfielcabral: 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:53Bjeringfielcabral: 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:55fielcabralBjering 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:03Bjeringfielcabral: 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:03Bjeringthank you
17:04fielcabralwelcome
17:04fielcabralBjering i gotta try counter clockwise again one of these days
17:07BjeringI 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:11fielcabralBjering 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:18raekwhich editor had that paredit-like thingy? ccw?
17:18qbgYes
17:22JoeyAQuick 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:22JoeyAIn other words, if you apply an argument to, say, addition, does it yield a function which adds 3 (single applicative)?
17:22JoeyAOr do you have to apply all arguments up front? (or use a lambda or #(+ 3 %))
17:23tomojare you asking if you can do ((+ 1) 2) to get 3?
17:23JoeyAyes
17:24tomojno, you can't
17:24tomoj((partial + 1) 2) works
17:24JoeyAis partial a special operator that only works in that context?
17:24tomojpartial is just a function
17:24JoeyAoh
17:25raekit does something like (defn partial [f val] (fn [& args] (apply f (cons val args))))
17:25raek,(source partial)
17:25clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
17:25raek~partial
17:26clojurebotIt's greek to me.
17:26tomoj([f arg1] (fn [& args] (apply f arg1 args)))
17:26raek(source partial)
17:26raekhrm, yeah
17:27JoeyACan you do this to create a partially applied function? #(function_of_5_args 1 2 %1 %2 5)
17:27tomojsure
17:27raekyes, that will yield a 2-arg functoin
17:27JoeyAcool
17:29JoeyAI've been thinking about how to implement a sort of drag-and-drop programming facility for an application.
17:29tomojso do we end up having to reimplement ring stuff for aleph?
17:30JoeyAOne 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:30JoeyAI'm not sure that idea would work so well in single-applicative style.
17:31JoeyAAnyway, thanks.
17:43technomancyJoeyA: single applicative functions like you're describing don't seem to be compatible with variable argument lists
17:44technomancyI think the term is currying
17:46Derandertechnomancy: 'tis indeed
17:46Deranderuncurried functions, currying, etc.
17:46Deranders/un//
17:46sexpbotcurried fctions, currying, etc.
17:47technomancysexpbot: I didn't see a g there...
17:49JoeyAright
18:17pdk[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:18pdke.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:31tomojit's #(apply * 2 %&)
18:32pdkOR THAT
18:33JoeyAThanks
18:33tomoj-> ((partial * 1))
18:33sexpbot=> 1
18:33tomojnever thought about that
18:58pdk(doc ->)
18:58clojurebot"([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:09lancepantz_github should map anchor tags to line numbers
19:10lancepantz_i should be able to do http://github.com/nablaone/slime/blob/master/slime.el#2214
19:10lancepantz_and that go to 2214
19:11tomojhttp://github.com/nablaone/slime/blob/master/slime.el#L2214
19:11lancepantz_nice!
19:11lancepantz_you always come through for me tomoj :)
19:11tomojyou can click on the line numbers to get those links
19:11lancepantz_i see
19:27pdk(doc read-lines)
19:27clojurebot"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:27pdk(doc line-seq)
19:27clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
19:28wwmorganwhat's the preferred way to submit patches?
19:29kencauseyhttp://www.assembla.com/wiki/show/clojure
20:47lancepantz_,(let [x (filter odd? [2 4])] (when (first x) x))
20:47clojurebotnil
20:48lancepantz_^ is there a cleaner way to do that?
20:48lancepantz_making a filtered seq return nil if it's empty
20:48wwmorgan,(seq (filter odd? [2 4]))
20:48clojurebotnil
20:50lancepantz_wwmorgan: ty
20:53pdk(doc when)
20:53clojurebot"([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."
21:09rhudsondon't we all
23:33BahmanHi all!
23:55gstamp,(clojure.stacktrace/root-cause (Exception.))
23:55clojurebot#<Exception java.lang.Exception>