#clojure log - Mar 15 2009

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

0:00 * hiredman claims his first victory against fnparse

0:01 durka42: got it to parse wiki markup did you?

0:02 hiredman: no

0:02 I got it to parse something

0:03 in this case, it just parses out odd and even digits (seperately), as a result I get a sequence composed of numbers that each are composed of either all odd or all even digits

0:04 durka42: cool

0:04 hiredman: it is a start

4:21 Lau_of_DK: Morning all

4:24 slashus2: hi Lau_of_DK

4:29 Lau_of_DK: Can somebody please explain to me, why we are told to use 'rest' in recursive calls, instead of next?

4:35 Can somebody please explain to me, why we are told to use 'rest' in recursive calls, instead of next?

4:35 someone like kotarak

4:35 :)

4:38 cmvkk_: who's telling us that?

4:38 Lau_of_DK: The Rich Man

4:39 Recipe - Porting

4:39 To move to the new model you'll need to take the following steps, in this order:

4:39 * Rename all your calls to rest to call next

4:39 * If you were defining your own lazy sequence functions, using lazy-cons, switch them over to lazy-seq using the recipe above. Make sure to call rest and not next in your recursive call.

4:39 from clojure.org/lazy

4:39 cmvkk_: ohhh.

4:39 that's when you're defining a lazy seq.

4:39 Lau_of_DK: thats right

4:40 cmvkk_: if you're defining a lazy-seq on top of an already existing seq (lazy or not)

4:40 it won't be totally lazy unless you use rest instead of next.

4:40 i think?

4:41 Lau_of_DK: I would have thought the opposite, because rest is eager

4:41 cmvkk_: what do you mean by that?

4:41 Lau_of_DK: But I guess when youre on top of another seq, you cant use the head, you need the frest

4:41 ,(rest [1 2 3 4 5])

4:41 clojurebot: (2 3 4 5)

4:41 Lau_of_DK: rest wil realize those 4 numbers, next will realize the first and remain lazy

4:41 cmvkk_: ,(next [1 2 3 4 5])

4:41 clojurebot: (2 3 4 5)

4:42 Lau_of_DK: yes, when printing you get the same ofc :)

4:42 cmvkk_: that's realizing the numbers is what prints them out onto the screen.

4:42 rest is lazier than next: it doesn't even evaluate the very next item.

4:42 in fact, next is the same as (seq (rest ...))

4:43 Lau_of_DK: from the same page : "rest is fundamentally eager"

4:43 You'll have to email Rich your findings :)

4:43 cmvkk_: (next aseq) === (seq (rest aseq))

4:43 from that page

4:44 the "rest is fundamentally eager" line is from the section about how it was before.

4:44 "the current seq model" refers to the old model.

4:44 Lau_of_DK: (doc next)

4:44 clojurebot: Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil.; arglists ([coll])

4:44 Lau_of_DK: (doc rest)

4:44 clojurebot: Returns a possibly empty seq of the items after the first. Calls seq on its argument.; arglists ([coll])

4:45 slashus2: So they are the same except next returning nil and rest returning an empty seq?

4:45 cmvkk_: rest returns a seq that MIGHT be empty.

4:45 slashus2: of course

4:45 cmvkk_: what makes next eager is that it evaluates the next item in line to check to see if it even exists at all.

4:45 if you want to see if the return value of rest is empty or not, you have to call 'seq' on it.

4:45 which is why nil punning doesn't work anymore...

4:46 Lau_of_DK: ah ok

4:46 Then I get it - thanks

4:46 slashus2: Is rest deprecated?

4:46 cmvkk_: no; sometimes that's the behavior you want.

4:46 Lau_of_DK: No just altered

4:57 javuchi: hello

4:57 when to learn clojure?

4:57 any recomended website'

4:57 Lau_of_DK: clojure.org -> screencasts

4:58 javuchi: hello Lau_of_DK: the problem is that i have a slow connection

4:58 Lau_of_DK: ok, www.projecteuler.net , solve 1 - 50 in clojure, compare with clojure-euler.wikispaces.com once you've solved everyone

4:59 hoeck: javuchi: or http://www.ociweb.com/mark/clojure/article.html if you're new to lisp

5:00 javuchi: thank you

5:01 do you think clojure is gonna be the lisp of the future?

5:02 Lau_of_DK: "gonna be" ?

5:02 No other Lisp can go toe to toe with Clojure atm - If the world will ever catch on, I dont know

5:04 javuchi: what is atm?

5:05 hoeck: it's the best lisp for now, and it has lots of possiblities to develop

5:05 arbscht: javuchi: I doubt the future can only handle one lisp at a time

5:05 javuchi: but i mean: the mainstream lisp

5:06 do you think clojure is going to catch up CL?

5:07 * Lau_of_DK giggles

5:07 arbscht: I don't think clojure is trying to

5:07 Lau_of_DK: catch up? :)

5:07 Where is it falling behind ?

5:13 javuchi: Lau_of_DK: some people says that clojure is worst because it lacks CLOS and can't modify its reader

5:14 Lau_of_DK: I dont think that the reader mods missing is a bad thing, and what do you need clos for? If you want objects just extends Java structure, which already surpasses CLs

5:14 hiredman: *cough*

5:15 I don't know if surpasses would be word

5:15 kotarak: javuchi: some people have opions, other people have other opinions, such general remarks show, that some people have a very limited view of the world.

5:16 hiredman: the bookkeeper at work likes to say "opinions are like assholes, everyone has got one"

5:20 javuchi: i think most people that are against clojure lives in comp.lang.lisp

5:21 Lau_of_DK: Common Lisp is an emotion- It was the first Lisp I got into - and I was very happy to get out it again :)

5:22 hiredman: javuchi: let them eat cake

5:22 and hopefuly stay in c.l.l

5:23 javuchi: hiredman: do you think they are problematic?

5:24 hiredman: just blind to anything that is not common lisp

5:24 and, just, ugh

5:25 reading c.l.l makes me want to alternate smacking my head with my hand and yelling

5:26 javuchi: i think the same

5:26 kotarak: javuchi: stay a while in c.l.l and in #clojure and you will see that CLOS is not everything. That's what they are missing. For me Clojure is better than CL because it throws away old cruft and brings a fresh breeze of air and because of the community, where Clojure *really* shines compared to CL

5:26 hiredman: the expression from the bookkeeper is most apt for c.l.l

5:27 clojurebot: what is #clojure?

5:27 clojurebot: clojure is the brand

5:27 hiredman: bah

5:27 clojurebot: this?

5:27 clojurebot: this is not a bug

5:27 kotarak: ~blabla and this

5:27 clojurebot: this is not a bug

5:27 kotarak: hehe

5:27 hiredman: clojurebot: you are pretty worthless sometimes

5:27 javuchi: kotarak: completely agree, i've been intermitently in c.l.l for some years, and they are insupportable at times. they seem to be the most hostile nerds in the world

5:27 clojurebot: It's greek to me.

7:12 Lau_of_DK: ping

7:19 eevar_: can I make swank-clojure-extra-classpaths load all jars in a given directory? "/my/dir/*.jar" doesn't seem to work

7:22 hoeck: eevar_: "/my/dir/*" (without the .jar") works for me

7:22 eevar_: hoeck, ok, thanks

8:25 Lau_of_DK: durka durka

8:25 hiredman, Cant we get that automated by Clojurebot?

8:25 I mean, I enjoy doing it, but I might skip a beat once in a while

12:20 hiredman: clojurebot: jar directory?

12:20 clojurebot: jar directory is find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

12:22 hiredman: clojurebot: jar directory is <reply>on with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

12:22 clojurebot: You don't have to tell me twice.

12:22 hiredman: clojurebot: jar directory?

12:22 clojurebot: on with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

12:23 hiredman: er

12:23 clojurebot: jar directory is <reply>with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

12:23 clojurebot: You don't have to tell me twice.

12:24 eevar_: clojurebot: wiki?

12:24 clojurebot: wiki is http://en.wikibooks.org/wiki/Clojure_Programming

12:24 eevar_: clojurebot: clojure-mode?

12:24 clojurebot: clojure-mode is an Emacs mode for Clojure, found at git://github.com/jochu/clojure-mode.git

12:25 kotarak: clojurebot: vimclojure is http://kotka.de/projects/clojure/vimclojure.html

12:25 clojurebot: 'Sea, mhuise.

12:25 eevar_: should clojure-mode do tab completion?

12:26 kotarak: clojurebot: gorilla is now merged with vimclojure http://kotka.de/projects/clojure/vimclojure.html

12:26 clojurebot: Alles klar

13:40 marklar: how does one implement a Java static interface in clojure? I thought I could just import it and then use proxy, but it keeps giving a ClassNotFoundException so I figure I'm doing something wrong

13:41 kotarak: marklar: then it's not in your classpath? I'm also not sure, whether you have to fully qualify the interface name or not. At least for gen-class have to do so.

13:41 marklar: kotarak: I'm able to extend classes in the same jar, so I was assuming it was some different with an interface vs a class

13:43 kotarak: marklar: then you should be able to just use it. Also importing should work. (import 'clojure.lang.IFn) (proxy [IFn] [])

13:44 did you check the backtrace where the CNFE comes from?

13:45 marklar: its from the import statement

13:45 kotarak: marklar: maybe a typo?

13:45 marklar: (import '(android.view.View OnClickListener))

13:45 I hoped so :(

13:45 kotarak: I this an inner interface?

13:46 marklar: kotarak: good question

13:47 kotarak: I would expect (import '(android.view View OnClickListener)) or (import 'android.view.View) and then (proxy [View$OnClickListener] [])

13:47 depending on the OCL being inside View or not.

13:47 marklar: kotarak: ah, yeah it is

13:47 kotarak: Thanks, I'll give that a shot

13:59 gnuvince_: I'm trying to convert a Clojure program to Haskell; just getting the FFI to work is probably gonna be as much work as the entire Clojure project :-/

14:02 Lau_of_DK: gnuvince, I actually yawned just from reading that

14:04 gnuvince_: Lau_of_DK: good for you

14:05 Lau_of_DK: yea it was nice

14:05 I'll need some coffee now though

14:26 danlarkin: hey hey play nice

14:26 Lau_of_DK: ~its his fault danlarkin, I was just minding my own business when suddenly...

14:26 clojurebot: CLABANGO!

14:28 Chousuke: ... what the hell is that about.

14:28 danlarkin: it's #clojure's new favorite meme

14:28 Lau_of_DK: Chousuke, www.clabango.com

14:29 Man I lolled at that

14:31 danlarkin: yeah it's pretty good

15:22 spacema__: hey guys - say I want to merge a set of lists of hashes, like ({:id 1, :value 6} {:id 5, :value 2}) and ({:id 1, :value 4}) and sum the value part when the id's are equal - what's the right approach?

15:25 slashus2: spacema__: (merge-with + {:id 1 :value 6} {:id 5 :value 2} {:id 1 :value 4})

15:25 oh wait

15:31 cgrand: ,(vals (clojure.set/index (apply concat '#{({:id 1, :value 6} {:id 5, :value 2}) ({:id 1, :value 4})}) #{:id}))

15:31 clojurebot: (#{{:id 5, :value 2}} #{{:id 1, :value 4} {:id 1, :value 6}})

15:31 cgrand: and then reduce on each item to sum?

15:39 spacema__: cgrand: Clever, thanks. DIdn't know about index

15:50 slashus2: ,(vals (clojure.set/index #{{:id 1 :value 6} {:id 5 :value 2} {:id 1 :value 4}} #{:id}))

15:50 clojurebot: (#{{:id 5, :value 2}} #{{:id 1, :value 4} {:id 1, :value 6}})

15:51 slashus2: Why the apply concat?

15:54 ,(map #(apply merge-with + %) (vals (clojure.set/index #{{:id 1 :value 6} {:id 5 :value 2} {:id 1 :value 4}} #{:id})))

15:54 clojurebot: ({:id 5, :value 2} {:id 2, :value 10})

15:55 spacema__: since the data comes in as lists of hashes

15:57 slashus2: spacema__: embedded in random lists? (hash1 hash2) (hash3) (hash4 hash5) ?

15:57 spacema__: yeah, that's how I've got it now. I'm thinking it'd make sense to reshape it to take advantage of merge-with

16:00 slashus2: ,(map #(apply merge-with + %) (vals (clojure.set/index (set (concat [{:id 1 :value 6} {:id 5 :value 2}] [{:id 1 :value 4}])) #{:id})))

16:00 clojurebot: ({:id 5, :value 2} {:id 2, :value 10})

16:01 slashus2: I made them vectors for clarity.

16:02 spacema__: yeah. the problem is that merge-with is applying + to both the id's and other fields

16:03 slashus2: You don't want it to add the values?

16:03 spacema__: I want to add the vals, but the id's should be preserved; that is, the output should be ({:id 5, :value 2} {:id 1, :value 10})

16:13 cmvkk_: i can't see the beginning of your conversation, but it seems like your problem would be easier if the ID were a key and the value were a value, rather than both being key-value pairs.

16:13 {5 2} rather than {:id 5 :value 2}

16:13 spacema__: yep, absolutely

16:14 I'm gonna change it to work like that

16:16 Thanks for the help thinking it over guys

16:22 kib2: Hi. I've just setup my EMacs to work with Clojure (using SLIME).

16:22 Now, I just want to learn how to use it :)

16:22 It's quiet confusing : you've got a Clojure and a SLIME menu.

16:22 Any advice ?

16:24 Hun: don't use the menus too much

16:24 (slime-setup '(slime-fancy))

16:24 use this.

16:24 most important stuff: load a file with C-c C-k, single defs with C-M-x

16:24 use the inspector with C-c I

16:24 try paredit for editing

16:25 kib2: Hur: thanks! I've tried paredit but found it very annoying : once on an open par, I just can't delete it.

16:26 Hur --> Hun, sorry

16:26 Hun: you can when there's nothing between

16:26 kib2: ah? ok, thanks for the tip.

16:26 Hun: navigate by C-M-[fbud], delete stuff with C-M-k and move it around

16:26 works pretty fast once you're used to it

16:27 you can jump into stuff with M-. and out via M-,. try it, works also on core-clojure-stuff

16:48 Lau_of_DK: ({:a 1, :b 2} {:a 2, :b 3} {:a 3, :b 4})

16:48 ({:a 41, :b 42} {:a 52, :b 53} {:a 63, :b 64})

16:48 Ok, lets say I have these 2 lists of hash-maps, and I want to merge them into 1 big hash-map

16:49 I need a very fast an effecient way to do this, since Im merging more than 150K maps

16:51 achim_p: Lau_of_DK: what's the result supposed to look like for these two lists?

16:52 Lau_of_DK: ({:a 1, :b 2} {:a 2, :b 3} {:a 3, :b 4} {:a 41, :b 42} {:a 52, :b 53} {:a 63, :b 64})

16:56 achim_p: hmm, list concatenation is linear time

16:57 Lau_of_DK: No chance of blowing the heap with that?

16:57 slashus2: (merge (concat [{:a 1, :b 2} {:a 2, :b 3} {:a 3, :b 4}] [{:a 41, :b 42} {:a 52, :b 53} {:a 63, :b 64}]))

16:57 ,(merge (concat [{:a 1, :b 2} {:a 2, :b 3} {:a 3, :b 4}] [{:a 41, :b 42} {:a 52, :b 53} {:a 63, :b 64}]))

16:57 clojurebot: ({:a 1, :b 2} {:a 2, :b 3} {:a 3, :b 4} {:a 41, :b 42} {:a 52, :b 53} {:a 63, :b 64})

16:59 slashus2: You don't even need merge

16:59 concat alone works.

16:59 cmvkk_: yep, this is a list concatenation problem.

16:59 Lau_of_DK: hmm, cool

16:59 I figured concat would give me 2 lists in a list

16:59 cmvkk_: that would be conj.

16:59 or cons maybe.

17:00 or list.

17:00 Lau_of_DK: or both

17:01 Raynes: ,(conj [{:a 1 :b 2} {:a 2 :b 3}])

17:01 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$conj

17:01 Raynes: Of course.

17:01 * Raynes smacks himself.

17:01 cmvkk_: ,(apply conj [{:a 1 :b 2} {:a 2 :b 3}])

17:01 clojurebot: {:a 2, :b 3}

17:02 Raynes: ,(conj [{:a 1 :b 2} {:a 2 :b 3}] [{:a 2 :b 4])

17:02 clojurebot: Unmatched delimiter: ]

17:02 Raynes: Damn it!

17:02 * Raynes can't type today.

17:02 Raynes: ,(conj [{:a 1 :b 2} {:a 2 :b 3}] [{:a 2 :b 4}])

17:02 clojurebot: [{:a 1, :b 2} {:a 2, :b 3} [{:a 2, :b 4}]]

17:02 Raynes: There. -_-

17:03 slashus2: ,(conj [{:a 1 :b 2} {:a 2 :b 3}] {:a 2 :b 4})

17:03 clojurebot: [{:a 1, :b 2} {:a 2, :b 3} {:a 2, :b 4}]

17:04 Raynes: So there.

17:05 I have lemon cookies!

17:08 hiredman: it is girl scout season

17:09 Raynes: Not those kind of lemon cookies.

17:15 achim_p: Lau_of_DK: but if the lists are long, linear time is pretty bad. if you're accessing the maps sequentially, you could as well keep the lists and build vectors or lists of them (instead of concatenating them), which you can then do a tree-walk on

17:16 Lau_of_DK: achim_p, I pretty fast going over 200000 lines, so no need to optimize

17:41 Mec: is there a way to cache the return values of a function?

17:42 dnolen: ,(doc memoize)

17:42 clojurebot: "([f]); Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use."

17:42 Retonator: i thought you could use memoization for that or are you looking for something in the lang?

17:42 lol, didn't know it was in the lang already

17:43 Mec: wow that's nifty

17:43 dnolen: ;) sometimes it's plain shocking how much stuff is already there, I'm surprised constantly.

17:43 Retonator: have to dive into it ;), just found out about clojure 2 days ago

17:45 Mec: ,([#(* 2 %)])

17:45 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: LazilyPersistentVector

17:45 Mec: shouldnt that work then?

17:45 Chousuke: ,`memoize

17:46 clojurebot: clojure.core/memoize

17:46 Chousuke: hm

17:46 Mec: or should it be (memoize #(* 2 %))

17:46 Chousuke: Mec: yeah. and you need to store the result somewhere

17:46 Mec: ok, so what does the ([f]) mean

17:47 Chousuke: function

17:47 durka42: that's the arglists for the function

17:47 Retonator: arg

17:47 Chousuke: (def memosquare (memoize #(* % %)))

17:47 durka42: (doc +)

17:47 clojurebot: Returns the sum of nums. (+) returns 0.; arglists ([] [x] [x y] [x y & more])

17:47 Mec: ah ok then

17:47 Chousuke: Mec: it corresponds to the arg vectors used when defining the function

17:47 durka42: + has more than one permissible arglist, they are listed at the end there

17:48 Chousuke: Mec: so if you (defn foo [a b c]) then (doc foo) will say it has arglists [a b c]

17:48 Mec: right right, just the way it was formatted threw me off

17:48 Chousuke: (doc memoize)

17:48 clojurebot: Returns a memoized version of a referentially transparent function. The memoized version of the function keeps a cache of the mapping from arguments to results and, when calls with the same arguments are repeated often, has higher performance at the expense of higher memory use.; arglists ([f])

17:48 Chousuke: doc is so common it gets some special treatment :)

17:49 Mec: doc memoize

17:49 Chousuke: (note there's no dot)

17:49 you still need the parens.

17:49 Mec: ah well, back to programming :D

17:49 Chousuke: and comma, not dot :P

17:49 there's also:

17:49 ~source memoize

17:49 (clojurebot is not very consistent.)

17:49 Retonator: is clojurebot coded in clojure or is it using eggbot or something?

17:50 Chousuke: it's clojure

17:50 using PIRCbot

17:50 clojurebot: source

17:50 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

17:50 Retonator: thanks

17:51 Chousuke: it started off as a simple script on gist so it's not very designed :P

17:52 all of its history has been preserved though so you can look at what it used to be :)

17:52 Retonator: nevermind i still have to learn so some pratical stuff is pretty nice for me

17:52 i like git ;)

17:52 Chousuke: yeah, me too.

17:53 it was pretty fun making the github project and then merging the gist history into it.

17:54 tashafa: hello all

17:54 is there a way to turn a string to a clojure regexp?

17:55 Retonator: i am still learning git too, but i find github and git very inspiring

17:55 Chousuke: if you look at the network graph there's a long line of "auto ci" commits and then it merges and there's some funky stuff

17:55 Retonator: as a developer i have been working with M$ most of my time

17:56 but i always had an intrest for functional languages

17:56 haskell, clean, f#

17:57 slashus2: tashafa: #"\w+"

17:57 danlarkin: tashafa: re-pattern

17:58 (doc re-pattern)

17:58 clojurebot: Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher.; arglists ([s])

17:58 tashafa: ah thanks

17:58 durka42: also, Pattern/compile, but that's what re-pattern does :p

17:58 tashafa: i need to read stus book more insead of hacking :P

17:59 ,(doc find-doc)

17:59 clojurebot: "([re-string-or-pattern]); Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern"

18:00 tashafa: ,(find-doc "re-")

18:00 clojurebot: ------------------------- clojure.core/binding ([bindings & body]) Macro binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. ------------------------- clojure.core/compare-and-set! ([atom oldval newval]) Atomically sets the value of atom to newval if and

18:00 slashus2: ..

18:01 Chousuke: it doesn't do reformatting :)

18:01 Lau_of_DK: tashafa, If you install emacs, you can have slime/repl in 1 window, and #clojure in the one side beside it :) Then you get (doc foo) w/o any pressure on your line

18:02 tashafa: l-o-dk: i use emac and slime... for some reason i just like using clojorebot :)

18:02 clojure*

18:03 Retonator: what is a good starting point for learing emacs/slime (i have already installed everything and runing using the ubuntu tutorial)

18:05 tashafa: whats the key bindings to the emacs tutorial again?

18:05 dnolen: I always post this about emacs http://home.uchicago.edu/~gan/file/emacs.pdf

18:05 it will save you a lot of time

18:05 also the pdf of the gnu emacs manual

18:06 slime isn't so tough, you have the menu commands, eventually you'll memorize the key-bindings

18:06 Retonator: that pdf should be hanging on a wall somewhere ;)

18:07 tashafa: its on my office wall

18:07 Retonator: if i do a C-x C-e on a line of code, should i see this line back in the slime-mode or is it just executed?

18:08 Mec: so memoize creates a map, is there a way to seed values?

18:10 dnolen: memoize creates a closure over an atom

18:11 you might want to suggest on the mailing list providing a version that can be seeded

18:11 in any case you should look at the source of memoize

18:11 it's only 8 lines of code ;)

18:11 Mec: i have, looks pretty easy to use seeds

18:13 hiredman: ,(class (memoize #(prn :foo)))

18:13 clojurebot: clojure.core$memoize__5054$fn__5056

18:13 hiredman: ~def memoie

18:13 ~def memoize

18:14 tashafa: im sorry im being a hassle..but how do you set the case sensitiviy of a clojure regexp pattern?

18:15 hiredman: (?i) will make a pattern case insensitive

18:16 ,(re-find #"(?i)foo" "FOO")

18:16 clojurebot: "FOO"

18:16 tashafa: cool thanks

18:19 another one... when you map over a sequece is the sequence created lazy and if not is there a lazy-map fn?

18:20 hiredman: clojurebot: map?

18:20 clojurebot: map is *LAZY*

18:20 Lau_of_DK: Good one :)

18:20 Mec: hmm memoize doesnt work for a function called form recur

18:20 from*

18:20 tashafa: hiredman: i cant thank you enough

18:20 hiredman: ~def map

18:21 tashafa: actually i'm giving clojurebot credit for that one

18:21 :)

18:21 * Raynes dreams of the day this channel has more users than #haskell

18:21 hiredman: you should

18:22 clojurebot: if you were a super hero, what would your origin story be?

18:22 clojurebot: http://clojure-log.n01se.net/date/2008-11-21.html#13:04

18:25 Raynes: ~and suddenly...

18:25 clojurebot: CLABANGO!

18:28 tashafa: ,(doc re-replace)

18:28 clojurebot: java.lang.Exception: Unable to resolve var: re-replace in this context

18:28 tashafa: are we still using java api for regex replace

18:28 ?

18:29 hiredman: the replace method on strings takes a regex

18:29 well, a string object that it uses as a regex

18:29 tashafa: (.replace "tester" #"^t" "b")

18:29 ,(.replace "tester" #"^t" "b")

18:29 clojurebot: java.lang.IllegalArgumentException: No matching method found: replace for class java.lang.String

18:29 hiredman: nah

18:30 ,(.replace "tester" "^t" "b")

18:30 clojurebot: "tester"

18:30 hiredman: er

18:30 hm

18:30 ah

18:30 .replace takes a string

18:30 Retonator: lol, i am scrolling through the clojurebot source and i see this line: "Ik begrijp" i don't know if this is intended but this is not "proper" dutch ;)

18:31 tashafa: ,(.replaceAll "tester" "^t" "b")

18:31 clojurebot: "bester"

18:31 hiredman: I forget where I got that

18:31 slashus2: hiredman: Are you going to add a javaDoc function?

18:31 hiredman: ~jdoc String

18:31 Retonator: it should be "Ik begrijp het" 'nitpicking'

18:33 slashus2: cool

18:35 Mec: is there a way to define a function in a function so that the inner function doesnt get redefined every time the outer function is called

18:39 gnuvince_: Mec: the compiler will take care of that.

19:02 kib2: Is there any solution to the last comment on http://www.newartisans.com/2009/03/hello-haskell-goodbye-lisp.html ?

19:03 Raynes: LISPers and Haskellers are meant to fight.

19:03 The rivalry will never end.

19:04 kib2: No, I don't think it's a fight here. It's a real question.

19:07 durka42: well the solution is to streamline it :p

19:07 once upon a time it must have been really hard to get GHC to do "simple" things

19:07 hiredman: hmmm

19:07 durka42: i think it will get better

19:07 um

19:08 hiredman: that should be it

19:08 sorry about that

19:08 durka42: this is like when i fix the wifi and my screen fills up with email notifications

19:08 streams are in now?

19:09 hiredman: the java side is

19:09 durka42: ah

19:09 hmm i was confused there for a second -- wondering what kind of genetic algorithms for math are going into contrib

19:11 Mec: is there a way to make reduce compare (5 4 3 2 1) as 1 &2, 3, 4, 5?

19:12 actually 2 & 1, 3, 4, 5. otherwise it's a simple reverse

19:13 hiredman: what?

19:13 gnuvince_: Mec: no, reduce is foldl and there is not foldr

19:13 Mec: poo, ok guess i can just rewrite the function i pass to filter

19:14 gnuvince_: What do you want to do?

19:15 Mec: reducing thru a list of lists

19:15 i figured it out tho, pretty easy fix

19:20 gnuvince_: kib2: that's an implementation problem, not a language problem.

19:21 kib2: gnuvince_: sorry, I don't really catch your answer.

19:23 durka42: kib2: as in, there's no real reason that should be hard, and a shell script or a small clojure program could smooth things over

19:24 (i think that's what gnuvince_ meant)

19:26 gnuvince_: Yeah

19:26 kib2: durka42: ok, thanks. I was just asking this because I have already seen this problems in CL world, and I expected Clojure to solve the issue easily.

19:26 gnuvince_: The CLs usually ship the entire compiler+runtime with the program, which explains why they're huge

19:26 kib2: but you're right, writting a script is rather easy.

19:27 gnuvince_: And Clojure... well, I don't know Java well enough, but I'm guessing it's bound by the same limits Java is.

19:27 kib2: gnuvince_: oh yes!

19:27 gnuvince_: If you strip everything like Haskell does, well then you just have something that a C compiler could've compiled.

19:28 Which means it's a static program, not something that you can extend and rework as it's running.

19:28 Hun: you can do similar stunts with a CL-Compiler if you try hard enough. it's usually not worth it

19:29 kib2: indeed, there are pros and cons with each system.

19:29 Hun: in my case, used ecl to compile lisp to c to binary. try to debug that when something crashes...

19:29 Raynes: Scala sends out shell scripts for compiling and such with it's distros.

19:30 Simple "Scala scala.scala" wewt compiled.

19:30 gnuvince_: I think there was a discussion on the mailing list a few months ago on such a tool, and there were technical limitations to getting something to work

19:31 kib2: Raynes: good idea. But you'll then have to write such script for each platform you run on ?

19:31 Raynes: kib2: They do that, and have multiple distros for each platform.

19:32 There /has/ to be some way to make it easier without completely screwing everything up.

19:32 :|

19:33 kib2: Raynes: why not, in fact you just have to write them once

19:34 Hun: be aware that stuff gets really ugly when there's a bug in that code-generation stage.

19:35 i had one that outputted the name of an internal symbol. i removed any reference to that symbol from my code, recompiled. it still was output

19:35 Raynes: I do know for people not coming from Java that the whole setup-clojure-with-perfected-classpaths thing jars them a good bit. When I came into Clojure I had no clue what a classpath was. I still haven't successfully compiled anything and jarred it. Of course I'm using netbeans and don't have too.

19:35 Hun: what happened? the compiler had an exotic crash and included the symbol in the linked in libraries

19:36 kib2: Hun: weird !

19:36 Hun: true. took me a whole day to sort that out

19:37 it's like that old story, about kernighan infecting his own compiler

19:37 my code was infecting other code, though i never wrote it that way

19:37 afterwards, the bug was in the statical library of cl-ppcre.

19:37 fun

19:37 kib2: Raynes: sure, classpaths are voodoo for me too.

19:38 Raynes: kib2: What got me is the whole, put Clojure here, start it with these classpaths make sure your class files are here and there, put this here and over there and then compile stuff.

19:39 durka42: what we need are some apt, yum, darwinports and windows installer packages

19:39 Raynes: It just makes you wish you could just type "Clojure Main.clj" ??? profit.

19:39 Mec: is there a way to for loop over the lines of a file?

19:40 durka42: well it's more like $ clojure -cp ??? profit

19:40 (doc line-seq)

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

19:41 Mec: yuck i remember bad things of java bufferreaders

19:41 durka42: then you should look at contrib.duck-streams

19:42 hiredman: Mec: what bad things?

19:43 Hun: here-be-dragons

19:43 Mec: like 5 lines of code to setup a reader just to read a file

19:43 Raynes: But this isn't Java.

19:43 hiredman: pfft

19:43 yeah

19:43 Raynes: This is teh Clojure.

19:43 Mec: line-seq still wants a bufferedreader, so what do you do in clojure

19:43 kib2: Raynes: +1

19:43 Hun: at least you don't have to do the cylinder juggling by hand (which reminds me that i wanted to write a driver. damn)

19:44 durka42: use clojure.contrib.duck-streams/reader

19:44 Raynes: ^

19:44 durka42: Attempts to coerce its argument into an open

19:44 java.io.BufferedReader. Argument may be an instance of Reader,

19:44 BufferedReader, InputStream, File, URI, URL, or String.

19:44 Mec: i dont have .contrib

19:44 Raynes: Mec: Get it.

19:44 durka42: well, you should get it

19:45 or you can do the gyrations (BufferedReader. (InputStream. (File. "blah...... or whatever

19:45 hiredman: (-> "file.txt" File. BufferedReader.)

19:45 er

19:45 Raynes: (doc ->)

19:45 clojurebot: 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.; arglists ([x form] [x form & more])

19:45 hiredman: you need a FileReader in there

19:46 Hun: that reads like forth :)

19:46 Mec: see what i mean :D why must reading a file be so difficult

19:46 durka42: (doc slurp)

19:46 clojurebot: Reads the file named by f into a string and returns it.; arglists ([f])

19:47 * Raynes uses slurp in his config reader.

19:47 Mec: ya, right now im using (for [line (.split "slurp file.txt") "\r\n")])

19:47 Raynes: Then I just trim out the line breaks and slice it apart at the spaces.

19:47 hiredman: ugh

19:48 durka42: you should use (System/getProperty "line.separator") instead of "\r\n"

19:48 Raynes: ...

19:49 durka42: Clojure=> (System/getProperty "line.separator")

19:49 "\n"

19:49 hiredman: reada whole file into a string is just icky

19:49 Raynes: durka42: Why didn't you tell me that /before/ I did this (.replaceAll (slurp f) "\r(\n)?" " "))?

19:49 Mec: that wouldnt work

19:49 Raynes: hiredman: It works pretty well for what I'm using the file for.

19:49 Mec: ,(System/getProperty "line.seperator")

19:49 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission line.seperator read)

19:49 Mec: well it just returns nil for me

19:50 durka42: separator

19:50 Mec: ah hah

19:50 not being able to spell has some serious drawbacks

19:50 Raynes: Mec: Spell separator right :p

19:51 Yay.

19:51 Now I don't have to use a regex.

19:51 <3

19:56 kib2: Have to go. Good night.

19:59 keithb: Ruby has IO.read to read the entire contents (like slurp), and IO.readlines to read the file into an array of lines. They're quite useful when the file is known to be of manageable size. A readlines type function would be useful. (Maybe I'll write one, but if someone wants to beat me to it... ;)

20:00 Mec: how come i keep getting unable to resolve classname for File, FileReader, and BufferedReader?

20:00 keithb: Mec, import java.io

20:00 durka42: (import '[java.io File FileReader BufferedReader])

20:01 achim_p: (doc line-seq)

20:01 keithb: That's what I meant. ;)

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

20:01 Mec: ClassNotFoundException

20:01 durka42: on which one

20:02 Mec: hmm i guess (import 'java.io) doesnt work, but (import '[java.io File FileReader BufferedReader]) does

20:02 durka42: clojure doesn't have an equivalent for java's "import java.io.*"

20:02 you have to name each class that you want

20:02 Mec: ah ok

20:03 keithb: Mec, sorry, I was a bit careless when i said import java.io, I should not have assumed anything...

20:03 Mec: no problem :D clojure api really needs an example for each function and it would clarify a lot

20:04 durka42: this is entirely true

20:04 Drakeson is compiling something i think

20:04 ~api examples

20:04 clojurebot: excusez-moi

20:04 durka42: ~examples

20:04 clojurebot: Excuse me?

20:04 durka42: what?

20:04 it used to know

20:05 clojurebot: api examples are http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

20:05 clojurebot: Huh?

20:05 durka42: clojurebot: api examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

20:05 Mec: so after importing it should be (-> "file.txt" File FileReader BufferedReader line-seq) right? :D

20:05 clojurebot: 'Sea, mhuise.

20:05 durka42: you may be able to skip the File. there

20:05 oh you will need dots after the classnames

20:05 to get the constructors

20:06 ,(String "boo")

20:06 clojurebot: java.lang.Exception: Expecting var, but String is mapped to class java.lang.String

20:06 durka42: ,(String. "boo")

20:06 clojurebot: "boo"

20:06 Mec: right

20:07 I dont know whats worse, (-> "file.txt" File. FileReader. BufferedReader. line-seq)

20:07 or (.split (slurp "file.txt") (System/getProperty "line.separator"))

20:08 hiredman: slurp is worse

20:10 clojurebot: slurp?

20:10 clojurebot: No entiendo

20:10 hiredman: clojurebot: slurp is worse

20:10 clojurebot: 'Sea, mhuise.

20:11 Mec: ~def slurp

20:12 gnuvince_: (with-open [rdr (reader "/etc/passwd")] (doall (line-seq rdr)))

20:18 Mec: if I do java.io.FileReader i don't have to import it right?

20:20 gnuvince_: Nope

20:32 Mec: any reason java.util.GregorianCalendar might not exist?

20:33 drewr: Mec: Not with a recent JVM.

20:35 Mec: i've got java 6u10

20:37 gah inability to spell strikes again

20:37 * Raynes smacks the parentheses out of Mec

20:37 Raynes: !

20:38 gnuvince_: Anyone knows what Rich said at QCon regarding Qi?

20:40 Raynes: Why would anyone acknowledge Qi's existence.

20:41 gnuvince_: Why?

20:41 It's an interesting project; I'm especially interested in hearing about what Rich thinks of the optional static typing that Qi offers.

20:41 Raynes: Qi is boring :(

20:42 Rich should add static typing, just to piss Stuart Halloway off.

20:43 * cmvkk_ now reading about qi

20:43 Raynes: "Buy our book and you get to use Qi!"

20:44 gnuvince_: Raynes: regardless of the "boringness" of Qi, I think that if a language has interesting features, they should be investigated.

20:44 Raynes: I'm sorry, I just don't find it interesting.

20:44 gnuvince_: And I think Rich made it pretty clear that he's against static typing through-and-through.

20:45 He's mentioned in the past that he would be interested in an � la carte static typing system, citing specifically Qi.

20:45 Apparently this topic came up at Qcon, and I was wondering if anything more was said about the matter.

20:46 Raynes: Mention it on the group.

20:47 cmvkk_: would creating a system like that allow for a speed boost for statically typed forms and functions?

20:48 or would it just be for the benefit of easier debugging or whatever.

20:49 albino: Why are we pissing off Stuart Halloway? IIRC he's the first one to write a book on clojure. It seem we ought to thank him for that not piss him off.

20:49 cmvkk_: actually, i was going to ask that too...

20:50 gnuvince_: albino: that was a joke

20:50 albino: Stu's been through a lot of big changes

20:50 albino: gnuvince_: oh, it was lost on me, sorry

20:51 gnuvince_: cmvkk_: I don't know about performance, I think the more interesting aspect is being able to prove properties of the code at compile time to prevent errors at runtime.

20:51 Raynes: albino: It was a joke. Stu knows the consequences of writing a book this early. He knows it's going to be outdated probably soon after being distributed.

20:51 albino: free unit tests

20:52 cmvkk_: oh i get it, it would piss him off because he'd have to change the whole book. i thought maybe he didn't like static typing or something.

20:52 albino: if the system lets me specify types after the fact then I'm good with it

20:53 I like to add my assertions after the initial problem is solved

20:53 Raynes: cmvkk_: I believe it's too late for him to change the book now anyways, when he updated it for lazy sequences he said it was just in time then.

20:53 If he would have made the book open on a website like real world haskell, he could of updated it any time :\.

20:53 cmvkk_: i wonder what that means for the impact of deciding to make breaking changes?

20:53 Raynes: But, not my story.

20:54 cmvkk_: like, maybe we're less likely to see them now that the way it is now is going to be hardwritten into a book.

20:54 Raynes: I feel if Rich decides to make a change that book darn sure wont stop him.

20:55 albino: I must have missed something on the lists. When did all this tension happen between Stuart's book and Rich's language

20:55 cmvkk_: i certainly think he would take the book into account...i think he looks at the community when he makes decisions like that

20:56 gnuvince_: albino: no "tension"; Rich took the language where it needed to go, and Stu had to rewrite many chapters to reflect those changes.

20:56 albino: gnuvince_: sounds fair to me, did Stu complain a lot when he had to make those changes?

20:57 gnuvince_: Stu has joked about it, but I'm sure he feels it's more important that the language be done right than that his book be up to date for a longer period of time.

20:57 Raynes: cmvkk_: Yes of course. Rich almost always looks to the community for opinions. I <3 Rich. I'm just saying that if it was important enough the book would be irrelevant.

20:57 gnuvince_: Exactly.

20:57 gnuvince_: No complaining, he took it like a champ.

20:58 albino: sounds like I need to buy a copy

20:58 or digital copy if it's not in dead tree form yet

20:58 Raynes: albino: You can buy both and get the book when it's in dead tree form.

20:59 gnuvince_: albino: both are available.

20:59 Raynes: You save ca$h that way too.

20:59 Oh really?

20:59 Cool.

21:00 gnuvince_: I meant that you can have the book in digital and dead tree format. The beta PDF is available now, the book in a couple months maybe?

21:00 Raynes: Oh, yeah, that's what I was saying.

21:06 Mec: cant you have clojure use static typing with metadata?

21:08 hiredman: Mec: more or less

21:08 the main issues is fn's interface is defined in turms of Object

21:09 so there is overhead for passing primitives through functions

21:09 Raynes: Haha turms. That made me giggle.

21:10 Mec: even if you define a function like: (defn foo [#^String s])

21:10 Jedi_Stannis: the tag metadata gives you speed ups, but it doesn't type-check at compile time. If you want to learn about static type checking, you shoul dlook into haskell - it has a real, powerful type checking system. java/c/c++ type checking is not very good in comparison

21:11 hiredman: Mec: I am not 100% on this, but I believe the type hinting only helps within the function

21:11 but String is not a primitive so it would not matter in that case

21:11 ,(ancestors String)

21:11 clojurebot: #{java.lang.Comparable java.lang.Object java.lang.CharSequence java.io.Serializable}

21:12 Mec: ah

21:12 * Raynes <3's Haskell

21:12 Raynes: Clojure will poke you if you get a type screwed up. Haskell will beat your ass in a dark alley and then cut you.

21:12 He might even piss on you.

21:12 Jedi_Stannis: I took a break from clojure for a little bit to explore with haskell, it's a really cool language

21:12 Raynes: Jedi_Stannis: It's the other way around for me.

21:13 Mec: how is it's type checking different from java/c/c++?

21:13 Jedi_Stannis: made me appreciate functional style a lot more

21:13 hiredman: rhickey has mentioned possibly making special purpose fn interfaces, for say functions that take doubles as arguments and return a double

21:13 Raynes: I took a break from Hasekll to explore Clojure and here I am.

21:13 hiredman: Mec: you don't have to do it?

21:13 oh

21:13 you meant haskell

21:13 Mec: yes

21:13 Jedi_Stannis: but I miss the dynamic nature of lisp and the homoiconicty

21:13 Raynes: Mec: If Java's type system is a dinosaur, then Haskell's is GODZILLA.

21:14 p_l: wasn't it possible to make haskell's type system turing-complete?

21:14 hiredman: (a nuclear dinosaur)

21:14 Jedi_Stannis: Mec: its very hard to explain, you really have to look into it, its very in depth

21:14 Raynes: p_l: Yes.

21:14 Mec: i know some newer feature of c++ was touring complete, but i cant remember the name of it... something with <>

21:15 p_l: otoh, clojure works on JVM, which has many advantages :D

21:15 Jedi_Stannis: ill try to explain though: it has type inference, so you can get by without declaring types if you don't have to

21:15 p_l: Mec: templates :P

21:15 Mec: ya c++ templates are turing complete

21:15 p_l: and possibly the scariest part of the language

21:15 Raynes: p_l: Plenty of advantages with some disadvantages such as no TCO and the stupid classpath stuff.

21:16 p_l: Raynes: it gives me possibility to target places I can't with CL or Haskell (or "can but it's a royal PITA and/or expensive")

21:16 frankly speaking, my main interest right now is in making android apps :)

21:16 Jedi_Stannis: raynes: I agree on the cp stuff, but once you get it right you can stop worrying about it. and no tco is somewhat overcome with recur, trampoline (although I agree, its inelegant)

21:18 hiredman: the classpath stuff is not that bad

21:18 Raynes: The classpath stuff itself is not that bad, the fact that in order to compile /anything/ you have to worry about it that's bad.

21:18 hiredman: you just need to know how the classpath works

21:18 Jedi_Stannis: its not that bad, but its not good

21:19 hiredman: *shrug**

21:19 Works For Me

21:19 Raynes: It's just weird to me to have to set up a directory structure and stuff. I'm spoiled by just calling a compiler and compiling shit.

21:19 Jedi_Stannis: its kinda a pain for those not coming from java land

21:19 hiredman: clojurebot: works on my machine is <reply>http://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png

21:19 clojurebot: c'est bon!

21:22 hiredman: not being able to dynamically alter the classpath in a reliable way is kind of a pain

21:23 it would be neat to have compiled class written into a jar

21:23 classes

21:25 hmm

21:25 ~def gen-class

21:30 Raynes: Liskell is neat.

21:31 p_l: Jedi_Stannis: I'd say that's because other environments don't have Java land problems :P

21:31 Jedi_Stannis: p_l: agreed

21:32 Raynes: p_l: Enclojure eliminates that problem for me, hence the reason I'm still using Clojure and loving it all the way.

21:33 * p_l had been experimenting with both enclojure and slime+clojure

21:33 Jedi_Stannis: never found an IDE I like more than using vim, good thing for vimclojure : )

21:34 * p_l stays on Emacs, due to SLIME :)

21:34 Raynes: I use Emacs for Haskell and Factor and usually anything else that isn't something to do with the JVM.

21:35 Jedi_Stannis: I've never used emacs, but im pretty happy with the features of vim clojure

21:35 maybe its better that I don't know what im missing out on

21:36 Raynes: Yeah, I get told everything I'm "missing out on" by using Enclojure whenever Lau_Of_DK is around.

21:36 I just smile and nod.

21:36 At least whenever I mention I'm using Enclojure.

21:37 Jedi_Stannis: does enclojure have any sort of integrated repl?

21:37 Raynes: Yes.

21:37 And you can M-x load files into it too ^_^

21:37 Scratch that.

21:38 M-l

21:38 :)

21:39 Jedi_Stannis: that's good then, I feel like that's the killer feature

21:39 Raynes: Damn right.

21:39 Couldn't live without it.

21:40 AntonyBlakey: raynes: as an enclojure user, do you know where the instructions to build/install from tip are? I can't find any and I'd like to use it with tip NetBeans.

21:41 Raynes: What's tip? o_o

21:41 AntonyBlakey: head

21:41 * Raynes isn't sure what you're talking about.

21:42 AntonyBlakey: Latest from SVN, rather than prebuilt

21:42 Raynes: Oh.

21:42 I believe there is a post on the group somewhere that links to build instructions.

21:43 Oh yeah, that was my post.

21:43 * Raynes looks for it.

21:44 AntonyBlakey: got it - Eric Thorsen ?

21:44 Dec 24 2008

21:44 Raynes: http://groups.google.com/group/enclojure/browse_thread/thread/93ecc3522607c5c9?hl=en

21:44 That was it.

21:44 I never actually built it though.

21:44 AntonyBlakey: Was expecting instructions on the site, sorry, should have searched the group.

21:44 Raynes: I'm too good to build my own software.

21:45 AntonyBlakey: :) Current build doesn't work with nice new OSX L&F in NetBeans.

21:46 gnuvince_: How do you declare a case-insensitive pattern?

21:46 re-pattern doesn't take any extra arguments

21:47 Chouser: #"(?i)foobar"

21:47 Raynes: (?i)

21:47 FUCK.

21:47 -_-

21:47 * Raynes slaps Chouser

21:47 * Chouser frowns

21:47 Raynes: :(

21:47 Chouser: sorry, I'll leave you to it. :-)

21:48 Raynes: Chouser: I think you look into the future and find out what questions will be asked and keep the answers in a text file to copy and paste when needed.

21:48 :|

21:50 ,(.replaceAll "(?i)chouserbot" "CHOUSERBOT" "Chouser")

21:50 clojurebot: "(?i)chouserbot"

21:50 Raynes: ,(.replaceAll #"(?i)chouserbot" "CHOUSERBOT" "Chouser")

21:50 clojurebot: java.lang.IllegalArgumentException: No matching method found: replaceAll for class java.util.regex.Pattern

21:51 Raynes: :| It worked on my machine.

21:51 danlarkin: Raynes: please stop with the profanity

21:51 Raynes: Er...

21:52 hiredman: Raynes: you have the arguments in the wrong order

21:52 Raynes: hiredman: I just realized that. :| I've been playing with factor all day.

21:52 It's got me thinking all postfixy.

21:53 ,(.replaceAll "CHOUSERBOT" "(?i)chouserbot" "Hai Chouser :)")

21:53 clojurebot: "Hai Chouser :)"

22:10 Mec: J looks a whole lot like a comic character throwing up

22:36 hiredman: hmmm

22:37 clojurebot: how much do you know?

22:37 clojurebot: I know 5 things

22:37 hiredman: uh

22:37 that is not good

22:39 how the hell

22:40 Mec: clojurebot: what do you know

22:41 hiredman: ~how much do you know?

22:41 clojurebot: I know 203 things

22:41 hiredman: restored from an old backup

22:41 but, uh, scary

22:42 how did that happen

22:42 albino: he's not serializing his knowledge?

22:42 Mec: is clojure.contrib on google code?

22:42 tashafa: should be

22:43 anyone know if there is an emacs irc mode?

22:43 hiredman: albino: he is, but something happened to the file

22:44 this machine had an unscheduled power cycle

22:44 very annoying

22:45 gnuvince_: tashafa: there's erc and rcirc. rcirc is included with Emacs, just to M-x irc

22:45 s/to/do

22:46 hiredman: clojurebot: slurp?

22:46 clojurebot: Titim gan �ir� ort.

22:46 albino: ahh, time for an ups

22:49 hiredman: ~latest

22:49 clojurebot: latest is 1327

22:51 Mec: any simple way to flatten 1 layer of a list?

22:51 Chouserbot: apply concat

22:51 Mec: ah ha, thanks

22:54 i thought count was O(1)

22:55 oh nvm, lazy squence

22:55 Chouserbot: you can find out with 'counted?'

22:56 ,(counted '(1 2 3))

22:56 clojurebot: java.lang.Exception: Unable to resolve symbol: counted in this context

22:56 Raynes: Hey, when we get to rev 1337 let me know, because I'm celebrating.

22:56 Chouserbot: ,(counted? '(1 2 3))

22:56 clojurebot: true

22:56 Mec: hmm i dont have counted?

22:56 Chouserbot: ,(counted? (map identity '(1 2 3)))

22:56 clojurebot: false

22:57 Chouserbot: 'counted?' was introduced in svn rev 1268

22:57 tashafa: thanks gnuvince

22:58 ,(doc counted?)

22:58 clojurebot: "([coll]); Returns true if coll implements count in constant time"

22:59 digash: is there a function somewhere to read-lines from the stream and re-find patterns w/ ability to stop at the first match?

23:03 Mec: if i want to (reduce +) a sequence that is too large for memory, I cant define it can I

23:04 hiredman: filter is lazy

23:04 Mec: nope

23:04 Chouser: digash: (some #(re-find #"^chouser.*" %) (line-seq (BufferedReader. (FileReader. "/etc/passwd"))))

23:04 hiredman: so (comp first filter)

23:05 ~how much do you know?

23:05 clojurebot: I know 225 things

23:06 digash: Chouser: i was looking at clojure.contrib.duck-streams/read-lines but could not see how to close the stream if match is found.

23:06 Chouser: thank you, i will use line-seq.

23:07 Chouser: good point, I always forget that.

23:07 Mec: hmm i thought numbers were automatically promoted to bignum, but I just got a wraparound from a large addition

23:08 dreish: Sounds like a bug.

23:10 Chouser: Mec: what opeartion? 'inc'?

23:10 Mec: (reduce +)

23:11 dreish: ,(reduce + (range 10000000))

23:11 clojurebot: 49999995000000

23:11 Mec: that was fast

23:12 ,(reduce + (range 48000000))

23:12 clojurebot: Execution Timed Out

23:13 dreish: ,(Thread/sleep 5000)

23:13 clojurebot: nil

23:13 digash: ,(with-open [rdr (java.io.BufferedReader. (java.io.FileReader. "/etc/passwd"))] (some #(re-find #"^chouser.*" %) (line-seq rdr)))

23:13 clojurebot: java.security.AccessControlException: access denied (java.io.FilePermission /etc/passwd read)

23:14 digash: oops, did not mean to raise some security alarms

23:18 dreish: ,(.. Runtime getRuntime availableProcessors)

23:18 clojurebot: 1

23:18 dreish: Wow, where do you get a one-core machine these days?

23:19 Mec: mine is one core :*(

23:20 is it even usefull to have multiple threads on a single core machine, with pipelining and whatnot

23:22 Chouser: Mec: it's useful to have threads blocking on IO instead of having to manage a select loop yourself.

23:23 Mec: true, but just calculation performance wise?

23:24 Chouser: You could profile it, but I'd be a bit surprised if there a noticable improvment.

23:46 hiredman: man

23:46 * hiredman feeds a few thousand lines of logs into clojurebot

Logging service provided by n01se.net