#clojure logs

2011-08-29

00:02ibdknoxhaha yeah I just found that out
00:02ibdknoxI created several rows of those
00:02ibdknoxand they're destroying
00:02amalloyyeah
00:03amalloywhereas if you have a big group of orange guys, they tend to all attack one enemy, and then take time recharging
00:03amalloyhaha wait, i don't even like tower-defense games, why am i doing this?
00:03ibdknoxlol
00:03ibdknoxcuz it's AWESOME
00:04ibdknox;)
00:04amalloyfo sho
00:04ibdknoxit was fun
00:04ibdknoxlots of learning. I had never used canvas before
00:04ibdknoxand never really written a game
00:11michaelr525hello!
00:18iceyibdknox: i think it's pretty fun; i like the geometry of it
00:18ibdknoxicey: haha, drawing those in code was interesting
00:18ibdknoxicey: the rects are obviously really easy
00:19iceyibdknox: do you think you'll try a clojurescript port later?
00:19ibdknoxicey: the purple teleporting ones too some drawing
00:19ibdknoxicey: I was thinking about it
00:19ibdknoxicey: I don't know that clojure works very well for games though
00:20iceyibdknox: trying to think of any games that were written using a functional lang
00:20amalloy$google purely functional games
00:20lazybot[prog21: Purely Functional Retrogames, Part 1] http://prog21.dadgum.com/23.html
00:21ibdknoxyeah, I've read through those
00:21ibdknoxI might still do it anyways
00:21ibdknoxjust to see what it's like
00:22ibdknoxI definitely missed parts of clojure while doing it
00:22amalloywell, let's hope you find out it's *not* like chewing on glass
00:22ibdknoxI used underscore.js to get some of the functional stuff, but it's just clunky compared to clojure
00:23ibdknoxamalloy: lol does he say that in there?
00:23amalloywho what?
00:23amalloyoh. no, that was me
00:23ibdknoxsounds painful
00:26amalloyibdknox: the number of enemies per wave does keep going up, though, right? ie if i stop building new towers i should lose eventually, even if it takes a few years?
00:26ibdknoxamalloy: yes
00:26ibdknoxamalloy: and they get progressively beefier
00:27ibdknoxthough that multiplier seems too low
00:28icey2 things would make this awesome: an ability to delete blocks, and a way to share final tower configuration with friends
00:29icey(like a url to a savegame)
00:29ibdknoxicey: yeah, I wanted to do deletes and upgrades, but there's no simple way to handle clicks on a canvas
00:29iceyibdknox: wow, that blows
00:29ibdknoxicey: I basically have to do collision detection with the mouse cursor
00:29ibdknoxthat's how the hovers work
00:30iceyhaving all the baddies take a single route makes me want to challenge people with stuff like "how long can you last with just 100,000kb"
00:30iceyactually, probably much less than that
00:31amalloymuch less, yeah
00:31icey5k, 10k maybe
00:32amalloyi've spent less than 100k, and on wave 31 i didn't see an enemy survive long enough to enter the screen
00:33amalloy100k...kb. ibdknox, you're a horrible person for using units like "274000kb"
00:36ibdknoxhaha
00:36ibdknoxjust to screw with you ;)
00:45akhudekoh man, that's too bad
00:46akhudekmy clojureql hack only works with persistent database connections :/
00:46akhudektldr: would love to have the autogenerated id of an inserted record returned somehow
01:08MasseRmudge: There's the JVM startup time, or if you keep the jvm running, the jvm doesn't update it's path, which might also cause problems
01:08MasseRBut you could look into jark and/or nailgun
01:42furdIs the 1.3 beta 2 known to be much slower than 1.2.1?
01:43furdI'm doing Project Euler and one of my programs runs in 1.9 seconds in 1.2.1 and 20 seconds in 1.3.0-beta2
01:44hiredmanfurd: care to share?
01:44furdI'll put up a gist
01:55furdhttps://gist.github.com/1177848
01:56wastrelseconds
01:56furdseconds
01:58hiredmanget rid of the (int ...) calls
01:58amalloyand don't use an int-array either
02:00furdIs that just general coding practice advice or would that have any kind of impact in going from 1.2.1 to 1.3.0?
02:01amalloyboth
02:01furdI appreciate any kind of coding practice help as I definitely need it
02:01furdhm
02:01amalloy1.3 defaults to using longs instead of ints
02:01hiredmanand defaults to primitive longs
02:02amalloyso your arithmetic does a lot of back-and-forth from long to int, and possibly from boxed to unboxed as well
02:05furdHm okay I'll try writing it with that in mind and see if that gets the times more in line with each other
02:05furdI was just very confused as I rewrote the sum-divisors function to be much faster and was getting much longer times
02:06furdUntil I realized I had decided to try 1.3
02:09furdThank you very much!
02:24scottjwhere is goog.dom.query in closure's api docs?
02:28amalloyfurd: if you're interested, i wrote a solution that is short but not very fast: https://gist.github.com/1177884
02:31furdOoh awesome thanks I will try to absorb what I can from that!
02:31ibdknoxscottj: it's a port of dojo's query stuff
02:32furdI got rid of the primes-to function by using the contrib.lazy-seqs prime generator
02:32furdhttps://gist.github.com/1177848
02:32furdAnd the difference is now 2.3 seconds in 1.2.1 to 17.3 seconds in 1.3.0-beta2
02:33scottjibdknox: when I require just pinot.html I get an error saying goog.dom.query not provided
02:33ibdknoxscottj: grab the goog-jar.jar that came down as a dependency and put it in clojurescript/lib/
02:33ibdknoxremove the goog.jar
02:33ibdknoxthat's in there
02:34furdamalloy: Thank you very much, I've never used letfn before so some reading is in order!
02:34scottjibdknox: add that to README?
02:34amalloymeh, it's just defn but lexically scoped instead of global
02:34ibdknoxscottj: it's on the mailing list, and it will be
02:35ibdknoxclojurescript's bootstrap doesn't package up all of closure, sadly
02:35furdah okay
02:37scottjibdknox: thanks
02:38amalloyfurd: my solution is a little silly, looping through all the numbers twice, because i started out misunderstanding their definition of amicable numbers
02:44furdamalloy: Nice to see another way of doing it anyway
02:45furdamalloy: I've never programmed functionally before and I just started with Clojure about a week ago, all the examples I can get are great
02:46furdThough I'm still really confused as to why my fairly simple, now efficient prime generating code takes so much longer in 1.3
02:48amalloyyeah, i dunno
02:54furdIs there some place I should submit the gist?
03:01ibdknoxscottj: added
03:36tsdhIs there a way to write readable clojure structures to a file so that I can load it back later? (spit "foo" [1 2 3]) writes [1 2 3], but (spit "foo" (doall (take 10 (iterate inc 0)))) writes clojure.lang.LazySeq@25b1c106...
03:37ibdknox,(doc pr-str)
03:37clojurebot"([& xs]); pr to a string, returning it"
03:37ibdknox,(pr-str (map inc [1 2 3]))
03:37clojurebot"(2 3 4)"
03:38tsdhibdknox: Ah, great. That does the trick!
03:39tsdhOk, and a related thing: Is there a way to define a costom read/print syntax for arbitrary objects?
03:43amalloytsdh: http://amalloy.hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging is an article i wrote a while ago about both of those topics
03:47tsdhamalloy: Great, thank you.
05:56MasseRHow come I get "No matching method: symbol"
06:05MasseRMacros weren't as simple as I thought :P
06:21MasseR(defmacro foobar [key] '(let [x# ~key] (name x#)) works as expected. If called with (let [y :helloworld] (foo y)) returns "helloworld", but I can't get the "helloworld" out if I unquote that expression
06:22MasseRFor example (defmacro foobar [key] (let [x (gensym)] `(let [x ~key] ~(symbol (name x))))
06:30ChousukeMasseR: you need to do `(let [~x ~key] (symbol (name ~x)))
06:31ChousukeMasseR: keep in mind that x is in the local scope of the syntax-quote form so ~x evaluates to whatever gensym returned
06:34nizzeHi! I have been doing OO (in dynamic languages, e.g. Ruby) for last 5 years and now I think about software through OO gogles
06:34nizzegoggles
06:35nizzeNoh, Clojure "does not do OO" or it's not the Clojure way. How to get rid of OO way of thinking and start thinking Clojure way?
06:35nizzeI'd like to have some concrete examples like how to build a blog in Compojure.
06:42thorwilnizze: you could have a look at https://github.com/ibdknox/Noir-blog
06:43nizzethorwil: Thanks!
06:43nizzeI'm currently reading the Joy of Clojure by @fogus one of the best IT books, heck the best IT book I have stumbled upon.
06:45Chousukenizze: I think it helps to have others critique your code
06:45kaiwrennizze: Read the SICP. Do the exercises. It'll help hugely with the OO centric view *and* help you write better OO FWIW.
06:46nizzekaiwren: Really? I'll add it to my reading list. What would be a good Scheme environment to use with the book? DrScheme?
06:47miclorbis there a dedicated room for leiningen or kosher to chat here about it?
06:47kaiwrennizze: They suggest a few things in the intro. You can use whatever editor you prefer, actually.
06:47nizzeThanks!
06:48Chousukealso you can try reminding yourself to do a double-take on any design/implementation decision you make and consider if it's using enough FP tools. For Clojure in particular, you will want to avoid loop, overusing defrecord, most of the mutation facilities; and use lots of small, independent functions, lazy sequences and clojure-provided functions to work with them
06:48nizzeOkay.
06:49thorwilnizze: afaik DrScheme is no more (if you don't dig out an old version). I think I read that DrRacket and Racket's Scheme profile have some incompatibilities with SICP
06:49ChousukeYou'll need some mutation of course but lots of people try to emulate actual mutation with them and end up having lots of atoms and refs everywhere. that's not usually a good thing :)
06:55thorwilgood thing i have no clue about atoms and refs at all ^^
07:02nizzeThanks. I'll really have to dig to SICP then (right after JoC) how about the Grahams book? Is it any good?
07:04pyrnizze: it seems people use racket for scheme these days
07:04pyrnizze: the grahams book seems to be hard to find
07:05pyrare there release notes anywhere for clojure 1.3.0beta2 ?
07:05nizzepyr: thanks.
07:06thorwilyou mean this: http://www.paulgraham.com/onlisp.html ?
07:06pyryes
07:07pyri'm a bit of a bitch, but these kind of books i enjoy reading in paper form
07:08thorwilwell amazon offers 18 used from $89.10 ... makes reading on screen more attractive than usual ;)
07:08pyryep
07:19robermannpyr: http://dev.clojure.org/display/doc/1.3
07:20pyrrobermann: thanks
07:21wunkiI can't seem to install clojure-1.2.0 from clojars. Is it down? Or is it my connection?
07:30robermannho committato sulla M061N il merge dalla M060N
07:30Netpilgrimwunki: The artifact is also in maven central.
07:31robermannops, sorry, wrong tab :)
07:33wunkiNetpilgrim: I'm using leiningen and a project.clj, can I redirect it to maven central? (just started clojure)
07:35Netpilgrimwunki: Sorry, I've never used leiningen, only maven. I had assumed that leiningen also looks in the central repository by default.
07:35wunkiNetpilgrim: np, thanks for the suggestion
07:36NetpilgrimI'd find it quite odd if Leiningen's artifact lookup did not default to maven central. Perhaps someone else here can comment on that?
07:42Netpilgrimwunki: You can try adding maven central manually to your leiningen config. The URL is http://repo1.maven.org/maven2/.
07:43wunkiNetpilgrim: Thanks, will try it
07:45NetpilgrimSpeaking about Leiningen, could someone explain to me the advantage of using it over Maven?
07:46manutterThe advantage is that if you don't already know maven, it's a lot easier to pick up leiningen
07:48Netpilgrimmanutter: OK. But Leiningen probably supports fewer features?
07:49manutterWell, I think it uses maven under the hood, so it's more like a simplified interface
07:51Netpilgrimmanutter: Sounds like a good idea for people who haven’t used Maven before. I was just wondering if I was missing something by sticking to Maven.
07:52manutterThe only thing you might be missing is some of the lein plugins like lein noir and lein midje
07:53Netpilgrimmanutter: I don't know the plugins. But if Leiningen is just a wrapper for Maven, wouldn't it be better to write plugins for Maven and then just use them through Leiningen like the rest?
07:55manutterWell, that might be an opinion question :)
07:55Netpilgrimmanutter: Since I know neither Leiningen nor the plugins, I'm not offering one. :)
07:55manutterIt's easy to write lein plugins in clojure, not sure how hard it would be to write a maven one
07:59Netpilgrimmanutter: From the Leiningen FAQ: “Leiningen only uses the dependency resolution parts of Maven”. So there is no way to use Maven plugins.
08:00manutteraha, there you go then
08:00raeklein has maven central by default. you don't need to add it.
08:01raekand clojure is not on clojars, but in another maven repo (which lein knowns about)
08:01raekwunki: which artifact are you adding to the project.clj?
08:02wunkiraek: I narrowed it down to "lein-ring"
08:02wunkiraek: which has a dependency on clojure 1.2.0
08:02wunkiraek: that seems to hang the "lein deps" process
08:10kzarI'm doing this puzzle: http://4clojure.com/problem/26#prob-title . I've written a function that works fine but I used defn to define it. Problem is defn turns out to be forbidden. How can I define a function that can refer to itself for recursion without defn? This is what I have http://paste.lisp.org/display/124341
08:11Netpilgrimkzar: (fn name [...] ...)
08:12raekkzar: you can have a "named anonymous function": (fn f [...] ...), where f can be used in the body to access the function itself
08:13raekyou don't need to use that very often, except for sandboxes like in 4clojure
08:19kzarraek: Aha thanks
08:19kzarIt's like a constant variable and a good boyband, a named anonymous function
09:06chouserdnolen: Surely IPersistentVector (a type name) is *less* generic than 'vector?' (a function), not more?
09:20pyrthe noir features for clojurescript seem really cool
09:25michaelr525helloooo
09:31samlhey, how can I compile clojure file and run it?
09:32samli want to put a clojure compiler/interpreter in an OSGi container. clojure files are storied in JCR
09:32samlnot sure how modules would work
09:35stevenfxsaml: Compile clojure to class?
09:35samlno.. i'm not familiar how clojure interpreter works.. does it compile to bytecode?
09:36stevenfxsaml: Yeah i think so check http://clojure.org/compilation
09:36samltahsnk
09:37stevenfxsaml: No problem
10:04chouserbrb
10:05chouserheh, wrong window
11:21TimMcamalloy_: Did you make a more advanced findfn at some point?
11:21TimMcI seem to remember some variant.
11:34TimMc$findargs 1 2 3
11:37kzarAnyone see a better way of doing the rotate puzzle http://4clojure.com/problem/44 ? Here's my solution http://paste.lisp.org/display/124344
12:07TimMckzar: Basically the same as mine, though I used (concat (drop n col) (take n col))
12:11kzarTimMc: How 'bout this, my shot at the longest-increasing one http://paste.lisp.org/display/124345
12:12kzarNot pleased with it really, works though
12:12TimMckzar: https://gist.github.com/1178735
12:12TimMc(final solution to rotate puzzle)
12:13TimMckzar: What is longest-increasing's problem ID?
12:13kzarhttp://4clojure.com/problem/53
12:16TimMcthanks
12:17TimMcAh, I don't have a solution for that one yet. I've been sort of poking around randomly.
12:17kzarYea me too, that one's a puzzler anyway
12:17kzarat least it was for me
12:26manutterwoohoo, made it onto page 1 of the 4clojure "Top Users" list :)
12:27jolynice :) I was there and stopped for a while, but I started working on the problems again
12:28manutteryeah, these guys got me going again
12:29manutterNow I have to learn graph theory for problem #89.
12:33pdknah
12:33pdkjust copy paste euler's solution :p
12:34kzarThe trick to a lot of the puzzles is to do (source restricted-function) and paste it in, goes against the point though
12:34manutterHeh, that's no fun!
12:35jolyoops, I read that as visiting every node once
12:40Mike|homeCan Clojure maps take a default value if a key is missing?
12:41Bronsa,(doc get)
12:41clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
12:41Mike|homeThanks Bronsa. Awesome.
12:41Bronsanp
12:43scgilardiget-like calls also allow a default value. (:contents monolith :stars)
12:44jolynice, didn't realize that worked also
12:46dnolenibdknox: cljs-watch is amazing btw. makes writing ClojureScript really fun.
12:46ibdknoxdnolen: :)
12:46ibdknoxdnolen: it's the colors right? ;)
12:47dnolenibdknox: I got match working w/ ClojureScript yesterday.
12:47Bronsalol
12:47ibdknoxsweet!
12:47Mike|homeWhat's cljs-watch, dnolen?
12:47ibdknoxMike|home: http://github.com/ibdknox/cljs-watch
12:47dnolenMike|home: it watches your ClojureScript files and recompiles them when they change. saves a lot of time.
12:47Mike|homeSick. =o
12:48ibdknoxdnolen: were there any gotchas with getting match to work in cljs?
12:51ibdknoxI think I might try to redo my nodeknockout entry from this weekend in clojurescript
12:51Mike|homeibdknox: Just poked around your website. You're very impressive.
12:51ibdknoxlol
12:51ibdknoxMike|home: thanks haha
12:51ibdknoxso soon we may have a cljs tower defense game :)
12:53dnolenibdknox: the only problem is that ClojureScript data types and Clojure data types are different. cljs.core.IVector not clojure.lang.IPersistentVector. I added 2 lines to the ClojureScript compiler and it just worked.
12:53ibdknoxdnolen: sweet
12:54dnolenibdknox: yeah, bringing all the matching machinery to JavaScript is pretty cool.
12:54ibdknoxdnolen: I saw you did a post on that this weekend, I still haven't caught up with everything after the nko.
12:54ibdknoxdnolen: yeah, it's impressive really
12:55ibdknoxdnolen: I wonder how it performs... did you try profiling it at all?
12:59dnolenibdknox: no I should. I don't think it'll be particularly fast (though I don't think it'll be slow either).
12:59dnolenOf course a lot of the work around primitive arrays / bits, is irrelevant for ClojureScript, and you not going to get anywhere near what the JVM can do anyhow.
13:11duncanmhey dnolen
13:11duncanmdnolen: did you have anything to do with that Irene tracker on nytimes.com, it's really pretty
13:16dnolenduncanm: I didn't work on it but I sit right next to the people that do.
13:33joly$findfn inc {:a 4 :b 5} {:a 5 :b 6}
13:33lazybot[]
13:33Somelauw#python-forum
13:34Somelauw(type, please ignore)]
13:34manutterShun! Shun the unbeliever!!!
13:34manutter:)
13:34technomancy~guards
13:34clojurebotSEIZE HIM!
13:35amalloyTimMc: Mec wrote $findargs
13:35amalloy$findarg map % [1 2 3] [2 3 4]
13:35lazybot[clojure.core/unchecked-inc clojure.core/inc]
13:43cch1Anybody have strong midje-fu here?
13:43amalloy~anyone
13:43clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
13:44cch1So, using midje, I want to mock (provides) a function that takes keyword arguments.f
13:45amalloydnolen: i don't think i understand the red-black matcher at all. i mean, i guess it's the matching that's more important than the tree (which is just an example). but it reads to me like you're saying that a red node with a red child is balanced, which is untrue
13:45cch1First, it seems that the provides would need to list the keywords and their values as positional arguments... but isn't that going to fail since the order of the keywords can't be guaranteed?
13:46cch1...and, how can I avoid specifying each and every possible keyword arg if I'm only interested in one?
13:46cch1even using "anything", that's too much detail.
13:54manuttercch1: part of your answer is that you can safely omit any keyword arg you're not interested in
13:54dnolenamalloy: it might be wrong, was just using the pattern supplied in a issue report.
13:55dnolenamalloy: https://github.com/swannodette/match/issues/35
13:55manuttercch1: but I haven't worked with midje provides so that might not apply
13:55cch1manutter: are you sure? If I pass the args like this: "f :a 1 :b 2 :c 3" then mocking is going to require that I do something like (f :a anything :b anything :c 3) even if I don't care about :a and :bv
13:57manuttercch1: actually, I'm not sure at all, I just thought I'd take a stab at it (in my ignorance) and see if anybody more knowledgeable chimed in :)
13:57SomelauwThis probably gets asked a lot (maybe it should even be put in the clojure faq) but does anyone know why clojure does not have letrec (a scheme construct)?
13:58manutterbut I would definitely try calling it with (f :c3) and see if it blew up
13:58manutterSomelauw: what does letrec do? Assign to a struct-ish thing?
13:59jolyI believe the standard let behaves like scheme's letrec
13:59Somelauwmanutter: Assign multiple vars at once which could use each other.
14:00Somelauwjoly: No, the standard let is like let* in scheme.
14:00Somelauwletfun is a bit like letrec, but only works for functions
14:00amalloy(letfn)
14:00Somelauwlazy lists / streams can be mutually recursice as well
14:00Somelauwrecursive *
14:02jolySomelauw: oh yeah, thanks. You should be able to do it with a combo of let and letfn then?
14:02SomelauwAnd clojure doesn't seem to cover that use case for local variables.
14:02SomelauwNot easily at least.
14:12Somelauwjoly: No, it is not that easy.
14:13jolythen perhaps the answer to the original question is "because let and letfn are sufficient for the vast majority of cases"
14:15lakerhello, does anyone know good books about writing a compiler for a functional language? except the SPJ ones...
14:16dnolenlaker: I've heard good things about Lisp In Small Pieces and Appel's compiler texts.
14:18Somelauwjoly: I think the reason is technical. letfn seems like a poor man's letrec to me. But I am not sure.
14:19lakerdnolen: those don't cover things like pattern matching/ algebraic data types, but thanks anyway =)
14:19amalloyi think it's just that letrec is hard to implement and let/letfn cover a huge majority of cases
14:20jolySomelauw: I agree with amalloy
14:20dnolenlaker: the pattern matching literature seems to be easily accessible on the web. I used Luc Maranget's paper from 2008, quite good.
14:21lakerdnolen: i'll check that out, thanks
14:22dnolenlaker: you might find this interesting, github.com/swannodette/match/, sources cited at the bottom.
14:22lakerdnolen: those are great, thank you
14:25amalloy&(macroexpand '(letfn [(x [] 1)] (x)))
14:25lazybot⇒ (letfn* [x (clojure.core/fn x [] 1)] (x))
14:25amalloyman. no wonder i was having so much trouble reading the compiler's impl of letfn - the syntax for letfn* and letfn are different
14:31Somelauwletfn*?
14:32theignoratilein jar is starting jetty in my compojure project.. what's happening
14:33amalloySomelauw: letfn is just a macro over letfn*, which is the real compiler primitive
14:33manuttertheignorati: you have code in your main file that launches a server on compile, I'm guessing?
14:35theignoratigood point
14:36hiredmanhttps://gist.github.com/1179073
14:37Somelauwok, thanks. I hope letrec will be added in a future version.
14:37hiredmanseems unlikely
14:37hiredmanis there a real use for letrec that is not covered by other features
14:38amalloyhey hiredman, i don't understand this. (eval (macroexpand '(letfn ...))) works, but if i copy the output of macroexpand and paste it to the repl i get "clojure.lang.Compiler$MetaExpr cannot be cast to clojure.lang.Compiler$ObjExpr". i've checked and none of the macroexpanded forms have any metadata on them, so the copy/paste should be copying everything that's relevant
14:39technomancyamalloy: slime macroexpand or clojure macroexpand?
14:39amalloytechnomancy: clojure
14:39technomancyoh, huh.
14:39amalloyi think so, anyway. maybe i'm using the slime one and don't know?
14:39hiredmanamalloy: I think letfn* is only legal inside the compiler e.g. the compiler can macroexpand and produce it, but you cannot pass it in
14:39technomancyI just know you can't always trust slime's C-c C-m
14:40amalloytechnomancy: yeah, definitely not using that
14:41Somelauwhiredman: Yes. recursive lists, mutually recursice lists or even a mutual recursive list and function.
14:41hiredmanSomelauw: those aren't uses of letrec, those are lists of things you can do with letrec
14:41amalloyhaha
14:41hiredmanlike, is there some problem you want to solve that you cannot solve without it?
14:42theignoratilein run works, but the jar produced by lein jar throws a classnotfoundexception for the class with my main method, what am I doing wrong?
14:42hiredman(no euler problems please)
14:42hiredmantheignorati: upgrade lein
14:42theignoratiI just did
14:42theignoratiI think
14:42theignoratiI just ran lein self-install
14:42technomancyhiredman: are you implying that euler is not a valid use case because some of us have homework to do here
14:43technomancyerr... that didn't really translate through my punctuation-removal filter
14:43theignorati1.6.1
14:43technomancythere should be a comma after case
14:43hiredmantheignorati: you are missing :gen-class
14:43amalloytechnomancy: no, the self-important anger really came through
14:43Somelauwhiredman: No, but that doesn't mean it has no merit.
14:43amalloy"No TIME for commas, I have euler problems to solve!"
14:44technomancyamalloy: absolutely
14:44hiredmanSomelauw: *shrug* it is not needed
14:44michaelr525hello!!
14:45technomancyamalloy: did you see my juxt fan club submission? http://p.hagelb.org/seajure-address.html
14:45amalloytechnomancy: holy smokes, variable-width font? is that on purpose?
14:45theignoraticheers
14:46technomancyamalloy: it's a bug in htmlfontify; I've discussed it with the owner
14:46technomancyit's not a variable-width font, it's just two different fonts getting pulled in
14:46technomancyerr--discussed it with the author
14:47technomancyhm; I guess there are only two juxts in there; I could probably sneak another one in
14:47amalloytechnomancy: the second one is crying out for help
14:48technomancythe second defn, or the defn that evaluates to 'second when called?
14:48amalloythe second juxt
14:48amalloythe comical ((apply juxt (for ...)))
14:50technomancycrying out for help as in "dear odin please release me from this torment" or "that could really use some changes"?
14:50amalloythe first. never change it
14:51technomancyexcellent
14:51technomancyI think you could almost figure it out all in your head except for the part about knowing the length of what (doc a) outputs
14:53amalloytechnomancy: -main is calling (b) (d) (c) (e), yeah?
14:53amalloyi guess i don't even know what order sort-by sorts in. this is hard without a compiler
14:53technomancytrue, that's pushing it as well
14:54technomancypossibly relying on implementation details
14:54technomancyit's (a) (c) (b) (d)
14:54amalloysee, that's just poor knowledge of the ascii tables. i thought 96 was a, in which case it all comes out right
14:54Bronsahow can i transform [{0 1} {0 2}] into [[0 [1 2]]]?
14:54technomancysince (a and c) and (b and d) sort to the same position, it's a bit arbitrary
14:55technomancyoh, yep
14:55amalloytechnomancy: i think it's actually not arbitrary - java.util.Collections.sort is guaranteed stable, last i checked
14:55dnolenBronsa: merge-with
14:56technomancywell... it's arbitrary in that they could have implemented it to sort differently and still be entirely reasonable
14:56Bronsathanks
14:58amalloyBronsa: there are an infinite number of ways to make that transformation. you don't provide enough data to clarify what you expect to happen if, say, there's another map {1 5}
14:59Bronsaamalloy: i need to unify all the vectors with the same first
14:59amalloy&(doc group-by)
14:59lazybot⇒ "([f coll]); Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
15:03TimMctechnomancy: What versions of Clojure does that mess work in?
15:03technomancyTimMc: only tested in 1.2 I guess. trouble in 1.3?
15:04TimMcHaven't tried.
15:04technomancy(doc second)
15:04clojurebot"([x]); Same as (first (next x))"
15:04TimMcI don't have a 1.3 installation.
15:04technomancyshould still work in 1.3
15:05amalloytechnomancy: there's still time to change the docstrings in 1.3
15:05amalloy(first (rest x))
15:05technomancynoooo
15:05TimMcThat'll teach those frequent upgraders.
15:08amalloytechnomancy: d is really hard for me to fit into my head at once
15:09amalloythe rest aren't so bad, aside from, as you say, having to know the length of (doc a)
15:09technomancyamalloy: once you can give f a name I think it should be more comprehensible
15:10technomancyamalloy: one and two are just wrappers around key and that comp call so they can fit into the juxt call
15:11amalloysure
15:12technomancyamalloy: this must be what writing 4clojure questions is like =)
15:12amalloyhaha mostly writing 4clojure questions is like "damn it, i wish dbyrne would come back, he liked writing questions"
15:14technomancyrpartial isn't implemented because it wouldn't work with laziness, is that correct?
15:19amalloythe reason i haven't implemented it is i don't konw what it is
15:19amalloycan't speak for anyone else
15:19technomancy(fn [f] (f key)) => (rpartial apply [key])
15:20technomancypartial that fills in the args from the right
15:21amalloyi doubt if laziness is the issue. i think partial has to hold onto the argseq at least once anyway
15:22amalloy&(let [p+ (apply partial + (range 1e6))] (p+ 10)
15:22lazybot⇒ 499999500010 ; Adjusted to (let [p+ (apply partial + (range 1000000.0))] (p+ 10))
15:22amalloyoh, but of course that's taking up heap, not stack, so i'm never going to prove it with an overflow
15:28TimMc&(+ 1 (+ 2 (+ 3 (+ 4
15:28lazybot⇒ 10 ; Adjusted to (+ 1 (+ 2 (+ 3 (+ 4))))
15:29TimMcI'm going to write an evalbot that uses ⇒ as its command prefix.
15:29amalloyTimMc: just fork lazybot and configure him that way'
15:30amalloythen when you start flooding the channel i'll already know all the back doors to crash your bot
15:31TimMchaha
15:34kzarWhat am I missing here? ,(contains? [:a :b :c] :b)
15:34clojurebotExcuse me?
15:34amalloycontains?
15:34clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
15:34kzarah
15:35hiredmankzar: read the docs for the functions you use
15:39TimMccontains? was named that way to teach you to read the docs
15:40TimMc(I can't think of any better reason.)
15:40kzarTimMc: I suppose it makes sense with sets
15:41TimMc&(get (set (list 1 2 3 4)) 1)
15:41lazybot⇒ 1
15:42TimMc&(get (set (list nil)) nil "nope")
15:42lazybot⇒ nil
15:42kzar,(contains? #{:a 2 :b 3} :a)
15:42clojurebottrue
15:43phenom_,(let [s1 "test"] (equals? "test" s1))
15:43clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: equals? in this context, compiling:(NO_SOURCE_PATH:0)>
15:43amalloyphenom_: you want either = or identical?
15:49phenom_amalloy: =
15:49phenom_,(let [s1 "test"] (equals "test" s1))
15:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: equals in this context, compiling:(NO_SOURCE_PATH:0)>
15:50amalloy...
15:50babilenheh
15:50phenom_eeps, completely misread that
15:50phenom_lol
15:57michaelr525hello
16:11michaelr525err
16:12michaelr525what tomcat is good for anyway?
16:13michaelr525suppose that i want to build a web site which should handle a lot of traffic and be able to scale, should i deploy to tomcat?
16:17michaelr525or should I just go for ROR frontend and clojure services like flightcaster did, if I recall correctly..
16:37peteriserinsis there a function [[1 2] [1 3] [1 4]] -> [[1 1 1] [2 3 4]]?
16:38hiredman(apply (juxt (partial map first) (partial map second)) [[1 2] [1 3] [1 4]])
16:38hiredman,(apply (juxt (partial map first) (partial map second)) [[1 2] [1 3] [1 4]])
16:38clojurebot#<ExecutionException java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (3) passed to: core$first>
16:39hiredmanbleh
16:39hiredman,((juxt (partial map first) (partial map second)) [[1 2] [1 3] [1 4]])
16:39clojurebot[(1 1 1) (2 3 4)]
16:39joly,(apply map vector [[1 2] [1 3] [1 4]])
16:39clojurebot([1 1 1] [2 3 4])
16:41joly,(apply vector (apply map vector [[1 2] [1 3] [1 4]]))
16:41clojurebot[[1 1 1] [2 3 4]]
16:42peteriserinsjoly: cool, how does it work?
16:42peteriserinsah I see
16:42jolypeteriserins: magic ;) I remembered it from when someone asked earlier
16:43jolypeteriserins: and (vec (apply map .....)) is even shorter
16:43amalloy(apply vector x) => (vec x)
16:43jolyremembered that too late :)
16:43amalloythough really, usually you don't need either, because a seq is fine
16:43jolyyeah
16:43peteriserinssure
16:43peteriserinsbtw anybody made ClojureScript work with jsfiddle.net?
16:44peteriserinsCoffeeScript works, and I'd assume it'd be neat to have this http://doc.jsfiddle.net/use/hacks.html
16:50scottjpeteriserins: you mean being able to run clojurescript in a web ide like enviornment? coffeescript has a compiler that runs in browser, clojurescript doesn't.
16:51chouserI haven't polished this yet, but it might suffice: https://github.com/Chouser/cljs-svc
16:53peteriserinschouser: it says Copyright 2010 :)
16:53dnolenchouser: that's not live anywhere is it?
16:55chouserdnolen: no, not live
16:55chouserpeteriserins: heh. oops.
16:56amalloyman. (loop for i from 1 to n collecting n). how can anyone want to write that instead of (range 1 (inc n))?
16:56chouserbecause that way you get more syntax.
16:57chousera small price to pay for lack of composability
17:00jolyis there a way to use memoize effectively without using def?
17:00KirinDaveamalloy: Loop doesn't scale small well
17:00KirinDaveamalloy: It was pretty slick back in 2003
17:00KirinDaveamalloy: I mean, some pretty epically big programs were just an instance of loop
17:01amalloyjoly: i hate to do this, but...yes, the effective way to do that is to use memoize but not def
17:01amalloynot really sure how else to answer that question without more specifics
17:01jolyamalloy: for use within something like... 4clojure answers :)
17:01hiredmanthe only question "def" is the answer to is "how do I def things?"
17:02amalloyjoly: interesting. we don't have any problems where memoize would be very interesting
17:02jolyamalloy: I'm trying to use it for one right now
17:02amalloyso i gathered. which one?
17:03joly101, Levenshtein distance
17:03amalloyhiredman: "What is an example of something I shouldn't do at runtime?"
17:03hiredmanah, that too
17:04amalloyblech. okay, i confess i haven't actually solved levenshtein. the imperative algorithm generally uses some kind of matrix; is there a reason memoize is more expressive functionally?
17:05jolyI have a dynamic programming example for it, and I usually do those using memoization if the memory requirements aren't large
17:06jolybeats having to manage a matrix myself, but I will if I need to
17:07amalloyi guess they're really just using the matrix for memoization
17:07jolyI tried (let [f (memoize (fn [n] .... but the inside function doesn't seem to have access to f
17:07amalloyright
17:08jolyah well, guess I'll take another approach
17:09amalloyjoly: the matrix solution is written to walk in a particular direction, and only need previous results from "behind" you. you can often do the same thing using iterate
17:11amalloyjoly: you can probably adapt something like https://gist.github.com/1140970
17:16jolyamalloy: nice. My solutions tend to be long-winded; that one looks very concise
17:16amalloyjoly: well, it's solving a totally different problem, of course. that helps
17:17jolytrue, but just thinking how I'd do Pascal's triangle, I'd get something a lot more verbose
17:18jolyToo much scheme ;) I'd like to work on being more idiomatic with my Clojure code
17:19scodeWhat's an idiomatic way to use lazy-seq in cases where you're not recursing on the surrounding function?
17:19scodeI.e., I want to do what I do in https://gist.github.com/1179436 but without using the separate helper function.
17:20scodeBut I can't recur inside a lazy-seq, and a (fn ...) inside a let cannot call itself.
17:20chouserfn's *can* call themselves
17:20hiredmanyou don't have a recur there
17:20scodeOh? Hmm. I must have screwed up somehow then.
17:20chouser(fn recurse-forever [] (recurse-forever))
17:20scodehiredman: I know, I'm recursing without recur due to lazy-seq.
17:21hiredmanscode: then why are you asking about recur?
17:21peteriserinsjoly: you might find this useful http://pastebin.com/MAEsKSjM.
17:21scodechouser: Oh! I was using (let [name (fn .... which was the problem.
17:21scodehiredman: I was asking about recursion, not recur.
17:21scodechouser: Thanks!
17:21hiredmanwell the code you posted just works, so you don't have a problem
17:22scodehiredman: Like I said, I want to avoid using the separate function (that pollutes the namespace).
17:22scodehiredman: chouser's solution is what I was after.
17:22scodeI had missed the non-anonmyous form of (fn ...)
17:22dnolenscode: you also have multiple arities
17:23scodednolen: The example is contrived; in the real case I don't want to expose the parameters involved in recursion in the public interface of the function.
17:23scodednolen: I have a "list-blobs" in a blob store that will iterate over keys in an S3 bucket, and I want to do so lazily in a streaming fashion. The public interface takes no parameters.
17:24scodednolen: But yes, otherwise I would have done that (like range, partition etc in clojure core).
17:24dnolenscode: gotcha. you should look at letfn as well
17:25amalloypeteriserins: yuck
17:26amalloynow i can't get the millionth fibonacci number without (a) causing a stackoverflow, and (b) causing all million of them to be held permanently on the heap?
17:26scodednolen: thanks!
17:33mjg123,(read-string "\"say \\\"aah\\\"\"")
17:33clojurebot"say \"aah\""
17:34mjg123That doesn't work in ClojureScript
17:34mjg123Am I doing something wrong?
17:39mjg123or - does it seem like a bug in clojurescript?
17:39mjg123are cljs.reader/read-string and clojure's normal read-string supposed to behave the same?
18:00devnmjg123: the reader-fixes branch is 2 ahead of master FWIW
18:01mjg123devn: I'll try it.
18:01devnmjg123: it's also 54 behind, so you may want to merge it in
18:13mjg123devn: not fixed yet :(
18:13mjg123thanks for the tip though
19:11stirfoois this: https://github.com/frenchy64/Logic-Starter/wiki out of date?
19:13manutterstirfoo: at the rate dnolen is going I think everything is at least a little out of date :)
19:14manutterbut that one should still be a good start, from what I've heard.
19:16stirfooI wasn't sure if the wiki had not been updated. The first run* example will not work because it's given 5 args, but the core fn takes 3.
19:18stirfooI've had a copy of the reasoned schemer on my desk for a long time but never got into it. I ran across core.logic and thought I'd give it a shot, with clojure instead of scheme.
19:18manutterI've only skimmed through the beginning of it so far, so I can't vouch for it personally
19:19manutterwould like to work thru the Reasoned Schemer someday tho
19:19manutterI'm about 60% of the way through Land of Lisp at least, so maybe someday
19:22stirfoomanutter: I've picked that book up a couple of times and thumbed through it. I finished Joy of Clojure a couple months ago. Pretty good book, but some of it was just beyond my level.
19:24manutterwell, sometimes you just skim and then put it aside for a while. The second reading is always better.
19:43megalomanHello everybody. I'm am searching for a senior design project and am thinking about building a wrapper library for MT4j, Multitouch for Java, that sensibly provide multitouch event listening to clojure apps.
19:43megalomanDoes anyone know if there has been multitouch work in clojure already?
19:44megalomanOr have any suggestions about whether MT4j is a good starting point?
19:56scottjstirfoo: https://github.com/frenchy64/Logic-Starter/wiki/_history doesn't look out of date
19:58scottjmegaloman: not aware of any clojure wrappers,overtone has it in their roadmap with links to http://code.google.com/p/multitouch/ and http://code.google.com/p/sparsh-ui/
20:02stirfooscottj: It's probably just me ;) I cracked the reason schemer open a while ago and looked at frenchy64's intro project to create a starting point. The examples from the book are working, which is really all I wanted in the first place.
20:06dnolenstirfoo: logic starter is definitely up-to-date, you should let ambrosebs know about bugs.
20:06megalomanscottj: Thanks.
20:07dnolenstirfoo: The Reasoned Schemer is a tough little read, but really fantastic.
21:23[swift]hi, i'm very new to clojure. i'm wondering if there is a clojure library function for "zip"? (ie, given two lists, return a list of tuples, where each tuple consists of one element from each of the lists) googling turns up a zipper library but not a zip function
21:24amalloymap
21:24amalloyman, i need to come up with a spiel for clojurebot to give whenever someone asks where to find `zip`
21:24[swift]this is a common question i take it? =)
21:25amalloyfrom everyone coming from haskell, scala, or python, yes
21:25clojurebotpython is ugly
21:25amalloythanks clojurebot
21:25[swift]i admit, i'm coming from haskell AND python
21:25amalloy&(map list '(1 2 3) '(a b c))
21:25lazybot⇒ ((1 a) (2 b) (3 c))
21:26amalloyclojurebot: zip?
21:26clojurebotzipper is http://clojure.org/other_libraries#toc5
21:26[swift]hmm, very nice!
21:27amalloyclojurebot: zip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))
21:27clojurebotAlles klar
21:27amalloyzip?
21:27clojurebotzip is not necessary in clojure, because map can walk over multiple sequences, acting as a zipWith. For example, (map list '(1 2 3) '(a b c)) yields ((1 a) (2 b) (3 c))
21:27amalloy[swift]: c'est bon, or could i make it clearer?
21:27[swift]amalloy: no, that makes it clear! i just didn't expect map to have such an ability! thanks!
22:05amalloyso i wanted to write a with-test-tags macro that wraps a bunch of forms, and adds some metadata to each deftest form. i was going to do this with (macrolet [(deftest [name & args] `(deftest ~(vary-meta name assoc :tagged true) ~@args))] body) or something like that, but then deftest tries to expand again, indefinitely
22:06amalloyi can instead expand to `(clojure.test/deftest), but then i can't nest with-test-tags incrementally adding more meta each time, because additional macrolets won't match the ns-qualified symbol
22:06dnolenhmm anyone else getting weird errors when using :require in ClojureScript ?
22:06amalloydoes anyone see a solution to this?
23:14sridmakes my macbookair cry. gave up.
23:18technomancyanyone want to try the new way-faster M-x clojure-jack-in before I cut the release?
23:25technomancyall the adventurous swankers are absent tonight, it appears
23:25technomancyoh well, here it is: https://github.com/technomancy/swank-clojure/commit/31058a
23:31redingeroh what the heck, I'll give it a try :)
23:31technomancyredinger: heh; thanks.
23:31tomojI'm thinking, hey, I'm an adventurous swanker, I just haven't ever tried clojure-jack-in. oh.. wait
23:32technomancyjust do a lein jar on the 1.3.x branch and symlink the result into ~/.lein/plugins
23:32technomancy(you may need to remove the existing swank jar you have there)
23:32patchworkhaving woes with jdbc and postgresql, can anyone help with this one? http://stackoverflow.com/questions/7238238/clojure-postgresql-how-do-i-access-the-enum-values-from-the-jdbc4array-results
23:36technomancymy bad; looks like symlinking may not work, try copying instead?
23:38technomancyhang on, it's not going to work out of a jar; oops
23:38technomancyI was trying it with no swank jar in ~/.lein/plugins
23:39redingerthat's too bad. I was looking forward to faster swanking
23:40technomancyhalf a minute; I think I've almost got it
23:42technomancyhm; I think it's loading *too* fast now
23:42technomancythe elisp is trying to connect before the clojure side is ready
23:43technomancyok, pushed; should work now
23:43sarcherrandom question. is there anything clojure provides that would make parsing / interpreting a large complex xml document (based on a schema) easier than normal java xml parsers?
23:44technomancyadded a 0.1s delay which hopefully I'll be able to remove upon further investigation
23:50redingererror in process filter: load-file: File `/Users/redinger/.emacs.d/swank/slime-cdf283b4.elc' was not compiled in Emacs
23:50redingerdidn't work for me
23:51technomancyhuh; what os/emacs?
23:52redingerLion, Emacs 24.0.50
23:54technomancyoh, I got it; I was mixing up the filenames.
23:54technomancypushed a fix
23:54technomancyI hope this qualifies as your daily dose of adventure =)
23:55sridin enlive, how do I do multiple transformations? eg: both `content` and `set-attr` (mainly for setting href and content of the <a> tag)?
23:59redingerI get the same problem with that build