#clojure log - Oct 21 2010

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

0:15 miltondsilva: Hi, some time ago I saw a post with some tips for emacs concerning good pratices for formating lisp code... among them was a one that had something to do with max number of columns, can somebody point me to that article? or provide a similar tip?

0:17 amalloy: miltondsilva: http://mumble.net/~campbell/scheme/style.txt is a reasonable style guide. he's a lot more religious about it than is really necessary, so take it with a grain of salt

0:18 miltondsilva: thanks

0:19 amalloy: tldr: he says 80 cols, preferably 72

0:19 which sounds about right to me

0:19 Once: 72 is what I use as a general max

0:20 amalloy: yeah, i like short lines cause i can't see without a pretty large font

0:20 LauJensen: Morning

0:20 amalloy: hi lau

0:31 hiredman: i started trying to figure out functional.clj. looks neat, though i'm curious what shortcuts you have to type in your shorthand symbols

0:32 the other thing is, i don't understand shuffle. Collections/shuffle is going to take the LinkedList you copy into, and copy it into an ArrayList before sorting

0:39 hiredman: amalloy: Collections/shuffle tries to shuffle the collection inplace, if you pass it an immutable collection, *boom*

0:40 amalloy: hiredman: right. but LinkedLists don't implement RandomAccess, so it will copy that into an ArrayList

0:40 if you send it an arraylist in the first place there's only one copy

0:47 i often find myself wanting (take-while f (iterate g x)) quite often. is there already a function for this?

0:48 tomoj: https://gist.github.com/2f060dde83ac1bfbe551 what do you think

0:52 LauJensen: Interesting idea tomoj

0:54 tomoj: I hate (let [x ... y ...] {:x x :y y})

0:56 and I have some which macros generate code like that, but with no let, and so the evaluation order is undefined

0:57 I wish there were a better way to handle records though

0:58 hmm, of course you need default values

1:03 amalloy: tomoj: i have a macro to generate a make-xxx function along with a macro, that takes keyword arguments

1:03 er, along with a record

1:03 tomoj: you have to supply a dummy instance still?

1:03 amalloy: it defaults to nils atm

1:04 tomoj: how, though?

1:04 amalloy: lemme find the gist

1:04 tomoj: (without reflection..)

1:04 amalloy: no, it's a substitute for the defrecord form

1:04 that expands to a defrecord as well as a make-xxx

1:04 tomoj: ah

1:04 right, that makes sense

1:05 amalloy: http://gist.github.com/608075 if you're interested

1:06 tomoj: thanks

1:07 amalloy: should be easy enough to add default arguments as well, by allowing [name default] as well as name

1:08 PS do not use this if you care about performance at all. it's like fifty times slower than (Record.)

1:08 tomoj: hmm

1:09 since we know the field names at macro time we could expand to a ctor which is just a let and a (Record.), right?

1:09 amalloy: oh sure. since you have default parameters

1:10 but you probably want to remove the & in the constructor function to make it take maps of keywords instead of actual keyword arguments; that's a big part of the slowdown

1:10 tomoj: what &?

1:12 amalloy: oh

1:12 haha i added that later but i guess i didn't put it in the gist

1:14 if you defined the constructor function as (defn whatever [& {:as argmap#}]) it would take arguments like (whatever :a 1 :b 2) instead of (whatever {:a 1 :b 2}) but it would be slower

1:18 tomoj: ah

1:38 bhenry: how dead will room be from people flying to nc later? or did everyone else book on flights with wifi?

1:40 sthuebne_: BTW: what's the hashtag for clojure-conj on twitter?

1:40 amalloy: someone said #clojure-conj

1:40 oh, no dash

1:40 http://twitter.com/clojure_conj

1:41 dnolen: wow, new perf w/o declaring static is pretty cool. can create closures. static code and protocols can intermix

1:41 LauJensen: dnolen: have you done some early benchmarking?

1:41 dnolen: LauJensen: yeah super naive stuff, but it looks stellar.

1:43 notsonerdysunny: is using clj-stacktrace just involve adding it as dev-dependency and saying "(use 'clj-stacktrace.repl)" and using repl as usual .. does it need anything else

1:45 dnolen: LauJensen: static not be able to interop w/ protocols always seemed wacky. Was wise to leave the static stuff out of 1.2.0

1:47 icing on the cake would be the ability to type hint protocol methods...

2:07 replaca: sthuebne_: according to the website it's #clojureconj

2:08 sthuebne_: replaca: cheers! should have had a look there myself… silly me

4:01 mike5160: hi all

4:02 leiningen + ubuntu + penumbra can't get it to work i have tried almost everything there is on googlespace. right now lein native-deps fails.

4:05 any body been around leiningen and penumbra to know why this is so? and github is down so can't access the git repo either to download and build lein again?

4:06 is there an alternative way to build all this in one directory clojure clojure contrib incanter and penumbra

4:09 esj: mike5160: i guess nobody knows. Probably nobody around now uses Penumbra. I'd try again later, once the channel fills up (ie the US wakes up) and you're chances of somebody having used it will go up dramatically.

4:09 s/you're/your/

4:09 sexpbot: <esj> mike5160: i guess nobody knows. Probably nobody around now uses Penumbra. I'd try again later, once the channel fills up (ie the US wakes up) and your chances of somebody having used it will go up dramatically.

4:10 mike5160: k will try again.

4:10 good to know that at least github is running now

4:10 esj: ohoh.... who long until sexpbot goes Clippy ?

4:10 mike5160: esj: thanks for your help

4:10 esj: np

4:16 raek: hrm...

4:18 mike5160: you have native-deps in dev-dependencies? (Swede here.... good morning)

4:19 mike5160: raek: hi sorry i did not update here. what happened is that github was offline. however when github came back on i could go to github penumbra's hub and look in issues and it was resolved. i was using native-deps 1.0.0 and was supposed to use 1.04

4:20 raek: 1.0.4 and finally got it to work. now i m actually trying to see if the example works? do you know any other example that uses penumbra?

4:22 raek: yeah, I found this while trying to set up a project

4:22 http://github.com/ztellman/penumbra/wiki/getting-started

4:23 hrm that [leiningen/lein-swank "1.1.0"] should be updated to [swank-clojure "1.2.1"]...

4:24 mike5160: raek: let me check. it works with lein-swank so far. i haven

4:24 raek: i haven't tried running lein swank or repl yet? lemme check.

4:24 raek: that version is old, but I think it should work

4:25 mike5160: raek: need your help on this one : http://messynotebook.com/?p=1496 i have downloaded tetris clojure source and i have ran lein deps lein compile now i m trying to see if this works. how do i launch it?

4:28 raek: mike5160: put all the contents of that zip file in the corresponding folders in your project

4:28 i.e., everyting from <zipfile>/src/ to <project>/src/, etc

4:29 mike5160: yep did that part. after unzip file i ran lein deps and lein compile ...

4:29 raek: mike5160: then I think a (require 'clojureTetris.main) should start it

4:29 you don't need to compile it

4:30 remember to clear the classes/ dir if you make modifications

4:30 mike5160: raek: compiled it cause i'm still in the c/c++ ;configure, make, make install mindset

4:31 raek: heh, understandable

4:31 its pretty neat to be able to update the display function while the program is still running

4:31 or looking at variable contents

4:32 if you are a an Emacs user, I really recommend checking out slime

4:32 mike5160: raek: thanks i do appreciate your help. I 'm not an emacs user but i m learning slowly. if only slime leiningen and clojure versions would play nice with each other inside my .emacs.d then i would proceed quickly.

4:33 raek: I installed slime, slime-repl and clojure-mode from ELPA

4:33 mike5160: raek: i tried setting up emacs 2 times with clojure slime etc. once with technomancy's quick starter kit and what not. but i just could not get the results portrayed on even the simplest of tutorials.

4:34 raek: it is simpler today

4:34 but there are still some old out of date tutorials out there

4:34 in the project, run lein swank

4:34 mike5160: raek: i will keep trying though. looking at the video above made me more interested in emacs. i may venture out of my vimdom just to get the emacsfu like the video and be able to code/repl/view my results instantly.

4:35 raek: in emacs, install ELPA, add packages slime, slime-repl and clojure-mode

4:35 M-x slime-connect

4:35 and then you should be done (in theory)

4:35 mike5160: raek: i get to the lein swank part in setting everything up but on ubuntu i cannot get clojure-mode installed with ELPA kept on giving me some error or the other.

4:35 raek: i will try again.

4:36 raek: in the above example of tetris i m getting org.lwjgl.opengl.GL11 (core.clj:9) not found error.

4:36 raek: did you run lein native-deps?

4:37 also, which version of clojure is the tetris written for?

4:37 mike5160: raek: cl 1.1.0 and cl-ctrb 1.1.0

4:38 raek: what project.clj file do you use? the one from the zip file?

4:38 mike5160: yes

4:39 raek: the only thing i changed after the error was native-deps from 1.0.0. to 1.0.4

4:39 raek: not to mention the error still persists

4:40 raek: mike5160: I don't think you should change that

4:40 mike5160: raek: ok back to 1.0.0

4:41 raek: make sure everything is set for the clojure 1.1 way according to http://github.com/ztellman/penumbra/wiki/getting-started

4:41 if the tetris is made for an earlier version of penumbra than 0.5.0, maybe those instructions don't apply

4:42 mike5160: raek: btw, the .m2 dir have a lwjgl dir by itself and is not under org where clojure and cl-contrib exists

4:42 raek: mike5160: I just found out that a tetris example is shipped with latest penumbra

4:43 mike5160: raek: yes the instructions are same, but they use ant launcher etc.

4:43 raek: sorry, but I have to go now

4:43 mike5160: raek: thanks a lot. i do appreciate it.

4:44 raek: my recommendation is to try everything with the latest versions

4:44 mike5160: raek: k i will do that

4:44 raek: also, they have a mail list

4:44 http://groups.google.com/group/penumbra-lib

4:44 good luck!

4:44 mike5160: raek: thanks u have a good day.

4:45 fliebel: Can someone explain me re-groups? I need to get the groups from a regex, but I can't get it to work.

4:45 ,(re-groups (re-matcher #"[0-9a-z]" "0a"))

4:45 clojurebot: java.lang.IllegalStateException: No match found

4:47 fliebel: The actual regex is more complicated, and does contain groups ;)

4:48 Uh? Oh, shit… re-find actually returns those? Then what is the use of re-groups?

4:49 TobiasRaeder: morning everybody :)

4:49 fliebel: morning

4:56 esj: Howdy all

4:56 TobiasRaeder: hey esj

4:57 AWizzArd: moin moin

4:57 TobiasRaeder: moin

4:57 LauJensen: Yo yo everybody

4:57 TobiasRaeder: morning lau

5:01 esj: hey Lau

6:44 jszakmeister: Hi folks! I'm looking to add a comment to a ticket in Assembla... how do I get permissions to do that?

6:48 bartj: jszakmeister, not too sure, try registering first on Assembla

6:49 jszakmeister: bartj: I did that... it still won't let me comment though. :-(

6:50 bartj: URL please?

6:50 hsarvell: I'm using leiningen 1.3.1 and when doing lein jar and the compile gets aborted because of some error I notice that the lib folder and all its jars are gone, how can I prevent this behavior?

6:51 jszakmeister: bartj: https://www.assembla.com/spaces/clojure/tickets/103-gc-issue-99--incorrect-error-with-if-let

7:18 jjido: ,(:id 0)

7:18 clojurebot: nil

7:34 Lajla: ,(nil nil)

7:34 clojurebot: Lajla: Huh?

7:34 Lajla: ->(nil nil)

7:34 sexpbot: java.lang.IllegalArgumentException: Can't call nil

7:52 bartj: ,(nil? nil)

7:52 clojurebot: true

7:53 bartj: Lajla, did you mean to test for nil. then you would be better off using "nil?" like the example above

7:55 hircus: ,(empty? nil)

7:55 clojurebot: true

7:56 hircus: ,(nil? '())

7:56 clojurebot: false

7:56 hircus: ,(nil? (rest (cons 'a '())))

7:56 clojurebot: false

8:00 LauJensen: ,(nil? (next (cons 'a '())))

8:00 clojurebot: true

9:44 perfect: someone knows how to make a perfect square in clojure?

9:45 joly: something other than (* side side)?

9:46 perfect: ^^^

9:46 perfect: not...just the formula

9:46 joly: hmm, (defn square [x] (* x x)) then?

9:46 perfect: i can not do

9:48 need a code that I enter a number and make sure it is a perfect square

9:48 jjido: ,(rand 20)

9:48 clojurebot: 19.501843150268495

9:48 jjido: ,(int (rand 20))

9:48 clojurebot: 19

9:48 jjido: ,(int (rand 20))

9:48 clojurebot: 0

9:48 jjido: ,(int (rand 20))

9:48 clojurebot: 2

9:48 jjido: thanks bot.

9:49 perfect: why in Clojure?

9:49 Chousuke: ,(rand-int 5)

9:49 clojurebot: 4

9:49 Uppercut: joly: i guess he wans to test if a number is or not a perfect square

9:49 perfect: yes

9:49 joly: you might need Math/sqrt then, and compare if it's equal to the rounded version

9:50 jjido: Chousuke: nice

9:50 ,(rand-int)

9:50 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$rand-int

9:50 perfect: got it

9:50 Uppercut: can you use Math.sqrt or do you want to sum only odd number?

9:50 joly: ,(= 3.5 (int 3.5))

9:50 clojurebot: false

9:54 perfect: you guys know how to do with recursion?

9:56 TobiasRaeder: @perfect what do you exactly want to do recursivly?

9:57 perfect: joly, you know to do with recursion?

9:57 joly: perfect: yes

9:58 perfect: TobiasRaeder, a perfect square

9:58 joly, can you do?

10:00 joly: perfect: I'm not sure how one would use recursion to see if something is a perfect square, unless you are using numeric methods instead of Math/sqrt

10:05 esj: well, sqrt is probably based on a newton method, which can be done recursively... but that's academic really

10:06 Uppercut: , (defn x[y] ( if (= (rem Math/­sqrt y) 0 ) true ))

10:06 clojurebot: DENIED

10:09 joly: I suppose you could start at n=0, compare (square n) to your given number, and return true if =, false if the square is bigger, or recur (n=1,2,3...) if the square is smaller

10:10 not fast, but if you're stuck using recursion for this...

10:13 perfect: joly: thanks

10:16 jjido: that was a homework question?

10:20 joly: Sounded like it, given the need to use recursion. Maybe I should have gone into a little less detail...

10:21 Uppercut: perfect: are you doing your homework here?

11:09 dpritchett: morning

11:09 bforester: g'morning

11:09 joly: morning

11:10 tonyl: hello everyone

11:11 dpritchett: i'm trying to figure out how to bind alt-up to slime-repl-backward-input in emacs... but only when i'm in a slime repl. gotta keep reading. using viper mode isn't simplifying things either :)

11:17 rlb: dpritchett: M-x local-setkey?

11:17 s/setkey/set-key/

11:17 sexpbot: <rlb> dpritchett: M-x local-set-key?

11:18 dpritchett: rlb: just found that a second ago... now i need to figure out how to make it persistent between sessions

11:18 rlb: dpritchett: if there's a mode hook, use add-hook with a suitable lambda

11:18 (would probably work)

11:18 I'd just glance in the source for the mode...

11:19 something like (add-hook slime-mode-hook (lambda () (local-set-key ...)))

11:19 dpritchett: neat thanks

11:19 rlb: Actually that's probably 'slime-mode-hook

11:20 And I forget if you need to quote the lambda too -- you could also just (defun my-slime-hook ...) and then (add-hoook 'slime-mode-hook 'my-slime-mode-hook)

11:27 dpritchett: turns out slime-repl-backward-input isnt doing what i wanted it to anyway

11:43 Uppercut: I have this code and it returns a List: --> (defn quadrado? [num] (== (mod num 2) 1)) (println (filter quadrado? (range 16))) ..... How can I change println to something like ".contains" to check if a number X is on List?

11:46 AWizzArd: Uppercut: (filter #(.contains container %) objects)

11:47 ,(filter #(.contains (java.util.ArrayList. [10 20 30]) %) (range 15))

11:47 clojurebot: (10)

11:47 hoeck: Uppercut: first

11:49 ,(first (filter odd? (range 0 2))

11:49 clojurebot: EOF while reading

11:49 hoeck: ,(first (filter odd? (range 0 2)))

11:49 clojurebot: 1

11:50 Uppercut: ,(first (filter odd? (range 0 20)))

11:50 clojurebot: 1

11:50 Uppercut: odd between 0 20

11:52 , (filter odd? (range 0 20))

11:52 clojurebot: (1 3 5 7 9 11 13 15 17 19)

11:53 Uppercut: , (filter even? (range 0 20))

11:53 clojurebot: (0 2 4 6 8 10 12 14 16 18)

11:53 Uppercut: magic

11:53 , ( + (filter even? (range 0 20)))

11:53 clojurebot: java.lang.ClassCastException

11:54 Uppercut: how to sum all elements

11:54 hoeck: ,(reduce + (range 4))

11:54 clojurebot: 6

11:54 Uppercut: ,(reduce + (filter even? (range 0 20)))

11:54 clojurebot: 90

11:55 Uppercut: ,(= (reduce + (filter even? (range 0 7)) 25)

11:55 clojurebot: EOF while reading

11:55 Uppercut: ,(== (reduce + (filter odd? (range 0 10))) 25)

11:55 clojurebot: true

11:56 Tordmor: ,(range 3 4)

11:56 clojurebot: (3)

11:56 Tordmor: ,(range 4 3)

11:56 clojurebot: ()

11:57 AWizzArd: ,(range 4 3 -1)

11:57 clojurebot: (4)

12:06 Uppercut: , (dotimes [n (+ n 1)] n)

12:06 clojurebot: java.lang.Exception: Unable to resolve symbol: n in this context

12:07 Uppercut: , (dotimes [n (+ n 1)] true)

12:07 clojurebot: java.lang.Exception: Unable to resolve symbol: n in this context

12:08 amalloy: ,(let [n 3] (dotimes [n (+ 1 n)] (print n)))

12:08 clojurebot: 0123

12:15 dpritchett: i downloaded a clojure syntax highlighter the other day that had golden parens and some other entertaining stuff including detecting my functions and coloring them green. i wish I could find it again

12:18 notsonerdysunny: ,(doc ref-history-count)

12:18 clojurebot: "([ref]); Returns the history count of a ref"

12:18 notsonerdysunny: ,(doc ref-min-history)

12:18 clojurebot: "([ref] [ref n]); Gets the min-history of a ref, or sets it and returns the ref"

12:18 notsonerdysunny: ,(doc ref-max-history)

12:18 clojurebot: "([ref] [ref n]); Gets the max-history of a ref, or sets it and returns the ref"

12:19 notsonerdysunny: ,(doc ref)

12:19 clojurebot: "([x] [x & options]); Creates and returns a Ref with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn :min-history (default 0) :max-history (default 10) If metadata-map is supplied, it will be come the metadata on the ref. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state

12:39 Uppercut: ,(let [n 5] (dotimes [n (+ 1 n)] (print n)))

12:39 clojurebot: 012345

12:42 Uppercut: ,(defn test [num] (let [n num] (dotimes [n (+ 1 n)] (print n))) (if (== (reduce + (filter odd? (range 0 n))) num)) ) ) ) (test(5))

12:42 clojurebot: DENIED

12:43 Uppercut: , (defn test [num] (let [n num] (dotimes [n (+ 1 n)] (if (== (reduce + (filter odd? (range 0 n))) num)) ))) ) ) (test 5)

12:43 clojurebot: DENIED

12:43 raek: Uppercut: use letfn

12:43 clojurebot doesn't allow defs

12:45 Uppercut: , (letfn [n num] (dotimes [n (+ 1 n)] (if (== (reduce + (filter odd? (range 0 n))) num)) ))) )

12:45 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

12:45 raek: ,(letfn [(foo [x] (inc x))] (foo 1))

12:45 clojurebot: 2

12:45 Uppercut: right

12:45 raek: also, = is used for equality

12:46 == is only used in special circumstances

12:49 Uppercut: , (if (== (reduce + (filter odd? (range 0 9))) 25))

12:49 clojurebot: java.lang.Exception: Too few arguments to if

12:49 LauJensen: Uppercut: s/if/when

12:49 Uppercut: (if (== (reduce + (filter odd? (range 0 n))) num) num)

12:50 (if (== (reduce + (filter odd? (range 0 9))) 25) 25)

12:50 ,(if (= (reduce + (filter odd? (range 0 9))) 25) 25)

12:50 clojurebot: nil

12:51 Uppercut: ahh, range 0 9 don´t include 9

12:52 , (if (= (reduce + (filter odd? (range 0 10))) 25) "i found")

12:52 clojurebot: "i found"

12:52 raek: ,(if false :foo)

12:52 clojurebot: nil

12:53 raek: that's why you got nil before

12:53 ,(range 5)

12:53 clojurebot: (0 1 2 3 4)

12:53 tonyl: ,(if nil :foo)

12:53 clojurebot: nil

12:53 raek: yes, it's exclusive

13:04 Uppercut: ,(letfn [(foo [x] (inc x))] (foo 4))

13:04 clojurebot: 5

13:05 amalloy: ,(let [f (fn [x] (inc x))] (f 4))

13:05 clojurebot: 5

13:05 amalloy: if you don't want to remember letfn's syntax

13:06 LauJensen: amalloy: letfn is fun in that it adds little or no clarity to what you just wrote

13:10 amalloy: LauJensen: yeah, i only use letfn for mutually recursive functions (ie, so far never)

13:11 LauJensen: hehe

13:21 Uppercut: , (14 " as string")

13:21 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

13:21 Uppercut: , (str (14 " as string"))

13:21 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

13:21 Uppercut: help

13:22 amalloy: ,(str 14 " as string")

13:22 clojurebot: "14 as string"

13:24 Uppercut: ,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")), :else("nao eh") )] (testar 11 25))

13:24 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:25 Uppercut: the bot is telling strange words in my pvt

13:26 'Sea, mhuise. .. Ik begrijp

13:26 raek: that is "I don't understand" in gaelic and dutch...

13:26 clojurebot: asdf

13:27 Uppercut: lol

13:27 edbond: is it possible to reset deftest?

13:27 fhd: Hi. Are the sessions at clojureconj recorded?

13:27 raek: reset, in what sense?

13:27 remove an old test?

13:27 amalloy: fhd: yes, i'm told that's so

13:27 Uppercut: ,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) )] (testar 10 25))

13:27 clojurebot: "25 is a"

13:27 raek: ooh

13:28 fhd: amalloy: Ah, thank goodness.

13:28 All interesting conferences are overseas it seems ;(

13:28 raek: Uppercut: swede? :)

13:28 edbond: raek: yes, I need to remove old tests

13:29 raek: you can use (ns-unmap 'the.ns 'the-var)

13:29 there might be a simpler way to do it

13:29 maybe remove-ns (go to anothe namespace before doing that...)

13:30 Uppercut: yeah, probably we can do it less complex

13:31 ,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) , :else("not is :(") )] (testar 10 25))

13:31 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:32 Uppercut: what the problem with ,:else ?

13:32 raek: Uppercut: what are you coding on?

13:32 amalloy: ,("not is:(")

13:32 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:32 amalloy: Uppercut: ^^

13:32 raek: ,"not is:(" ; this is probably what you want

13:32 clojurebot: "not is:("

13:33 raek: ,("trying to use a string as a function" 1 2 3)

13:33 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn

13:34 Uppercut: I would like to test if a number if perfect square. 25 is the sum of (+ 1 3 5 7 9) .. (testar 10 25) ... i count (1 10) and 25 to use to compare the final result

13:37 raek: ,((fn [max n] (= n (reduce + (filter odd? (range (inc max)))))) 10 25) ; like this?

13:37 clojurebot: true

13:38 raek: ,((fn [max n] (= n (reduce + (filter odd? (range (inc max)))))) 10 24) ; like this?

13:38 clojurebot: false

13:38 raek: pretty much what you wrote

13:38 dnolen: amalloy: letfn is also a fun way to attach the constructor fn to the constructed map.

13:39 raek: there is also this way (fn fact [n] (if (zero? n) 1 (* n (fact (dec n)))))....

13:39 I have never used that though

13:40 ,(fn f [] f)

13:40 clojurebot: #<sandbox$eval4902$f__4903 sandbox$eval4902$f__4903@e746d4>

13:42 amalloy: dnolen: how do you mean?

13:42 sproust: What is the best way to fetch a local copy of the Clojure website documentation?

13:43 ohpauleez: sproust: (doc whatever)

13:43 or you want to browse, search, etc?

13:44 sproust: ohpauleez: yes, I know how to access the source code, but what about the website?

13:45 amalloy: sproust: wget?

13:45 LauJensen: Does anybody have some more news on this latest intel from Apple, that they're deprecating Java for OSX ?

13:45 sproust: Yeah, I did that. Allright, never mind then. I was just wondering if there was a package for local copies.

13:45 ohpauleez: sproust: I guess I'm unsure why you want a hard copy of the HMTLized docs. You have the docs built into the language

13:45 amalloy: LauJensen: no, but if you find out please let me know. a friend of mine on apple is just starting with clojure

13:46 ohpauleez: LauJensen amalloy: I wouldn't worry too much

13:46 dnolen: amalloy: (letfn [(ctor [& rest] (-> (into {} (partition 2 rest)) (meta {:ctor ctor :some-closed-over-local foo})))] ctor)

13:47 ohpauleez: I run OpenJDK7 on my mac, based on the FreeBSD distro

13:47 the only difference is swing uses X, not Aqua

13:47 that was really the only difference in Apple JDK anyway

13:48 sproust: ohpauleez: I use a combo of both to find what I need when I need it.

13:48 ohpauleez: ahhh cool. Well ClojureDocs has an API now

13:48 sproust: Python provides a download of their exact website: http://docs.python.org/

13:48 raek: sproust: it should be possible to use autodoc to generate html docs for whichever namespace you want

13:48 amalloy: dnolen: (let [ctor (fn [& rest]...)])? letfn is no better for this purpose than for any other

13:48 Uppercut: raek: yes, very good tk

13:49 raek: but that might not be very convenient to do for all the namespaces

13:49 but in principle, that should work

13:49 sproust: raek: Thanks, didn't know about it. I guess it's the same tool that generates the website, very cool.

13:50 raek: going to CC?

13:50 LauJensen: amalloy: http://developer.apple.com/library/mac/#releasenotes/Java/JavaSnowLeopardUpdate3LeopardUpdate8RN/NewandNoteworthy/NewandNoteworthy.html#//apple_ref/doc/uid/TP40010380-CH4-SW1

13:51 raek: sproust: unfortunately not...

13:51 dnolen: amalloy: you cannot refer to ctor w/ the anon fn

13:51 s/w/within

13:52 LauJensen: dnolen: Would you mind gisting your benchmarks re static/dynamic ?

13:52 dnolen: amalloy: w/ letfn you can

13:52 LauJensen: dnolen: amalloy only uses letfn for trampolines

13:53 amalloy: ,(let [f (fn f [x] f)] (f 10))

13:53 clojurebot: #<sandbox$eval4906$f__4907 sandbox$eval4906$f__4907@18b8315>

13:53 amalloy: dnolen: ^^

13:53 dnolen: LauJensen: I don't but they were all simple, fib, arithmetic operators and the like.

13:53 LauJensen: great

13:53 dnolen: amalloy: yes sorry, a named anon fn and letfn accomplish the same thing.

13:54 amalloy: I didn't know you could name fns that way.

13:54 amalloy: or even without the let:

13:54 ((fn ctor [] {:ctor ctor :data 10}))

13:54 ,((fn ctor [] {:ctor ctor :data 10}))

13:54 clojurebot: {:ctor #<sandbox$eval4910$ctor__4911 sandbox$eval4910$ctor__4911@2128d0>, :data 10}

13:54 amalloy: heh, named anonymous functions. i like it

13:55 LauJensen: amalloy: even better than signed unsigned ints

13:55 dnolen: amalloy: named unbound fn?

13:55 amalloy: dnolen: iunno. i like named anon

14:02 ,(let [x (fn f [] f)] (identical? (x) (x)))

14:02 clojurebot: true

14:02 amalloy: neat

14:13 LauJensen: dnolen: just paste the gist when you're good and ready :)

14:14 amalloy: ,(let [x (fn f [] f)] [(x) f])

14:14 clojurebot: java.lang.Exception: Unable to resolve symbol: f in this context

14:15 amalloy: i think it really is fair to call it a named anonymous function

14:15 raek: heh

14:15 how strange that it actually makes sense to call it both named anonymous...

14:16 joly: the name is only bound internally to the function?

14:16 raek: yes

14:16 a name the function can use to refer to itself (in order to call or return itself)

14:17 joly: ,(= #(1) #(1))

14:17 clojurebot: false

14:19 joly: ,(#(% %) #(% %))

14:19 clojurebot: java.lang.StackOverflowError

14:20 raek: ,((fn f [] (f)))

14:20 clojurebot: java.lang.StackOverflowError

14:21 amalloy: ,(trampoline (fn f [] f))

14:21 clojurebot: Execution Timed Out

14:21 joly: ,((fn [] (recur)))

14:21 clojurebot: Execution Timed Out

14:21 * raek HEAD ASPLODE

14:21 amalloy: joly: (#(recur))

14:21 joly: ah, even better

14:27 sproust: What is the proper idiom for replacing the value of a map by something else which uses that value?

14:28 e.g. in Python: m[foo].append(2), re, clojure's:

14:28 amalloy: ,(update-in {:t 4} [:t] inc)

14:28 clojurebot: {:t 5}

14:28 sproust: ,(let [m {:foo [1]}] (assoc m :foo (conj (get m :foo) 2)))

14:28 clojurebot: {:foo [1 2]}

14:28 sproust: Ha! Nice. Thanks amalloy.

14:28 It's like you guys thought of everything.

14:29 amalloy: ,(update-in {:t {:a 4}} [:t :a] inc)

14:29 clojurebot: {:t {:a 5}}

14:29 sproust: Wow. Two-levels. Insane. That's actually just what I need right now!

14:30 amalloy: sproust: see also assoc-in

14:30 jarpiain: ,(update-in {:t {:a [4]}} [:t :a] conj 5)

14:30 clojurebot: {:t {:a [4 5]}}

14:31 sproust: amalloy: It looks like (assoc-in) could be a drop-in replacement for (assoc).

14:31 amalloy: ,(assoc {} 1 2, 3 4}

14:31 clojurebot: Unmatched delimiter: }

14:31 amalloy: ,(assoc {} 1 2, 3 4})

14:31 clojurebot: Unmatched delimiter: }

14:31 amalloy: ,(assoc {} 1 2, 3 4)

14:31 clojurebot: {3 4, 1 2}

14:31 amalloy: can't do that with assoc-in

14:40 sproust: Q: Is there a way to avoid the fully-qualifying nature of Clojure's syntax-quote?

14:40 amalloy: `(~'x)

14:40 ,`(~'x)

14:40 clojurebot: (x)

14:40 sproust: Haaa. Thx,

14:40 amalloy: sproust: think carefully before doing that though

14:40 ohpauleez: Does Bradford Cross hang out in here?

14:41 sproust: Works! Lovely.

14:41 amalloy: I know I should be using keywords instead.

14:41 amalloy: Is that what you mean?

14:41 amalloy: well, i suppose it depends on your application. but in general if you use an unqualified symbol in your macro, you might have leakage if the caller is also using that symbol

14:43 it doesn't happen as much with immutable data, but in CL it's often a problem and in clojure it can still sneak up on your

14:43 s/r$//

14:43 sexpbot: <amalloy> it doesn't happen as much with immutable data, but in CL it's often a problem and in clojure it can still sneak up on you

14:43 raek: sproust: the qualifying thingy is to make macros safe. if you use syntax-quote outside macros, then go for it

14:47 amalloy: ,(let [mymac (fn [arg] `(let [~'x 4] (* ~arg ~'x))), x 10] (mymac x))

14:47 clojurebot: (clojure.core/let [x 4] (clojure.core/* 10 x))

14:47 amalloy: would be a problem if mymac were a real macro

14:49 ie, it would multiply anything by four, unless the argument is named x in which case it returns 16

14:50 sproust: ^^

15:02 sproust: amalloy: yes, I understand.

15:03 Allrighty, leaving for the conf now, see some of you there tomorrow! cheers,

15:04 _rata_: hi

15:09 KirinDave: Ugh, that's a nasty bug in ring

15:09 If it gets a HEAD request and that request has a body in the response structure, it just hangs.

15:16 zaphar_ps: KirinDave: I was just hearing about a similiar bug in python project :-) I have a feeling a number of people are a little sloppy with HEAD requests

15:17 KirinDave: And OPTIONS.

15:17 And GET

15:17 ;0

15:17 ANd PUT

15:17 raek: how does Ring (or the servlet container?) handle HEAD anyway?

15:17 zaphar_ps: yeah but I wouldn't be surprised if HEAD and options were top of the heap for sloppiness

15:27 KirinDave: raek: It doesn't.

15:27 I'm confused what is happening.

15:27 Oh, and now I see.

15:27 Ring doesn't do anything, so if you say Content-Length 3 by accident, anything will hang forever awaiting those 3 bytes

15:27 And if you don't have an explicit close, then the socket can stay open for a long time

15:28 raek: so, I'll have to implement all HEAD stuff myself?

15:28 if so, the tutorials should be clear about that...

15:29 or is there some default, like handling HEAD as GET, but ignoring the body?

15:33 dpritchett: is it odd that the same function would take 3 seconds in vimclojure/nailgun and 50ish in swank clojure?

15:34 here's the function fwiw http://github.com/dpritchett/euler-clj/blob/master/src/euler_clj/core.clj#L360

15:35 (time (problem-14)) is off by an order of magnitude in emacs with swank

15:35 i invoked swank via cake swank if it matters

15:35 jjido: I want to use a variable of specific name in current context, can a macro do that?

15:38 raek: jjido: can you show us an example of how that construct would be used?

15:39 jjido: raek: it is a bit complicated. I want to fill in missing arguments of a function I am calling

15:42 raek: you could perhaps make a function that takes a function (with, say, 'n' arguments), some default arguments ('n' number of them), and return a new function taking 0 to 'n' arguments

15:42 dpritchett: nevermind the swank vs nailgun question, turns out i had it cached in one repl and not the other so my memoization kicked in

15:45 jjido: raek: with that variable, which varies according to the invoker context. Like that: http://gist.github.com/639173

15:49 raek: jjido: http://gist.github.com/639185

15:50 dunno if that was exactly what you were looking for

15:50 amalloy: raek, jjido: isn't that what fnil already does?

15:50 raek: it is very similar, at least

15:50 ,(doc fnil)

15:50 clojurebot: "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."

15:51 raek: ...but with arity rather than nil

15:51 arity-patching :)

15:53 jjido: I need to think how I can insert these default args

15:53 raek: ,(let [f (fnil + 1 2)] [(f) (f 0) (f 0 0)])

15:53 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$fnil$fn

15:55 raek: hrm, I smell monads...

15:56 hiredman: anyone at o'hare?

15:56 * dpritchett titters

15:57 ohpauleez: +1 on monads

15:58 anytime I need some for of functional accumulator of sorts, I've been turning to monads

16:00 LauJensen: ohpauleez: example?

16:00 jjido: raek: which monads?

16:01 ohpauleez: LauJensen: fnparse is a good one

16:02 for me personally, I'm using a monad to functional register certain things for net-ns

16:02 (which is more of a sandbox for me to explore this more)

16:03 those two examples aside, I'm pretty new to monads, so I'm sure I'm abusing them in some case

16:06 raek: does CPS have something in common with monads, or is this just a pattern I think I'm seeing?

16:06 hiredman: there is actually a cps monad

16:06 amalloy: raek: i believe CPS is a special case of monads

16:07 hiredman: I don't think so

16:08 edbond: how to cast bytes-array to char-array?

16:08 raek: jjido: well, the (fn [a] (-> (... a ...) ((fn [b] (-> (... b ...) ((fn [c] pattern reminded me of a tutorial explaining monads in clojure

16:08 hiredman: functions that live in a monad return monadic values, cps doesn't return anything

16:09 raek: edbond: you have to decode the bytes into wharacters with some charset

16:09 jjido: raek: I see

16:09 hiredman: the computation just continues

16:09 jjido: hiredman: that is the way I do it

16:09 hiredman: right

16:09 raek: *characters

16:10 hiredman: cps on the jvm is kind of icky

16:10 no tailcalls :(

16:10 ohpauleez: agreed

16:12 raek: edbond: the Java way: (let [bytes (.getBytes "hello" "UTF-8")] (.toString (.decode (java.nio.charset.Charset/forName "UTF-8") (java.nio.ByteBuffer/wrap bytes))))

16:14 if you got the bytes from a stream, it's probably easier to wrap the InputStream in a Reader instead

16:15 jjido: I got it working! Nice nice nice

16:17 kmc: yeah there's a cps monad, which turns direct-style monadic code into cps'd code

16:17 it's named Cont in Haskell

16:17 and it can be used to implement most other monads

16:18 ohpauleez: edbond: You can also use the formats file in aleph

16:18 which has all the format conversion stuff for you

16:20 anonymouse89: I'm looking for a map function that works over several machines. Any suggestions?

16:21 dpritchett: erlang?

16:21 clojurebot: erlang is http://clojure.googlegroups.com/web/erlang.clj

16:21 anonymouse89: dpritchett: as in, use erlang?

16:22 dpritchett: i didn't think distribution beyond a single machine was a focus of clojure's

16:23 hiredman: it's very doable, just nothing in clojure.core for it

16:23 anonymouse89: I don't mean baked-in, just some sort of library.

16:23 ohpauleez: anonymouse89: Take a look at Jobim. You can also use a library called work

16:25 anonymouse89: You can also roll your own

16:25 anonymouse89: ohpauleez: thanks for the suggestion, I've encountered "work" before

16:26 ohpauleez: I've done some parallelism, but more like a pub/sub type pattern where I didn't have to worry about getting results back to the sender

16:26 ohpauleez: anonymouse89: Another route would be using JXTA and pushing onto a P2P distribution. Lastly, there's always Hadoop and map/reduce

16:28 anonymouse89: ohpauleez: I'm actually very interested in playing with hadoop, but it seems that development has stopped since ~february. do you know anything about that?

16:28 I mean on the clojure-hadoop lib

16:28 amalloy: anonymouse89: look into cascalog

16:28 i'm doing hadoop at work, but can't justify switching to clojure. cascalog looks really nice if i could use it

16:28 ohpauleez: once a wrapper has wrapped something, there's nothing left to innovate

16:29 shanmu: hello everyone, its me again... is there any way to get a list of fields in a record (as defined using defrecord)?

16:29 amalloy: shanmu: keys

16:29 probably

16:29 shanmu: amalloy: thanks! as you can imagine I am still chipping away at my mini orm :)

16:30 amalloy: yeah, keys works

16:30 records are just like maps, except in the one or two caseds where they aren't

16:30 shanmu: thanks! will remember that

16:31 this is the beauty of clojure.. most things work as you would intiutively expect them to :)

16:32 amalloy: heh, except nth. i can't seem to remember the order or arguments to nth, no matter how many times i use it

16:33 shanmu: amalloy: no does not seem to work :(

16:33 ,defrecord2 :only (defrecord2 prewalk2 postwalk2 camel-to-dashed)

16:33 clojurebot: java.lang.Exception: Unable to resolve symbol: defrecord2 in this context

16:33 shanmu: sorry wrong paste

16:33 ,(do (defrecord trec [a b c]) (keys trex))

16:33 clojurebot: DENIED

16:33 amalloy: (defrecord X [a])

16:33 (keys (X. 1))

16:33 (:a)

16:34 shanmu: amalloy: oh ok... :)

16:34 ,(do (defrecord trec [a b c]) (let [q (trec. 1 2 3)] (keys q)))

16:34 clojurebot: DENIED

16:35 shanmu: works fine.. thanks!

16:35 amalloy: shanmu: just fyi, you can't (def) anything in clojurebot or sexpbot

16:36 shanmu: oh.. ok :)

16:37 amalloy: keys don't quite cut it for me :( If I have defrecord var, with not all fields bound then the keys gets only the currently assigned fields, is there any way to get all the defined fields/keys

16:38 for instance I have (defrecord X [a b c])

16:38 amalloy: shanmu: how can you create a defrecord var without all fields bound? the constructor requires you pass it everything

16:38 shanmu: oh.. I am sorry.. didnot mention that I am using defrecord2 (http://github.com/david-mcneil/defrecord2)

16:39 defrecord2 supports partial values for creating an instance of a defrecord type

16:39 and a few other goodies

16:42 amalloy: shanmu: i haven't used defrecord2. if it's just a defrecord under the hood, how can you possibly have unbound fields? could you show me a snippet that doesn't work?

16:43 i mean, it looks like (new-foo 10) just calls (Foo. 10 nil nil), and that will still have three keys

16:44 shanmu: amalloy: sorry, it works fine :)

16:44 jjido: What I came up with for missing args does not really work the way I want. The missing args are bound at the site of declaration, not the site of call. Never mind...

16:44 shanmu: amalloy: I had messed up the constructors for defrecord2 and defrecord

16:54 jjido: how do I know that deref will cause a NPE in advance?

16:55 Chousuke: huh? deref shouldn't cause NPEs

16:55 unless what you're derefing is null

16:56 amalloy: jjido: Chousuke is right. (defn will-cause-npe [deref])

16:57 jjido: Chousuke: happens often to me

16:58 ,(deref (:bad {}))

16:58 clojurebot: java.lang.NullPointerException

16:58 amalloy: oh. if you're derefing a non-ref, then yeah?

16:59 ,(instance? IDeref (:bad {}))

16:59 clojurebot: java.lang.Exception: Unable to resolve symbol: IDeref in this context

16:59 jjido: amalloy: programmer error... I would like to catch that

17:00 ok

17:00 amalloy: ,(instance? clojure.lang.IDeref (:bad {}))

17:00 clojurebot: false

17:00 amalloy: ,(instance? clojure.lang.IDeref (atom (:bad {})))

17:00 clojurebot: true

17:00 ohpauleez: jjido: you can also shorthand that to is-deref? (just tuck it in a function)

17:01 amalloy: or even (defn maybe-deref [obj] (if (is-deref? obj) @obj obj))

17:02 Chousuke: eh, that's not even the problem here

17:02 ,(:bad {})

17:02 clojurebot: nil

17:02 Chousuke: you can't do anything with nil without getting an NPE

17:02 well, unless the function guards against it

17:02 like many clojure ones do

17:02 but deref doesn't

17:03 so just check for nil

17:03 jjido: Chousuke: not true, nil is all right but not deref

17:03 ,(deref 4)

17:03 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IDeref

17:03 Chousuke: jjido: I don't understand your problem

17:03 jjido: I will check for IDeref.

17:03 Chousuke: better recovery from my coding mistakes

17:04 Chousuke: hm

17:04 you might be using too many refs if accidentally derefing non-refs is a problem for you :)

17:04 or doing the dereferencing in too many places perhaps

17:05 clizzin: is anyone here familiar with mattrepl's clojure-twitter library?

17:05 Chousuke: ideally, you should make functions so that they don't deref anything

17:05 ohpauleez: (isa? (class init-set) clojure.lang.PersistentHashSet) ?= (instance? clojure.lang.PersistentHashSet init-set)

17:05 Chousuke: and then handle state outside those functions

17:08 ohpauleez: can anyone comment on the above? assume they are equal

17:09 Chousuke: not equal

17:09 well, hm

17:09 amalloy: ohpauleez: i think that's true for the class hierarchy. but isa? is more general

17:09 Chousuke: I guess that specific instance might be

17:09 no pun intended :P

17:09 ohpauleez: haha

17:10 thanks guys

17:10 just trying to clean up some code

17:12 raek: instance? is only for classes; isa? is for any type of hierarchy

17:13 ohpauleez: raek: It also works for interfaces too though

17:13 (instance?)

17:14 raek: yes. more accurately: the java type hierarchy

17:14 ohpauleez: ahh, ok. Gotcha. So in this specific case, I'm ok doing that "refactor"

17:14 thanks guys

17:18 raek: I should use make-hierarchy more...

17:20 * raek looks around in the room for things that looks hierarchical

17:25 amalloy: raek: model the #clojure pecking order. that will surely be a useful, non-controversial topic

17:26 ohpauleez: haha

17:27 at least then we all know who we have to over throw

17:27 * ohpauleez gives chouser the shifty eye

17:27 * amalloy peers craftily upwards at raek

17:28 ohpauleez: this is slowly turning into a game of Diplomacy.

17:44 akhudek: this is probably not the best place to ask, but I'm trying to get swingrepl to support unicode and I'm having difficulty

17:44 ohpauleez: what's tripping you up?

17:45 akhudek: I've modified the source so that PrintStream and InputStreamReader use UTF-8 in Jconsole

17:45 and similar for the OuptutStreamWriter in swingrepl

17:45 but it's still giving garbled output

17:45 and doesn't accept any unicode input

17:46 if I try to give it a \⊕

17:47 the repl returns with java.lang.Exception: Unsupported character: \\u2295

17:47 ohpauleez: it sounds like your output stream is encoding correctly, but not encoding a byte stream. It appears like the input stream isn't getting converted correctly. Typically when I need to do things like this I always go to a byte stream first then re-encode

17:47 but by default, aren't Java strings utf-16?

17:48 raek: java strings are implemented with UTF-16 internally

17:48 ohpauleez: akhudek: these are just guesses

17:49 raek: hrm, can one start a clojure repl an communicate with it with a Reader and a Writer, instead of an InputStream and an OutputStream?

17:49 akhudek: where is the source for swingrepl?

17:50 akhudek: reak, let me push my changes to my fork

17:50 hld on

17:50 raek: if everything is done inside the same process, I think the whole string -> byte -> string conversion should be avoided if possible

17:50 I assume swing gives you strings in some way, rather than byte arrays

17:51 akhudek: http://github.com/akhudek/clj-swingrepl

17:52 tensorpudding: can you get by in clojure without having to know or think about java?

17:53 amalloy: tensorpudding: you can do a lot without java

17:54 raek: well, with clojure.java.* and clojure.string, you rarely need to do java interop for basic stuff

17:54 java interop, as in .method calls

17:56 hrm, JConsole uses byte-oriented streams internally

17:56 ohpauleez: weird then, things should encode fine then?

17:57 raek: would be better if it just had been using characters all the way through

17:57 ohpauleez: ahh

17:58 raek: at least it explicitly uses UTF-8

17:59 no weird "operating system default encoding" issues, hopefully

17:59 akhudek: The original didn't actually.

17:59 I added in all those explicit UTF-8's

17:59 original is here: http://github.com/alandipert/clj-swingrepl

18:00 raek: ah, I started to suspect so...

18:01 akhudek: It seems that even if I do an internal print("⊕"); it doesn't come out correctly

18:01 raek: it should really use a PrintWriter

18:01 akhudek: ‚äïClojure 1.2.0

18:01 user=>

18:01 the ai should have been an xor symbol

18:02 raek: the input is a Reader but the output is a OutputStream (more specifically PrintStream)

18:04 I think JConsole should be rewritten to only use Readers and (Print)Writers

18:05 akhudek: What's the difference between them? My Java isn't particularly strong.

18:05 raek: ok, strings are sequences of characters

18:05 and not bytes

18:06 that one needs to be aware of

18:06 InputStream and OutputStream represents streams of bytes (like files and sockets)

18:07 Readers and Writers, very similarily, represent streams of characters

18:07 akhudek: ah, I see

18:07 so the readers and writers should automatically handle whatever encoding the characters use

18:07 where as the streams need to be explicitly aware

18:08 raek: character (and strings) are independent of encoding

18:08 for example, the string "åäö" consists of three characters

18:08 akhudek: so then the only difference is that characters are multi-byte?

18:09 raek: that string can be *encoded* to a sequence of 3 bytes with the Latin-1 encoding

18:09 AWizzArd: ,(map #(vec (.getBytes ^String %)) ["hallo" "äöüß"])

18:09 clojurebot: ([104 97 108 108 111] [-61 -92 -61 -74 -61 -68 -61 -97])

18:09 raek: or to another sequence of 6 bytes with the UTF-8 encoding

18:09 there is no inherit mapping between bytes and characters

18:10 AWizzArd: ,(map #(vec (.getBytes "ä" ^String %)) ["LATIN1" "UTF-8"])

18:10 clojurebot: ([-28] [-61 -92])

18:10 raek: the getBytes method's encoding parameter defaults to the "operating system default encoding"

18:10 so, when having a byte sequence, you have to remember which charset it is encoded in

18:10 AWizzArd: It is interesting to note though that Java strings are broken. In a way.

18:11 raek: broken? how?

18:11 strings abstracts away byte representation

18:11 AWizzArd: For example, you should not expect (count "your string") to tell you how many visible characters are in the string.

18:11 Instead it will tell you how big its char[] array is.

18:11 raek: for characters in the basic multilingual plane, it does

18:11 no

18:11 akhudek: ah, ok, I get it

18:11 raek: (seq "åäö")

18:11 ,(seq "åäö")

18:11 clojurebot: (\å \ä \ö)

18:11 AWizzArd: The string "\ud80e\udc80" is exactly one char

18:11 but: (count "\ud80e\udc80") ==> 2

18:12 raek: but that is outside the basic multilingual plane

18:12 AWizzArd: It still is a string.

18:12 Chousuke: Most software dealing with strings is broken

18:12 AWizzArd: yes!

18:12 Chousuke: Java is no exception ;P

18:12 raek: so yes, strings are broken, if they include characters in the astral planes

18:12 AWizzArd: They can even be *really* broken.

18:12 If you mess the order of high and low surrogates

18:13 Chousuke: like ruby 1.8 strings :P

18:13 AWizzArd: ,(vec (.getBytes "\ud80e\udc80" "UTF-8")) ; this works fine

18:13 Chousuke: where indexing a string gives you an integer

18:13 clojurebot: [-16 -109 -94 -128]

18:13 raek: has ruby realized yet that bytes and characters aint the same thing?

18:13 AWizzArd: ,(vec (.getBytes "\udc80\ud80e" "UTF-8")) ; Argh!! Thanks Sun.

18:13 clojurebot: [63 63]

18:13 Chousuke: 1.9 has fixed that I think

18:14 AWizzArd: ,(= (String. (.getBytes "\ud80e\udc80" "UTF-8") "UTF-8") "\ud80e\udc80")

18:14 clojurebot: true

18:14 Chousuke: what character is that by the way?

18:14 AWizzArd: ,(= (String. (.getBytes "\udc80\ud80e" "UTF-8") "UTF-8") "\udc80\ud80e")

18:14 clojurebot: false

18:15 AWizzArd: I forgot

18:15 ,[0xdc80 0xd80e]

18:15 clojurebot: [56448 55310]

18:15 Chousuke: ,(print "\udc80\ud80e")

18:15 clojurebot: ??

18:15 Chousuke: hah

18:15 raek: ,"𐌰𐌱𐌲𐌳"

18:15 clojurebot: "𐌰𐌱𐌲𐌳"

18:15 akhudek: hmm, so probably the problem is when Jconsole does outPipe.write( line.getBytes() ); ?

18:16 raek: nooo.... no gothic support in the Inconsolata font

18:16 Chousuke: I get just unicode wtf marks

18:16 raek: if outpipe is a writer instead, you could drop the getBytes step

18:16 shanmu: is there a xml/node to help extract nodes from a zipped, parsed xml?

18:16 amalloy: raek's thing looks fine to me

18:17 Chousuke: my terminal's unicode support is probably lacking

18:17 raek: Ahsa Bairkan Giba Dags were the letters

18:18 akhudek: ew, there is some strange looking unicode patch in the acceptLine function

18:18 guess I'll need to work on this a bit more

18:18 Chousuke: I wonder how to find out if a character is in the BMP

18:20 ah, right.

18:20 raek: Chousuke: if its codepoint is in the interval U+0000 - U+D7FF, U+E000 - U+FFFF I think

18:20 Chousuke: Just checked if I ever have had need for characters outside the BMP

18:20 and it turns out the answer is yes, once :P

18:20 shanmu: I saw an example using 'xml/node' in xml->, but its not there in the lastest version of xml/node

18:20 raek: Chousuke: you probably don't, unless you pick upp some lessons on Gothic or other ancient languages

18:20 shanmu: http://gist.github.com/199309

18:21 raek: Chousuke: ooh, which one? :)

18:21 Chousuke: raek: the character 𠀋

18:21 which I can't see right now. :D

18:22 so I hope I got it right.

18:22 but it was used in a name

18:22 raek: all I got was U+FFFD REPLACEMENT CHARACTER

18:23 Chousuke: hm :/

18:23 2000B anyway

18:25 rlb: I assume I'm just missing something, but why doesn't this work?

18:26 (with-in-reader (reader "foo") (repeatedly #(prn (read))))

18:26 Chousuke: repeatedly returns a lazy seq

18:26 rlb: Oh, right -- I was thinking it was just for side-effects.

18:26 raek: which gets realized outside the with-in-reader form

18:27 rlb: So the port's gone?

18:27 Chousuke: Or: It exits the scope of the bindings that the with-in-reader macro establishes

18:27 rlb: s/?/./

18:27 Thanks -- I'd wondered if that might be it.

18:28 Chousuke: you can force it by using doall to realise the entire sequence while it's still within the scope of the binding

18:28 raek: (with-in-reader (reader "foo") (doseq [x (repeatedly #(read))] (prn x)))

18:29 rlb: raek: right.

18:30 raek: just may daily lobbying for 'for' and 'doseq'...

18:32 Chousuke: btw, (repeatedly #(read)) = (repeatedly read) :P

18:33 raek: yeah... I guess my brain was in refactor-blindly-mode...

18:34 or at least I could claim that

18:37 gah! non-ascii byte != unicode character

18:42 akhudek: I begun a quick sweep throught the unmodified JConsole trying to replace all byte streams with character streams. I will see how much of it that compiles. I won't have much time to look at this, but it is in my interest that things like this gets attention.

18:44 akhudek: raek: I was just in the process of starting that myself, but if you're in the middle I'll wait a bit and pick up where you leave off

18:49 amalloy: rlb: want sexpbot to fix your typos for you? he will if you use valid regexes:

18:49 s/\?/./

18:49 sexpbot: <amalloy> rlb: want sexpbot to fix your typos for you. he will if you use valid regexes:

18:53 raek: hrm, BlockingPipedInputStream accesses internals of PipedInputStream (defined by Java)...

18:55 akhudek: this is how far I got http://gist.github.com/639537

18:56 the BlockingPipedReader helper class does not compile since it uses private internals of PipedReader (was like that when I got it)

18:57 akhudek: ok, thanks, I'll grab the edits and see if I can get it going

18:58 raek: beware, I haven't looked too deep into this, so there might some big things I got wrong

18:58 but this is how I would get started...

19:00 akhudek: yep, I appreciate the help. I'll spend some time on this since it'd be really nice to have a working swingrepl with unicode.

19:18 looks like I got it working

19:18 I think PipedReader blocks correctly by default, and there is no need to extend

19:18 at least I haven't noticed any problems so far

19:26 jjido: Ooh, I missed a great discussion about strings.

19:28 This is what I have been doing with Clojure --> https://sourceforge.net/projects/dodo/files//README.txt/view

19:29 I definitely plan to do something about the broken string model in my language.

19:29 akhudek: raek: It also appears to work in conjunction with my own project. I've pushed the code to my fork. Thanks for your help!

19:40 qbg: The recent addition of ~350 interfaces is scary

19:42 jjido: qbg: is that for handling all primitive type combinations?

19:42 qbg: Yes

19:46 dnolen: qbg: why scary? it's pretty cool actually.

19:47 qbg: It feels so wrong

19:54 dnolen: qbg: well the end result feels so right. fn w/ the speed of static which can be closed over and can interoperate w/ protocols.

19:55 * qbg mumbles at the JVM

19:57 _rata_: does anybody know how to "bookmark" emacs buffers for coming back later easily?

19:58 qbg: I wonder if invokedynamic could make that mess cleaner

19:59 _rata_: ideally giving a buffer a number and then pressing C-x number to come back or something like that

20:07 dnolen: _rata_: http://www.gnu.org/software/emacs/manual/html_node/emacs/RegPos.html#RegPos

20:07 _rata_: tho I find it way faster to just use ido mode w/ fuzzy completion

21:08 dash: howdy.

21:11 Nafai: Howdy dash

21:11 dash: So I'm reading about Clojure and I keep tripping over the phrase 'persistent data structure'

21:11 to me that means 'data structure on disk'

21:11 but obviously that's not what's implied

21:12 how did we end up with a confusing term like this? can I just say "immutable data structure" and mean the same thing? :)

21:12 Nafai: dash: that tripped me up as well when I've heard the term elsewhere

21:13 I don't know the entomology though

21:13 dash: Nafai: i blame my misspent youth working on orthogonal persistence

21:13 tomoj: http://en.wikipedia.org/wiki/Persistent_data_structure

21:13 Nafai: dash: heh

21:13 dash: tomoj: yeah i know

21:13 tomoj: but that doesn't really answer the question

21:14 tomoj: well

21:14 it doesn't answer whether you can say "immutable data structure" and mean the same thing

21:14 (of course you can)

21:15 dash: and it doesn't help at all to say "A persistent data structure is not a data structure committed to persistent storage, such as a disk"

21:15 tomoj: seems pretty clear from the article that "persistent" and "immutable" don't mean the same thing, though

21:15 dash: because that's a common usage as well

21:46 * xkb

21:53 Anniepoo_: how's the conj?

22:11 xxpor: does anyone know of a lib for clojure that implements a graph data structure

22:11 Anniepoo_: not sure you need a lib. I've done it by using a netlist

22:12 what sort of operations do you need to do on the graph?

22:13 mabes: xxpor: I've not used it but I saw this lib the other day: http://github.com/jkk/loom

22:14 xxpor: Anniepoo_: basicly traverse it and assign a color to each node based on the colors of connected nodes

22:16 mabes: that looks interesting, ill check it out, thanks

22:17 Anniepoo_: @xxpor - how big r ur maps?

22:18 xxpor: Anniepoo_: 81 nodes

22:40 qbg: A possible bug in the latest master: if a function taking a primitive is type hinted to return a subtype of Object, invoking the function will fail with an AbstractMethodError

23:06 trptcolin: is this the quiet before the clojureconj storm? or just what happens on eastern time?

23:07 Anniepoo_: The one conjugate that I'm tracking isn't yet there

23:08 _rata_: I'm eager to hear and view those clojureconj talks :)

23:08 when are they uploading the videos?

23:09 cemerick: _rata_: gotta wait 'till the talks are given, at the very least :-)

23:10 _rata_: hahahahaha :) yeah, but I want them :)

23:10 trptcolin: cemerick: :)

23:12 _rata_: does anyone happen to know how to mark emacs buffers to come back easily afterwards?

23:18 bhenry: _rata_ remembering the name of the file is the easiest way. C-x-b will give you a list of all your buffers or C-x b [start typing] will let you filter out the one you want.

23:21 _rata_: bhenry, but that's a lot more keystrokes than what I want... for such a common task

23:21 amalloy: _rata_: C-x b uses fuzzy completion, so to get the repl you can type, eg, *re<TAB>

23:27 bhenry: _rata_ you could M-x rename-buffer RET 1 RET then C-x b 1 RET

23:28 but i don't know if that messes with the file for saving

23:28 _rata_: mmmm... thank you guys... I was hoping something like C-1 could do the job

23:29 bhenry: are you looking for a short cut to the repl always? or you just want to make changes to the buffers you're using most at any given time?

23:30 amalloy: maybe there's a mode to make the mark global rather than per-buffer? then you could C-u C-<space> a few times to got where you recently were

23:31 KirinDave: Man, is ab a liar?

23:31 amalloy: Rail a basin am?

23:31 bhenry: also, if you amde a keyboard macro to make C-1 be equivalent to C-x b 1 RET then you could rename the buffer you want to get to with C-1 as said before. is C-1 reserved?

23:31 KirinDave: it says 7/10 reqs fail

23:31 But... uh, I can see on wireshark they are succeeding and my jetty logs say they're fire.

23:33 tomoj: why does it say they failed?

23:34 _rata_: bhenry, that's a good idea :) I'll read about keyboard macros

23:35 I hate when people say Scheme (or any other Lisp) is useless for real world

23:36 KirinDave: tomoj: It won't ay

23:36 Anniepoo_: Shhhhh..... You're letting our competitors know.

23:36 KirinDave: tomoj: When I do -v 5, it doesn't fail.

23:46 amalloy: bhenry: i'd be surprised if C-1 were reserved. i mean, even 1 all by itself is rebindable if you don't mind the inability to type the number 1

23:46 (but that would make it such a lonely number)

23:48 maharishi: how do I turn (rest "foobar") into a string again I just get (\o \o \b \a \r)

23:49 dakrone: maharishi: (str (rest "foobar"))

23:49 nope, nevermind, that doesn't work

23:49 maharishi: dakrone: thats what I thought it would be too

23:49 dakrone: maharishi: (apply str (rest "foobar"))

23:49 KirinDave: ,(apply str (list \a \b \c))

23:49 clojurebot: "abc"

23:51 maharishi: sweet, thanks, clojure is so damn cool

23:51 Derander: why is apply necessary?

23:52 dakrone: calling 'rest' on the string makes it into a sequence of chars, you need to apply str to the sequence to collapse it back into a non-sequence string

23:53 Derander: thanks

Logging service provided by n01se.net