#clojure logs

2010-10-21

00:15miltondsilvaHi, 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?
00:17amalloymiltondsilva: 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
00:18miltondsilvathanks
00:19amalloytldr: he says 80 cols, preferably 72
00:19amalloywhich sounds about right to me
00:19Once72 is what I use as a general max
00:20amalloyyeah, i like short lines cause i can't see without a pretty large font
00:20LauJensenMorning
00:20amalloyhi lau
00:31amalloyhiredman: i started trying to figure out functional.clj. looks neat, though i'm curious what shortcuts you have to type in your shorthand symbols
00:32amalloythe 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
00:39hiredmanamalloy: Collections/shuffle tries to shuffle the collection inplace, if you pass it an immutable collection, *boom*
00:40amalloyhiredman: right. but LinkedLists don't implement RandomAccess, so it will copy that into an ArrayList
00:40amalloyif you send it an arraylist in the first place there's only one copy
00:47amalloyi often find myself wanting (take-while f (iterate g x)) quite often. is there already a function for this?
00:48tomojhttps://gist.github.com/2f060dde83ac1bfbe551 what do you think
00:52LauJensenInteresting idea tomoj
00:54tomojI hate (let [x ... y ...] {:x x :y y})
00:56tomojand I have some which macros generate code like that, but with no let, and so the evaluation order is undefined
00:57tomojI wish there were a better way to handle records though
00:58tomojhmm, of course you need default values
01:03amalloytomoj: i have a macro to generate a make-xxx function along with a macro, that takes keyword arguments
01:03amalloyer, along with a record
01:03tomojyou have to supply a dummy instance still?
01:03amalloyit defaults to nils atm
01:04tomojhow, though?
01:04amalloylemme find the gist
01:04tomoj(without reflection..)
01:04amalloyno, it's a substitute for the defrecord form
01:04amalloythat expands to a defrecord as well as a make-xxx
01:04tomojah
01:04tomojright, that makes sense
01:05amalloyhttp://gist.github.com/608075 if you're interested
01:06tomojthanks
01:07amalloyshould be easy enough to add default arguments as well, by allowing [name default] as well as name
01:08amalloyPS do not use this if you care about performance at all. it's like fifty times slower than (Record.)
01:08tomojhmm
01:09tomojsince we know the field names at macro time we could expand to a ctor which is just a let and a (Record.), right?
01:09amalloyoh sure. since you have default parameters
01:10amalloybut 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
01:10tomojwhat &?
01:12amalloyoh
01:12amalloyhaha i added that later but i guess i didn't put it in the gist
01:14amalloyif 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
01:18tomojah
01:38bhenryhow dead will room be from people flying to nc later? or did everyone else book on flights with wifi?
01:40sthuebne_BTW: what's the hashtag for clojure-conj on twitter?
01:40amalloysomeone said #clojure-conj
01:40amalloyoh, no dash
01:40amalloyhttp://twitter.com/clojure_conj
01:41dnolenwow, new perf w/o declaring static is pretty cool. can create closures. static code and protocols can intermix
01:41LauJensendnolen: have you done some early benchmarking?
01:41dnolenLauJensen: yeah super naive stuff, but it looks stellar.
01:43notsonerdysunnyis 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
01:45dnolenLauJensen: static not be able to interop w/ protocols always seemed wacky. Was wise to leave the static stuff out of 1.2.0
01:47dnolenicing on the cake would be the ability to type hint protocol methods...
02:07replacasthuebne_: according to the website it's #clojureconj
02:08sthuebne_replaca: cheers! should have had a look there myself… silly me
04:01mike5160hi all
04:02mike5160leiningen + ubuntu + penumbra can't get it to work i have tried almost everything there is on googlespace. right now lein native-deps fails.
04:05mike5160any 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?
04:06mike5160is there an alternative way to build all this in one directory clojure clojure contrib incanter and penumbra
04:09esjmike5160: 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.
04:09esjs/you're/your/
04:09sexpbot<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.
04:10mike5160k will try again.
04:10mike5160good to know that at least github is running now
04:10esjohoh.... who long until sexpbot goes Clippy ?
04:10mike5160esj: thanks for your help
04:10esjnp
04:16raekhrm...
04:18raekmike5160: you have native-deps in dev-dependencies? (Swede here.... good morning)
04:19mike5160raek: 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
04:20mike5160raek: 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?
04:22raekyeah, I found this while trying to set up a project
04:22raekhttp://github.com/ztellman/penumbra/wiki/getting-started
04:23raekhrm that [leiningen/lein-swank "1.1.0"] should be updated to [swank-clojure "1.2.1"]...
04:24mike5160raek: let me check. it works with lein-swank so far. i haven
04:24mike5160raek: i haven't tried running lein swank or repl yet? lemme check.
04:24raekthat version is old, but I think it should work
04:25mike5160raek: 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?
04:28raekmike5160: put all the contents of that zip file in the corresponding folders in your project
04:28raeki.e., everyting from <zipfile>/src/ to <project>/src/, etc
04:29mike5160yep did that part. after unzip file i ran lein deps and lein compile ...
04:29raekmike5160: then I think a (require 'clojureTetris.main) should start it
04:29raekyou don't need to compile it
04:30raekremember to clear the classes/ dir if you make modifications
04:30mike5160raek: compiled it cause i'm still in the c/c++ ;configure, make, make install mindset
04:31raekheh, understandable
04:31raekits pretty neat to be able to update the display function while the program is still running
04:31raekor looking at variable contents
04:32raekif you are a an Emacs user, I really recommend checking out slime
04:32mike5160raek: 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.
04:33raekI installed slime, slime-repl and clojure-mode from ELPA
04:33mike5160raek: 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.
04:34raekit is simpler today
04:34raekbut there are still some old out of date tutorials out there
04:34raekin the project, run lein swank
04:34mike5160raek: 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.
04:35raekin emacs, install ELPA, add packages slime, slime-repl and clojure-mode
04:35raekM-x slime-connect
04:35raekand then you should be done (in theory)
04:35mike5160raek: 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.
04:35mike5160raek: i will try again.
04:36mike5160raek: in the above example of tetris i m getting org.lwjgl.opengl.GL11 (core.clj:9) not found error.
04:36raekdid you run lein native-deps?
04:37raekalso, which version of clojure is the tetris written for?
04:37mike5160raek: cl 1.1.0 and cl-ctrb 1.1.0
04:38raekwhat project.clj file do you use? the one from the zip file?
04:38mike5160yes
04:39mike5160raek: the only thing i changed after the error was native-deps from 1.0.0. to 1.0.4
04:39mike5160raek: not to mention the error still persists
04:40raekmike5160: I don't think you should change that
04:40mike5160raek: ok back to 1.0.0
04:41raekmake sure everything is set for the clojure 1.1 way according to http://github.com/ztellman/penumbra/wiki/getting-started
04:41raekif the tetris is made for an earlier version of penumbra than 0.5.0, maybe those instructions don't apply
04:42mike5160raek: btw, the .m2 dir have a lwjgl dir by itself and is not under org where clojure and cl-contrib exists
04:42raekmike5160: I just found out that a tetris example is shipped with latest penumbra
04:43mike5160raek: yes the instructions are same, but they use ant launcher etc.
04:43raeksorry, but I have to go now
04:43mike5160raek: thanks a lot. i do appreciate it.
04:44raekmy recommendation is to try everything with the latest versions
04:44mike5160raek: k i will do that
04:44raekalso, they have a mail list
04:44raekhttp://groups.google.com/group/penumbra-lib
04:44raekgood luck!
04:44mike5160raek: thanks u have a good day.
04:45fliebelCan someone explain me re-groups? I need to get the groups from a regex, but I can't get it to work.
04:45fliebel,(re-groups (re-matcher #"[0-9a-z]" "0a"))
04:45clojurebotjava.lang.IllegalStateException: No match found
04:47fliebelThe actual regex is more complicated, and does contain groups ;)
04:48fliebelUh? Oh, shit… re-find actually returns those? Then what is the use of re-groups?
04:49TobiasRaedermorning everybody :)
04:49fliebelmorning
04:56esjHowdy all
04:56TobiasRaederhey esj
04:57AWizzArdmoin moin
04:57TobiasRaedermoin
04:57LauJensenYo yo everybody
04:57TobiasRaedermorning lau
05:01esjhey Lau
06:44jszakmeisterHi folks! I'm looking to add a comment to a ticket in Assembla... how do I get permissions to do that?
06:48bartjjszakmeister, not too sure, try registering first on Assembla
06:49jszakmeisterbartj: I did that... it still won't let me comment though. :-(
06:50bartjURL please?
06:50hsarvellI'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?
06:51jszakmeisterbartj: https://www.assembla.com/spaces/clojure/tickets/103-gc-issue-99--incorrect-error-with-if-let
07:18jjido,(:id 0)
07:18clojurebotnil
07:34Lajla,(nil nil)
07:34clojurebotLajla: Huh?
07:34Lajla->(nil nil)
07:34sexpbotjava.lang.IllegalArgumentException: Can't call nil
07:52bartj,(nil? nil)
07:52clojurebottrue
07:53bartjLajla, did you mean to test for nil. then you would be better off using "nil?" like the example above
07:55hircus,(empty? nil)
07:55clojurebottrue
07:56hircus,(nil? '())
07:56clojurebotfalse
07:56hircus,(nil? (rest (cons 'a '())))
07:56clojurebotfalse
08:00LauJensen,(nil? (next (cons 'a '())))
08:00clojurebottrue
09:44perfectsomeone knows how to make a perfect square in clojure?
09:45jolysomething other than (* side side)?
09:46jolyperfect: ^^^
09:46perfectnot...just the formula
09:46jolyhmm, (defn square [x] (* x x)) then?
09:46perfecti can not do
09:48perfectneed a code that I enter a number and make sure it is a perfect square
09:48jjido,(rand 20)
09:48clojurebot19.501843150268495
09:48jjido,(int (rand 20))
09:48clojurebot19
09:48jjido,(int (rand 20))
09:48clojurebot0
09:48jjido,(int (rand 20))
09:48clojurebot2
09:48jjidothanks bot.
09:49jjidoperfect: why in Clojure?
09:49Chousuke,(rand-int 5)
09:49clojurebot4
09:49Uppercutjoly: i guess he wans to test if a number is or not a perfect square
09:49perfectyes
09:49jolyyou might need Math/sqrt then, and compare if it's equal to the rounded version
09:50jjidoChousuke: nice
09:50jjido,(rand-int)
09:50clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$rand-int
09:50perfectgot it
09:50Uppercutcan you use Math.sqrt or do you want to sum only odd number?
09:50joly,(= 3.5 (int 3.5))
09:50clojurebotfalse
09:54perfectyou guys know how to do with recursion?
09:56TobiasRaeder@perfect what do you exactly want to do recursivly?
09:57perfectjoly, you know to do with recursion?
09:57jolyperfect: yes
09:58perfectTobiasRaeder, a perfect square
09:58perfectjoly, can you do?
10:00jolyperfect: 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:05esjwell, sqrt is probably based on a newton method, which can be done recursively... but that's academic really
10:06Uppercut, (defn x[y] ( if (= (rem Math/­sqrt y) 0 ) true ))
10:06clojurebotDENIED
10:09jolyI 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:10jolynot fast, but if you're stuck using recursion for this...
10:13perfectjoly: thanks
10:16jjidothat was a homework question?
10:20jolySounded like it, given the need to use recursion. Maybe I should have gone into a little less detail...
10:21Uppercutperfect: are you doing your homework here?
11:09dpritchettmorning
11:09bforesterg'morning
11:09jolymorning
11:10tonylhello everyone
11:11dpritchetti'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:17rlbdpritchett: M-x local-setkey?
11:17rlbs/setkey/set-key/
11:17sexpbot<rlb> dpritchett: M-x local-set-key?
11:18dpritchettrlb: just found that a second ago... now i need to figure out how to make it persistent between sessions
11:18rlbdpritchett: if there's a mode hook, use add-hook with a suitable lambda
11:18rlb(would probably work)
11:18rlbI'd just glance in the source for the mode...
11:19rlbsomething like (add-hook slime-mode-hook (lambda () (local-set-key ...)))
11:19dpritchettneat thanks
11:19rlbActually that's probably 'slime-mode-hook
11:20rlbAnd 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:27dpritchettturns out slime-repl-backward-input isnt doing what i wanted it to anyway
11:43UppercutI 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:46AWizzArdUppercut: (filter #(.contains container %) objects)
11:47AWizzArd,(filter #(.contains (java.util.ArrayList. [10 20 30]) %) (range 15))
11:47clojurebot(10)
11:47hoeckUppercut: first
11:49hoeck,(first (filter odd? (range 0 2))
11:49clojurebotEOF while reading
11:49hoeck,(first (filter odd? (range 0 2)))
11:49clojurebot1
11:50Uppercut,(first (filter odd? (range 0 20)))
11:50clojurebot1
11:50Uppercutodd between 0 20
11:52Uppercut, (filter odd? (range 0 20))
11:52clojurebot(1 3 5 7 9 11 13 15 17 19)
11:53Uppercut, (filter even? (range 0 20))
11:53clojurebot(0 2 4 6 8 10 12 14 16 18)
11:53Uppercutmagic
11:53Uppercut, ( + (filter even? (range 0 20)))
11:53clojurebotjava.lang.ClassCastException
11:54Uppercuthow to sum all elements
11:54hoeck,(reduce + (range 4))
11:54clojurebot6
11:54Uppercut,(reduce + (filter even? (range 0 20)))
11:54clojurebot90
11:55Uppercut,(= (reduce + (filter even? (range 0 7)) 25)
11:55clojurebotEOF while reading
11:55Uppercut,(== (reduce + (filter odd? (range 0 10))) 25)
11:55clojurebottrue
11:56Tordmor,(range 3 4)
11:56clojurebot(3)
11:56Tordmor,(range 4 3)
11:56clojurebot()
11:57AWizzArd,(range 4 3 -1)
11:57clojurebot(4)
12:06Uppercut, (dotimes [n (+ n 1)] n)
12:06clojurebotjava.lang.Exception: Unable to resolve symbol: n in this context
12:07Uppercut, (dotimes [n (+ n 1)] true)
12:07clojurebotjava.lang.Exception: Unable to resolve symbol: n in this context
12:08amalloy,(let [n 3] (dotimes [n (+ 1 n)] (print n)))
12:08clojurebot0123
12:15dpritchetti 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:18notsonerdysunny,(doc ref-history-count)
12:18clojurebot"([ref]); Returns the history count of a ref"
12:18notsonerdysunny,(doc ref-min-history)
12:18clojurebot"([ref] [ref n]); Gets the min-history of a ref, or sets it and returns the ref"
12:18notsonerdysunny,(doc ref-max-history)
12:18clojurebot"([ref] [ref n]); Gets the max-history of a ref, or sets it and returns the ref"
12:19notsonerdysunny,(doc ref)
12:19clojurebot"([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:39Uppercut,(let [n 5] (dotimes [n (+ 1 n)] (print n)))
12:39clojurebot012345
12:42Uppercut,(defn test [num] (let [n num] (dotimes [n (+ 1 n)] (print n))) (if (== (reduce + (filter odd? (range 0 n))) num)) ) ) ) (test(5))
12:42clojurebotDENIED
12:43Uppercut, (defn test [num] (let [n num] (dotimes [n (+ 1 n)] (if (== (reduce + (filter odd? (range 0 n))) num)) ))) ) ) (test 5)
12:43clojurebotDENIED
12:43raekUppercut: use letfn
12:43raekclojurebot doesn't allow defs
12:45Uppercut, (letfn [n num] (dotimes [n (+ 1 n)] (if (== (reduce + (filter odd? (range 0 n))) num)) ))) )
12:45clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
12:45raek,(letfn [(foo [x] (inc x))] (foo 1))
12:45clojurebot2
12:45Uppercutright
12:45raekalso, = is used for equality
12:46raek== is only used in special circumstances
12:49Uppercut, (if (== (reduce + (filter odd? (range 0 9))) 25))
12:49clojurebotjava.lang.Exception: Too few arguments to if
12:49LauJensenUppercut: s/if/when
12:49Uppercut(if (== (reduce + (filter odd? (range 0 n))) num) num)
12:50Uppercut(if (== (reduce + (filter odd? (range 0 9))) 25) 25)
12:50Uppercut,(if (= (reduce + (filter odd? (range 0 9))) 25) 25)
12:50clojurebotnil
12:51Uppercutahh, range 0 9 don´t include 9
12:52Uppercut, (if (= (reduce + (filter odd? (range 0 10))) 25) "i found")
12:52clojurebot"i found"
12:52raek,(if false :foo)
12:52clojurebotnil
12:53raekthat's why you got nil before
12:53raek,(range 5)
12:53clojurebot(0 1 2 3 4)
12:53tonyl,(if nil :foo)
12:53clojurebotnil
12:53raekyes, it's exclusive
13:04Uppercut,(letfn [(foo [x] (inc x))] (foo 4))
13:04clojurebot5
13:05amalloy,(let [f (fn [x] (inc x))] (f 4))
13:05clojurebot5
13:05amalloyif you don't want to remember letfn's syntax
13:06LauJensenamalloy: letfn is fun in that it adds little or no clarity to what you just wrote
13:10amalloyLauJensen: yeah, i only use letfn for mutually recursive functions (ie, so far never)
13:11LauJensenhehe
13:21Uppercut, (14 " as string")
13:21clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
13:21Uppercut, (str (14 " as string"))
13:21clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
13:21Uppercuthelp
13:22amalloy,(str 14 " as string")
13:22clojurebot"14 as string"
13:24Uppercut,(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:24clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
13:25Uppercutthe bot is telling strange words in my pvt
13:26Uppercut'Sea, mhuise. .. Ik begrijp
13:26raekthat is "I don't understand" in gaelic and dutch...
13:26raekclojurebot: asdf
13:27Uppercutlol
13:27edbondis it possible to reset deftest?
13:27fhdHi. Are the sessions at clojureconj recorded?
13:27raekreset, in what sense?
13:27raekremove an old test?
13:27amalloyfhd: yes, i'm told that's so
13:27Uppercut,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) )] (testar 10 25))
13:27clojurebot"25 is a"
13:27raekooh
13:28fhdamalloy: Ah, thank goodness.
13:28fhdAll interesting conferences are overseas it seems ;(
13:28raekUppercut: swede? :)
13:28edbondraek: yes, I need to remove old tests
13:29raekyou can use (ns-unmap 'the.ns 'the-var)
13:29raekthere might be a simpler way to do it
13:29raekmaybe remove-ns (go to anothe namespace before doing that...)
13:30Uppercutyeah, probably we can do it less complex
13:31Uppercut,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) , :else("not is :(") )] (testar 10 25))
13:31clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
13:32Uppercutwhat the problem with ,:else ?
13:32raekUppercut: what are you coding on?
13:32amalloy,("not is:(")
13:32clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
13:32amalloyUppercut: ^^
13:32raek,"not is:(" ; this is probably what you want
13:32clojurebot"not is:("
13:33raek,("trying to use a string as a function" 1 2 3)
13:33clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
13:34UppercutI 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:37raek,((fn [max n] (= n (reduce + (filter odd? (range (inc max)))))) 10 25) ; like this?
13:37clojurebottrue
13:38raek,((fn [max n] (= n (reduce + (filter odd? (range (inc max)))))) 10 24) ; like this?
13:38clojurebotfalse
13:38raekpretty much what you wrote
13:38dnolenamalloy: letfn is also a fun way to attach the constructor fn to the constructed map.
13:39raekthere is also this way (fn fact [n] (if (zero? n) 1 (* n (fact (dec n)))))....
13:39raekI have never used that though
13:40raek,(fn f [] f)
13:40clojurebot#<sandbox$eval4902$f__4903 sandbox$eval4902$f__4903@e746d4>
13:42amalloydnolen: how do you mean?
13:42sproustWhat is the best way to fetch a local copy of the Clojure website documentation?
13:43ohpauleezsproust: (doc whatever)
13:43ohpauleezor you want to browse, search, etc?
13:44sproustohpauleez: yes, I know how to access the source code, but what about the website?
13:45amalloysproust: wget?
13:45LauJensenDoes anybody have some more news on this latest intel from Apple, that they're deprecating Java for OSX ?
13:45sproustYeah, I did that. Allright, never mind then. I was just wondering if there was a package for local copies.
13:45ohpauleezsproust: I guess I'm unsure why you want a hard copy of the HMTLized docs. You have the docs built into the language
13:45amalloyLauJensen: no, but if you find out please let me know. a friend of mine on apple is just starting with clojure
13:46ohpauleezLauJensen amalloy: I wouldn't worry too much
13:46dnolenamalloy: (letfn [(ctor [& rest] (-> (into {} (partition 2 rest)) (meta {:ctor ctor :some-closed-over-local foo})))] ctor)
13:47ohpauleezI run OpenJDK7 on my mac, based on the FreeBSD distro
13:47ohpauleezthe only difference is swing uses X, not Aqua
13:47ohpauleezthat was really the only difference in Apple JDK anyway
13:48sproustohpauleez: I use a combo of both to find what I need when I need it.
13:48ohpauleezahhh cool. Well ClojureDocs has an API now
13:48sproustPython provides a download of their exact website: http://docs.python.org/
13:48raeksproust: it should be possible to use autodoc to generate html docs for whichever namespace you want
13:48amalloydnolen: (let [ctor (fn [& rest]...)])? letfn is no better for this purpose than for any other
13:48Uppercutraek: yes, very good tk
13:49raekbut that might not be very convenient to do for all the namespaces
13:49raekbut in principle, that should work
13:49sproustraek: Thanks, didn't know about it. I guess it's the same tool that generates the website, very cool.
13:50sproustraek: going to CC?
13:50LauJensenamalloy: http://developer.apple.com/library/mac/#releasenotes/Java/JavaSnowLeopardUpdate3LeopardUpdate8RN/NewandNoteworthy/NewandNoteworthy.html#//apple_ref/doc/uid/TP40010380-CH4-SW1
13:51raeksproust: unfortunately not...
13:51dnolenamalloy: you cannot refer to ctor w/ the anon fn
13:51dnolens/w/within
13:52LauJensendnolen: Would you mind gisting your benchmarks re static/dynamic ?
13:52dnolenamalloy: w/ letfn you can
13:52LauJensendnolen: amalloy only uses letfn for trampolines
13:53amalloy,(let [f (fn f [x] f)] (f 10))
13:53clojurebot#<sandbox$eval4906$f__4907 sandbox$eval4906$f__4907@18b8315>
13:53amalloydnolen: ^^
13:53dnolenLauJensen: I don't but they were all simple, fib, arithmetic operators and the like.
13:53LauJensengreat
13:53dnolenamalloy: yes sorry, a named anon fn and letfn accomplish the same thing.
13:54dnolenamalloy: I didn't know you could name fns that way.
13:54amalloyor even without the let:
13:54amalloy((fn ctor [] {:ctor ctor :data 10}))
13:54amalloy,((fn ctor [] {:ctor ctor :data 10}))
13:54clojurebot{:ctor #<sandbox$eval4910$ctor__4911 sandbox$eval4910$ctor__4911@2128d0>, :data 10}
13:54amalloyheh, named anonymous functions. i like it
13:55LauJensenamalloy: even better than signed unsigned ints
13:55dnolenamalloy: named unbound fn?
13:55amalloydnolen: iunno. i like named anon
14:02amalloy,(let [x (fn f [] f)] (identical? (x) (x)))
14:02clojurebottrue
14:02amalloyneat
14:13LauJensendnolen: just paste the gist when you're good and ready :)
14:14amalloy,(let [x (fn f [] f)] [(x) f])
14:14clojurebotjava.lang.Exception: Unable to resolve symbol: f in this context
14:15amalloyi think it really is fair to call it a named anonymous function
14:15raekheh
14:15raekhow strange that it actually makes sense to call it both named anonymous...
14:16jolythe name is only bound internally to the function?
14:16raekyes
14:16raeka name the function can use to refer to itself (in order to call or return itself)
14:17joly,(= #(1) #(1))
14:17clojurebotfalse
14:19joly,(#(% %) #(% %))
14:19clojurebotjava.lang.StackOverflowError
14:20raek,((fn f [] (f)))
14:20clojurebotjava.lang.StackOverflowError
14:21amalloy,(trampoline (fn f [] f))
14:21clojurebotExecution Timed Out
14:21joly,((fn [] (recur)))
14:21clojurebotExecution Timed Out
14:21amalloyjoly: (#(recur))
14:21jolyah, even better
14:27sproustWhat is the proper idiom for replacing the value of a map by something else which uses that value?
14:28sprouste.g. in Python: m[foo].append(2), re, clojure's:
14:28amalloy,(update-in {:t 4} [:t] inc)
14:28clojurebot{:t 5}
14:28sproust,(let [m {:foo [1]}] (assoc m :foo (conj (get m :foo) 2)))
14:28clojurebot{:foo [1 2]}
14:28sproustHa! Nice. Thanks amalloy.
14:28sproustIt's like you guys thought of everything.
14:29amalloy,(update-in {:t {:a 4}} [:t :a] inc)
14:29clojurebot{:t {:a 5}}
14:29sproustWow. Two-levels. Insane. That's actually just what I need right now!
14:30amalloysproust: see also assoc-in
14:30jarpiain,(update-in {:t {:a [4]}} [:t :a] conj 5)
14:30clojurebot{:t {:a [4 5]}}
14:31sproustamalloy: It looks like (assoc-in) could be a drop-in replacement for (assoc).
14:31amalloy,(assoc {} 1 2, 3 4}
14:31clojurebotUnmatched delimiter: }
14:31amalloy,(assoc {} 1 2, 3 4})
14:31clojurebotUnmatched delimiter: }
14:31amalloy,(assoc {} 1 2, 3 4)
14:31clojurebot{3 4, 1 2}
14:31amalloycan't do that with assoc-in
14:40sproustQ: Is there a way to avoid the fully-qualifying nature of Clojure's syntax-quote?
14:40amalloy`(~'x)
14:40amalloy,`(~'x)
14:40clojurebot(x)
14:40sproustHaaa. Thx,
14:40amalloysproust: think carefully before doing that though
14:40ohpauleezDoes Bradford Cross hang out in here?
14:41sproustWorks! Lovely.
14:41sproustamalloy: I know I should be using keywords instead.
14:41sproustamalloy: Is that what you mean?
14:41amalloywell, 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:43amalloyit 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:43amalloys/r$//
14:43sexpbot<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:43raeksproust: the qualifying thingy is to make macros safe. if you use syntax-quote outside macros, then go for it
14:47amalloy,(let [mymac (fn [arg] `(let [~'x 4] (* ~arg ~'x))), x 10] (mymac x))
14:47clojurebot(clojure.core/let [x 4] (clojure.core/* 10 x))
14:47amalloywould be a problem if mymac were a real macro
14:49amalloyie, it would multiply anything by four, unless the argument is named x in which case it returns 16
14:50amalloysproust: ^^
15:02sproustamalloy: yes, I understand.
15:03sproustAllrighty, leaving for the conf now, see some of you there tomorrow! cheers,
15:04_rata_hi
15:09KirinDaveUgh, that's a nasty bug in ring
15:09KirinDaveIf it gets a HEAD request and that request has a body in the response structure, it just hangs.
15:16zaphar_psKirinDave: 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:17KirinDaveAnd OPTIONS.
15:17KirinDaveAnd GET
15:17KirinDave;0
15:17KirinDaveANd PUT
15:17raekhow does Ring (or the servlet container?) handle HEAD anyway?
15:17zaphar_psyeah but I wouldn't be surprised if HEAD and options were top of the heap for sloppiness
15:27KirinDaveraek: It doesn't.
15:27KirinDaveI'm confused what is happening.
15:27KirinDaveOh, and now I see.
15:27KirinDaveRing doesn't do anything, so if you say Content-Length 3 by accident, anything will hang forever awaiting those 3 bytes
15:27KirinDaveAnd if you don't have an explicit close, then the socket can stay open for a long time
15:28raekso, I'll have to implement all HEAD stuff myself?
15:28raekif so, the tutorials should be clear about that...
15:29raekor is there some default, like handling HEAD as GET, but ignoring the body?
15:33dpritchettis it odd that the same function would take 3 seconds in vimclojure/nailgun and 50ish in swank clojure?
15:34dpritchetthere's the function fwiw http://github.com/dpritchett/euler-clj/blob/master/src/euler_clj/core.clj#L360
15:35dpritchett(time (problem-14)) is off by an order of magnitude in emacs with swank
15:35dpritchetti invoked swank via cake swank if it matters
15:35jjidoI want to use a variable of specific name in current context, can a macro do that?
15:38raekjjido: can you show us an example of how that construct would be used?
15:39jjidoraek: it is a bit complicated. I want to fill in missing arguments of a function I am calling
15:42raekyou 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:42dpritchettnevermind the swank vs nailgun question, turns out i had it cached in one repl and not the other so my memoization kicked in
15:45jjidoraek: with that variable, which varies according to the invoker context. Like that: http://gist.github.com/639173
15:49raekjjido: http://gist.github.com/639185
15:50raekdunno if that was exactly what you were looking for
15:50amalloyraek, jjido: isn't that what fnil already does?
15:50raekit is very similar, at least
15:50raek,(doc fnil)
15:50clojurebot"([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:51raek...but with arity rather than nil
15:51raekarity-patching :)
15:53jjidoI need to think how I can insert these default args
15:53raek,(let [f (fnil + 1 2)] [(f) (f 0) (f 0 0)])
15:53clojurebotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$fnil$fn
15:55raekhrm, I smell monads...
15:56hiredmananyone at o'hare?
15:57ohpauleez+1 on monads
15:58ohpauleezanytime I need some for of functional accumulator of sorts, I've been turning to monads
16:00LauJensenohpauleez: example?
16:00jjidoraek: which monads?
16:01ohpauleezLauJensen: fnparse is a good one
16:02ohpauleezfor me personally, I'm using a monad to functional register certain things for net-ns
16:02ohpauleez(which is more of a sandbox for me to explore this more)
16:03ohpauleezthose two examples aside, I'm pretty new to monads, so I'm sure I'm abusing them in some case
16:06raekdoes CPS have something in common with monads, or is this just a pattern I think I'm seeing?
16:06hiredmanthere is actually a cps monad
16:06amalloyraek: i believe CPS is a special case of monads
16:07hiredmanI don't think so
16:08edbondhow to cast bytes-array to char-array?
16:08raekjjido: well, the (fn [a] (-> (... a ...) ((fn [b] (-> (... b ...) ((fn [c] pattern reminded me of a tutorial explaining monads in clojure
16:08hiredmanfunctions that live in a monad return monadic values, cps doesn't return anything
16:09raekedbond: you have to decode the bytes into wharacters with some charset
16:09jjidoraek: I see
16:09hiredmanthe computation just continues
16:09jjidohiredman: that is the way I do it
16:09hiredmanright
16:09raek*characters
16:10hiredmancps on the jvm is kind of icky
16:10hiredmanno tailcalls :(
16:10ohpauleezagreed
16:12raekedbond: the Java way: (let [bytes (.getBytes "hello" "UTF-8")] (.toString (.decode (java.nio.charset.Charset/forName "UTF-8") (java.nio.ByteBuffer/wrap bytes))))
16:14raekif you got the bytes from a stream, it's probably easier to wrap the InputStream in a Reader instead
16:15jjidoI got it working! Nice nice nice
16:17kmcyeah there's a cps monad, which turns direct-style monadic code into cps'd code
16:17kmcit's named Cont in Haskell
16:17kmcand it can be used to implement most other monads
16:18ohpauleezedbond: You can also use the formats file in aleph
16:18ohpauleezwhich has all the format conversion stuff for you
16:20anonymouse89I'm looking for a map function that works over several machines. Any suggestions?
16:21dpritchetterlang?
16:21clojureboterlang is http://clojure.googlegroups.com/web/erlang.clj
16:21anonymouse89dpritchett: as in, use erlang?
16:22dpritchetti didn't think distribution beyond a single machine was a focus of clojure's
16:23hiredmanit's very doable, just nothing in clojure.core for it
16:23anonymouse89I don't mean baked-in, just some sort of library.
16:23ohpauleezanonymouse89: Take a look at Jobim. You can also use a library called work
16:25ohpauleezanonymouse89: You can also roll your own
16:25anonymouse89ohpauleez: thanks for the suggestion, I've encountered "work" before
16:26anonymouse89ohpauleez: 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:26ohpauleezanonymouse89: Another route would be using JXTA and pushing onto a P2P distribution. Lastly, there's always Hadoop and map/reduce
16:28anonymouse89ohpauleez: 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:28anonymouse89I mean on the clojure-hadoop lib
16:28amalloyanonymouse89: look into cascalog
16:28amalloyi'm doing hadoop at work, but can't justify switching to clojure. cascalog looks really nice if i could use it
16:28ohpauleezonce a wrapper has wrapped something, there's nothing left to innovate
16:29shanmuhello everyone, its me again... is there any way to get a list of fields in a record (as defined using defrecord)?
16:29amalloyshanmu: keys
16:29amalloyprobably
16:29shanmuamalloy: thanks! as you can imagine I am still chipping away at my mini orm :)
16:30amalloyyeah, keys works
16:30amalloyrecords are just like maps, except in the one or two caseds where they aren't
16:30shanmuthanks! will remember that
16:31shanmuthis is the beauty of clojure.. most things work as you would intiutively expect them to :)
16:32amalloyheh, except nth. i can't seem to remember the order or arguments to nth, no matter how many times i use it
16:33shanmuamalloy: no does not seem to work :(
16:33shanmu,defrecord2 :only (defrecord2 prewalk2 postwalk2 camel-to-dashed)
16:33clojurebotjava.lang.Exception: Unable to resolve symbol: defrecord2 in this context
16:33shanmusorry wrong paste
16:33shanmu,(do (defrecord trec [a b c]) (keys trex))
16:33clojurebotDENIED
16:33amalloy(defrecord X [a])
16:33amalloy(keys (X. 1))
16:33amalloy(:a)
16:34shanmuamalloy: oh ok... :)
16:34shanmu,(do (defrecord trec [a b c]) (let [q (trec. 1 2 3)] (keys q)))
16:34clojurebotDENIED
16:35shanmuworks fine.. thanks!
16:35amalloyshanmu: just fyi, you can't (def) anything in clojurebot or sexpbot
16:36shanmuoh.. ok :)
16:37shanmuamalloy: 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:38shanmufor instance I have (defrecord X [a b c])
16:38amalloyshanmu: how can you create a defrecord var without all fields bound? the constructor requires you pass it everything
16:38shanmuoh.. I am sorry.. didnot mention that I am using defrecord2 (http://github.com/david-mcneil/defrecord2)
16:39shanmudefrecord2 supports partial values for creating an instance of a defrecord type
16:39shanmuand a few other goodies
16:42amalloyshanmu: 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:43amalloyi mean, it looks like (new-foo 10) just calls (Foo. 10 nil nil), and that will still have three keys
16:44shanmuamalloy: sorry, it works fine :)
16:44jjidoWhat 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:44shanmuamalloy: I had messed up the constructors for defrecord2 and defrecord
16:54jjidohow do I know that deref will cause a NPE in advance?
16:55Chousukehuh? deref shouldn't cause NPEs
16:55Chousukeunless what you're derefing is null
16:56amalloyjjido: Chousuke is right. (defn will-cause-npe [deref])
16:57jjidoChousuke: happens often to me
16:58jjido,(deref (:bad {}))
16:58clojurebotjava.lang.NullPointerException
16:58amalloyoh. if you're derefing a non-ref, then yeah?
16:59amalloy,(instance? IDeref (:bad {}))
16:59clojurebotjava.lang.Exception: Unable to resolve symbol: IDeref in this context
16:59jjidoamalloy: programmer error... I would like to catch that
17:00jjidook
17:00amalloy,(instance? clojure.lang.IDeref (:bad {}))
17:00clojurebotfalse
17:00amalloy,(instance? clojure.lang.IDeref (atom (:bad {})))
17:00clojurebottrue
17:00ohpauleezjjido: you can also shorthand that to is-deref? (just tuck it in a function)
17:01amalloyor even (defn maybe-deref [obj] (if (is-deref? obj) @obj obj))
17:02Chousukeeh, that's not even the problem here
17:02Chousuke,(:bad {})
17:02clojurebotnil
17:02Chousukeyou can't do anything with nil without getting an NPE
17:02Chousukewell, unless the function guards against it
17:02Chousukelike many clojure ones do
17:02Chousukebut deref doesn't
17:03Chousukeso just check for nil
17:03jjidoChousuke: not true, nil is all right but not deref
17:03jjido,(deref 4)
17:03clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IDeref
17:03Chousukejjido: I don't understand your problem
17:03jjidoI will check for IDeref.
17:03jjidoChousuke: better recovery from my coding mistakes
17:04Chousukehm
17:04Chousukeyou might be using too many refs if accidentally derefing non-refs is a problem for you :)
17:04Chousukeor doing the dereferencing in too many places perhaps
17:05clizzinis anyone here familiar with mattrepl's clojure-twitter library?
17:05Chousukeideally, you should make functions so that they don't deref anything
17:05ohpauleez(isa? (class init-set) clojure.lang.PersistentHashSet) ?= (instance? clojure.lang.PersistentHashSet init-set)
17:05Chousukeand then handle state outside those functions
17:08ohpauleezcan anyone comment on the above? assume they are equal
17:09Chousukenot equal
17:09Chousukewell, hm
17:09amalloyohpauleez: i think that's true for the class hierarchy. but isa? is more general
17:09ChousukeI guess that specific instance might be
17:09Chousukeno pun intended :P
17:09ohpauleezhaha
17:10ohpauleezthanks guys
17:10ohpauleezjust trying to clean up some code
17:12raekinstance? is only for classes; isa? is for any type of hierarchy
17:13ohpauleezraek: It also works for interfaces too though
17:13ohpauleez(instance?)
17:14raekyes. more accurately: the java type hierarchy
17:14ohpauleezahh, ok. Gotcha. So in this specific case, I'm ok doing that "refactor"
17:14ohpauleezthanks guys
17:18raekI should use make-hierarchy more...
17:25amalloyraek: model the #clojure pecking order. that will surely be a useful, non-controversial topic
17:26ohpauleezhaha
17:27ohpauleezat least then we all know who we have to over throw
17:28ohpauleezthis is slowly turning into a game of Diplomacy.
17:44akhudekthis is probably not the best place to ask, but I'm trying to get swingrepl to support unicode and I'm having difficulty
17:44ohpauleezwhat's tripping you up?
17:45akhudekI've modified the source so that PrintStream and InputStreamReader use UTF-8 in Jconsole
17:45akhudekand similar for the OuptutStreamWriter in swingrepl
17:45akhudekbut it's still giving garbled output
17:45akhudekand doesn't accept any unicode input
17:46akhudekif I try to give it a \⊕
17:47akhudekthe repl returns with java.lang.Exception: Unsupported character: \\u2295
17:47ohpauleezit 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:47ohpauleezbut by default, aren't Java strings utf-16?
17:48raekjava strings are implemented with UTF-16 internally
17:48ohpauleezakhudek: these are just guesses
17:49raekhrm, can one start a clojure repl an communicate with it with a Reader and a Writer, instead of an InputStream and an OutputStream?
17:49raekakhudek: where is the source for swingrepl?
17:50akhudekreak, let me push my changes to my fork
17:50akhudekhld on
17:50raekif everything is done inside the same process, I think the whole string -> byte -> string conversion should be avoided if possible
17:50raekI assume swing gives you strings in some way, rather than byte arrays
17:51akhudekhttp://github.com/akhudek/clj-swingrepl
17:52tensorpuddingcan you get by in clojure without having to know or think about java?
17:53amalloytensorpudding: you can do a lot without java
17:54raekwell, with clojure.java.* and clojure.string, you rarely need to do java interop for basic stuff
17:54raekjava interop, as in .method calls
17:56raekhrm, JConsole uses byte-oriented streams internally
17:56ohpauleezweird then, things should encode fine then?
17:57raekwould be better if it just had been using characters all the way through
17:57ohpauleezahh
17:58raekat least it explicitly uses UTF-8
17:59raekno weird "operating system default encoding" issues, hopefully
17:59akhudekThe original didn't actually.
17:59akhudekI added in all those explicit UTF-8's
17:59akhudekoriginal is here: http://github.com/alandipert/clj-swingrepl
18:00raekah, I started to suspect so...
18:01akhudekIt seems that even if I do an internal print("⊕"); it doesn't come out correctly
18:01raekit should really use a PrintWriter
18:01akhudek‚äïClojure 1.2.0
18:01akhudekuser=>
18:01akhudekthe ai should have been an xor symbol
18:02raekthe input is a Reader but the output is a OutputStream (more specifically PrintStream)
18:04raekI think JConsole should be rewritten to only use Readers and (Print)Writers
18:05akhudekWhat's the difference between them? My Java isn't particularly strong.
18:05raekok, strings are sequences of characters
18:05raekand not bytes
18:06raekthat one needs to be aware of
18:06raekInputStream and OutputStream represents streams of bytes (like files and sockets)
18:07raekReaders and Writers, very similarily, represent streams of characters
18:07akhudekah, I see
18:07akhudekso the readers and writers should automatically handle whatever encoding the characters use
18:07akhudekwhere as the streams need to be explicitly aware
18:08raekcharacter (and strings) are independent of encoding
18:08raekfor example, the string "åäö" consists of three characters
18:08akhudekso then the only difference is that characters are multi-byte?
18:09raekthat string can be *encoded* to a sequence of 3 bytes with the Latin-1 encoding
18:09AWizzArd,(map #(vec (.getBytes ^String %)) ["hallo" "äöüß"])
18:09clojurebot([104 97 108 108 111] [-61 -92 -61 -74 -61 -68 -61 -97])
18:09raekor to another sequence of 6 bytes with the UTF-8 encoding
18:09raekthere is no inherit mapping between bytes and characters
18:10AWizzArd,(map #(vec (.getBytes "ä" ^String %)) ["LATIN1" "UTF-8"])
18:10clojurebot([-28] [-61 -92])
18:10raekthe getBytes method's encoding parameter defaults to the "operating system default encoding"
18:10raekso, when having a byte sequence, you have to remember which charset it is encoded in
18:10AWizzArdIt is interesting to note though that Java strings are broken. In a way.
18:11raekbroken? how?
18:11raekstrings abstracts away byte representation
18:11AWizzArdFor example, you should not expect (count "your string") to tell you how many visible characters are in the string.
18:11AWizzArdInstead it will tell you how big its char[] array is.
18:11raekfor characters in the basic multilingual plane, it does
18:11raekno
18:11akhudekah, ok, I get it
18:11raek(seq "åäö")
18:11raek,(seq "åäö")
18:11clojurebot(\å \ä \ö)
18:11AWizzArdThe string "\ud80e\udc80" is exactly one char
18:11AWizzArdbut: (count "\ud80e\udc80") ==> 2
18:12raekbut that is outside the basic multilingual plane
18:12AWizzArdIt still is a string.
18:12ChousukeMost software dealing with strings is broken
18:12AWizzArdyes!
18:12ChousukeJava is no exception ;P
18:12raekso yes, strings are broken, if they include characters in the astral planes
18:12AWizzArdThey can even be *really* broken.
18:12AWizzArdIf you mess the order of high and low surrogates
18:13Chousukelike ruby 1.8 strings :P
18:13AWizzArd,(vec (.getBytes "\ud80e\udc80" "UTF-8")) ; this works fine
18:13Chousukewhere indexing a string gives you an integer
18:13clojurebot[-16 -109 -94 -128]
18:13raekhas ruby realized yet that bytes and characters aint the same thing?
18:13AWizzArd,(vec (.getBytes "\udc80\ud80e" "UTF-8")) ; Argh!! Thanks Sun.
18:13clojurebot[63 63]
18:13Chousuke1.9 has fixed that I think
18:14AWizzArd,(= (String. (.getBytes "\ud80e\udc80" "UTF-8") "UTF-8") "\ud80e\udc80")
18:14clojurebottrue
18:14Chousukewhat character is that by the way?
18:14AWizzArd,(= (String. (.getBytes "\udc80\ud80e" "UTF-8") "UTF-8") "\udc80\ud80e")
18:14clojurebotfalse
18:15AWizzArdI forgot
18:15AWizzArd,[0xdc80 0xd80e]
18:15clojurebot[56448 55310]
18:15Chousuke,(print "\udc80\ud80e")
18:15clojurebot??
18:15Chousukehah
18:15raek,"𐌰𐌱𐌲𐌳"
18:15clojurebot"𐌰𐌱𐌲𐌳"
18:15akhudekhmm, so probably the problem is when Jconsole does outPipe.write( line.getBytes() ); ?
18:16raeknooo.... no gothic support in the Inconsolata font
18:16ChousukeI get just unicode wtf marks
18:16raekif outpipe is a writer instead, you could drop the getBytes step
18:16shanmuis there a xml/node to help extract nodes from a zipped, parsed xml?
18:16amalloyraek's thing looks fine to me
18:17Chousukemy terminal's unicode support is probably lacking
18:17raekAhsa Bairkan Giba Dags were the letters
18:18akhudekew, there is some strange looking unicode patch in the acceptLine function
18:18akhudekguess I'll need to work on this a bit more
18:18ChousukeI wonder how to find out if a character is in the BMP
18:20Chousukeah, right.
18:20raekChousuke: if its codepoint is in the interval U+0000 - U+D7FF, U+E000 - U+FFFF I think
18:20ChousukeJust checked if I ever have had need for characters outside the BMP
18:20Chousukeand it turns out the answer is yes, once :P
18:20shanmuI saw an example using 'xml/node' in xml->, but its not there in the lastest version of xml/node
18:20raekChousuke: you probably don't, unless you pick upp some lessons on Gothic or other ancient languages
18:20shanmuhttp://gist.github.com/199309
18:21raekChousuke: ooh, which one? :)
18:21Chousukeraek: the character 𠀋
18:21Chousukewhich I can't see right now. :D
18:22Chousukeso I hope I got it right.
18:22Chousukebut it was used in a name
18:22raekall I got was U+FFFD REPLACEMENT CHARACTER
18:23Chousukehm :/
18:23Chousuke2000B anyway
18:25rlbI assume I'm just missing something, but why doesn't this work?
18:26rlb(with-in-reader (reader "foo") (repeatedly #(prn (read))))
18:26Chousukerepeatedly returns a lazy seq
18:26rlbOh, right -- I was thinking it was just for side-effects.
18:26raekwhich gets realized outside the with-in-reader form
18:27rlbSo the port's gone?
18:27ChousukeOr: It exits the scope of the bindings that the with-in-reader macro establishes
18:27rlbs/?/./
18:27rlbThanks -- I'd wondered if that might be it.
18:28Chousukeyou can force it by using doall to realise the entire sequence while it's still within the scope of the binding
18:28raek(with-in-reader (reader "foo") (doseq [x (repeatedly #(read))] (prn x)))
18:29rlbraek: right.
18:30raekjust may daily lobbying for 'for' and 'doseq'...
18:32Chousukebtw, (repeatedly #(read)) = (repeatedly read) :P
18:33raekyeah... I guess my brain was in refactor-blindly-mode...
18:34raekor at least I could claim that
18:37raekgah! non-ascii byte != unicode character
18:42raekakhudek: 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:44akhudekraek: 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:49amalloyrlb: want sexpbot to fix your typos for you? he will if you use valid regexes:
18:49amalloys/\?/./
18:49sexpbot<amalloy> rlb: want sexpbot to fix your typos for you. he will if you use valid regexes:
18:53raekhrm, BlockingPipedInputStream accesses internals of PipedInputStream (defined by Java)...
18:55raekakhudek: this is how far I got http://gist.github.com/639537
18:56raekthe BlockingPipedReader helper class does not compile since it uses private internals of PipedReader (was like that when I got it)
18:57akhudekok, thanks, I'll grab the edits and see if I can get it going
18:58raekbeware, I haven't looked too deep into this, so there might some big things I got wrong
18:58raekbut this is how I would get started...
19:00akhudekyep, 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:18akhudeklooks like I got it working
19:18akhudekI think PipedReader blocks correctly by default, and there is no need to extend
19:18akhudekat least I haven't noticed any problems so far
19:26jjidoOoh, I missed a great discussion about strings.
19:28jjidoThis is what I have been doing with Clojure --> https://sourceforge.net/projects/dodo/files//README.txt/view
19:29jjidoI definitely plan to do something about the broken string model in my language.
19:29akhudekraek: It also appears to work in conjunction with my own project. I've pushed the code to my fork. Thanks for your help!
19:40qbgThe recent addition of ~350 interfaces is scary
19:42jjidoqbg: is that for handling all primitive type combinations?
19:42qbgYes
19:46dnolenqbg: why scary? it's pretty cool actually.
19:47qbgIt feels so wrong
19:54dnolenqbg: well the end result feels so right. fn w/ the speed of static which can be closed over and can interoperate w/ protocols.
19:57_rata_does anybody know how to "bookmark" emacs buffers for coming back later easily?
19:58qbgI 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:07dnolen_rata_: http://www.gnu.org/software/emacs/manual/html_node/emacs/RegPos.html#RegPos
20:07dnolen_rata_: tho I find it way faster to just use ido mode w/ fuzzy completion
21:08dashhowdy.
21:11NafaiHowdy dash
21:11dashSo I'm reading about Clojure and I keep tripping over the phrase 'persistent data structure'
21:11dashto me that means 'data structure on disk'
21:11dashbut obviously that's not what's implied
21:12dashhow did we end up with a confusing term like this? can I just say "immutable data structure" and mean the same thing? :)
21:12Nafaidash: that tripped me up as well when I've heard the term elsewhere
21:13NafaiI don't know the entomology though
21:13dashNafai: i blame my misspent youth working on orthogonal persistence
21:13tomojhttp://en.wikipedia.org/wiki/Persistent_data_structure
21:13Nafaidash: heh
21:13dashtomoj: yeah i know
21:13dashtomoj: but that doesn't really answer the question
21:14tomojwell
21:14tomojit doesn't answer whether you can say "immutable data structure" and mean the same thing
21:14tomoj(of course you can)
21:15dashand 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:15tomojseems pretty clear from the article that "persistent" and "immutable" don't mean the same thing, though
21:15dashbecause that's a common usage as well
21:53Anniepoo_how's the conj?
22:11xxpordoes anyone know of a lib for clojure that implements a graph data structure
22:11Anniepoo_not sure you need a lib. I've done it by using a netlist
22:12Anniepoo_what sort of operations do you need to do on the graph?
22:13mabesxxpor: I've not used it but I saw this lib the other day: http://github.com/jkk/loom
22:14xxporAnniepoo_: basicly traverse it and assign a color to each node based on the colors of connected nodes
22:16xxpormabes: that looks interesting, ill check it out, thanks
22:17Anniepoo_@xxpor - how big r ur maps?
22:18xxporAnniepoo_: 81 nodes
22:40qbgA 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:06trptcolinis this the quiet before the clojureconj storm? or just what happens on eastern time?
23:07Anniepoo_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_rata_when are they uploading the videos?
23:09cemerick_rata_: gotta wait 'till the talks are given, at the very least :-)
23:10_rata_hahahahaha :) yeah, but I want them :)
23:10trptcolincemerick: :)
23:12_rata_does anyone happen to know how to mark emacs buffers to come back easily afterwards?
23:18bhenry_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:21amalloy_rata_: C-x b uses fuzzy completion, so to get the repl you can type, eg, *re<TAB>
23:27bhenry_rata_ you could M-x rename-buffer RET 1 RET then C-x b 1 RET
23:28bhenrybut 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:29bhenryare 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:30amalloymaybe 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:31KirinDaveMan, is ab a liar?
23:31amalloyRail a basin am?
23:31bhenryalso, 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:31KirinDaveit says 7/10 reqs fail
23:31KirinDaveBut... uh, I can see on wireshark they are succeeding and my jetty logs say they're fire.
23:33tomojwhy does it say they failed?
23:34_rata_bhenry, that's a good idea :) I'll read about keyboard macros
23:35_rata_I hate when people say Scheme (or any other Lisp) is useless for real world
23:36KirinDavetomoj: It won't ay
23:36Anniepoo_Shhhhh..... You're letting our competitors know.
23:36KirinDavetomoj: When I do -v 5, it doesn't fail.
23:46amalloybhenry: 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:46amalloy(but that would make it such a lonely number)
23:48maharishihow do I turn (rest "foobar") into a string again I just get (\o \o \b \a \r)
23:49dakronemaharishi: (str (rest "foobar"))
23:49dakronenope, nevermind, that doesn't work
23:49maharishidakrone: thats what I thought it would be too
23:49dakronemaharishi: (apply str (rest "foobar"))
23:49KirinDave,(apply str (list \a \b \c))
23:49clojurebot"abc"
23:51maharishisweet, thanks, clojure is so damn cool
23:51Deranderwhy is apply necessary?
23:52dakronecalling '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:53Deranderthanks