#clojure logs

2010-10-27

00:04amalloyhmm. ninjudd, lancepantz, Raynes? anyone interested in some cake behavior i don't understand?
00:05Raynesamalloy: Shoot. I'll be slow to reply. Little busy at the moment.
00:08amalloyRaynes: i have a project on computer A, which i've mounted as a directory on computer B via sshfs. on computer B, cake repl works when i'm not inside the sshfs tree; on computer A, cake repl works anywhere. but on computer B, if i navigate into my project, cake repl hangs forever (this is after cake kill all on both machines)
00:09amalloyit warns me that the connection to the bake jvm is taking a long time
00:09RaynesThat sounds like a monster. Join #cake.clj and reiterate your question. If you don't get a reply tonight, come back tomorrow, or post it on the clojure-cake google group.
00:10tomojomg
00:10RaynesUnfortunately, I don't yet know enough about cakes internals to even know where to start on that one.
00:10tomoj32:35 in http://vimeo.com/15046335
00:23tomojoh, I see chouser explained things below for vimeo users :)
00:31cpfrhey how do I add essentially java jars to clojars?
00:33cpfrah I see I generate the pom file by hand
00:34amalloycpfr: you should be able to add them as deps
00:34amalloyin project.clj
00:34tomojyou can also install the jar into your local maven repo@
00:34cpframalloy, this is a jar that isn't in clojars yet
00:34amalloyif they're in a standard maven repo, anyway. if you have them locally you can put it locally
00:34tomojbut that can be annoying
00:34tomojyeah, search jarvana or mvnrepository or something
00:35cpfrI want it to be since I want people to be able to use this package more readily
00:40dnolenwow, awesome, http://landoflisp.com/
00:45tomoj:D
00:46trptcolindnolen: nice
00:51trptcolintechnomancy: pushed the plugin subtask help to the help ns, so everyone has access to that now through the meta :subtasks
01:01defnif anyone wants the audio from rich's talk on sort of a shaky pen microphone: http://db.tt/TK5M0ch
01:01defnit's listenable, but some of it is garbled
01:06tomojdefn: thanks!
01:07tomojwas someone getting video?
01:09defntomoj: yeah but no telling when it'll be online
01:10tomojjust good to know it will be out eventually
01:10defn:)
01:10defni have a "pencast" im putting up
01:10defni outlined the slides with my livescribe pen
01:10defnso you can see the headings while you listen to the audio
01:10tomojawesome
01:11tomojdoes the hand writing recognition work really well?
01:11defnit's more impressive than i thought it would be
01:11defnmy handwriting is so-so, but i do loopy d's and other little weird things
01:11defnbut it picks them up
01:11tomojyeah.. I'm very pessimistic about anything like that
01:11tomojcool
01:12defni mean it's not foolproof, you need to be conscious of it and draw something at least resembling the symbol you're trying to represent
01:12defnbut it's pretty liberal in its interpretation
01:12defni used it in a recent interview i had which was interesting
01:13defni could listen to my responses and their questions again
01:13defnand watch my notes as i went along
01:14tomojnice
01:14_seanc_Howdy folks, can anyone answer a quick question for a newbie?
01:14_seanc_I've been reading through a couple of clojure sites, but I have yet to find the meaning to '&'
01:15_seanc_like [x y & more]
01:15tomoj,((fn [x & rest] rest) 1 2 3 4)
01:15clojurebot(2 3 4)
01:15tomojit just gathers up the remaining args into a seq
01:15tomojnaming the seq with the symbol that comes after the &
01:16_seanc_fascinating
01:16_seanc_Clojure is so neat, but definitely intimidating
01:19bhenry1anyone experienced in writing lein plugins?
01:19bhenry1lein help lists my newly made plugin, but lein plugin-name says it's not a task
01:20defntomoj: did you see the cljc?
01:20defnhttp://github.com/jarpiain/cljc
01:21tomojno, wow
01:22tomojthat binfmt looks like it might be what I recently needed
01:28defn_seanc_: dont be intimidated. there's a feeling of confidence that comes with a little practice.
01:29defn_seanc_: you'll pick it up quick, just dont be expecting immediate feedback (until of course, you start up a REPL ;)
01:30defntomoj: i really have no idea what's going on in that source -- im trying to get my compiler chops up to par, any recommendations on books?
01:30tomojno, I know nothing about compilers
01:30defndragon book? i have been reading through lisp in small pieces...
01:30tomojI was a philosophy major
01:30defntomoj: i was a lot of majors, not CS... yet
01:32defnI figure I'll just teach myself compilers -- dragon book, steal some assignments from google's curriculum search, and boom
01:32defn(over the course of several months, possibly years ;)
01:37tomojI don't feel like I need to learn about compilers
01:37tomojI hope I'm right
01:37defntomoj: i dont think it hurts to get closer to the metal
01:37defnthere's a lot of open ground there for problem solving
01:37defns/open/fertile
01:38defnso many of the libraries out there that spring up are based on exploiting powerful language features, not other libraries
01:38defnthere's usually the core requirement of something that actually solves the problem you want to solve
01:38defnmashups are fun, but not as rewarding i think
01:41tomojcertainly doesn't hurt
01:41tomojjust doesn't sound like any fun to me :)
01:49zmyrgelhi, I'm trying to convert Hughes Why FP matters papers haskell code into Clojure but I'm not that good in Haskell to get it done
01:49zmyrgelcould somebody check my progress so far to give pointers: http://clojure.pastebin.com/Wbm1vXmy
01:50zmyrgelparticularry the haskell code starting no line 79 is odd to me to comprehend
02:00defnzmyrgel: wow. that is crazy code. sorry i cant help...
02:04zmyrgelI think thats what the code should look like compared to what my stuff is currently
02:04zmyrgelI'm trying to make chess engine in clojure and the lazy game tree would seem spot on to add to it
02:05zmyrgelProblems for the tasks are that I haven't done anything bigger in Clojure or any functional language which is apparent when looking my results :)
02:06duncanmsigh, i still can't haven't come up with a way that i'm comfortable doing this - i want a (foo {:a 1, :b 2} inc), that returns {:a 2, :b 3}
02:06duncanmi dunno how to write 'foo'
02:08tomojyou can't get anything working?
02:08tomojor the stuff you've got working has some unfavorable characteristics?
02:09duncanm(into {} (map #(vector (key %) (inc (val %))) {:a 1 :b 2}))
02:09duncanm,(into {} (map #(vector (key %) (inc (val %))) {:a 1 :b 2}))
02:09clojurebot{:a 2, :b 3}
02:09duncanmthat's so-so
02:09duncanmi guess i can call that update-map, kinda like update-in
02:09tomoj,(letfn [(foo [f m] (into {} (for [[k v] m] [k (f v)])))] (foo inc {:a 1 :b 2}))
02:09clojurebot{:a 2, :b 3}
02:10duncanmtomoj: i wish something like that were part of clojure.core
02:10DeranderI had to write something exactly like that in ruby for a project
02:10zmyrgelsimple question, is let* just and alias for let?
02:10duncanmzmyrgel: you don't need to think about let* in clojure, it's always let*
02:10tomoj,(macroexpand-1 '(let [x 1] x))
02:10clojurebot(let* [x 1] x)
02:11tomojhope not
02:11tomojthen every let infinite loops?
02:11duncanmi thought there's no difference between let and let* in Clojure, unlike, say, Scheme
02:12zmyrgellet* isn't even listed in API but it won't cause any errors / warnings either
02:12tomoj,(let [[x y] [1 2]] [x y])
02:12zmyrgelgotta clean up my code then a bit :)
02:12clojurebot[1 2]
02:12tomoj,(let* [[x y] [1 2]] [x y])
02:12clojurebotjava.lang.IllegalArgumentException: Bad binding form, expected symbol, got: [x y]
02:13tomoj,(macroexpand-1 '(let [[x y] [1 2]] [x y]))
02:13clojurebot(let* [vec__229 [1 2] x (clojure.core/nth vec__229 0 nil) y (clojure.core/nth vec__229 1 nil)] [x y])
02:14zmyrgelso let* is internal thing not to be messed around
02:14duncanmzmyrgel: so, in Scheme, if you use a let, later bindings cannot have to earlier bindings on the RHS
02:14duncanmwait, i think i got that backwards
02:14zmyrgelyep, I know. I did some small snippets in Scheme before
02:14duncanmzmyrgel: so in Clojure, all lets have let* semantics
03:02duncanmdum de dum
03:08amalloyduncanm: dum be doo, even?
03:15notsonerdysunnyhow can I avoid the slime from bringing up the backtrace when I know that I am handling the exception in a try-catch block?
03:16notsonerdysunny,(try (/ 1 0) (catch IllegalArgumentException e (prn "in catch")) (finally (prn "in finally")))
03:16clojurebotnotsonerdysunny: No entiendo
03:16amalloynotsonerdysunny: i'm surprised it doesn't do that already. i'll take a look
03:16notsonerdysunny~(try (/ 1 0) (catch IllegalArgumentException e (prn "in catch")) (finally (prn "in finally")))
03:16clojurebotthe leiningen screencast is on full disclojure: http://vimeo.com/8934942
03:17notsonerdysunnythanks amalloy
03:20amalloynotsonerdysunny: are you sure it's trapping on the exception you throw, and not some other exception? i'm having trouble reproducing but my swank setup is kinda weird so it could be me
03:21notsonerdysunnycan you just try the above expression...
03:21notsonerdysunnyI presume the above s-exp should go through fine..
03:21amalloynotsonerdysunny: it's some kind of classpath issue
03:22amalloywhen i run your sexp, i get an erithmetic exception just like you
03:22amalloybut try changing it to (try (/ 1 0) (catch Throwable e (prn "in catch")) (finally (prn "in finally")))
03:22amalloy,(try (/ 1 0) (catch Throwable e (prn "in catch")) (finally (prn "in finally")))
03:22clojurebotamalloy: Gabh mo leithscéal?
03:23notsonerdysunnyamalloy: yea it goes through fine
03:23amalloyfor me that works, and i don't know why, but i think it's something to do with trouble finding the ArithmeticException class in some weird env. sorry i can't help more, i'm just off to bed
03:23notsonerdysunnythanks amalloy ... I will look around a little more
03:23amalloygood luck'
03:23notsonerdysunnyamalloy: good night
03:26notsonerdysunny~(try (/ 1 0) (catch Throwable e (prn "in catch")) (finally (prn "in finally")))
03:26clojurebotclojurebot will become skynet
03:26notsonerdysunny->(try (/ 1 0) (catch Throwable e (prn "in catch")) (finally (prn "in finally")))
03:26sexpbot⟹ "in catch" "in finally" nil
03:26notsonerdysunny,(try (/ 1 0) (catch Throwable e (prn "in catch")) (finally (prn "in finally")))
03:26clojurebotnotsonerdysunny: excusez-moi
03:27notsonerdysunny->(try (/ 1 0) (catch IllegalArgumentException e (prn "in catch")) (finally (prn "in finally")))
03:27sexpbotjava.lang.ArithmeticException: Divide by zero
03:29edbondhow to change a vector several times? Suppose I have changes vec [[1 4] [2 3]] in form [index value]
03:29notsonerdysunny,(try (/ 1 0) (finally (prn "in finally")))
03:29clojurebotnotsonerdysunny: Titim gan éirí ort.
03:29notsonerdysunny->(try (/ 1 0) (finally (prn "in finally")))
03:29sexpbotjava.lang.ArithmeticException: Divide by zero
03:34hoeck,(apply assoc [:a :b :c] (apply concat [[1 4] [2 3]]))
03:34clojurebot[:a 4 3]
03:34hoeckedbond: ^
03:34notsonerdysunnyHow do i increase java heap space
03:34notsonerdysunnyis there a limit that is preset?
03:35notsonerdysunnycan I change it? I am using cake+slime+emacs
03:35v-alexnotsonerdysunny: -Xmx512m
03:35v-alexnotsonerdysunny: see also java -X
03:35sandGorgonnotsonerdysunny, try "java -X" to see all X options. The heap options are -Xms and -Xmx
03:36notsonerdysunnythanks sandGorgon and v-alex
03:37edbondhoeck: thanks
03:49raek,(reduce (fn [v [i x]] (assoc v i x)) [:a :b :c] [[1 :x] [2 :y]]) ; <-- another variant
03:49clojurebot[:a :x :y]
03:59hoeck,(reduce (partial apply assoc) [:a :b :c] [[1 4] [2 3]])
03:59clojurebot[:a 4 3]
04:00raeknice.
04:07TobiasRaedermorning everybody
05:19eMortiferusanyone know if there is a defacto way of checking what record-type some "thing" is of?
05:19eMortiferusI have problem getting instance? to work reliably
05:19AWizzArdeMortiferus: can you give an Example?
05:20eMortiferus(defrecord lterm [var body]
05:20eMortiferus T (t [this]
05:20eMortiferus (println (type body))
05:20eMortiferus (println (instance? lterm body))
05:20eMortiferus (if (instance? lterm body) (println "int "))))
05:20AWizzArd(defrecord Foo []) ... (class (Foo.)) ==> your.namespace.Foo
05:20eMortiferusif I do (t (lterm. :x (lterm. :y :z)))
05:20eMortiferusI get:
05:20eMortiferususer.lterm
05:20eMortiferusfalse
05:20eMortiferusnil
05:21eMortiferusSo the type of body is user.lterm, but not (instance? lterm body)
05:22angermanhmm.... the error "Unable to resolve symbol" is not very helpful with a backtrace that doesn't tell me where to look ://
05:22AWizzArdeMortiferus: (instance? YourRecord obj) would work.
05:22AWizzArdHallo angerman
05:23angermanhi AWizzArd
05:24eMortiferusAWizzArd: Yeah, but then the above example should print true, not false. Could it be in the way I denote "MyRecord"? Now I write (instance? lterm body), I also tried writing (instance? user.lterm body), but then the loader complains
05:26eMortiferusAWizzArd: It should be said that it did work a while, then I did some more development, and it stopped working, which made me unsure if (instance? .. ..) should work or not. If it is supposed to work then maybe this is an artifact of me not restarting the clojure session for 4 days, and some old and new versions of the classes are hanging around?
05:28ChousukeI don't think the class is available during definition of the record :/
05:28AWizzArdeMortiferus: try (do (defrecord Foo []) (instance? Foo (Foo.)))
05:29AWizzArdIf it is not available then the compiler should throw an error.
05:29eMortiferusAWizzArd: that returns true, but it seams to do something else then my example
05:30eMortiferusAWizzArd: pardon my clumsy terminology, but it seams to check if the "Class" Foo is (instance? Foo (Foo.)), while I want to check if an "instance" of Foo is of type Foo
05:31eMortiferusAWizzArd: Ahh forget what I said, I understand now that (Foo.) makes an instance
05:34hoeckeMortiferus: to, it looks like the instance? check uses the old version of lterm, the one that was present before compiling the defrecord and loading the new class
05:34hoeckeMortiferus: if you do a (let [c lterm] (instance? c body)) it returns actually true
05:34AWizzArdeMortiferus: (do (defprotocol Lala (bar [this])) (defrecord Foos [x] Lala (bar [this] (println (class this) (instance? Foos this)))) (bar (Foos. 1)))
05:35hoeckI'm on clojure 1.2, btw
05:35AWizzArdThis returns true for the instance? check for me.
05:35eMortiferus"user> (do (defprotocol Lala (bar [this])) (defrecord Foos [x] Lala (bar [this] (println (class this) (instance? Foos this)))) (bar (Foos. 1)))
05:35eMortiferususer.Foos false
05:35eMortiferusnil
05:35eMortiferususer> "
05:36AWizzArdeMortiferus: for me this results in user.Foos true
05:38TobiasRaederreturns false for me aswell :/
05:38eMortiferusAWizzArd: Interesting, I will restart my clojure session and see what happends.
05:38TobiasRaederwhat version clojure your running AWizzArd?
05:38eMortiferusAWizzArd: This is btw the code I am trying: http://pastebin.com/yVskNgUx
05:38Chousukehave you restarted the jvm?
05:39Chousukeredefining the record might be causing trouble
05:39eMortiferusChousuke: No, it has been running for quite some time, with several iterations of the development, I restart it now and try
05:40eMortiferusI am using "Clojure 1.2.0" btw
05:40TobiasRaederi just tried it with a clean emacs
05:42eMortiferusMe too, does not work wit a fresh emacs/slime
05:44AWizzArdI am using Clojure 1.3 Alpha 1.
05:44TobiasRaederah :) im using1.2 aswell
05:44TobiasRaederthat might be it
05:44AWizzArdyup
05:46eMortiferusAWizzArd: I will try 1.3 Aplha 2 and see what happends here
05:48eMortiferusAWizzArd: With 1.3A2 it works :D
05:48eMortiferusThanks for the help everyone
05:48AWizzArdeMortiferus: but there may be other things in A2 which will not work.
05:48AWizzArdIt is still a fast moving target.
05:49eMortiferusAWizzArd: yeah I know, but this is just private play-code, so if I find bugs it is no crisis, I will submit bugreport and wait till it gets fixed:p
05:49AWizzArdgood
06:53zmyrgelCould somebody aid me defining the taketree function on line 140: http://clojure.pastebin.com/Wbm1vXmy
06:53zmyrgelit seems to need partial but how to make it work with the 'n' parameter?
06:55Chousuke(redtree (partial nodett n) ...)?
06:57Chousukeoh, I suppose you need the subtree argument too
06:57Chousukein that case it would be (defn taketree [n subtree] (redtree (partial nodett n) cons nil subtree))
06:58ChousukeClojure doesn't have currying like Haskell so you can't translate too literally :P
06:58zmyrgelI've noticed that
06:59Chousukespecifically, if you call (foo bar) for a function foo of two arguments, it won't give you a function of one argument
07:00Chousukeit would be nice if it did but unfortunately that's not feasible to implement in Clojure :/
07:00zmyrgelthat needs the partial function?
07:00Chousukeyeah
07:00zmyrgelslowly starts to getting these stuff
07:00Chousukeor you can use the fn shortcut reader macro: #(foo bar %)
07:01Chousukewhere % = %1 = first parameter
07:02zmyrgelWell, my current fixed version starts to seem pretty ok, we'll see how it works once I get it included to my chess engine project :)
07:59fliebelIs there any way I can 'reset' a zipper, short of doing root and then make a new zipper? I made a few functions that use a zipper, but threading the zipper through them would leave the successive functions with some random loc where the previous function left of.
08:17zmyrgelhi, do these let forms yield same result: http://clojure.pastebin.com/wC9UmPMJ
08:31hartohello - anybody know how to add jars to classpath for cake tasks?
08:32hartoi.e. my tasks.clj depends on an external lib, which is a project dependency, but I'm getting class not found
08:38mister_robotoit seems like all the samples i see lately are using (fn [] foo...) rather than #(foo ...) is the latter syntax considered ugly or something? wondering about the idioms
08:50fogus_mister_roboto: It often comes down to personal style.
08:50mister_robotofogus_: ok. i was wondering if #() was starting to be a "deprecated" style
08:50fogus_not at all
08:51mister_robotootherwise it seemed overly verbose for a lot of the one-liners i see posted here
08:51mister_robotobut thanks!
09:20tonylgood morning
09:20arkhtechnomancy: thank you - if that was covered at the conj then I missed it o.0
09:43technomancyarkh: it wasn't mentioned; it's pretty new.
09:46TobiasRaeder@arkh, technomancy did i just miss something? whats new? :o
09:47technomancyTobiasRaeder: $ java -cp [...] clojure.main -m my-non-aotd.namespace
09:48technomancyuses the -main defn in that ns
09:48TobiasRaederah nice :D
09:48TobiasRaederthanks
09:49arkhthat seems like a good option to have
09:50fliebelI only wonder wh… Oh, m for main of course.
09:50fliebeltechnomancy: I assume that also includes args?
09:50technomancyaye
09:51technomancyreduces the need for AOT; a lot of people use AOT only for -main
09:51technomancyFSVO a lot
10:10apgwozare people here using plain ole paredit.el, or is there a clojure specific paredit.el that handles clojure's Character type better?
10:11tomojparedit-beta.el
10:11tomojI haven't noticed any char problems
10:11apgwozthis morning I found myself really annoyed when doing case statements with \c, etc, which paredit proper uses \ as an escape key
10:12tomojwhy does that cause problems?
10:12tomojparedit-beta.el does the same
10:13apgwozbecause it turns the character into an integer as far as emacs is concerned, and not the string "\c" for which clojure's reader can read
10:14hiredmanI've never had problems with character literals in emacs
10:14apgwozmaybe i should just update paredit
10:14tomoj\ is paredit-backslash?
10:14apgwozyes
10:16apgwoztwo things are possible, i'm either making shit up, or doing something incredibly wrong
10:16apgwozi tend to think i'm doing something wrong (maybe just using an old paredit)
10:17apgwozsince, i don't see the wrong behavior at work right now, but saw it this morning on my laptop, to the point where i turned off paredit when editing characters.
10:57bhenry1Ruby Learning Clojure 101 activity has died off in the final two weeks.
11:44_rata_hi
12:00_rata_has anybody seen jkkramer?
12:03stuarthallowaychouser: did you ever get the clojure projtools stuff to do a secure GET from assembla?
12:04chouserstuarthalloway: I don't remember, let me check.
12:05stuarthallowayI have some modifications to the code...
12:05duncanmis there a common predicate to identify both a PersisentList and a PersistentVector?
12:05duncanm,[(seq? (vector)) (seq? (list))]
12:05duncanmhmm
12:05duncanmno response
12:06stuarthallowayhttp://paste.lisp.org/display/115960
12:06stuarthallowayI am trying to do an HTTP GET of the user profile that returns the email address as well as the id, which requires that one be logged in
12:07stuarthallowayif I could get that to work, I could move all the accounts from assembla to Crowd/JIRA/Confluence
12:07MayDanielduncanm: sequential? ?
12:08duncanmMayDaniel: ah, thanks
12:09technomancystuarthalloway: jweiss mentioned last night he may be able to help with the jira migration
12:09stuarthallowaytechnomancy: I emailed him back but got bounced
12:09chouserstuarthalloway: I must have been able to log in -- I was using the script to attach patches to tickets and such
12:10stuarthallowaytechnomancy: the next step is deciding what the next step is. Please have jweiss look over the site and make a list of things he thinks need doing
12:10jweissstuarthalloway: that's odd - sorry about that. try jeffrey.m.weiss@gmail.com
12:10chouserstuarthalloway: http://github.com/Chouser/clojure-projtools/blob/master/src/net/n01se/clojure_projtools.clj#L43
12:11stuarthallowaychouser: I see it in the code, but haven't been able to get it to happen
12:11stuarthallowayNot worth too much effort here: I can scrape the 120 users by hand, or people can recreate the accouns on their own
12:12chouserok. it's entirely possible they've changed things on their side since I last used this code.
12:12jweissstuarthalloway: a selenium ide script might work - i have written those before
12:12jweissto read the fields from the webui and type em in on the new one (if there's a simple mapping)
12:16LOPPguys I have a problem with using recur
12:17LOPPstand-by for code
12:17LOPPuser> (defn get-no-markup [seqe num-open-bracket]
12:17LOPP (if (empty? seqe)
12:17LOPP seqe
12:17LOPP (case (first seqe)
12:17LOPP \< (recur (rest seqe) (inc num-open-bracket))
12:17LOPP \> (recur (rest seqe) (inc num-open-bracket))
12:17LOPP :other (if (= num-open-bracket 0)
12:17LOPP (cons (first seqe)
12:17LOPP (recur (rest seqe) num-open-bracket))
12:17LOPP (recur (rest seqe) num-open-bracket)))))
12:18LOPPbasically the function returns input character sequence with parts left out that are within tags
12:18LOPPhowever it won't let me use recur like that
12:18LOPPeven though it's the last sentence in each code path
12:19LOPPwhat do I do?
12:19MayDanielLOPP: recur needs to be in tail position
12:19LOPPthat makes it damn useless
12:20jweisslopp, just turn your code inside out to calc the values to pass to recur *inside* the recur form instead of outside
12:21LOPPoh god
12:22LOPPthat will make some buttugly code
12:22dnolenLOPP: please use a pasting service
12:22LOPPwhat's that?
12:22MayDanielLOPP: gist.github.com
12:22LOPPoh I see what you mean
12:22LOPPlike pastebin
12:23chouserrecur is for tail recurion. If you don't want tail recursion, use regular named-function recursion.
12:24jweissLOPP - something like (recur (rest seqe) (if ... case... ))
12:24jonasenA simple example generating Pascal's triangle using chousers new double-list: http://gist.github.com/649317
12:25LOPPchouser but then I will blow the stack]
12:25LOPPthe string HTML page sized
12:26chouserLOPP: that's true in really every language -- if you aren't using tail recursion, you will consume stack, regardless of whether or not your language has a special 'recur' keyword.
12:26LOPPjweiss: right I can do that but where do I call cons?
12:27chouserjonasen: you're using double-list! yay! :-) Note that conls will probably be renamed to conjl soon, but will act exactly the same.
12:27chouserconsl -> conjl
12:27LOPPhttp://pastebin.com/YJK5btCx
12:27LOPPhere's my second try
12:27LOPPwith single recur invocation right at the end
12:28LOPPstill doesn't work :(
12:28chouserthat's not the tail position
12:28LOPPwhat would be a tail position?
12:28chousersee, this is actually good.
12:29chouserin langauges like scala and scheme that do tail-call optimization, one could write code like this and believe it was safe from blowing the stack, but be wrong.
12:29jonasenchouser: It's fun to try all this ne stuff in Clojure..
12:29LOPPOh I thought you liked the code :(
12:29chouserclojure's helping you learn what the tail position *isn't*. :-)
12:29LOPP:D
12:30LOPPI am unsure about the "correct" way to do this kind of sequence processing
12:30chouserLOPP: try thinking of it this way: the tail position is where an expression will be the return value of the outer expression.
12:30chouserso, in (do a b c) the tail position is c
12:30LOPPso the second one fails because recur should be in position of apply?
12:30chouserin (if foo? x y), both x and y are tail positions
12:31MayDanielLOPP: With `case`, you don't need an :else/:other/:default to match a default clause.
12:31chouserLOPP: generally to convert a non-tail recursive fn to a tail-recursive one, you have to add a new argument to act as an accumulator of what you will eventually return.
12:31LOPPin other words it fails because I have apply wrapped around recur in return expression?
12:32chouserLOPP: right. In (apply foo bar) or (+ a b c), none of the interior items [foo, bar, a, b, c] are in a tail position
12:32LOPPok, do you reckon using let sentence in such fashion is constructive or is the first version better?
12:33LOPPI'm having a hard time with design in clojure since I'm used to imperative thinking
12:34LOPPin java I'd probably go with string buffer, a for loop, and I'd add the right characters to string buffer
12:35amalloyLOPP: the idea is very much the same in clojure. you need an accumulator of some sort, like a stringbuilder, which you append to and pass along with each instance of recur
12:35dnolenLOPP: the beauty of tail recursive functions is that they can be composed, you can't compose for loops. you just have to write them over and over again. Depending on what text editor you use, you might not notice ;)
12:36LOPPamalloy: so you recommend using a mutable java object like string buffer to store the result rather than clojure seq?
12:36amalloyno
12:37LOPPok...a vector then?
12:37amalloysure, something like that
12:37amalloyhave you seen a tail-recusive version of summing a list?
12:38LOPPI can't see using cons in this case since it adds to the front, so I'll need something that is cheap to add in the back
12:38amalloyLOPP: vectors add in back cheaply
12:38LOPPand using str to append to string at the end will probably be slow as hell
12:38chouserAnother option is to use the 'reduce' function.
12:39chouseranytime you can use loop/recur you could also use reduce, though it's not always better.
12:39amalloy,((fn [sum [x & xs]] (if x (recur (+ x sum) xs) sum)) 0 [1 2 3 4 5 6])
12:39amalloyclojurebot: ping?
12:39amalloy->((fn [sum [x & xs]] (if x (recur (+ x sum) xs) sum)) 0 [1 2 3 4 5 6])
12:39sexpbot⟹ 21
12:40LOPPhm
12:40amalloyLOPP: you see how i've added a sum parameter, which is used to track intermediate results? it doesn't have to be mutable, because i replace it with a new number every time i recur
12:40jsandahey folks, i'm trying to extend a protocol on a java type and getting the error message, "interface core.Translatable is not a protocol" and i don't understand that because prior to this code in the same file i extend the protocol on a defrecord
12:40LOPPthough concatenating strings probably has same cost as making a shitload of new vectors each step
12:40replacaLOPP: one option that people use is simply to accumulate a sequence of strings (or generate one by map or some such) and then apply str to the result
12:41jsandacan anyone shed some light on that error?
12:41chousernote that it's recuring on (at least) two args: the accumulator (sum) which is growing, and the input ([x & xs]) which is shrinking
12:41LOPPaha
12:42amalloyLOPP: appending to vectors isn't that expensive, because they're persistent and can have pointers to the same data
12:42LOPPyou think I'm better off using them rather than str function?
12:42amalloymeh. i don't know what your actual problem is; i joined after that
12:43amalloyi'm just demonstrating tail recursion
12:43LOPPaha
12:45amalloywhat is your actual goal, anyway?
12:45LOPPto throw tags out of a piece of HTML
12:45LOPPI don't need any fancy parsing
12:45chousernested angle brackets even, which aren't actually valid html
12:46LOPPI just want everything between < and > to disappear
12:46LOPPI know
12:46amalloyLOPP: use a regex global replace instead?
12:46LOPPI haven't thought of that
12:46amalloyor are you using this as a learning problem to figure out recursion in clojure?
12:47LOPPI was thinking I can use regex, then I remembered I can match things but not delete things with regex
12:47LOPPnow I realize how stupid of me
12:47chouser(clojure.string/replace "this<is>ok" #"<.*?>" "") ; doesn't handle nested brackets
12:47LOPPjust replace with ""
12:47LOPPyeah...what a brainfart
12:47LOPPI don't think I'll need to handle nested
12:47chouserbut tail recursion is really useful to understand
12:47LOPPI know
12:47chouseras is correct use of HOF like 'reduce'
12:48chouserso we're happy to help with those if you're still interested. :-)
12:48LOPPfirst I'll have to try out earlier suggestions
12:48LOPPbeen busy typing
12:48amalloychouser: fwiw, .*? is much slower than [^>]*
12:48LOPPfwiw?
12:49amalloyfor what it's worth
12:49chouseramalloy: ok
12:49LOPPah
12:49LOPP:)
12:49LOPPI thought all regexes are about the same
12:49LOPPsince it compiles into a state machine?
12:49LOPPor am I wrong yet again
12:50amalloywell your second statement is correct
12:50chousercan backtracking regex engines compile to a state machine?
12:50LOPPok backtracking...
12:50LOPPbut using a reluctant quantifier
12:50LOPPshouldn't be slower IMO
12:51amalloythe state machine created by .*? is much slower at matching because of the way *? is implemented
12:51LOPPtransitioning a state is a constant time operation IMO
12:51amalloyone sec i'll find the link
12:51LOPPand with each character you do 1 state transition
12:52amalloyhttp://www.regular-expressions.info/repeat.html
12:52amalloycontains, in fact, a discussion of how to match html tags
12:53amalloyand near the end, under An Alternative To Laziness, it explains why .*? is slow
12:54LOPPread it
12:54LOPPinteresting
12:55LOPPso while transitioning states is constant
12:55LOPPyou need to consider each character multiple times if you need to do backtracking and your regex does the least backtracking
12:55amalloyyeah, in fact it does no backtracking at all
12:56amalloythat page is fantastic if you want to get better acquainted with regexes
12:58LOPPoh java, you so crazy
12:59LOPPon another topic, if clojure gonna get ported to Java 7 anytime soon?
12:59technomancyclojure runs fine on openjdk 7
12:59LOPPI see it will have some kind of support for dynamically typed languages
12:59LOPPof course
12:59LOPPthat's not the same as port :)
13:00LOPPall java code runs fine on newer version than it's compiled for
13:00LOPPthat's directive #1 on Oracle's list
13:01cemerickadding support for invokedynamic would hardly qualify as a "port" IMO
13:01LOPPcemerick: I am unaware about the actual extent of new stuff
13:02cemerickThat would be the biggest item, and it's "just" an optimization.
13:02LOPPthe only interesting thing for me in Java 7 is the array bounds check elimination optimizer
13:02cemerickNow, ClojureCLR, *that's* a port. Poor dmiller2718 ;-)
13:03LOPPthey are gonna drive Java into the ground with all these featureless versions
13:03LOPPcan't wait for CLR port...C# is a tons better language
13:04cemerickIf you're using Clojure, why do you give a toss about Java vs. C#?
13:07LOPPwell.. if you are working with Windows
13:07LOPPC# gives you easier access to Win32 and DLLs with PInvoke
13:07LOPPit also have better gui
13:07LOPPanchors > layout managers
13:08cemerickwell, fair enough, but that's due to the CLR and .NET, not C#
13:09LOPPwith java you break your balls to make your app have an icon with menu in task bar or if you want to make it a service
13:09LOPPok that's true...it's not different as far as using a clojure goes
13:09cemerickYou should check out swt sometime. There's lots of thick-client goodness in there.
13:10LOPPit's just that Sun/Oracle is so frustratingly incompetent at adding language features
13:10LOPPI work with java and I rage every day
13:10LOPP"C# HAD THIS 5 YEARS AGO JESUS CHRIST"
13:11cemerickBreathe, man, breathe.
13:11cemerick:-)
13:11LOPP:D
13:11LOPPif you don't work with java you won't understand this
13:11cemerickI still do, I get you.
13:12cemerickThere are upsides to the glacial rate of language change though.
13:12LOPPI was ecstatic when I worked with delegates and C# properties
13:12LOPPand events
13:13LOPPholy crap that alone would solve like 95% of my java problems
13:14LOPPand that was in 3.0, now they have added lambda functions, lazy sequences, multi methods
13:14KirinDave So, I'm still staring a bizarre problem in the face.
13:14KirinDaveI have a gen-class form with a static method
13:14KirinDaveAnd when I try and compile, the compiler complains a var that is clearly bound is in fact unbound.
13:18dnolenKirinDave: sounds like you're using 1.3.0-alpha2 ?
13:19chouserno, I think he said 1.2. He means a method marked as static in gen-class
13:21dnolenchouser: I see.
13:21KirinDave_Sorry, my network is unreliable
13:22KirinDave_This is the module I'm trying to compile: https://gist.github.com/be11b181842fce78ade5
13:22KirinDaveThis is the module that it complains about, and the error: https://gist.github.com/47de41199aabd74df3c0
13:23KirinDaveIt makes no sense, because if I load the module (after clearing the .class files, of course), it loads just fine.
13:23KirinDaveAnd protocol-machine only does one simple thing right now: https://gist.github.com/b26834d128610b428f2b
13:24cemerickKirinDave: have you fixed the :static metadata in core yet?
13:24KirinDavecemerick: Yes
13:24KirinDaveThere, updated.
13:25cemerickok; and you can load the namespaces in question without any AOT artifacts, but you cannot load the resulting gen-class'ed classfile without getting the error?
13:25KirinDavecemerick: As long as I don't have the compiled files around
13:25KirinDaveWhat's really weird
13:25KirinDaveis that the compile works the first time
13:25KirinDaveSubsequent compiles (and loads) fail.
13:25KirinDaveIf I delete the class files, it all works.
13:25cemerickWell, that's not actually odd.
13:26LOPPdoesn't the newest version have static vars by default?
13:26LOPPI remember hearing something along these lines
13:26cemerickThe compiler looks for previously-compiled classes, and loads them if they're there instead of loading the source file. So, the problem is the loading of compiled classfiles.
13:26KirinDaveRight.
13:26KirinDaveSo does this suggest some sort of error in the way clojure is compiling these files?
13:26cemerickhave you tried just throwing a (def b13 :foo) at the top?
13:27KirinDaveNo, i suppose it'll be re-def'd
13:27cemerickwell, that's what adding the dummy would test
13:28KirinDavecemerick: So, now it complains about b12
13:28cemerickok, good
13:28KirinDaveMaybe instead of declaring the vars, I should def identity them.
13:29cemerickSure, add dummies for all of those nodes in the graph.
13:34KirinDaveAh, it worked.
13:34KirinDavecemerick: That's... really weird.
13:34KirinDaveBecuase I _do_ def the symbols.
13:34KirinDaveBut if I remove all declares and instead predef the symbols
13:34KirinDavethen it works.
13:35cemerickyeah, I think it's an oddity w.r.t. :static that might not apply anymore
13:35cemerickchouser: I presume this is the cause of KirinDave's troubles http://github.com/clojure/clojure/blob/master/src/clj/clojure/genclass.clj#L205
13:36cemerickoh bugger, nevermind
13:36KirinDave??
13:36cemerickit's been a *long* time since I looked at genclass.clj
13:36cemerick:-(
13:37KirinDaveSo I can only interpret that as a bug.
13:37KirinDaveUnless it's documented somewhere...
13:38cemerickPerhaps. Don't take my word for it.
13:38cemerickThe specific lifecycle of an AOT init class is a mysterious thing.
13:53kumarshantanuhi, I am looking for a way to find the current namespace...can somebody throw a pointer?
13:53cemerick*ns*
13:53Raynes-> *ns*
13:53sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/*ns*)
13:53RaynesHeh.
13:54kumarshantanucemerick: thanks!
13:56cemerickKirinDave: In any case, if you can distill that into a 10-liner example, that'd be a good bug report.
13:56KirinDavecemerick: I think I can
13:57cemerickReading the genclass source, I don't see why changing the static param into emit-forwarding-fn should impact the semantics of the loading of required namespaces.
14:05LOPPclojure doesn't have a fn for regex find+replace?
14:05sethtrainLOPP: clojure.contrib.str-utils.re-sub
14:05Raynes(find-doc "re-")
14:06RaynesThere is a replace function in clojure.string
14:06RaynesBut, you might as well just use .replace
14:06LOPPwell
14:07LOPPgotta install some build tools for clojure already
14:07LOPPcan't even use this contrib stuff
14:07Raynesclojure.string isn't contrib.
14:12LOPPwhat's the difference between use and require?
14:12dnolenclojurebot: use
14:13dnolenI forget how do you ask clojurebot something?
14:13nDuffLOPP, whether the references are made available under their own namespaces or copied into the local namespace
14:13dnolenor is he out of commission?
14:13raekLOPP: the difference is how you refer to the vars of the other namespace
14:14cemerickclojurebot's been down for a while
14:14raek(require 'foo.bar) (foo.bar/some-function ...)
14:14cemerick-> (println "Enter sexpbot!")
14:14sexpbot⟹ Enter sexpbot! nil
14:14raek(use 'foo.bar) (some-function ...)
14:14Rayneshttp://stackoverflow.com/questions/3408076/difference-in-clojure-between-use-and-require
14:14raekLOPP: ...but mostly you use these with the :as and :only options:
14:15raek(require '[foo.bar :as bar]) (bar/some-function ...)
14:15raek(use '[foo.bar :only (some-function)]) (some-function ...)
14:15raek:as introduces a shorter alias for the namespace
14:16hiredmanping?
14:16raek:only makes use only make some of the vars available without namespace prefix (in any case, you can always us the full namespace qualified name)
14:17Rayneshiredman: Have you considered factoring out your sandboxing stuff into a separate library? Maybe contribify it.
14:29jlaskowskihi
14:29jlaskowskiin c.c.monads
14:30jlaskowskithere's flatten* function used
14:30jlaskowskiwhere can I find what it does?
14:30jlaskowskiI can find the one without the star
14:30jlaskowskibut not the one w/ it
14:32raekyou could do something like this:
14:32raek(in-ns 'clojure.contrib.monads)
14:32raek(resolve 'flatten*)
14:32raekthat will tell you where it is defined
14:32lrennit's private.
14:32lrennhttp://github.com/clojure/clojure-contrib/blob/master/modules/monads/src/main/clojure/clojure/contrib/monads.clj
14:33jlaskowskiis it idiomatic to name private functions this way?
14:34raekno, the asterisk usually means something like "related variant to"
14:34tomojdefn: happen have that keynote audio link handy still?
14:34raeklike bound-fn and bound-fn*
14:35jlaskowskithanks
14:35jlaskowskithat helped a lot
14:35jlaskowskifound it
14:45KirinDaveSo, static gen-class methods in my project, just totally broken. :\
14:46KirinDavePretty brutal as brutal things go
14:48cemerickKirinDave: def'ing as opposed to declaring the vars is a no-go?
14:48KirinDavecemerick: Oh it works
14:48KirinDaveAs in it doesn't fail
14:48KirinDavebut now it doesn't generate the static method
14:48cemerickyou've done a clean build?
14:49KirinDaveYes
14:50cemerickwhat happened between the time it was generating the static method and now?
14:50Raynesivey: I merged pushed your karma plugin to master. I lowered the default karma value to zero (makes more sense to me) and added some cooldown functionality so as to not encourage abuse.
14:51KirinDavecemerick: It was never generating the static method
14:51KirinDavei just got it to stop bailing with that erroneous error on compile
14:52KirinDaveaha, progress
14:53cemerickKirinDave: https://gist.github.com/69ec769dc32b2995fae7
14:53cemerickstatic methods in genclass work
14:53cemerick(honestly) :-)
14:53LOPPRaynes: talking about Karma STM Conflict resolver?
14:53KirinDaveI think they do
14:53KirinDaveBut
14:53KirinDaveI suspect something I am doing is pissing them off.
14:53KirinDaveWouldn't be the first time something worked fine except in AOT.
14:53RaynesLOPP: A sexpbot plugin.
14:53KirinDave... Honestly i am starting to wonder if i made a mistake picking clojure for this project tho
14:53cemerickThem? heh
14:54KirinDaveI'm watching my co-worker hit a lot of problems trying to get scala to talk to clojure cleanly
14:54KirinDaveSure, this code worked well
14:54LOPPyou work with scala and clojure? :) lucky guy
14:54cemerickKirinDave: problems, meaning?
14:55KirinDavecemerick: Poor Thomas is just having a hell of a time trying to pass things into clojure functions, for example.
14:55cemerickPuzzlement. Why?
14:55KirinDaveAnd clojure maps trying to be java.lang.Maps but there are no template parameters.
14:56alpheusIs it dumb of me to put gigantic data structures into a set to get rid of duplicates?
14:57chouserI wrote a clojure library that is consumed effortlessly by our Java programmers
14:57chouserusing gen-class with static methods, among other things.
14:58Raynes(inc ivey) for writing a neat karma plugin :>
14:58sexpbot=> 1
14:59iveyRaynes: very cool. i'll pull so i can see the cooldown code
15:01cemerick(inc chouser), FWIW
15:01sexpbot=> 1
15:01cemerickwha?
15:01cemerick(inc chouser)
15:01chouser(inc cemerick), for (inc chouser)
15:01cemerickhrm
15:01sexpbot=> 2
15:01sexpbot=> 1
15:02cemerickwaitaminute, karma?!
15:02cemerickThis is going to either get fun or be a disaster. :-)
15:02KirinDave_chouser: Maybe at some point I could offer you some sort of wonderful favor in exchange for some insights on java interop
15:02KirinDave_chouser: Chief among my problems is passing maps back and forther.
15:02KirinDave_err, forth.
15:03KirinDave_Like, we need to exchange freeform data. Clojure is exceptionally good at this and Java, not so much.
15:03Raynescemerick: Probably the latter. Hopefully the fact that you can't adjust someone's karma more than three times in 5 minutes will discourage abuse.
15:03chouserhm, I don't think we used maps. I think everything I offer the Java side implements an appropriate interface, so they're always calling specific methods of my objects.
15:03KirinDave(dec KirinDave_)
15:03sexpbot=> -1
15:03KirinDaveAwww
15:03cemerickKirinDave: is j.u.Map not good enough somehow?
15:04KirinDaveWell
15:04KirinDavecemerick: Evidently because it doesn't provide template parameters there is some problem.
15:04KirinDaveOr so Thomas said. I have no effin' clue.
15:04KirinDaveThat's what I thought it'd be.
15:05chousercan he not cast the map to a specific type of generic map?
15:05cemerickclojureMap.asInstanceOf[Map[KeyType, ValueType]]?
15:05chouserI never did try to put scala and clojure in the same project
15:06chouserfogus_: have you?
15:07cemerickI did in the very early days.
15:07cemerickHaven't in many years though.
15:07fogus_chouser: Just as an exercise. Not in a production env.
15:15ataggartis anyone aware of a way to resolve ambiguous method resolution when dealing with nill args?
15:16chouserwe
15:16chouserew
15:16chousermaybe ^String (do nil)
15:16chouserbleh
15:16ataggartyeah, I tried typehinting and cast
15:16ataggartneither worked
15:17ataggart,(.append (StringBuilder.) nil)
15:17clojurebotjava.lang.IllegalArgumentException: More than one matching method found: append
15:17ataggart,(.append (StringBuilder.) ^String nil)
15:17clojurebotMetadata can only be applied to IMetas
15:17ataggart,(.append (StringBuilder.) (cast String nil))
15:17clojurebot#<StringBuilder null>
15:17ataggartorly
15:17ataggarthmm
15:19jarpiainmaybe ^String (identity nil)
15:20ataggartcast seems to work
15:20ataggartwhich makes sense since that's how one would resolve it in java
15:41jarpiainataggart: (.append (StringBuilder.) (cast String nil)) calls append(Object)
15:41ataggartjarplain: thank you! I was beating my head against a wall trying to figure out why another more complicated example wasn't working.
15:42ataggartok, so cast doesn't truly work
15:45@rhickeycast just does a type check, it doesn't (can't) have polymorphic return type. could if it was a macro
15:45ataggartjarpiain's suggestion of ^type (identity nil) works
15:45ataggartit'd be nice if typehinting nil worked
15:46ataggartmaybe I'll work on that tonight
15:46hiredmanping?
15:46clojurebotPONG!
15:46@rhickeynil reads as null, nowhere to put a hint
15:47ataggartdrats
15:48ataggartWhile you're here, there are a number of tickets that could be closed with the patch attached to https://www.assembla.com/spaces/clojure/tickets/445
16:09ossarehI should really know this, but I just can't rationalise it - what is the *key* difference between [] and '() ?
16:10ossarehI see examples of this quite often ["a" '(1 2 3) "c"] - why would it not be written as ["a" [1 2 3] "c"] ?
16:12dnolenossareh: different datastructures, list and a vector, it could easily be written the second way.
16:13ossarehI guess being a java 1.5+ guy I've only really used Lists, particularly in their generic sense, is a list vs vector conversation in clojure similar to the one that would be had in java ?
16:14dnolenossareh: not really, lists have O(n) lookup and vectors have constant time lookup. lists are rare in clojure unless you're manipulating code in macros.
16:15dnolennear constant time rather.
16:17ossarehaha, so in java you can myList.get(x) which is the same as (nth our-vector x)
16:18ossarehOK, I get it.
16:18ossarehThanks dnolen
16:18ossarehI'll probably ask again in a few weeks ;)
16:19bobo_do i remember wrong if i think arraylist has constant time lookup?
16:20dnolenbobo_: it does, but I was only referring to list and vectors in clojure, not java.
16:21bobo_yeh, but then you could perhaps compare it to linkedlist vs arraylist?
16:43vibrantok so what if i have something like (def game {:player { some map } :units [vector of maps]})
16:43vibrantshould i make everything one big atom, or the vector an atom, or individual units atoms?
16:46raekwhen making them interact with each other, it's probably easier to have the as their own refs/atoms
16:46raekI read some interesting articles about game programming in functional languages
16:47vibrantbecause right now i have :animations there and when I want to add one I can either make a function getting and returning the game object (without using atoms), or make a function which swap!s something in a global game object
16:47vibrantraek; i didn't gety our first sentence
16:47vibrantcan you point me to those articles? but i guess they won't discuss atoms unless they are about games in clojure.
16:48raekhttp://www.st.cs.uni-sb.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf
16:48raekI found that interesting
16:49raekI was thinking about when you want to apply rules of physics, etc
16:49vibrantok. well right now i have a triangle which rotates
16:49raekthing A uses special power on thing B
16:50vibrantnow i want to make it shoot :)
16:50raekah, here it is: http://prog21.dadgum.com/23.html
16:51raekand here http://prog21.dadgum.com/54.html
16:52raekI have a feeling that it is easier to do a shoot function that only has to do touch the two involved parties, rather than having a one that gets the whole world and creates a new world with some things changed
16:53raekespecially if you want to make these changes concurrent
16:53vibrantright now the shoot function has to append something to the game map {:animations []}
16:53vibrantappend that bullet
16:53vibrantthen some animate function will have to step all the animations in there modifying them of course
16:54raekref ganularity is indeed not a trivial issue...
16:56vibrantyeah so maybe i should just have a global +animations+ vector?
16:56vibrantaccording to these articles
16:58raekclojure lets you mutate certain explicit points in a controlled manner. I would guess that the article doesn't explore that possibility very deeply.
16:58raekI am by no means experienced in making games in clojure
16:58vibranti'm determined to write one.
17:02raekbut a general idea could be to model things that behaves as an entity that changes over time but still remains identifiable with a ref or atom
17:02raekif a unit only consists of the keys :image, :pos, and :hp, all these might vary during the game
17:03vibrantyup
17:03raekbut a ref is something that represents an identity
17:04raekthe states a ref changes between might have nothing in common
17:05raekeither, the identities of the objects could be their indicies in the units vectors of the world
17:05raekor it could be their ref
17:05raekI think the latter case would be simpler
17:06raekI got to go now, but good luck and happy hacking!
17:07vibrantok thanks!
17:09nickikwhats the best way to get 1 from "1"?
17:10tonyl(Integer/parseInt "1")
17:11tonyl->(Integer/parseInt "1")
17:11sexpbot⟹ 1
17:11tonyl,(Integer/parseInt "1")
17:11clojurebot1
17:11tonylyeah clojurebot is up
17:12drewr,(Integer. "1")
17:12clojurebot1
17:12nickik,(Integer. "1")
17:12clojurebot1
17:12nickikhehe
17:12nickikis that the same or does parseInt provide something more=
17:13drewrparseInt can also take a radix
17:13philjordanalso note that Integer obviously is limited in range
17:14philjordanyou might want (BigInteger. "12345678901234567890") instead
17:17@rhickeyAnyone tried Google Closure js lib, esp the template engine?
17:21wlangstrothyep - they're nifty, but kind of an extra step; anything specific?
17:22chousermongodb's query language is (mostly) homoiconic js objects.
17:23chouserwhich nearly led me to design a homoiconic minilanguage for its map and reduce steps too, before I came to my senses.
17:24@rhickeyick
17:24wlangstrothrhickey: ah, yes - that would convenient for an all-Clojure set-up; you wouldn't have to switch gears mentally to JavaScript
17:24chouserthe minilanguage would have of course been expanded, via javascript "macros" into javascript source strings and then eval'ed. bleh.
17:24@rhickeymost interesting is generating Closure template fns that run on the client
17:25nickik@rhicky did you see the presentation of the "The Deadline" Guys too?
17:25@rhickeynickik: yes
17:26@rhickeyI always thought GXP was a great design, but largely ignored
17:26nickikGXP?
17:27@rhickeyhttp://code.google.com/p/gxp/wiki/WhyGxp
17:27dysinger<3 that rhickey's clojure book list has a hammock at the bottom. :)
17:28@rhickeydysinger: the list is maxxed out, so I couldn't add the stand :(
17:33nickikrhickey: In dylan multimethods you can dispatch stuff like integer = 1. Did you consider something like that for clojure?
17:49duncanmis there a char->integer method somewhere?
17:49duncanmi mean, integer->character
17:50nickiktry char
17:50duncanmah
17:50duncanmCharacter/forDigit
17:50nickik,(char 99)
17:50clojurebot\c
17:50nickik,(inc \c)
17:50clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
17:50duncanmi want (char 1) -> \1
17:50raekduncanm: from where did you get the integer?
17:50LOPPit's easy
17:50nickik,(int \c)
17:50clojurebot99
17:51raekif you got it from read(), then (char the-int) should be fine
17:51LOPPchar c -> int i = c - '0'
17:51LOPP,(int (\6 - \0))
17:51clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn
17:51LOPP,(int (- \6 \0))
17:51clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
17:52LOPPman, clojure has a problem with perfectly good java code :P
17:52LOPPgoddamn wrappers
17:52raekwhat I actually wanted to say was that you have to consider what the integer represents... is it a unicode code point number (like the one read() returns)? is it a digit?
17:52LOPP,(int (- (char \6) (char \0)))
17:52clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number
17:53raek\0 is already a character
17:53LOPPI know
17:53LOPPbut not char
17:53LOPPit's Character
17:53raek,(- (int \6) (int \0))
17:53clojurebot6
17:53LOPPthat's why I can't do arithmetric with it
17:53LOPPok
17:54LOPPthat works I guess
17:54raekno, you can't do arithmetic with chars/Characters because they don't represent numbers
17:54raekwell
17:54LOPPchar does
17:54raekthey can be coded as numbers (which is the interpretation of the cast)
17:54LOPPtry to substract two chars in java, I think it works
17:54nickik,(first (seq (str 1)))
17:54clojurebot\1
17:54nickikugly :)
17:55LOPP(.toCharArray (.toString 1))
17:55LOPP:P
17:56raek,(-> 1 str first)
17:56clojurebot\1
17:56LOPP,(Character. 1)
17:56clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Character
18:02LOPPfound it
18:02LOPP(Character/forDigit 9 10)
18:02LOPP,(Character/forDigit 9 10)
18:02clojurebot\9
18:40raek...and it mentions Clojure!
18:41technomancyit also implies that CLOS is hot stuff... o_O
18:43dnolentechnomancy: what, you don't like CLOS ?
18:51technomancynot so much
18:51technomancyit has a lot of features
19:06hiredmanping?
19:06clojurebotPONG!
19:10nickiki orderd the land of lisp. I want to support people that write books on lisp today. He sais on HN. I used Commen Lisp but tried to include some aspects of the new lisps.
19:12nickikhttp://landoflisp.com/ follow the arrow down its well worth it !!!!!
19:13nickikn8
19:19amalloyhi, #clojure! nice to be back since my office, despite being a web company, has had no internet connection all day
19:19tomojthat happened to us, but the engineer had a mobile clear router thingy :)
19:21amalloywell, this happens to be a day our DBA/IT guy is out of town, so...
19:23ohpauleezamalloy: Weird, I was in a similar situation too
19:24amalloycrazy
19:25ohpauleezamalloy: Were you at conj?
19:25amalloyohpauleez: no, sadly not
19:25amalloybut we're definitely not in the same company :P
19:26ohpauleezhaha
19:26ohpauleezI also was sadly not at conj. I had to cancel my plans
19:26amalloywe're a startup in sf, with ~8 engineers. two pauls, but no deGrandis's
19:28ohpauleezahh. Too bad. I hear that dude is a total ace engineer :P
19:33amalloyohpauleez: well, we're hiring! let him know if you see him
19:46_seanc_Howdy folks. I have another question pertaining to the '&' and it's usage. In some sample code there had fn [&], how would you reference the passed in arguments in that circumstance?
19:49Raynes_seanc_: (fn [&]) doesn't work.
19:49tonylhas to be (fn [& rest])
19:49RaynesHowever, (fn [& args]) just tells Clojure to put all arguments passed after the & into a sequence named args.
19:49tonylcan change rest for whatever name you want
19:50_seanc_Ok, perhaps the code wasn't correct. I'm not savvy enough to catch those things
19:50amalloy,((fn [& args] args) 1 2 4 :a)
19:50clojurebot(1 2 4 :a)
19:50Raynes-> ((fn [x & args] (println x args)) 1 2 3 4)
19:50sexpbot⟹ 1 (2 3 4) nil
19:50Raynesamalloy: You're a traitor, you know. Working on sexpbot, but still using it as a backup when clojurebot isn't working. :P
19:50_seanc_Trying to familiarize myself enough with Clojure to try my hand at Compojure. I appreciate your help guys :)
19:50amalloyRaynes: i need to get into the habit of using sexpbot. clojurebot seems to be down a lot more
19:51amalloyRaynes: tbh it's just the -> vs , thing. , is so easy to type
19:51Raynesamalloy: sexpbot's sandbox isn't quite as good. I need to fix a few bugs in clj-sandbox in order to get a sandbox that works pretty much the same as clojurebot's. Right now it's running on a whitelist rather than a blacklist, which it should be running off of.
19:51Raynes&(println "ohai")
19:51sexpbot⟹ ohai nil
19:52amalloyyeah, i've noticed it refusing a lot of totally reasonable requests
19:52RaynesI'm accepting suggestions for new evaluation prefixes. It's actually more challenging than you might expect, since sexpbot is in so many channels, many with other bots. It's difficult to choose prefixes that people don't accidentally use, and aren't already used by other bots.
19:53RaynesI could just steal clojurebot's sandbox for the time-being, but I'd really, really rather not.
19:54RaynesAnyways, & works the same as ->.
19:54amalloyah
19:54amalloyRaynes: per-channel prefixes perhaps?
19:56RaynesThat's a possibility. Gets complicated for lots of channels though. That complication goes away if you have a default prefix with overriding prefixes for various channels. It's still a little blah, because then you have people in other channels trying to use the evaluation with one prefix that only works in channel x.
19:56amalloyyeah
19:56amalloyi was thinking the other way though: N default prefixes, with per-channel "don't use this" settings
19:59RaynesLicenser: You wouldn't happen to be around, would you?
19:59amalloy &"do you mind spaces before the &?"
19:59amalloy& "or after?"
19:59sexpbot⟹ "or after?"
19:59RaynesWhat he said.
20:00amalloyyeah, that's what i guessed, but figured i might as well check
20:00amalloy ,"what about you?"
20:05amalloyRaynes: so what do you think about several prefixes with per-channel "but not these prefixes" settings? that sounds easy enough for me to add if you like it
20:06Raynesamalloy: It can't hurt. Go for it. I'm improving the timer plugin at the moment.
20:06RaynesAnd by improving, I mean breaking of course.
20:07amalloycool. well at the moment i'm on a netflix/tv marathon, but i can do it by tonight or tomorrow prolly
20:07RaynesCool. When you do, I'll make the prefix a period for Clojure.
20:08RaynesThere is only one channel that sexpbot is in (that I can think of) where a period would cause problems.
20:08amalloyah
20:08amalloynice
20:08amalloywhat about when the answer to someone's question is .replace
20:13amalloybut i guess that's a fairly rare case, and it's pretty easy to ignore if he does that
20:18Raynesamalloy: That's a sucky edge-case. Damn you people and your one-word replies.
20:18Raynesamalloy: Anyways, it was just one idea.
20:18amalloyyeah
20:18amalloythe general idea is still good; that's just a detail
20:18RaynesIt might be a good idea to post a mailing list thread and just see what everybody would be happy with.
20:18RaynesOf course, I'm not going to really focus on the perfect prefix until I have the perfect evaluation. If it isn't as good as clojurebot's, it shouldn't even be here.
20:54amalloyRaynes: what do i have to do to enable eval?
20:54Raynesamalloy: -> #clojure-casual
21:40hiredmanping?
21:40clojurebotPONG!
21:41tonylis clojurebot fully functional?
21:42tonyl*ns*
21:42tonyl,*ns*
21:42clojurebot#<Namespace sandbox>
21:45amalloytonyl: he's sandboxed - he won't do things that might be evil
21:45amalloy,(def println 'delete-my-hard-drive)
21:45clojurebotDENIED
21:46tonylunderstandable
21:47tonyl->(def println 'delete-pri)
21:47sexpbot⟹ #'net.licenser.sandbox.box7352/println
21:47tonyl->println
21:47sexpbot⟹ delete-pri
21:48amalloybut he's fully functional in that he evaluates clojure stuff:
21:48amalloy,(take 15 (iterate (fn [[a b]] [b (+ a b)]) [1 0]))
21:48clojurebot([1 0] [0 1] [1 1] [1 2] [2 3] [3 5] [5 8] [8 13] [13 21] [21 34] ...)
21:48amalloy,(map second (take 15 (iterate (fn [[a b]] [b (+ a b)]) [1 0])))
21:48clojurebot(0 1 1 2 3 5 8 13 21 34 ...)
21:48tonylgreat
21:49tonylwonder what was the problem
21:49tonylwho manages clojurebot?
21:49amalloyin what?
21:49amalloyhiredman owns him
21:49amalloyother people contribute some, but he's the "manager", if you like
21:50tonylok, i'll look into the source code, just wondering how it works
21:50amalloyclojurebot: source?
21:50clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
21:52tonylthanks amalloy
21:53trptcolinso i just submitted my first clojure.contrib patch (ticket 35 on assembla) - do i need to post to the mailing list or will the powers-that-be just find my patch since i marked the ticket as "Test"?
21:54cemericktrptcolin: and tag the patch file with "patch"
21:54hiredman~contrib ticket #35
21:54clojurebot{:url http://tinyurl.com/27bhpfo, :summary "clojure.contrib.trace/deftrace does not work with function definitions with doc-strings", :status :test, :priority :normal, :created-on "2009-10-09T19:22:46...
21:56trptcolincemerick: tagged.
21:56trptcolinhiredman: that's pretty rad
22:01hiredman~ticket search recur
22:01clojurebot("31-recur-across-try.diff" "31-recur-across-try2.diff" "#31: GC Issue 27:\tDisallow recur across try" "#258: can't recur from case special form" "#31: GC Issue 27:\tDisallow recur across try" "#31: GC Issue 27:\tDisallow recur across try" "#283: recur ignores rest args" "#283: recur ignores rest args" "#444: Infinite recursion in Keyword.intern leads to stack overflow" "#92: GC Issue 88: \t Add :let support for 'doseq'
22:01hiredman~ticket #31
22:01clojurebot{:url http://tinyurl.com/25ll5ey, :summary "GC Issue 27: Disallow recur across try", :status :test, :priority :normal, :created-on "2009-06-17T16:06:57-03:00"}
22:07hiredmanugh, time to rewrite for jira
22:17technomancytrptcolin: bizarre that docstrings affect dotrace.
22:17technomancyoh wait, deftrace... never mind. I only use dotrace.
22:18trptcolinright, i don't think i've used deftrace either
22:23trptcolintechnomancy: did you see i moved the subtask help stuff last night? i'm wondering if it could also have applications for `lein help` at the base level...
22:24technomancyI haven't gotten a chance to look at it... was doing some profiling of test.
22:25trptcolinah ok, cool no worries
22:44_seanc_Hey guys, I'm looking through the Clojure site and a few others, I can't find what `^String` means. Am I to believe that is some kind of shortcut for Java classes?
22:44amalloy_seanc_: it's a type hint
22:44amalloyyou're telling the compiler "this object will be of type String"
22:45amalloyif it doesn't have hints it will use reflection to find the appropriate methods to call when doing java interop; hints can speed up execution by using actual method calls instead of reflection
22:46amalloy(do not overuse this feature)
22:46_seanc_I'm looking through the hiccup source, the defn escape-html has this. Doesn't make sense to me
22:47amalloylink?
22:47clojurebotyour link is dead
22:47_seanc_http://github.com/weavejester/hiccup/blob/master/src/hiccup/core.clj
22:47amalloyugh, screw you clojurebot
22:47amalloy_seanc_: escape-html is asserting that the result of (as-str text) will be a String
22:48amalloythat way, the compiler can resolve the (replace) calls at compile time instead of run time
22:49_seanc_wow, that confuses me. Ugh
22:50amalloyyeah, just ignore any type hints you see; pretend they're just for the compiler, though some people prefer to use them for other purposes
22:50amalloyyou won't lose anything
22:52_seanc_Alright, thanks amalloy
22:59amalloy,1
22:59clojurebot1
22:59amalloy->1
22:59sexpbot⟹ 1
22:59amalloy-sexpbot-⟹ 1
22:59amalloy.1
22:59amalloy-sexpbot-⟹ 1
22:59amalloywoo
23:00cemerickwhoa, they're multiplying!
23:01amalloycemerick: just added a feature to sexpbot to let him use different eval prefixes in different channels, so he doesn't need something globally unique
23:01Nafaicemerick: Question, is there a tools.nrepl client implemented yet?
23:05technomancymultiplying sexpbots? let's keep it PG-13 in here.
23:06technomancyhttp://wondermark.com/136/
23:06sexpbot-test"Wondermark » Archive » #136; Which may not be appropriate for Children"
23:06dysingertechnomancy: :)
23:08hiredmanugh
23:08amalloyheh. my adjustment to sexpbot has (set (get ...)) - almost looks like mutable state!
23:09hiredmanso I need to add ignores for multiple other sexpbots now?
23:09amalloyhiredman: no
23:09Raynesamalloy: If you're going to test sexpbot anywhere, do it in #(code) or #clojure-casual.
23:09Rayneshiredman: What's your problem with sexpbot? And me, for that matter.
23:09RaynesYou seem to make it a goal to ignore me.
23:09amalloyRaynes: i know. i tested him in tempchan and stuff, but wanted to 100% confirm it in #clojure before committing
23:10amalloysince the whole idea was to have per-channel settings
23:10cemerickNafai: Yes, it's there already; see clojure.tools.nrepl/connect, and the tests for examples
23:10cemerickthe docs will get some more love shortly
23:10NafaiCool
23:10RaynesI guess he has me ignored as well.
23:11RaynesI wonder what I ever did to him. :\
23:12amalloyoh haha, sorry. i see what you mean; i thought i'd logged him out of #clojure
23:13defnRaynes, maybe he's off doing something else, but regardless don't worry about it. Some people on IRC take issue with anything that contributes to "noise", where noise is a very ambiguous term meaning many things.
23:14amalloydefn: Raynes isn't actually offended, bet you a million dollars
23:14defnamalloy: a million? that's all you got?
23:14replacatechnomancy: are user plugins in the current lein?
23:14defnamalloy: did you get a chance to listen to the audio i posted?
23:14amalloyno, what audio?
23:14defnthe rich talk at clojureconj
23:14defnone of them anyway
23:15defni have the other one one the new 1.3 performance stuff
23:15defnhavent ripped it yet
23:15RaynesI'm not really offended. I just have no clue what I ever did to cause such dislike. I should have asked him at the Conj, when he could only physically ignore me. :\
23:16Nafaidefn: link to the audio?
23:17technomancyreplaca: yeah.
23:21defnNafai: sure
23:22defnNafai: http://db.tt/TK5M0ch
23:22defnit cuts off the first minute or two but the good stuff came later anyway
23:22NafaiThanks!
23:23replacatechnomancy: cool, thx
23:23replacatechnomancy: when you do a lein cmd for it, will it pull straight from a repo?
23:23defnhow does one convert a decimal to a ratio?
23:24tomoja decimal, really?
23:24tomojor a float/double?
23:24defndidn't mean the type there, sorry
23:24defndouble
23:24defni have 2.666667, but (rationalize... is not giving me what I need
23:25tomojthat's a difficult problem
23:25defn:)
23:25defn(hopefully one that someone else has solved! :)
23:25tomojI think all you can really do in most cases is find ratios which approximate the double well
23:25tomojmaybe you try to pick the lowest denominator which has low error
23:26defnyou need to guess at closed forms
23:26defnyeah
23:26defngood idea
23:26defntrying that out...
23:26tomojdunno how low you'd have to restrict the error to get good results
23:27technomancyreplaca: yeah, that's merged in snapshot. "lein plugin install swank-clojure 1.3.0-SNAPSHOT"
23:27cemerickdefn: Hey :-) Have you recovered from the conj yet?
23:28defncemerick: wow. still working on it to be perfectly honest. the last night was just a blur.
23:28defnmy brain was loaded sufficiently to induce a plane-coma
23:29sproustI was stuck at the airport the whole sunday. Broken part on plane, and full flights due to "parent week."
23:29defnwhat the hell is parent week?
23:30cemerickdefn: Same here. Then there was breakfast with Rich, Christophe, and Laurent. That didn't help. :-)
23:30sproustBUT we had tethering from a cell phone and our laptops :-)
23:30technomancyman... there is nothing like committing to git on a plane.
23:30sproust(and some Clojure goodness)
23:30defnsproust: did we meet?
23:30technomancyoh... except pulling from another passenger using gitjour.
23:30tomojI think you can actually work it out formally
23:31tomojwhere are these doubles coming from?
23:31defntechnomancy: we need to do a *nerd-version* of "I'm on a boat.", except it's "On a Plane", with git.
23:31sproustdefn: Yes. Was sitting on the right side for a while with Julie, talked between talks.
23:31sproust(In the front)
23:31hiredmantechnomancy: yes, that is something for adrenaline junkies
23:31defntomoj: something i have no control over programatically, 2.66667 is all i get
23:32tomojbut I mean.. how are they created?
23:32defnsproust: michael?
23:32technomancy,o/
23:32clojurebotInvalid token: o/
23:32tomojif they're created from fractions with small denominators, this method will work well
23:32technomancy...
23:32technomancy~o/
23:32clojurebot\o ... High five!
23:32sproustIs there an end to clojurebot? How many billion features does it have?
23:32tomojbecause if the denominator is low enough, you will find a low denominator that closely matches the double
23:33defnmust. get. bigger.
23:33defnclojurebot: skynet?
23:33clojurebotI will become skynet. Mark my words.
23:33technomancysproust: that's just request/response. composability
23:33defntomoj: mmm, interesting
23:33tomojbut if the denominator gets too big, it will exceed the double error rate and you'll get weird results, I think
23:35defntomoj: im just messing with some recurrence relationship homework
23:35tomojbasically you're taking a grainy picture of the reals and breaking it up into subsets of the rationals like {a/b in Q | b<i}
23:35defni figured out how to programatically do it
23:35tomojI started on it, but haven't finished
23:35defnthere's a common factor -- i just got bored calculating the first 10 in a sequence
23:35defni just wanted to map over a sequence
23:36tomojcan you use it to approximate pi as a fraction?
23:36defnhell no
23:36defnim avoiding the problem
23:36tomojoh, I see
23:36defn:)
23:36defnthat'd be fun to write though
23:36defnim just doing homework and am sick of working out 10 calculations per problem in the problem set
23:41replacatechnomancy: perfect. How'd you know that's what I wanted to install? :)
23:43defncemerick: how far did you and george get on the CDT discussion?
23:43cemerickdefn: we have a plan for Eclipse / NetBeans
23:43cemerickreally, any Java-based IDE that uses JDI
23:49tomojdefn: https://gist.github.com/abd1d5806736a8a60fa1
23:54defncemerick: glad to hear it
23:54defnkudos
23:55cemerickwell, let's see how well we can get the thing built first :-)
23:55defni have faith.
23:55cemerickheh
23:56defngeorge is one of the smartest guys ive ever met
23:56defnor at least i perceived him that way
23:56cemerickI only go to talk with him for an hour or two, but that doesn't seem unreasonable. :-)
23:57defnthe only people i had trouble talking with over the conj were people who insisted on talking about their crappy .NET jobs
23:57defnnot many of them, but a few
23:57defnit's like "yeah dude, I get it, your life sucks -- we're here to have fun."
23:58cemerickheh
23:58defni kid the .NET people, im just being snarky
23:58cemerickThe jobs may suck, but C# is pretty damn nice as things go.
23:58defnwhat i was /going/ to say was I don't think I met anyone who didn't seem less than abnormally intelligent