2011-07-01
| 00:04 | dnolen | is there any literature on efficient incremental tree building in a functional programming language ? |
| 00:14 | devn | dnolen: yes ;) |
| 00:15 | dnolen | devn: heh, links? I see zippers could work but they seem to slow down w/ the depth of the tree. It's seems like you could do it with CPS but I don't see how yet... |
| 00:15 | devn | dnolen: finger trees? :X |
| 00:16 | devn | constant time in lots of cases |
| 00:16 | devn | dnolen: maybe not what you're looking for -- perhaps I'm misunderstanding what you mean when you say incremental |
| 00:17 | dnolen | devn: I'd like to incrementally construct a parse tree. |
| 00:17 | devn | oh. |
| 00:17 | devn | hmm |
| 00:18 | devn | http://www.cse.chalmers.se/~bernardy/FunctionalIncrementalParsing.pdf |
| 00:18 | devn | dnolen: ^Is that more along the lines of what you're looking for? |
| 00:22 | devn | dnolen: after thinking about it I guess finger trees are probably the wrong way to go for walking incrementally |
| 00:23 | dnolen | devn: yeah I saw that paper, seems to recommend zippers as well. |
| 00:23 | devn | dnolen: *nod* |
| 00:24 | devn | yeah, zippers seem to be de rigueur |
| 00:24 | devn | based on what I've read anyway... |
| 00:25 | devn | </pretentious> |
| 00:25 | tomoj | what are you parsing? |
| 00:26 | devn | tomoj: my guess is a code walker |
| 00:26 | dnolen | tomoj: hmm I think I'm wrong about the efficiency of zippers, interesting. |
| 00:27 | dnolen | devn: tomoj: no, I've struggling with how to optimize core.logic for the parsing case. |
| 00:27 | devn | dnolen: what was the assumption? |
| 00:27 | devn | (w/r/t zippers) |
| 00:27 | dnolen | devn: just bad microbench really. |
| 00:28 | devn | what does that mean? |
| 00:28 | devn | (not being antagonistic, just generally curious) |
| 00:29 | dnolen | Prolog DCG let's you take a stream of characters and efficiently produce a parse tree, there's no separate lex, parse phases. |
| 00:29 | devn | DCG? |
| 00:29 | dnolen | devn: testing the perf of the modification + descent, not modification cost once descended. |
| 00:29 | dnolen | devn: Definite Clause Grammar |
| 00:30 | devn | I recently received the art of prolog in the mail |
| 00:30 | dnolen | devn: they are quite cool. |
| 00:30 | dnolen | devn: whoa. |
| 00:30 | devn | I'm excited/scared to crack it open |
| 00:31 | dnolen | devn: Prolog is the shit, pardon my french. http://www.cs.nmsu.edu/ALP/2011/06/bpsolvers-solutions-to-the-third-asp-competition-problems/ show how much Prolog still has to offer. |
| 00:31 | brehaut | devn: thats the Serious Prolog book right? |
| 00:31 | devn | dnolen: It's cool how we were talking about datalog at clojure conj and now one of my favorite libraries is core.loigc |
| 00:31 | devn | logic* |
| 00:32 | devn | It's exciting to think how much can be done in a years' time. |
| 00:32 | dnolen | devn: there's a lot left to do, narrowing in on perf a lot now. |
| 00:32 | devn | *nod*, but even still, it's very cool to see. thanks for it. |
| 00:32 | devn | brehaut: |
| 00:33 | devn | brehaut: "Serious" -- I don't know. I don't find it to be that daunting, honestly. The Craft of Prolog might be a different story. |
| 00:33 | brehaut | devn: i have the bratko book, which is a relatively gentle introduction to it |
| 00:33 | devn | Think: The Little Schemer vs The Seasoned Schemer |
| 00:33 | dnolen | waiting on William Byrds and Daniel Friendman paper on miniKaren CLP programming is nerve wracking, exciting. |
| 00:34 | devn | I'm not familiar with William Byrds |
| 00:34 | devn | :X |
| 00:34 | dnolen | William Byrd, Daniel Friedman - miniKanren creators. no core.logic w/o them. |
| 00:34 | devn | This is my treasure trove of resources on prolog so far: http://paste.lisp.org/display/96726 |
| 00:35 | devn | dnolen: d'oh. shoula known that. |
| 00:35 | devn | shoulda* |
| 00:35 | devn | Did you read nakkaya's post today? |
| 00:35 | dnolen | devn: yes quite cool, if not generally useful |
| 00:36 | devn | heh, it's timely I think |
| 00:38 | devn | I think there's a groundswell of people who are realizing with some tooling and a little bit of community we could hack on C, Java, etc. in Clojure by just doing a bit of research |
| 00:40 | devn | I know that's terribly vague but I've felt something recently, watching the mini-functional-dsls pop up that can just be used wherever without fear, and really 'getting it'. |
| 00:41 | devn | Again terrible vague, maybe you follow... The point is, no matter how much I think I get it, the more I realize there's something else to it. |
| 00:41 | devn | terribly* |
| 00:42 | devn | Insert some deeply philosophical notion of the nature of reality here. |
| 00:43 | devn | Continuity of becoming and all that A.N.W. jazz. |
| 00:45 | devn | dnolen: Are there any tasks a prolog newb could help out on with core.logic? |
| 00:46 | dnolen | devn: I'm loathe to foist any core.logic on anyone yet. I'm still trying to understand it myself. |
| 00:47 | devn | dnolen: that being said, any stuff you'd touch with a 3 foot pole? ;) |
| 00:48 | devn | It's only 3 feet, and yet, it's 3 feet away! |
| 00:48 | devn | dnolen: any ideas on monte carlo simulations in clojure? |
| 00:49 | devn | literature appreciate |
| 00:49 | devn | appreciated* |
| 00:49 | dnolen | devn: no. current big goal is to get DCG optimization stuff in. Then play around with parsing Clojure and feeding it into a rudimentary type checker and get some basic notion of performance. After that I'm probably going to dive back into predicate dispatch + core.logic with gusto. |
| 00:50 | devn | I've never known you to do anything without gusto |
| 00:50 | dnolen | devn: no don't know anything about monte carlo simulation beyond it's usefulness in computer Go |
| 00:51 | devn | I'm never going to have enough time in my life to consume what I've already implicitly agreed to. |
| 00:52 | dnolen | tell me about it. |
| 00:58 | devn | dnolen: have any brilliant ideas on how to match valid paren'd sexps where all sexps are contained in a single line? |
| 00:59 | dnolen | devn: ? |
| 00:59 | devn | so this line you're reading right now (would (recognize (this (is (a valid) s) expression))) |
| 01:00 | devn | where the signal to noise ratio is high |
| 01:02 | dnolen | devn: what is this for? |
| 01:04 | cheier | devn: rainbow-delimiters? |
| 01:14 | devn | dnolen: parsing irc logs of course |
| 01:14 | devn | dnolen: I have a really ugly, bespoke solution right now that bothers me |
| 01:15 | dnolen | devn: maybe one day core.logic, why not fnparse? |
| 01:15 | devn | Is that still around? I felt like the last time I used it, it wasn't finished. |
| 01:16 | dnolen | devn: still around I think. |
| 03:55 | neotyk | Good morning everyone! |
| 04:08 | fliebel | neotyk: Morning |
| 04:09 | ejackson | hello alls |
| 04:21 | seancorfield__ | mornin' ejackson |
| 06:49 | talios | Where does one find info on the current state of clojure-contrib? |
| 07:23 | neotyk | Hi talios, I was trying to fix clojure-maven-plugin to work with swank-clojure 1.3.1 today |
| 07:23 | neotyk | but neither maven 2 nor maven 3 can build current master |
| 07:24 | talios | try curret development branch |
| 07:24 | talios | +n |
| 07:24 | neotyk | anyway only change is that no port file is needed with new swank-clojure |
| 07:24 | talios | mmm, no port - I thought that was fixed ages ago - maybe thats on development? |
| 07:24 | neotyk | let me see |
| 07:25 | talios | trying to chase down some "it breaks in 1.3.x" issues currently actually for a new release |
| 07:25 | talios | can't for the life of me find details on the current breakdown of contrib libs tho :( |
| 07:25 | talios | I know I saved that URL somewhere |
| 07:26 | neotyk | can't help you with that one |
| 07:27 | neotyk | in develop branch I still see portfile been used |
| 07:27 | neotyk | let me see if I can build on it |
| 07:27 | neotyk | which maven it is expected to build with? |
| 07:28 | neotyk | Error resolving version for 'org.apache.maven.plugins:maven-site-plugin': Plugin requires Maven version 3.0 |
| 07:28 | talios | I'm using 3.x, but it -should- work with 2 as I've not changed any deps. or maybe I did? |
| 07:28 | neotyk | I might have borked my local repo |
| 07:28 | talios | ahh - remove the site plugin fromt the pom. |
| 07:29 | talios | I don't actually build a maven site so no point having it :) |
| 07:29 | talios | I think I added that ages ago when I started looking at adding maven reports - but then got sidetracked with work. |
| 07:30 | neotyk | ok, progressing |
| 07:32 | talios | any joy: |
| 07:32 | talios | ? |
| 07:32 | neotyk | qdox failed on compile mojo |
| 07:33 | neotyk | and that is why I don't like developing maven plugins |
| 07:33 | talios | qdox is EVIL |
| 07:34 | neotyk | and when it gets to integration testing, I'm already thinking of getting drunk |
| 07:34 | talios | at least that old one. It barfs all over the place ;( hit me yesterday at work as well. qdox 2.0 is due soon tho - hopefully that fixes all maner of issues |
| 07:34 | talios | neotyk: run with -Dinvoker.skip=true to skip the ITs |
| 07:34 | neotyk | once I get there |
| 07:35 | neotyk | ;-0 |
| 07:35 | talios | tho that qdox issue is odd. what version of maven? 2.2? |
| 07:35 | talios | I don't recall having that issue when I was using 2.x, but that was so long ago now. |
| 07:36 | neotyk | mvn3 is not working on my local repo |
| 07:36 | neotyk | my change is very local |
| 07:36 | neotyk | but it requires swank-clojure 1.3.1 |
| 07:36 | ahritaur | hello. problem is: i have simple app (compojure) and i want to deploy it to GAE. but i use enlive and moustache too, so i have a strange problems when trying to launch this app on a local server from sdk. exception here http://paste.org.ru/?oaj0lr and code is here http://paste.org.ru/?j75md1 |
| 07:36 | neotyk | I can submit pull req |
| 07:36 | talios | sure :) |
| 07:37 | ahritaur | i think that problem is stupid, but im newbie in clojure. |
| 07:37 | talios | does your m3 problem sound like "artifact not found" even if its in your local? we've traced a nasty aether bug in mvn3 and trying ( TRYING ) to get someone in sonatype to fix it :( |
| 07:38 | talios | problem doesn't occur -if- you use a mirror to download your maven artifacts |
| 07:41 | ilyak | ,(concat 1 [2 3] 4) |
| 07:41 | clojurebot | java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer |
| 07:41 | ilyak | I guess I'll have to make my own concat |
| 07:44 | talios | ,(concat [1] [2 3] [4]) |
| 07:44 | clojurebot | (1 2 3 4) |
| 07:46 | neotyk | talios: no idea what it is with my mvn3, don't have patience to care for it |
| 07:46 | neotyk | talios: submitted pull req, though it compares against your master, so it looks huge, while it is just one commit |
| 07:48 | neotyk | talios: fixed it: https://github.com/talios/clojure-maven-plugin/pull/38 |
| 07:50 | talios | neotyk: sweet, will pull that in, is 1.3.1 released? I could have sworn I'd pulled a similar patch awhile ago. odd. |
| 07:52 | neotyk | 1.3.1 was released already |
| 07:53 | neotyk | talios: maybe it was just a foresight |
| 07:55 | neotyk | but careful with that patch, it will work with 1.3.1 but not with anything earlier |
| 07:57 | talios | was going to ask about that :) I might have to break my "rule" and include a depdendency on swank-clojure 1.3.1, will mean one less dep needed for users which is good |
| 07:58 | neotyk | or make it scope optional |
| 07:58 | talios | true |
| 08:17 | ilyak | Is there a function in clojure like (def negate [pred] (fn [x] (not (pred x)))? |
| 08:18 | raek | complement |
| 08:18 | ilyak | thanks! |
| 08:20 | nizze | Hi! Clojure newbie here. |
| 08:20 | nizze | I just did (source map) |
| 08:21 | nizze | Why is the function so complicated? Is it cause of performance or laziness? |
| 08:46 | ebaxt | This must be implemented in Clojure :p http://make-everything-ok.com/ |
| 08:52 | hoeck | nizze: its because of performance and laziness :) |
| 08:59 | hoeck | nizze: earlier versions of map (e.g. this one from 2008: https://github.com/clojure/clojure/blob/a25af8d4b183e0bd3220e155e41efc4baa991922/src/clj/clojure/core.clj#L1240) are a bit simpler |
| 09:00 | hoeck | nizze: and mapping over a single argument, leaving chunked seqs and mapping over more than two arguments aside, is as simple as https://github.com/clojure/clojure/blob/a25af8d4b183e0bd3220e155e41efc4baa991922/src/clj/clojure/core.clj#L1246 |
| 09:07 | nizze | Thanks. |
| 09:07 | nizze | Can you then explain me why Haskell's version of map is much more simple? |
| 09:12 | Cozey | Hi, is there some way to speedup lein's startup ? |
| 09:13 | lnostdal-laptop | i think configuring the jvm to start in client mode as opposed to server mode will help |
| 09:14 | lnostdal-laptop | oh, and there's some info about this at the bottom here https://github.com/technomancy/leiningen |
| 09:14 | hoeck | nizze: where are the sources for haskells map? |
| 09:14 | nizze | http://www.haskell.org/onlinereport/standard-prelude.html |
| 09:14 | nizze | ctrl-f to map |
| 09:15 | hugod | talios: http://clojure02.managed.contegix.com/display/design/Contrib+Library+Names if you haven't yet found it |
| 09:15 | raek | Cozey: you can also use lein interactive |
| 09:16 | Cozey | raek: good point |
| 09:16 | talios | hugod: hazah! cheers |
| 09:16 | nizze | map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x:xs) = f x : map f xs |
| 09:17 | Cozey | ok, but no client mode on 64bit perhaps there is no difference |
| 09:17 | hoeck | nizze: yeah, found it, I'd say is because haskell has operators and pattern matching and laziness built into the compiler |
| 09:18 | hoeck | nizze: whereas clojures laziness lies in the lazy seq datastructure, so in clojure you have to wrap the function body in a lazy-seq macro |
| 09:19 | nizze | Tjamkl |
| 09:19 | joly | nizze: haskell's also just deals with one collection and only with lists. Clojure's works with multiple sequences of various collections |
| 09:19 | nizze | Thanks!! |
| 09:20 | joly | (given my little understanding of Haskell) |
| 09:21 | nizze | Joly, what does "multiple sequences of various collecitons" mean? |
| 09:22 | joly | ,(map + [5 6 7] [1 2 3]) |
| 09:22 | clojurebot | (6 8 10) |
| 09:22 | joly | ,(map inc #{5 6 7}) |
| 09:22 | clojurebot | (6 7 8) |
| 09:22 | nizze | ,(map inc [1 2 3]) |
| 09:22 | clojurebot | (2 3 4) |
| 09:23 | nizze | joly, should that case be "zipped" and then reduced? |
| 09:23 | nizze | (map + [5 6 7] [1 2 3]) |
| 09:26 | joly | nizze: looks like maybe zipWith would do it |
| 09:38 | nizze | joly: One more thing, why isn't map implemented as macro? |
| 09:39 | gfrlog` | nizze: why would it need to be a macro? |
| 09:39 | nizze | And why isn't if implemented as macro? |
| 09:39 | talios | macros are evil. |
| 09:39 | talios | just saying. |
| 09:39 | nizze | gfrlog`: I I understood everything correctly it would be faster. |
| 09:39 | gfrlog` | nizze: I think if is a special form |
| 09:40 | nizze | talios: Why is that? Hygienic things? |
| 09:40 | gfrlog` | by my own reasoning, it is a special form because you need some fundamental built-in way to do conditional evaluation |
| 09:40 | gfrlog` | so all the other macros will output if expressions |
| 09:40 | gfrlog` | (e.g., cond) |
| 09:40 | gfrlog` | nizze: I have no idea why you think macros would make map faster |
| 09:41 | talios | macro overuse makes debugging a pain in the bum, also writes out more bytecode that you need. reuse is good. |
| 09:41 | nizze | talios: So when are macros called for? |
| 09:41 | gfrlog` | macros aren't needed until you want a new kind of syntax |
| 09:41 | schasi | If something is not a var, (ref, atom, agent), then what is it? In terms of "variables" |
| 09:41 | nizze | I come from Ruby land and there it's an obsession to roll up DSL for everything. |
| 09:41 | gfrlog` | schasi: a local variable? |
| 09:42 | schasi | gfrlog`: Because macros are "evaluated" at compile time. That could make them "faster" |
| 09:42 | gfrlog` | schasi: all they do is rearrange the code. At some point it has to turn into actual non-macro code |
| 09:42 | schasi | So there is kinda 5 types of variables? local, var, atom, ref, agent? So to speak |
| 09:43 | gfrlog` | schasi: I can imagine various people around here yelling about your terms, but *I* think you're not too far off-base :) |
| 09:43 | gfrlog` | mostly I think we try to avoid the word "variable" |
| 09:43 | talios | binding |
| 09:43 | gfrlog` | the first of your five cannot vary |
| 09:44 | joly | nizze: macros are used when you want to control when argument evaluation takes place, or to help with syntax. You can't do some things with them |
| 09:44 | gfrlog` | the others are called "reference types" |
| 09:44 | joly | ,(#(% true true) or) |
| 09:44 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/or |
| 09:44 | schasi | gfrlog`: yes :D But well. Ahem. Identifiers, maybe? |
| 09:44 | joly | functions compose better and are generally preferred for that reason |
| 09:45 | joly | nizze: ^ |
| 09:45 | gfrlog` | schasi: as a name for the whole group? |
| 09:45 | schasi | yes |
| 09:45 | nizze | joly: Thanks. |
| 09:46 | gfrlog` | schasi: I'm not sure we'd want to group them together at all. the reference types are for managing the relationship between state and identity. the locals are just for making code more readable |
| 09:46 | nizze | Okay. What's the difference between :keywords and 'symbols |
| 09:46 | schasi | And I find it rather strange so far that vars are global and can be dynamically overridden. Which makes them differ from local identifiers, which can't and are looked up lexically. If I got that right |
| 09:46 | gfrlog` | schasi: any code with locals can be transformed into code without locals |
| 09:46 | nizze | I red the explanation in the manual but only thing I got wast that there were some rule regarding what kind of chars can be in :keyword and 'symbol |
| 09:46 | Chousuke | nizze: keywords evaluate to themselves |
| 09:47 | gfrlog` | schasi: yeah, that feature doesn't get used very often, for obvious reasons |
| 09:47 | talios | mmm, almost 2am, I should crash. night all. |
| 09:47 | Chousuke | nizze: symbols evaluate to whatever value is bound to said symbol in the evaluation context. |
| 09:47 | schasi | gfrlog`: Right now I am actually not sure anymore what a local is. Do you mean a parameter to a function? Or something created with let, which is not a reference type? |
| 09:48 | gfrlog` | schasi: both of those |
| 09:48 | Chousuke | nizze: and you can have several separate symbols that have the same name, too. |
| 09:48 | gfrlog` | theoretically (let) could be transformed into a function, so that the bound symbols are the function parameters |
| 09:48 | nizze | Chousuke: So 'symbol <- Protected symbol <- un protected? |
| 09:48 | nizze | (i.e. evaluated) |
| 09:48 | Chousuke | nizze: quoted |
| 09:48 | Chousuke | nizze: quote is a special operator that prevents evaluation |
| 09:49 | nizze | Is quote magic or is it defined somewhere? |
| 09:49 | gfrlog` | should be a special form |
| 09:49 | raek | nizze: it's a special form, so it's implemented in the compiler |
| 09:49 | gfrlog` | which is as good a definition of "magic" as any |
| 09:50 | nizze | I will count "special form" as magic |
| 09:50 | gfrlog` | :) |
| 09:50 | schasi | lol |
| 09:50 | nizze | Thanks guys. |
| 09:50 | nizze | I much like turtles all the way down. And as little syntax as possible. |
| 09:51 | schasi | "Any sufficiently advanced technology is indistinguishable from magic" |
| 09:53 | lnostdal-laptop | http://paste.lisp.org/display/123070 |
| 09:53 | lnostdal-laptop | in CL i recall something related to this via &allow-other-keys or :allow-other-keys .. but i guess that's sort of the opposite of what i'm looking for here since clojure "allows by default" |
| 09:53 | fliebel | How do I get a seq from an Enumeration? |
| 09:54 | stuartsierra | `enumerator-seq` |
| 09:54 | fliebel | ah, sweet :) |
| 09:55 | gfrlog` | lnostdal-laptop: the only thing I know of off the top of my head is to use a precondition |
| 09:55 | wastrel | acronyms |
| 09:55 | gfrlog` | (or write a macro) |
| 09:56 | lnostdal-laptop | mh, yeah, not sure but anything but a macro would mean repetition |
| 09:57 | gfrlog` | lnostdal-laptop: yeah, at least some minimal repetition |
| 09:57 | gfrlog` | lnostdal-laptop: I've found sometimes it's better to adjust what you want from the language than to rewrite the language with macros :) |
| 09:58 | lnostdal-laptop | yes |
| 09:58 | gfrlog` | lnostdal-laptop: it's a dynamic language, so this kind of situation comes up a lot. I deal with it by writing tests. |
| 09:58 | lnostdal-laptop | i'm hoping i don't have to do this |
| 09:58 | lnostdal-laptop | ..write a macro for something like this |
| 09:59 | gfrlog` | if you absolutely need compile-time guarantees, then clojure's not a good choice |
| 09:59 | gfrlog` | although I guess you weren't asking about compile-time specifically, so I retract that statement |
| 09:59 | lnostdal-laptop | oh, it doesn't have to be compile time |
| 09:59 | lnostdal-laptop | yep |
| 10:00 | gfrlog` | lnostdal-laptop: you could avoid most of the repetition by creating a (has-only-keys?) function and throwing that in the precondition |
| 10:00 | gfrlog` | (fn [& {:keys [a] :or {a "default"} :as m}] {:pre (has-only-keys? m :a)} (println a)) |
| 10:00 | lnostdal-laptop | yeah, perhaps (meta ...) or something can read out arg-list info? |
| 10:01 | gfrlog` | if you're doing this a lot, a macro could also reduce the repetition that you already have |
| 10:01 | gfrlog` | (i.e., you have 'a' twice) |
| 10:01 | lnostdal-laptop | yeah, i'm having a lot of keys here |
| 10:01 | gfrlog` | so I think something like (named-arg-fn [a "default", b "foobar"] ...) |
| 10:02 | gfrlog` | you could have that give you not only the destructuring but also check that no other keys are present |
| 10:02 | gfrlog` | if you don't want defaults for everything then it'd be a bit more complex |
| 10:02 | hoeck | or find a way to patch the destructuring function and provide a :keys-only clause |
| 10:03 | gfrlog` | lnostdal-laptop: is the whole point of this to be able to catch typos easier? |
| 10:03 | hoeck | ((fn [& {:only-keys [a]} (+ a a)) :b 10) -> exceptoin |
| 10:04 | lnostdal-laptop | yeah, gfrlog` .. so i'm not stuck wondering why :a ends up with "default" even though i surely have changed it |
| 10:04 | Chousuke | :only-keys? :/ |
| 10:04 | gfrlog` | lnostdal-laptop: I think that's a more general problem that's better dealt with by testing :) |
| 10:05 | Chousuke | or a code analysis tool |
| 10:05 | Chousuke | but it's going to be a lot of work to write one. |
| 10:06 | lnostdal-laptop | just run-time is fine, ChanServ |
| 10:06 | lnostdal-laptop | Chousuke, |
| 10:06 | lnostdal-laptop | (see? .. i made a typo.... :P) |
| 10:06 | Chousuke | I don't really agree with checking the keys in principle though. what if you *want* to pass in a map that has extra keys? |
| 10:06 | Chousuke | just don't make silly typos :P |
| 10:06 | lnostdal-laptop | both things should be possible |
| 10:06 | gfrlog` | lnostdal-laptop: ^ that too :) it's not very clojure-like |
| 10:07 | Chousuke | besides, if you just test your functions you'll catch something like that pretty easily :) |
| 10:07 | Chousuke | one of the nice things about Clojure is that you *can* test things independently |
| 10:08 | lnostdal-laptop | yeah, but repetition |
| 10:08 | Chousuke | repetition? :/ |
| 10:08 | gfrlog` | you mean the repeated a? |
| 10:08 | lnostdal-laptop | testing is just another word for what i'm really after here .. it doesn't change anything |
| 10:08 | lnostdal-laptop | no .. the typo'ed :a |
| 10:08 | Chousuke | in more strict languages it's hard to even test such things because you can't run code that's not complete yet :P |
| 10:09 | Chousuke | but in Clojure functions are often self-contained so you can just call them from the repl and see if they work |
| 10:10 | gfrlog` | Chousuke: isn't that more about composing pure functions than it is about static vs. dynamic? |
| 10:10 | Chousuke | yes. |
| 10:13 | lnostdal-laptop | http://paste.lisp.org/display/123070#1 |
| 10:14 | lnostdal-laptop | ..and i can use &rest to catch all .. like the :as thingy in clojure |
| 10:15 | lnostdal-laptop | ..so CL is strict here by default, but switches to the clojure way via the &allow-other-keys option |
| 10:16 | mjg123 | Hi all - what's the idiomatic clojure which reads an inputstream into a string |
| 10:16 | mjg123 | ? |
| 10:17 | gfrlog` | mjg123: I think slurp does that? |
| 10:17 | gfrlog` | the java IO classes confuse me, that's the only reason I'm not positive |
| 10:18 | mjg123 | gfrlog`, perfect :) |
| 10:18 | gfrlog` | mjg123: good good |
| 10:19 | lnostdal-laptop | http://paste.lisp.org/display/123070#2 .. i suppose i could extract meta-data for the function in a pre-condition test |
| 10:19 | lnostdal-laptop | ..to avoid having to repeat the keys |
| 10:19 | gfrlog` | lnostdal-laptop: you can access the function object from the function itself? |
| 10:19 | lnostdal-laptop | gfrlog`, i would guess so .. since the pre-condition test runs at run-time; not compile-time |
| 10:20 | gfrlog` | lnostdal-laptop: it doesn't need metadata |
| 10:20 | lnostdal-laptop | how so? |
| 10:20 | gfrlog` | lnostdal-laptop: it's just macro expanded into assert expressions |
| 10:20 | gfrlog` | so (fn [x] {:pre (pos? x)} (inc x)) would expand to... |
| 10:20 | lnostdal-laptop | ..of course it needs to know about the argument list, or i'll have to type the keys again |
| 10:21 | gfrlog` | (fn [x] (assert (pos? x)) (inc x)) |
| 10:21 | gfrlog` | lnostdal-laptop: my guess is you can't programamtically access the argument list of the function you're in without a macro to make that available. But there might be a clojure feature I don't know about. |
| 10:22 | lnostdal-laptop | http://paste.lisp.org/display/123070#3 |
| 10:23 | gfrlog` | lnostdal-laptop: ah, yeah if it's a def'ed function I guess that would work |
| 10:23 | gfrlog` | and perhaps for an anon-fn you could just name it...lessee |
| 10:23 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta get-args)))) |
| 10:23 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: sandbox$eval579$get-args |
| 10:23 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta get-args))) 1 2 3) |
| 10:23 | clojurebot | nil |
| 10:24 | gfrlog` | maybe w/o defn there's no metadata |
| 10:24 | lnostdal-laptop | need the ns-reslove stuff |
| 10:24 | lnostdal-laptop | ..before passing it to meta |
| 10:24 | gfrlog` | lnostdal-laptop: I don't think that'll work for these, as there's no var |
| 10:24 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta (ns-resolve get-args)))) 1 2 3) |
| 10:24 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$ns-resolve |
| 10:25 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta (ns-resolve *ns* get-args)))) 1 2 3) |
| 10:25 | clojurebot | java.lang.ClassCastException: sandbox$eval591$get_args__592 cannot be cast to clojure.lang.Symbol |
| 10:25 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta (ns-resolve (ns-name *ns*) get-args)))) 1 2 3) |
| 10:25 | clojurebot | java.lang.ClassCastException: sandbox$eval595$get_args__596 cannot be cast to clojure.lang.Symbol |
| 10:26 | gfrlog` | ,((fn get-args [x y z] (:arglists (meta (ns-resolve (ns-name *ns*) 'get-args)))) 1 2 3) |
| 10:26 | clojurebot | nil |
| 10:26 | gfrlog` | I think the ns-resolve is returning nil there |
| 10:27 | lnostdal-laptop | ,((fn get-args [x y z] (:arglists (meta #'get-args))) 1 2 3) |
| 10:27 | clojurebot | java.lang.Exception: Unable to resolve var: get-args in this context |
| 10:27 | lnostdal-laptop | ok, it works here |
| 10:27 | lnostdal-laptop | => ([x y z]) |
| 10:27 | lnostdal-laptop | which is correct |
| 10:27 | gfrlog` | lnostdal-laptop: did you def it at some point? |
| 10:27 | lnostdal-laptop | nope |
| 10:28 | gfrlog` | cause it sure doesn't work for me and I wouldn't expect it to |
| 10:28 | gfrlog` | what about just #'get-args by itself? |
| 10:28 | lnostdal-laptop | oh, wait .. |
| 10:29 | lnostdal-laptop | yeah, doesn't work with anon fns |
| 10:30 | gfrlog` | lnostdal-laptop: and with that strategy you're still repeating something (the function name), as well as making it harder to rename your functions |
| 10:30 | lnostdal-laptop | yup |
| 10:34 | jao | hm. so there's no way to make ns A re-export names it's using from a second package B (so that anyone importing A also imports B's names), is there? |
| 10:35 | gfrlog` | jao: I think there is |
| 10:35 | gfrlog` | I saw a contrib library do it once... |
| 10:35 | jao | gfrlog`, i've seen solutions manipulating the ns symbol maps explicitly... yes |
| 10:36 | jao | i was thinking of something in core |
| 10:36 | raek | jao: nothin in core |
| 10:36 | gfrlog` | I can't remember if it used something from core or not |
| 10:36 | gfrlog` | welp never mind then, I'll stop looking :) |
| 10:36 | jao | :) |
| 10:36 | gfrlog` | and now I remember it was c.c.mock |
| 10:36 | jao | thanks anyway |
| 10:37 | raek | http://clojure.github.com/clojure-contrib/ns-utils-api.html |
| 10:37 | raek | maybe you are thinking of 'immigrate' |
| 10:37 | gfrlog` | yeah, that's how c.c.mock.test_adapter imports c.c.mock |
| 10:37 | stuartsierra | `immigrate` does not work. |
| 10:37 | raek | it has some caveats |
| 10:38 | jao | raek, ah thanks |
| 10:38 | raek | jao: I would not recommend using it |
| 10:38 | jao | immigrate is was i was thinking of |
| 10:38 | jao | well, a working version of it |
| 10:39 | raek | if you update the vars in the "original" namespace, the vars of the namespace that called immigrate won't be updated |
| 10:39 | jao | i see. most inconvenient. |
| 10:40 | raek | if the functions are public anyway, i think it's simpler to just let the user of the namespace require two namespaces instead of one |
| 10:40 | jao | are there any plans to add this functionality in the future to core clojure? |
| 10:41 | stuartsierra | One of the properties of a Var is the namespace it belongs to, so no. |
| 10:41 | jao | raek, well, in simple cases yes. but transitivity might mean a handful of requires that have to be maintained during refactorings. |
| 10:41 | gfrlog` | well apparently I was wrong about vars |
| 10:41 | raek | compojure used to use immigrate but does nowadays |
| 10:42 | raek | *doesn't |
| 10:42 | stuartsierra | If you need a convenient way to make multiple namespaces available without repeating :use/:require directives, you can write a helper function which calls `refer` and call it at the top of your namespace. |
| 10:42 | raek | you kind of always have that problem if you rename a ns |
| 10:43 | jao | stuartsierra, aha, that sounds like a plan |
| 10:43 | jao | stuartsierra, thanks |
| 10:44 | jcromartie | Is rhickey ever on much anymore? |
| 10:45 | gfrlog` | stuartsierra: why should a var be associated with a namespace? |
| 10:45 | gfrlog` | (I imagined a "namespace" was a map from symbols to vars, which wouldn't require the vars knowing about the namespace[s]) |
| 10:45 | stuartsierra | I dunno, but that's the way it works. |
| 10:46 | gfrlog` | hmm... and it knows the symbol too |
| 10:46 | gfrlog` | I could see it being metadata...oh well |
| 10:51 | fliebel | $findfn 0 [5 0 1 2 0 4 0 1 4] [[5] [1 2] [4] [1 4]] |
| 10:51 | sexpbot | [] |
| 10:51 | gfrlog` | fliebel: clojure.string/split for seqs? |
| 10:51 | fliebel | gfrlog`: yea... |
| 10:52 | fliebel | I could do a recursive split-at maybe... |
| 10:52 | gfrlog` | yeah I was just thinking of using loop |
| 10:52 | gfrlog` | split-at can't be right though |
| 10:52 | raek | ,(take-nth 2 (partition-by #{0} [5 0 1 2 0 4 0 1 4])) |
| 10:52 | clojurebot | ((5) (1 2) (4) (1 4)) |
| 10:52 | gfrlog` | split-with is it |
| 10:53 | gfrlog` | kay I'll shut up now |
| 10:53 | fliebel | raek: yuk, feeding the CG, arn't you? |
| 10:53 | gfrlog` | he's coding faster :) |
| 10:54 | gfrlog` | ~optimize |
| 10:54 | clojurebot | I don't understand. |
| 10:54 | gfrlog` | clojurebot: optimize? |
| 10:54 | clojurebot | No entiendo |
| 10:54 | fliebel | gfrlog`: I see.. |
| 10:54 | gfrlog` | ggggrg |
| 10:55 | gfrlog` | clojurebot was supposed to have something snarky to say about premature optimization |
| 10:55 | raek | fliebel: the GC? |
| 10:55 | gfrlog` | the carbage gollector of course |
| 10:56 | fliebel | gfrlog`: Yea, I know... |
| 10:57 | gfrlog` | fliebel: thinking about that makes me want to start adding comments to my code when I write something that could be made faster by complicating it |
| 10:57 | gfrlog` | like ; SLOW |
| 10:58 | gfrlog` | then I'm acknowledging the fact, but not doing anything about it unless it becomes necessary |
| 10:58 | jcromartie | ^{:slow true} |
| 10:58 | gfrlog` | yeah I thought of that too...I like SLOW for grepping |
| 10:59 | gfrlog` | like TODO |
| 10:59 | jcromartie | metadata FTW though |
| 10:59 | jcromartie | :SLOW would be fine |
| 10:59 | gfrlog` | jcromartie: maybe I don't use metadata well enough |
| 10:59 | lnostdal-laptop | so in 1.3.x .. defstruct is out and defrecord is better? |
| 10:59 | gfrlog` | jcromartie: I wouldn't know what to do with that |
| 10:59 | jcromartie | you can have greppable metadata |
| 11:00 | lnostdal-laptop | fliebel, thank the jvm |
| 11:00 | lnostdal-laptop | :) |
| 11:00 | jcromartie | searching namespaces for metadata on vars is pretty easy, I wonder if there's any fn that makes it easier |
| 11:00 | jcromartie | apropos and find-doc are my new best friends |
| 11:00 | jcromartie | they should appear if you type "help" at the repl |
| 11:01 | gfrlog` | does anybody object to "premature" optimization when something can be made an order of magnitude faster? |
| 11:01 | jcromartie | that's not really premature |
| 11:01 | jcromartie | is it? |
| 11:01 | gfrlog` | "order of magnitude" was a bad word there |
| 11:01 | jcromartie | how much does it complicate the public API |
| 11:01 | gfrlog` | jcromartie: I think of "premature" as being "optimizing before you have a problem" |
| 11:02 | jcromartie | well I had some code where changing one keyword made it two orders of magnitude faster :) |
| 11:02 | jcromartie | sorry symbol |
| 11:02 | jcromartie | :) thinking in C-type languages today |
| 11:02 | gfrlog` | jcromartie: you changed Thread/sleep to prn? |
| 11:02 | jcromartie | hah hah |
| 11:03 | jcromartie | changed from conj to into |
| 11:03 | gfrlog` | hmm |
| 11:03 | gfrlog` | I'm curious the context |
| 11:04 | jcromartie | merging new information into a markov chain trigram occurrence structure |
| 11:19 | jcromartie | what's the deal with namespace metadata |
| 11:21 | gfrlog` | yeah what's the deal! |
| 11:21 | gfrlog` | ,(meta *ns*) |
| 11:21 | clojurebot | nil |
| 11:25 | stuartsierra | `ns` supports reader metadata on the namespace name. |
| 13:14 | ahritaur | hello guys anybody here who use clojure-compojure with eclipse? i'm interested with "full integration" - with leiningen etc. Is it real? I mean: edit, build and then launch web-browser. |
| 13:52 | derp__ | what is a {}? is it a hash-map? |
| 13:52 | gfrlog` | (type {}) |
| 13:52 | gfrlog` | ,(type {}) |
| 13:52 | clojurebot | clojure.lang.PersistentArrayMap |
| 13:52 | derp__ | ah |
| 13:52 | technomancy | derp__: it's a map. the specific implementation class is irrelevant |
| 13:53 | derp__ | is there a way to create a map within a map? |
| 13:53 | gfrlog` | ,(type (zipmap (range 10000) (range 7 280833))) |
| 13:53 | clojurebot | clojure.lang.PersistentHashMap |
| 13:53 | technomancy | ,{{}} |
| 13:53 | clojurebot | java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1 |
| 13:53 | derp__ | I just tried (def a {:b {}}) and got an error, so I assume not |
| 13:53 | technomancy | wat |
| 13:53 | gfrlog` | ,{{} {}} |
| 13:53 | clojurebot | {{} {}} |
| 13:53 | technomancy | oh duh |
| 13:53 | gfrlog` | :) |
| 13:54 | gfrlog` | derp__: that looks good to me -- what error? |
| 13:54 | gfrlog` | (all the general clojure collections can be nested arbitrarily) |
| 13:54 | derp__ | gfrlog: lol, I'm an idiot. I have been typing "b:" instead of ":b" in the repl for a while |
| 13:55 | gfrlog` | derp__: apologize to your poor repl |
| 13:55 | derp__ | the poor thing does deserve better |
| 13:59 | S11001001 | ,(do {{}} 'hi-there) |
| 13:59 | clojurebot | 1 |
| 14:00 | S11001001 | huh |
| 14:00 | gfrlog` | ,(do {{}}) |
| 14:00 | clojurebot | 1 |
| 14:00 | gfrlog` | ,(do :wut) |
| 14:00 | clojurebot | :wut |
| 14:00 | gfrlog` | ,(do {:foo 'bar}) |
| 14:00 | clojurebot | {:foo bar} |
| 14:01 | gfrlog` | ,(read-string "(do {{}})") |
| 14:01 | clojurebot | 1 |
| 14:01 | gfrlog` | wut it doing. |
| 14:01 | S11001001 | ,(do {{}} :wha) |
| 14:01 | clojurebot | 1 |
| 14:01 | amalloy | 1 is the error message for the exception |
| 14:01 | amalloy | not for any obvious reason |
| 14:02 | gfrlog` | ,(type (do {{}} :wha)) |
| 14:02 | clojurebot | 1 |
| 14:02 | gfrlog` | aah okay. so it's not actually returning 1 :) |
| 14:02 | gfrlog` | that's encouraging. Thanks clojurebot for making that clear. |
| 14:03 | gfrlog` | &(type (do {{}} "can sexpbot do better?")) |
| 14:03 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 1 |
| 14:03 | amalloy | &(do {{}} 20) |
| 14:03 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 1 |
| 14:03 | gfrlog` | sexpbot: botsnack |
| 14:03 | sexpbot | gfrlog`: Thanks! Om nom nom!! |
| 14:06 | S11001001 | &(do (array-map 1 2 3) 42) |
| 14:06 | sexpbot | ⟹ 42 |
| 14:13 | amalloy | S11001001: funny. PersistentArrayMap.createWithCheck only checks that none of the keys are the same |
| 14:13 | amalloy | &(array-map 1 2 3) |
| 14:13 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 3 |
| 14:14 | S11001001 | &((array-map 1 2 3) 1) |
| 14:14 | sexpbot | ⟹ 2 |
| 14:15 | amalloy | i think the exception is getting thrown by clojure.lang.RT when it tries to print the map |
| 14:15 | amalloy | &(seq (array-map 1 2 3)) |
| 14:15 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 3 |
| 14:18 | S11001001 | &((array-map :a :b :c) :c) |
| 14:18 | sexpbot | java.lang.ArrayIndexOutOfBoundsException: 3 |
| 14:20 | amalloy | huh. well, i see what's going on, but personally i think array-map should do the same checking as hash-map does |
| 14:42 | amalloy | Caused by: java.lang.RuntimeException: java.io.IOException: success ;; i do so love java |
| 14:45 | ilyak | Hi * |
| 14:45 | ilyak | I'm using clojure's defrecord |
| 14:45 | ilyak | it's like (defrecord Download [id date-time region ip]) |
| 14:45 | ilyak | and if I swap region and ip my program slows down 2.5x times |
| 14:46 | ilyak | (defrecord Download [id date-time ip region]) => 2.5x times slowdown |
| 14:46 | ilyak | WTF?? |
| 14:50 | gfrlog` | ilyak: won't that change what your code does? |
| 14:51 | gfrlog` | ilyak: or are you changing all the (new Download ...) calls too? |
| 14:52 | hiredman | ilyak: also you need to reload all code that accesses :region and :ip to get new inline caches, I believe |
| 14:53 | ilyak | gfrlog`: I sure do |
| 14:53 | ilyak | hiredman: I restart the process each time, and the effect is stable |
| 14:54 | gfrlog` | ilyak: is it possible to create a minimal example, perhaps where you create two differente (defrecord)s and do some basic performance tests, outside the context of the rest of your code? |
| 14:55 | ilyak | I'm trying |
| 14:55 | cemerick | ejackson: I think you'll appreciate this: http://www.statisticalengineering.com/frequentists_and_bayesians.htm |
| 14:55 | ilyak | The only idea I have is that defrecord constructor is lazy in some bizzare way |
| 14:55 | ilyak | and that it skips initializing the last member, which is ip, which doesn't get used |
| 14:55 | ilyak | unless it's not last, in which case it does |
| 14:56 | hiredman | ilyak: have you cleared out classes? |
| 14:56 | hiredman | ./classes/ |
| 14:59 | ilyak | Oh, you imply that maybe I'm converting a field access to assoc? |
| 14:59 | ilyak | I'll definitely check |
| 15:04 | ilyak | I think you're probably right. Sigh for ccw not being able to recompile classes on its own |
| 15:06 | ejackson | cemerick: I do lurlllve me some good stats throw down. |
| 15:06 | ilyak | Yeah, it looks like that it was writing wrong types into wrong slots |
| 15:06 | ilyak | and then trying to use wrong types in inappropriate context |
| 15:06 | ilyak | still it's mystery why it didn't fail instead of busy working |
| 15:08 | ejackson | cemerick: a good tract that gets into this 'division' is http://www.cambridge.org/gb/knowledge/isbn/item1155795/?site_locale=en_GB by Jaynes |
| 15:10 | jweiss | fn takes an option name as the first arg. how do you get that name back? it's not in the meta |
| 15:11 | jweiss | ,(meta (fn heresthename [] 1)) |
| 15:11 | clojurebot | nil |
| 15:11 | gfrlog` | jweiss: I would expect it to just be a local variable, and not accessible programmatically |
| 15:11 | gfrlog` | i.e., just for recursion |
| 15:11 | gfrlog` | or other self-reference |
| 15:11 | jweiss | oh. that kinda sucks |
| 15:11 | gfrlog` | jweiss: whyso? |
| 15:12 | gfrlog` | ,(macroexpand '(fn foo [] :foo)) |
| 15:12 | clojurebot | (fn* foo ([] :foo)) |
| 15:12 | jweiss | ok, so if i do (def x (fn-that-returns-fn)) is it not possible to get the kind of metadata that defn gives it? |
| 15:12 | jweiss | i mean, i guess i could apply it myself since i control that function |
| 15:12 | pcavs_ | jweiss: you could always write a your own macro to throw the function name into the meta data? I don't know what the use case for that would be, but it's possible |
| 15:12 | jweiss | pcavs_: i'm trying to do trace |
| 15:13 | jweiss | and non-defn'd fns don't have the metadata |
| 15:13 | cemerick | ejackson: looks interesting, but probably *way* over my head? |
| 15:13 | gfrlog` | jweiss: can a function ever generally access itself in any way that doesn't involve hard-coding the var-name or something else? |
| 15:13 | ejackson | doubt it - the description is more frightening than the book.... lemme just go upstairs and have a gander at mine |
| 15:14 | jweiss | gfrlog`: well i just want the var to have more info than it does |
| 15:14 | gfrlog` | jweiss: how would you get to the var? |
| 15:14 | jweiss | oh wait srry, i want the actual fn to have more data than it does :) |
| 15:14 | gfrlog` | same question -- how do you access the fn? |
| 15:15 | jweiss | my trace fn just has it passed to it |
| 15:15 | jweiss | and it wants to print out the ns and name |
| 15:15 | gfrlog` | okay, so you're not trying to do something from inside the fn |
| 15:15 | gfrlog` | I see |
| 15:15 | jweiss | fn's defined with defn have metadata |
| 15:15 | gfrlog` | right |
| 15:15 | gfrlog` | you could...rebind clojure.core/fn :) |
| 15:16 | jweiss | i think i can just add some meta to the fn :) |
| 15:17 | cemerick | ejackson: actually, the ToC gives me much hope that it's relatively comprehensible |
| 15:25 | ejackson | cemerick: its a funny one, lots of discussion, and not actually a great deal of maths. |
| 15:26 | cemerick | ejackson: So I gather. The title should be a little more lighthearted in that case. "So I heard you like stats", or something. |
| 15:27 | kryft | ejackson: Oo, Jaynes |
| 15:27 | kryft | cemerick: Jaynes is very readable. |
| 15:28 | cemerick | kryft: we'll find out soon enough if he can penetrate a dullard like myself. :-P |
| 15:28 | ejackson | cemerick: more like 'frequentists are stupid, like macaques' |
| 15:28 | kryft | cemerick: He's very opinionated, and a mathematician complained to me that his statements about Gödel's incompleteness theorem don't make a lot of sense, but for understanding Bayesian inference, it's great. |
| 15:29 | ejackson | cemerick: I really, really like MacKays book http://www.inference.phy.cam.ac.uk/mackay/itila/ |
| 15:29 | kryft | I wonder why I inserted that last comma. |
| 15:29 | kryft | gfrlog`: *drumfill* |
| 15:29 | gfrlog` | :) |
| 15:30 | matthias__ | hmm, i have a map and in it is a number, i checked it is 0. but when i try to coerce that number into a double, i get a nullpointerexception Oo |
| 15:30 | kryft | cemerick: Yeah, MacKay's book is great too. |
| 15:30 | ejackson | and you can read on your screen free of charge, which is a plus. A bit more mathsy, calculation wise, though. |
| 15:30 | clojurebot | You don't have to tell me twice. |
| 15:30 | gfrlog` | matthias__: sounds weird. can you show us the code? |
| 15:31 | ejackson | cemerick: oh dear, you bought it already ! |
| 15:32 | matthias__ | http://pastebin.com/twBLSNT8 there it is, gfrlog` |
| 15:33 | matthias__ | i only put the double in to test, the nullpointerexception comes somewhere out of rotation-matrix without it |
| 15:34 | gfrlog` | matthias__: so you're saying that (double (:player-angle state)) throws an exception? |
| 15:35 | matthias__ | yeah |
| 15:35 | gfrlog` | ,(double (:player-angle {:player-angle 0})) |
| 15:35 | clojurebot | 0.0 |
| 15:35 | matthias__ | the same code used to work actually... |
| 15:36 | matthias__ | and :player-angle is in the map. at least it is at the time of the breakpoint |
| 15:36 | cemerick | ejackson: I'm sadly fast and loose with the book purchases. I've got four heavy-hitters waiting for me on my desk already. :-/ |
| 15:36 | gfrlog` | matthias__: if I was debugging it I would add (let [pa (:player-angle state)] (prn pa) (prn (type pa))) to the top of the function |
| 15:36 | ejackson | cemerick: you and me both :) |
| 15:37 | gfrlog` | matthias__: and see what it spits out |
| 15:38 | gfrlog` | matthias__: or check the type using your swank voodoo :P |
| 15:38 | matthias__ | omg |
| 15:39 | ejackson | cemerick: so, being nosy, what are these Barry Bonds Books ? |
| 15:39 | matthias__ | im an idiot, thanks gfrlog` :S |
| 15:39 | gfrlog` | anytime |
| 15:43 | cemerick | ejackson: Pearl's Causality is the most serious one |
| 15:44 | cemerick | Also, Hopcraft and Ullman's Automata Theory (1979 ed) |
| 15:44 | ejackson | i've not read that one. |
| 15:45 | cemerick | ejackson: http://t.co/TyLvDnQ |
| 15:46 | cemerick | The later editions are apparently pretty watered down |
| 15:47 | cemerick | I can get hand-wavy stuff anywhere, so I wanted to get the authoritative, rigorous approach |
| 15:50 | amalloy | gfrlog`: c'mon, you missed a perfect chance to use juxt |
| 15:51 | amalloy | (prn ((juxt identity type) (:player-angle state))) |
| 15:51 | gfrlog` | amalloy: I was trying to figure out if you were on or not |
| 15:51 | amalloy | very clever scheme |
| 15:52 | amalloy | and what you discovered was that for fifteen minutes i wasn't |
| 15:52 | gfrlog` | yep |
| 15:54 | gfrlog` | (defn make-vector-from-three-fns-and-two-args [f g h x y] [(f x y) (g x y) (h x y)]) |
| 16:11 | rbuchmann | ,(update-in '(1 2 3 4) [1] #(+ 1 %)) |
| 16:11 | clojurebot | java.lang.NullPointerException |
| 16:12 | rbuchmann | What do I miss here...? O_o |
| 16:12 | amalloy | vectors aren't lists |
| 16:12 | amalloy | er, other way round: lists aren't vectors |
| 16:12 | amalloy | &(update-in [1 2 3 4] [1] inc) |
| 16:12 | sexpbot | ⟹ [1 3 3 4] |
| 16:13 | rbuchmann | so, if I want to do that on a general sequence I have to do (vec ..) first= |
| 16:13 | rbuchmann | ? |
| 16:14 | rbuchmann | If I have to update something in a nested sequence of lists, what do I do? |
| 16:15 | rbuchmann | *list of lists |
| 16:16 | rbuchmann | turning it into a zipper or the like seems like overkill |
| 16:17 | rbuchmann | seems a little silly that update-in doesnt work, considering stuff like nth is well defined |
| 16:19 | amalloy | rbuchmann: update-in is supposed to be fast |
| 16:20 | amalloy | it only works with Associative |
| 16:20 | amalloy | those are both good reasons not to make it work for lists |
| 16:20 | rbuchmann | hm, okay |
| 16:20 | rbuchmann | So how would I go about updating a nested list? |
| 16:20 | raek | by index? |
| 16:20 | raek | then you want nested vectors |
| 16:21 | raek | lists/seqs are not the right data structures for random access and updates |
| 16:21 | rbuchmann | hm, and if I have stuff in the generation process that returns lazy seqs? should I always (vec ...) it then? |
| 16:22 | raek | if you choose vectors as you representation, then yes |
| 16:22 | raek | *your |
| 16:22 | rbuchmann | okay, thanks |
| 16:25 | rbuchmann | I was working on http://4clojure.com/problem/43 , but I guess I am on the wrong track :D |
| 16:27 | rbuchmann | I believe it does |
| 16:27 | rbuchmann | :) |
| 16:28 | rbuchmann | that wasn't exactly what I had in mind ^^ |
| 16:28 | gfrlog` | I'm hoping it will crash the site |
| 16:28 | raek | isn't the number given as the second argument always the length of the input list? |
| 16:29 | gfrlog` | raek: on prob-43? no... |
| 16:29 | raek | er, I kinda looked at this in a mirrored way |
| 16:31 | gfrlog` | rbuchmann: got it! https://gist.github.com/1059331 |
| 16:31 | rbuchmann | haha |
| 16:31 | rbuchmann | nice |
| 16:31 | gfrlog` | there was a bug in it the first time, but I fixed it |
| 16:32 | derp__ | why doesn't this code work? |
| 16:32 | derp__ | ,(do (def a (fn [] ({:b "test"}))) (a :b)) |
| 16:32 | clojurebot | DENIED |
| 16:32 | gfrlog` | derp__: ##({:b "test"}) |
| 16:32 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentArrayMap |
| 16:32 | gfrlog` | you're calling a map with no args |
| 16:32 | gfrlog` | maps want a key :) |
| 16:33 | gfrlog` | not to mention your function a takes no args, and then you're calling it with one arg :) so it can fail on two places |
| 16:33 | gfrlog` | rbuchmann: actually there oughta be a mildly cleverer way to do it... |
| 16:33 | rbuchmann | should be ((a) :b) |
| 16:33 | derp__ | ah |
| 16:33 | raek | derp__: 1) you call a with one arg, but it accepts zero 2) you call the map {:b "test"} as a function |
| 16:34 | amalloy | gfrlog`: for a while we did have hidden tests |
| 16:34 | amalloy | but they confused a lot of users, and we don't really care if losers like you hard-code the test cases |
| 16:34 | gfrlog` | amalloy: your site didn't say I was a loser |
| 16:34 | amalloy | it's in an html comment |
| 16:34 | gfrlog` | oh okay |
| 16:34 | derp__ | well I what I want to do is create a function that returns a dynamically made map |
| 16:35 | gfrlog` | derp__: why dynamically? |
| 16:35 | gfrlog` | derp__: why not (constantly {:foo "bar"}) |
| 16:35 | gfrlog` | (I guess I mean your example sure didn't seem dynamic -- it seems like a constant function) |
| 16:36 | rbuchmann | I guess it was meant as a theoretical example |
| 16:36 | gfrlog` | rbuchmann: this is a bit cleaner: https://gist.github.com/1059341 |
| 16:37 | gfrlog` | derp__: if it's not a constant function, you can just remove the parens from around the map in your example and it should work |
| 16:37 | rbuchmann | amalloy: you're involved in that site? nice, I like it |
| 16:38 | amalloy | rbuchmann: if you're interested you can see a lot of neat solutions by searching for #4clojure on twitter |
| 16:38 | derp__ | gfrlog: thank you! |
| 16:38 | gfrlog` | derp__: yessir |
| 16:40 | raek | there, #43 solved :) |
| 16:40 | amalloy | rbuchmann: *spoiler* my favorite solution is https://gist.github.com/1059351 (i didn't come up with it, but saw it on twitter) |
| 16:40 | gfrlog` | amalloy: have you ever tried to solve each problem with juxt? |
| 16:40 | rbuchmann | amalloy: aaah, I got to partition, but couldn't see how to use it effectively after that |
| 16:40 | rbuchmann | that ones very nice |
| 16:41 | rbuchmann | haha |
| 16:41 | rbuchmann | yes, mine is a *tad* longer too |
| 16:41 | raek | https://gist.github.com/1059347 well, here it is |
| 16:41 | raek | *spoiler* etc |
| 16:41 | amalloy | raek: i know, right!? mine was https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils/seq.clj#L19 before i saw that one posted on 4clojure |
| 16:42 | amalloy | and then i was ashamed |
| 16:42 | rbuchmann | hehe |
| 16:45 | amalloy | *chuckle* raek, i like how you were careful enough to doall, just in case |
| 16:46 | raek | :-) |
| 16:49 | raek | amalloy: ...but you would get a StackOverflowError if you called it with (range 10000) and 1 otherwise! |
| 16:49 | amalloy | exactly! good save |
| 17:24 | hippytaf1 | hi..can anyone give me a link to a good lispbox tutorial...downloaded the lispbox package as lisp in a box is defunct, but the tutorial I was following was for commom lisp not clojure common list...so I wasted a whole afternoon (of very sparse free time) |
| 17:25 | hippytaf1 | I'd rather spend my sparce free tim with lisp than python or c |
| 17:26 | hippytaf1 | having read a this http://www.gigamonkeys.com/book/ |
| 17:26 | clojurebot | I think you mean gnir. |
| 17:26 | amalloy | hippytaf1: maybe technomancy's emacs-starter-kit? |
| 17:26 | hippytaf1 | thanks bot |
| 17:26 | hippytaf1 | got a link amalloy |
| 17:26 | hippytaf1 | ? |
| 17:27 | technomancy | hippytaf1: there's clojurebox, but as far as I know it's pretty dated and windows-only |
| 17:27 | amalloy | $google emacs technomancy emacs-starter-kit |
| 17:27 | sexpbot | First out of 865 results is: technomancy/emacs-starter-kit at master - GitHub |
| 17:27 | sexpbot | https://github.com/technomancy/emacs-starter-kit/blame/master/starter-kit-lisp.el |
| 17:30 | hippytaf1 | thanks sexpbot, that seems like some source code though :) |
| 17:31 | hippytaf1 | appreciate the link though...always amazes me how compact lisp source code is |
| 17:32 | hippytaf1 | technomancy: thanks dude, just looking for an easy way to set up the environment so I can learn the language :) |
| 17:33 | hippytaf1 | for me on linux I can try to learn python quite easily, but I have seen that lisp is far superiror even than c |
| 17:34 | hippytaf1 | bash is fairlt simple and all precedural languages are learnable, but lisp has something else...and the syntax makes sense ll |
| 17:34 | hippytaf1 | lol |
| 17:36 | gfrlog` | hippytaf1: it's quite the thing |
| 17:38 | hippytaf1 | defining functions with lisp...there is no nonsense...(defun capitalism-sucks () (format t "yes it does")) |
| 17:38 | hippytaf1 | gfrlog`: it has opened my eyes |
| 17:38 | gfrlog` | :) |
| 17:38 | hippytaf1 | lisp makes sense more than any other language I've looked into |
| 17:39 | hippytaf1 | namely python, bash and c |
| 17:39 | hippytaf1 | bash is a must for a linux user |
| 17:39 | gfrlog` | I like clojure's choice of immutable data structures |
| 17:40 | hippytaf1 | as opposed to persistent ones? |
| 17:40 | gfrlog` | no; they're immutable and persistent |
| 17:41 | gfrlog` | I like both parts |
| 17:41 | hippytaf1 | ah i see |
| 17:41 | hippytaf1 | and that makes sense to me |
| 17:41 | hippytaf1 | define something and it is defined |
| 17:41 | hippytaf1 | and then use what is defined |
| 17:44 | hippytaf1 | not ephemerial |
| 17:45 | hippytaf1 | anyway...a tutorial about setting up an ide for coljure and then |
| 17:46 | hippytaf1 | I'll bugger off :) |
| 17:46 | technomancy | hippytaf1: the swank clojure readme combined with the leiningen tutorial will get you pretty far |
| 17:46 | gfrlog` | the eclipse plugin is called counterclockwise |
| 17:47 | hippytaf1 | technomancy: got a link? |
| 17:47 | hippytaf1 | and then I will never bother you again |
| 17:47 | hippytaf1 | untill I have another question :) |
| 17:49 | gfrlog` | hippytaf1: googling "swank clojure readme" leads to https://github.com/technomancy/swank-clojure |
| 17:50 | hippytaf1 | gfrlog`: thanks...did google it, and yes, I was being lazy asking for a link :) |
| 17:52 | hippytaf1 | thanks guys |
| 17:52 | gfrlog` | yessir |
| 17:55 | gfrlog` | ,(numerator 5/1) |
| 17:55 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Ratio |
| 17:55 | hiredman | interesting |
| 17:55 | gfrlog` | I figured there'd be a clojure.core/ratio to help me out... |
| 17:55 | hiredman | I wrote numerator so that could be my fault |
| 17:56 | hiredman | I guess |
| 17:56 | gfrlog` | ha |
| 17:56 | gfrlog` | is there a way to coerce to ratio? |
| 17:56 | __name__ | ,(ratio 1 2) |
| 17:56 | clojurebot | java.lang.Exception: Unable to resolve symbol: ratio in this context |
| 17:56 | __name__ | ,(/ 1 2) |
| 17:56 | clojurebot | 1/2 |
| 17:56 | gfrlog` | __name__: ##(type (/ 2 1)) |
| 17:56 | hiredman | ,(map bean (.getConstructors clojure.lang.Ratio)) |
| 17:56 | sexpbot | ⟹ java.lang.Integer |
| 17:56 | clojurebot | ({:declaringClass clojure.lang.Ratio, :typeParameters #<TypeVariable[] [Ljava.lang.reflect.TypeVariable;@1a3e9cb>, :class java.lang.reflect.Constructor, :synthetic false, :accessible false, :name "clojure.lang.Ratio", :declaredAnnotations #<Annotation[] [Ljava.lang.annotation.Annotation;@4a25d5>, :exceptionTypes #<Class[] [Ljava.lang.Class;@19efe65>, :parameterAnnotations #<Annotation[][] [[Ljava.... |
| 17:56 | __name__ | ##(type (/1 2)) |
| 17:56 | hiredman | ,(clojure.lang.Ratio. 5 1) |
| 17:57 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigInteger |
| 17:57 | __name__ | ##(type (/ 1 2)) |
| 17:57 | sexpbot | ⟹ clojure.lang.Ratio |
| 17:57 | hiredman | ,(clojure.lang.Ratio. (bigint 5) (bigint 1)) |
| 17:57 | clojurebot | 5/1 |
| 17:57 | gfrlog` | hiredman: those are viable options; thanks |
| 18:04 | hippytaf1 | technomancy: missed the leinigen tutorial bit earlier... |
| 18:04 | hippytaf1 | bookmarked for the next time I a get a significant space of free time :) |
| 19:31 | duck1123 | What's the best way to "pop" a value off a set? The best I've found is (let [s #{:foo :bar} i (first s)] (disj s i)) |
| 19:39 | Scriptor | duck1123: do you mean remove a value from a set? Otherwise sets aren't really supposed to have an order |
| 19:39 | Scriptor | so pop has no meaning when it comes to sets |
| 19:40 | duck1123 | what I wanted to do was just remove one element at random from the set |
| 19:40 | Scriptor | ah |
| 19:40 | duck1123 | the modified set goes back in the ref, and the removed item is returned |
| 19:40 | duck1123 | I got it working, but it doesn't seem very elegant |
| 19:41 | duck1123 | I'll probably replace it with an ordered queue of some sort, but I want to maintain uniqueness |
| 19:42 | duck1123 | and really, I don't care too much about the order if it ever gets to this point |
| 19:42 | ampleyfly | (disj s (rand-nth (seq s))) perhaps |
| 19:42 | duck1123 | that's basically what I have, but I just used first |
| 19:43 | ampleyfly | well, isn't the set ordered somehow? |
| 19:43 | hiredman | why not use a queue and a set? |
| 19:43 | duck1123 | hiredman: how do you mean? |
| 19:44 | hiredman | pushing is: check if in set, if not alter set to contain and alter queue to contain |
| 19:44 | hiredman | poping is peek+pop+disj |
| 19:45 | duck1123 | Here's my use case. If a discovery is done on a remote user, but the domain hasn't been discovered then I need to queue the discovery of the user until the domain is done. |
| 19:45 | duck1123 | that's basically what I have right now |
| 19:46 | hiredman | with the set to keep form queueing the same thing over and over? |
| 19:46 | duck1123 | I have the added complication that I have a map of sets |
| 19:46 | duck1123 | right, I only really need to discover the user once |
| 19:57 | Scriptor | what's the general differences between functions and their * forms? |
| 19:57 | Scriptor | like, list and list*, and fn and fn* |
| 19:57 | Scriptor | wait, ignore the fn* |
| 19:58 | amalloy | the * forms are different :) |
| 19:58 | hiredman | foo* can be used to implement foo |
| 19:58 | Scriptor | ah, so it's the more abstracted version? |
| 19:58 | amalloy | Scriptor: hiredman's definition is the most common, but not everyone uses it |
| 19:58 | amalloy | less abstracted |
| 19:58 | Scriptor | right |
| 21:00 | bdesham | anyone know of a good tutorial for getting nailgun working with MacVim? |
| 21:35 | hiredman | dnolen: is there a way to make a logic var that only unifies with objects of a particular type? |
| 21:48 | hiredman | I'd like to be able to do something like ^Symbol ?a and have ?a only unify with symbols |
| 21:51 | dnolen | hiredman: not w/o some kind of general constraint system no. But it's looking like that will be a part of core.logic sooner rather than later. |
| 21:54 | dnolen | hiredman: miniKanren folks submitted their CLP paper to the Scheme Workshop 2011 and they're gonna pass it along to me if it gets accepted (which I'm sure it will). |
| 21:57 | dnolen | hiredman: er, now that I think about it you can do what you want with project, but it's a bit verbose. |
| 21:57 | dnolen | (project [v] (== (type v) Symbol)) |
| 21:57 | hiredman | :/ |
| 21:59 | dnolen | hiredman: you could always hide that behind your own goal fn tho, so you can write, (typeo v Symbol) |
| 22:00 | dnolen | (defn typeo [x t] (project [x] (== x t))) |
| 22:00 | hiredman | right, thanks |
| 22:02 | dnolen | hiredman: only thing to watch out for is that since it uses project, order matters. order wouldn't matter with a proper constraint system in place. |
| 22:03 | dnolen | (typeo v Symbol) (== v 'a) would not fail for example. |
| 22:11 | dnolen | hugod: I just pushed a real 0.6.1 |
| 22:17 | hugod | dnolen: thanks :) |
| 22:17 | dnolen | hugod: np |
| 22:17 | hugod | now I have no excuse to get going |
| 23:42 | amalloy | so suppose i were defining a macro that just quotes its argument. do folks prefer (defmacro quote* [x] (list `quote x)) or (defmacro quote* [x] `'~x)? |
| 23:47 | amalloy | of course it's not useful in isolation; i'm writing a macro that does more data-structure fiddling than template-replacing, so it's not already in a backtick-form |