2011-01-25
| 00:00 | brehaut | dnolen: i grabbed the miniKanren thesis and the ~dec23rd copy of the repo and took it away over the holiday |
| 00:00 | dnolen | brehaut: rad. it's come a long way since then :) |
| 00:00 | brehaut | frankly its very exciting, but i did have some trouble translating between the scheme notation and the clojure notation |
| 00:00 | brehaut | yeah so i see :) |
| 00:01 | dnolen | brehaut: notation is not set in stone. I'm open to changing some of that around. |
| 00:01 | brehaut | i want to write a little blog post about it at some point; taking an algorithm from straight clojure, through a nondeterministic monad and then finally proper logical programming |
| 00:01 | dnolen | brehaut: I look forward to that. |
| 00:02 | brehaut | dnolen: the notation looked fine; i just had some trouble doing the translation |
| 00:02 | brehaut | lead to more than one infinite loop |
| 00:04 | dnolen | brehaut: the next few things will give a few more knobs to prevent common cases of divergence. but first I'm focusing on pattern matching so writing logic programs in miniKanren isn't so tedious. |
| 00:04 | brehaut | dnolen: that sounds sensible |
| 00:05 | scottj | are there more/bigger logos examples than examples.clj? |
| 00:05 | brehaut | right, i better go cook some dinner |
| 00:07 | dnolen | scottj: sadly not really. I can't say I'm an experienced LP programmer. Been focusing more on the details of implementing a logic engine. But key goal though is to make sure that I can easily convert most of Bratko's Prolog book into miniKanren. |
| 00:08 | dnolen | plenty of juicy real-world stuff in the Bratko book. |
| 00:57 | scottj | re discussion earlier about type inference/static typechecking in clojure, https://bitbucket.org/tarballs_are_good/lisp-random/src/e3c23510d062/HindleyMilner/tests.lisp |
| 02:19 | amalloy | i just had a probably-crazy idea. is it feasible to make j.u.regex.Pattern act like a predicate? eg (let [filters [#"puts" #"string"]] (some #(% "input string") filters)) to try a set of matches |
| 02:21 | amalloy | i realize that in this example it's not hard to change it to (re-find % "input string") but if you want to use them as HOFs it's inconvenient to create anonymous functions all the time |
| 02:23 | brehaut | that does seem sensible |
| 02:23 | amalloy | brehaut: i seem to recall that it's actually not feasible but i just wanted to check |
| 02:23 | brehaut | really? |
| 02:23 | brehaut | huh |
| 02:24 | amalloy | on account if IFn being an interface rather than protocol, for apparently-huge performance reasons |
| 02:24 | brehaut | was about to ask that |
| 02:24 | amalloy | and we can't make Pattern implement IFn |
| 02:24 | brehaut | yeah |
| 02:26 | LauJensen | Morning |
| 02:26 | brehaut | Morning Lau |
| 02:26 | amalloy | bonjour lau |
| 02:28 | brehaut | i really look forward to infoq not using flash for its videos |
| 02:29 | brehaut | my laptop is toasty warm now |
| 02:32 | LauJensen | brehaut: What could change that? |
| 02:32 | brehaut | html5 video tag |
| 02:32 | brehaut | so my browser could offload to the hardware to decode |
| 02:33 | brehaut | this is at least partly apples fault for not letting adobe access its hardware api for video decoding |
| 02:33 | LauJensen | That would be nice. Though in my experience I dont recall seeing less CPU usage |
| 02:34 | brehaut | oh well |
| 02:36 | brehaut | the clojure website should probably link 'dev' (in the top right) to dev.clojure.org raher than the old assembla shouldnt it |
| 02:39 | LauJensen | Yea |
| 02:45 | brehaut | i should probably make a ticket or rsomething then |
| 02:49 | amalloy | brehaut: i am dazzled by your enthusiasm |
| 02:55 | amalloy | so dazzled that i'm falling asleep. night folks |
| 02:57 | LauJensen | brehaut: man you dazzled him to sleep :( |
| 03:07 | brehaut | thats how i roll |
| 04:01 | kanzeon | #MacPorts |
| 04:40 | TobiasRaeder | morning |
| 04:40 | LauJensen | morning |
| 04:44 | ejackson | Hello everybody |
| 06:49 | Licenser | aloa |
| 07:49 | Hali_303 | what's the closest concept in Clojure what's Enum in Java? |
| 07:50 | Hali_303 | many cases I'd need keywords from a restricted set |
| 07:53 | clgv | Keywords would fit. |
| 07:54 | clgv | like :foo or :bar or :foobar |
| 07:55 | clgv | &:foo |
| 07:55 | sexpbot | ⟹ :foo |
| 07:55 | Hali_303 | clgv: sure, however in that case there is no compile time check that the value is indeed a part of an enumeration |
| 07:55 | clgv | you won't get a compile time check for that in a dynamic typed language, I suppose |
| 07:56 | Hali_303 | clgv: yeah the problem is however, that it is very easy to mistype all these enumeration values and it would be cool if the compiler could catch that |
| 07:56 | Hali_303 | so I know that even tough clojure is dynamic, there would be an enumeration type |
| 07:57 | clgv | you might use java enumerations if you really need to |
| 07:57 | Hali_303 | how else could someone catch all these mistyped keywords? |
| 07:58 | clgv | no idea. I had that problem too. I guess your IDE should support you in that matter.. that would be possible to a certain degree... |
| 07:59 | clgv | atm I try to copy the keywords to avoid typos |
| 07:59 | Hali_303 | i see |
| 07:59 | clgv | or in some cases I can encapsulate the usage of keywords behing my function api |
| 07:59 | clgv | s/behing/behind/ |
| 08:00 | sexpbot | <clgv> or in some cases I can encapsulate the usage of keywords behind my function api |
| 08:02 | clgv | as conclusion I'd say use the Java Enums in case you really need their strict behavior. you will have compiler checks with them. |
| 08:03 | Hali_303 | clgv: I see, thank you |
| 08:08 | LauJensen | Is this still the best way to round up? ##(int (+ 0.5 (/ 11 2))) |
| 08:08 | sexpbot | ⟹ 6 |
| 08:09 | mduerksen | int isn't round, to be exact |
| 08:09 | LauJensen | mduerksen: Its an old trick for rouding, legendary |
| 08:10 | mduerksen | ah, now i get you ^^ |
| 08:11 | mduerksen | which rounding do you mean then? math rounding wouldn't be accomplished by that trick, economic rounding would (i'm not sure if it's called that way in english) |
| 08:13 | LauJensen | The above rounds to 5 with (/ 10 2) and 6 with (/ 11 2) which is what I need for pagination, ie. round up if theres a remainder |
| 08:13 | mduerksen | ok, then that should be okay. if you need something stochastically stable, it wouldn't be the right way |
| 09:05 | fliebel | morning |
| 09:08 | bsteuber | do type hints on protocols get used in the generated interface declaration? |
| 09:14 | zmyrgel | I'm making chess engine and it's still pretty slow |
| 09:15 | zmyrgel | It takes about 15sec to calculate legal moves to depth of 4 |
| 09:16 | zmyrgel | I was thinking that memoize could give nice boost in move generation and in check detection but I just can't seem to figure out how to accomplish that |
| 09:17 | chouser | bsteuber: hm, it doesn't look like it. I thought at least primitives would be generated where hinted, but apparently not. Everything is Object. |
| 09:24 | robonobo | zmyrgel: is it a large codebase? I tried to write one in python last summer, but I didn't know enough about branch and bound to make it performant. What algorithm do you use? |
| 09:26 | zmyrgel | robonobo: it's about 2000 lines at the moment |
| 09:27 | chouser | zmyrgel: are you aware of the memoize function? |
| 09:27 | zmyrgel | chouser: as I pointed out I'm aware of memoize, not enough to make it work :) |
| 09:28 | zmyrgel | some peer review would be nice |
| 09:28 | jweiss | i'm having an issue with leiningen where there's a newer SNAPSHOT on clojars, but it keeps copying in the old one from the local repository. is there a way to force it to update? |
| 09:29 | jweiss | (i know i can manually delete from my local repo, but i mean something in leiningen) |
| 09:30 | robonobo | i'm not sure dynamic programming would work with a set of possibities a large as with a chess game |
| 09:30 | zmyrgel | robonobo: what do you mean/ |
| 09:30 | zmyrgel | ? |
| 09:31 | robonobo | if i' not mistaken, memoize is like automatic dynamic programming (if i am, just shout at me) |
| 09:32 | zmyrgel | I gotta admit that the term automatic dynamic programming doesn't ring a bell for me |
| 09:32 | chouser | memoize just maintains a map of function args to values for you |
| 09:32 | robonobo | dynamic programming is keeping the values you already calculated in memory so you don't have to calculate them again |
| 09:33 | chouser | certinaly there are functions that can compute their results faster than memoize can look them up, in which cases it would be a poor choice. |
| 09:33 | chouser | robonobo: I don't think that definition is quite right. That sounds specifically like memoization to me. |
| 09:33 | zmyrgel | I thought the 'sliders |
| 09:34 | zmyrgel | I thought memoize would help generating slider and knight movements on the game board |
| 09:34 | chouser | zmyrgel: for a function f that isn't self-recursive, these days I like: (defn f ...) (alter-var-root #'f memoize) |
| 09:35 | robonobo | chouser: Isn't the difference that in what you would call dynamic programming you store them yourself, in memoization it does it for you? |
| 09:36 | chouser | robonobo: "dynamic programming" to me sounds more like generating code at runtime, which is unrelated to memoization |
| 09:36 | zmyrgel | chouser: ok, lemme try that |
| 09:37 | chouser | zmyrgel: if f is self-recursize that probably won't do what you want. And also note that with stock memoize there's no control on the cache size -- it just grows. |
| 09:37 | robonobo | chouser: i might be translating wrong (from dutch) , but that's what we call it in my algortihms class |
| 09:37 | zmyrgel | chouser: yep, that could be an issue with chess :) |
| 09:38 | chouser | robonobo: interesting. saving previous results of a function for use later so you don't have to re-calculate sounds like exactly the definition of "memoize", and I don't think I've heard another word for it. |
| 09:38 | chouser | hm, though http://en.wikipedia.org/wiki/Memoization does at least mention dynamic programming |
| 09:38 | robonobo | from wikipedia: The key idea behind dynamic programming is quite simple. In general, to solve a given problem, we need to solve different parts of the problem (subproblems), then combine the solutions of the subproblems to reach an overall solution. |
| 09:40 | chouser | robonobo: well. You appear to be exactly correct. |
| 09:40 | chouser | robonobo: thanks for teaching me something! |
| 09:40 | robonobo | \o/ |
| 09:41 | robonobo | now I don't think memoization would do a lot of speeding up of a chess game |
| 09:42 | robonobo | i would think the nr of possibilities is just too big |
| 09:43 | clgv | robonobo: you could use it with a caching strategy instead of storing everything and see if that speeds it up a bit. could be likely |
| 09:44 | zmyrgel | I was planning to see if I could cache the calls to slider move-generation and threaten checks |
| 09:45 | zmyrgel | as sliders can return to positions they have already occupied so I wouldn't need to re-calculate their moves again |
| 09:46 | robonobo | sliders? |
| 09:47 | zmyrgel | bishop and queen moves as they 'slide' in the board |
| 09:47 | clgv | zmyrgel: what is your general approach? are you using a game tree? |
| 09:47 | zmyrgel | and rooks |
| 09:48 | zmyrgel | clgv: sort of, my ultimate plan would be to have lazy gametree and progress that once the game proceeds |
| 09:48 | zmyrgel | the code is in github: https://github.com/zmyrgel/tursas |
| 09:49 | clgv | uhm does that make sense to try to get a lazy game tree? you have to evaluate it in some specified depth to be able to choose the current move. |
| 09:50 | zmyrgel | yes, it would make sense |
| 09:50 | zmyrgel | at least that's what I gathered from John Hughes 'Why Functional Programming Matters' paper |
| 09:51 | zmyrgel | also, Land of Lisp seems to refer to same paper when making game tree though I haven't yet gotten to the lazy programming section |
| 09:52 | zmyrgel | its kinda difficult for a first lisp/functional programming project |
| 09:54 | robonobo | zmyrgel: i would say so |
| 09:54 | zmyrgel | well, its my bachelors thesis project, still have about 2 months to work on it |
| 09:56 | robonobo | is there a reason you use (== x y) in stead of (= x y) ? |
| 09:57 | zmyrgel | only my assumption that == would be faster as it only works for numbers |
| 09:57 | raek | "The word dynamic was chosen by Bellman because it sounded impressive, not because it described how the method worked." |
| 09:57 | raek | re. "Dynamic Programming" |
| 09:57 | chouser | heh |
| 09:58 | chouser | == is correct for numbers |
| 09:58 | raek | is there any difference between = and == for numbers in Clojure? |
| 09:59 | chouser | yes, though the specific differences depend on the Clojure version. |
| 09:59 | raek | ,((juxt = ==) (int 1) (long 1)) |
| 09:59 | clojurebot | [true true] |
| 10:00 | chouser | In 1.3, ((juxt = ==) 1 1.0) returns [false true] |
| 10:01 | raek | = has clojure semantics and == java semantics? |
| 10:01 | fliebel | chouser: Why is that? |
| 10:01 | chouser | In 1.2, == is much faster for numbers than = is. |
| 10:01 | robonobo | = calls .equals according to doc |
| 10:01 | robonobo | &(doc =) |
| 10:01 | sexpbot | ⟹ "([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) a... http://gist.github.com/795023 |
| 10:02 | raek | ,(.equals (int 1) (long 1)) |
| 10:02 | clojurebot | false |
| 10:03 | chouser | http://www.assembla.com/wiki/show/clojure/Enhanced_Primitive_Support -- I think "Update redux" is what's currently in 1.3 |
| 10:14 | fliebel | Has anyone tried Amazon Beanstalk with Clojure? I'm still looking for my Heroku for Clojure. GAE is close, but I don't want to be tied to their API. |
| 10:17 | chouser | fliebel: tell me when you find it |
| 10:18 | fliebel | chouser: Beanstalk + lein war + AWS free tier, sounds okay... |
| 10:20 | ejackson | Yeah - I thought it was a pretty interesting development |
| 10:20 | ejackson | they apparently give you a tomcat to deploy right into |
| 10:21 | chouser | 1 year limit? |
| 10:21 | fliebel | yes, after that, you start to pay €10/mo I think. |
| 10:21 | ejackson | thats not much money |
| 10:22 | fliebel | That's only the micro instance, last time I calculated, so I think you'll have to pay for S3 and what more as well. |
| 10:24 | clgv | Provided I have lazy sequence where entries 1 to n are already evaluated and the sequence is infinite, can I only iterate over the already evaluated entries? |
| 10:25 | chouser | It looks like a reserved micro instance running constantly would cost $115.32 per year |
| 10:25 | chouser | clgv: you want to be able to detect what has been unrealized? |
| 10:25 | fliebel | chouser: Including all the extra bits required to boot it? |
| 10:25 | clgv | chouser: yes. it's for debugging purpose |
| 10:28 | fliebel | Now that I think about it, if lazy seqs are immutable, how does Clojure *not* evaluate them every time you do (take 10)? |
| 10:28 | chouser | clgv: for debugging I wrote this: https://gist.github.com/589694 |
| 10:28 | clgv | chouser: well mnot really what has been unrealized. I want to know what has been realized and iterate over it to print it for example |
| 10:28 | raek | fliebel: they contain something mutable internally |
| 10:29 | raek | but the user can only affect it indirectly |
| 10:29 | chouser | clgv: note that code is a giant hack and could break at any moment, but I sometimes find it useful |
| 10:29 | dnolen | interesting. is it possible to get the following behavior from vectors or list? |
| 10:30 | dnolen | ,(let [x '(2) y (cons 1 x)] (identical? x (rest y))) |
| 10:30 | clojurebot | true |
| 10:30 | chouser | fliebel: it looks like that price does not include storage after the first year. :-P |
| 10:31 | raek | ,(let [x (list 2) y (conj x 1)] (identical? x (rest y))) |
| 10:31 | clojurebot | true |
| 10:31 | chouser | ,(let [x (list 1 2)] (identical? (pop x) (pop x))) |
| 10:31 | clojurebot | true |
| 10:31 | fliebel | chouser: That deems it as expensive for me. (I'd call myself a self-employed student) |
| 10:31 | chouser | fliebel: yeah, it's more than I'd like. |
| 10:32 | raek | ,(let [x (vec (range 32)) y (conj x 1)] (identical? x (pop y))) |
| 10:32 | clojurebot | false |
| 10:33 | chouser | lists and Cons' retain the original "rest" value internally. vectors and maps don't, so that behavior is impossible for them. |
| 10:33 | fliebel | chouser: I can only hope to have a profitable web service by then. |
| 10:33 | chouser | :-) |
| 10:35 | raek | I don't think it's possible for vectors. in some cases, they can probably share the same tree, but iirc there's a "header" object that holds a reference to that tree and a new instance of that is constructed for each operation |
| 10:35 | raek | s/instance of that/header/ |
| 10:35 | sexpbot | <raek> I don't think it's possible for vectors. in some cases, they can probably share the same tree, but iirc there's a "header" object that holds a reference to that tree and a new header is constructed for each operation |
| 10:37 | fliebel | Hrm, so all of RoR, Django and CouchDB have IaaS with a basic free plan. How hard would it be to do Clojure? Even sexpbot can run my code ;) |
| 10:37 | chouser | right. and even if there's an identical tree inside, you never get to see that -- you only have access to the wrapper or root object which is different every time. |
| 10:37 | clgv | chouser: having checked the java-implementation I now udnerstand what your hack is doing. |
| 10:38 | chouser | clgv: great! |
| 10:38 | clgv | chouser: I think that "feature" could be easily supported by default |
| 10:40 | chouser | well, my code demonstrates it can be done. The question then is should it? |
| 10:41 | clgv | I guess for general purpose you wont need it really often |
| 10:41 | clgv | I can think of anything else than debugging right now |
| 10:41 | clgv | s/can/can't/ |
| 10:41 | sexpbot | <clgv> I can't think of anything else than debugging right now |
| 10:44 | fliebel | clgv: You could have a loop of growing size :) Not sure what that is good for... |
| 10:45 | clgv | fliebel: I am writing a debugging tool for myself and run into the issue that I used infinite lazy loops which is totally reasonable for the program but which the debuggingtool couldn't handle until now. |
| 10:49 | clgv | *lazy seqs I meant |
| 11:04 | dnolen | chouser: raek: very interesting. I suppose that's yet another reason for list and cons to exist. That's a very useful property for some applications. |
| 11:34 | hoggarth | anyone care to help me understand recur ? |
| 11:34 | hoggarth | trying to implement sieve of eratosthenes |
| 11:35 | hoggarth | (defn seive [lst] |
| 11:35 | hoggarth | (lazy-seq |
| 11:35 | hoggarth | (cons |
| 11:35 | hoggarth | (first lst) |
| 11:35 | hoggarth | (seive (remove #(zero? (mod % (first lst))) (rest lst)))))) |
| 11:35 | hoggarth | (defn primes [] |
| 11:35 | hoggarth | (seive (map #(+ 2 %) (range)))) |
| 11:36 | hoggarth | it works, but will give stack overflow with large numbers |
| 11:36 | robonobo | hoggarth not an expert: recur works differently than recursion would work in other languages |
| 11:37 | robonobo | (i mean i'm not the expert) |
| 11:37 | robonobo | when you do it the way you did, a new function gets put on the stack every time you call it |
| 11:38 | hoggarth | yep |
| 11:38 | chouser | hoggarth: the problem is that as you progress down the input seq, each element of your returned seq has more and more layers of (remove ...) around it |
| 11:38 | robonobo | if you would use (loop [...] ... (recur)), the program just 'rewinds' to that position with the new values given to recur and starts over |
| 11:38 | clgv | or you could use successive calls to filter |
| 11:39 | pdk | you're trying to apply remove to the whole list after the current call to sieve |
| 11:39 | robonobo | the simplest example would be (loop [i 0] (if (< i 5) (recur (inc i))) |
| 11:39 | pdk | and again after the call after that etc etc |
| 11:39 | chouser | what he's got is essentially successive (that is, wrapped) calls to filter (remove in this case) |
| 11:39 | robonobo | which does nothing but count to five internally |
| 11:40 | chouser | hoggarth: doing a *real* sieve of eratosthenes on an infinite lazy sequence is acutally rather tricky (in any language I'm aware of) |
| 11:41 | hoggarth | figures |
| 11:41 | fliebel | Okay, now even I — who knows how recur works — lost track of 4 people explaining it at the same time ;) |
| 11:41 | chouser | :-) |
| 11:41 | robonobo | haha |
| 11:42 | robonobo | maybe just a pointer to some good tutorial would be in order |
| 11:42 | hoggarth | the take away I got was use loop with recur |
| 11:42 | robonobo | hoggarth: yes |
| 11:42 | robonobo | hoggarth: then you use that loop recur as you would any other recursive function |
| 11:42 | fliebel | Now I'd like to know what a *real* sieve of eratosthenes os… *googles* |
| 11:43 | chouser | http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf |
| 11:44 | robonobo | i think wikipedia has a nice animation |
| 11:44 | fliebel | I'm looking at it now... |
| 11:44 | robonobo | maaagical |
| 11:49 | fliebel | So, why would it be tricky to implement a real one in a lazy manner, and what is the one posted above doing? |
| 11:49 | clgv | small version with loop-recur: |
| 11:49 | clgv | (defn sieve |
| 11:50 | clgv | [max] |
| 11:50 | clgv | (loop [primes [2] left-numbers (range 2 (inc max))] |
| 11:50 | clgv | (if (empty? left-numbers) |
| 11:50 | clgv | primes |
| 11:50 | clgv | (let [last-prime (last primes), |
| 11:50 | clgv | non-div (filter #(-> % (mod last-prime) zero? not) left-numbers)] |
| 11:50 | clgv | (if (empty? non-div) |
| 11:50 | clgv | primes |
| 11:50 | clgv | (recur (conj primes (first non-div)) non-div)))))) |
| 11:52 | fliebel | I see... |
| 11:54 | fliebel | It should be possible to do lazily, without the p^2 check of course. |
| 11:55 | amalloy | doesn't c.c.lazy-seq already do lazy primes, fliebel? |
| 11:56 | hoggarth | :) |
| 11:56 | hoggarth | i guess it does |
| 11:56 | fliebel | amalloy: Yes… but I'm not sure how. |
| 11:56 | hoggarth | Mismatched argument count to recur, expected: 2 args, got: 1 |
| 11:56 | hoggarth | oops |
| 11:56 | robonobo | http://clojuredocs.org/clojure_contrib/clojure.contrib.lazy-seqs/primes |
| 11:56 | hoggarth | http://richhickey.github.com/clojure-contrib/lazy-seqs-api.html |
| 11:59 | fliebel | Oh, right, the wheel, I studied this before :P |
| 12:00 | clgv | better just use filter on range with Miller-Rabin-Test ;) |
| 12:19 | fliebel | Are some, every? and not-every? all predicate functions for seqs? |
| 12:22 | hoggarth | i think so (according to http://clojure.org/sequences) |
| 12:24 | amalloy | fliebel: yeah, as well as not-any? |
| 12:25 | amalloy | though some technically isn't, since it doesn't return true/false unless the predicate you use with it does |
| 12:28 | fliebel | amalloy: Ah! I was looking for not-any, but that isn;t there ;) |
| 12:28 | fliebel | *any |
| 12:39 | ejackson | I'm trying to parse a java object with a bunch of string properties into a clojure map, keyed off a simple mangling of the property time (ie x.m_name becomes :name). Is there a way for Clojure to give me a list of the objects properties to help here ? |
| 12:40 | tonyl | maybe bean |
| 12:40 | ejackson | cool |
| 12:41 | ejackson | thanks |
| 12:41 | clojurebot | Gabh mo leithscéal? |
| 12:43 | amalloy | ejackson: bean is the way to go if your object has getX methods; if you want to get the m_name field itself...well, you're probably wrong :) |
| 12:44 | ejackson | amalloy: yeah, i'm making a wrapper over an API to stop being wrong :) |
| 12:52 | zippy314 | hi folks, I'm having a weird situation where running a test with lein fails during compilation with: java.lang.IllegalAccessError: execute does not exist |
| 12:52 | zippy314 | where execute if s a function that should exist. |
| 12:52 | zippy314 | And the code runs fine not it test mode. |
| 12:53 | zippy314 | The test file doesn't even have anything in it other than the simple ns declaration: |
| 12:53 | zippy314 | (ns anansi.test.commands |
| 12:53 | zippy314 | (:use [anansi.commands] :reload) |
| 12:53 | zippy314 | (:use [clojure.test])) |
| 12:54 | zippy314 | any thoughts? |
| 13:03 | pdk | my favorite part of vimclojure |
| 13:03 | pdk | is how the parens matching is far from bug free |
| 13:03 | hoggarth | zippy314 you are sure the namespace is included? |
| 13:04 | zippy314 | hoggarth: thanks, it turned out I had a circular reference. The file refered to a file which refered to it, which seems to be ok when you do lein run, but not when testing. |
| 13:07 | amalloy | zippy314: no thoughts re your error, but i love that you're writing something called anansi |
| 13:07 | zippy314 | amalloy: thanks. It's gonna be very cool... |
| 13:07 | zippy314 | :-) |
| 13:14 | amalloy | chouser: i watched your thing on finger trees this morning, and while i didn't learn that i didn't know from reading the paper, i thought it was quite handy that conjr and consl are like real words with vowels missing. i mentally pronounce them as conjure and conzle |
| 13:24 | LauJensen | amalloy: link? |
| 13:25 | amalloy | LauJensen: http://twitter.com/#!/clojure_conj/status/29896738538000384 |
| 13:25 | zippy314 | Are assignments in a let block guaranteed to happen in the order they are declared? |
| 13:25 | amalloy | zippy314: yes |
| 13:26 | hiredman | uh |
| 13:26 | hiredman | assignments? |
| 13:26 | amalloy | hiredman: bindings, i assume he means |
| 13:26 | zippy314 | yah. |
| 13:27 | zippy314 | so (let [first "1" second (str first "2")] (println second)) should allways return "12" |
| 13:27 | amalloy | zippy314: yes |
| 13:28 | amalloy | &(use 'clojure.walk) |
| 13:28 | sexpbot | ⟹ nil |
| 13:28 | amalloy | &(macroexpand-all '(let [first "1" second (str first "2")] (println second))) |
| 13:28 | sexpbot | ⟹ (let* [first "1" second (str first "2")] (println second)) |
| 13:28 | amalloy | aw, that doesn't make it clear like i thought. nonetheless it's true |
| 13:29 | zippy314 | thx, so there's something else wrong with my code... |
| 13:41 | mrBliss` | I hope the slides are in sync with the speaker this time. It wasn't the case for at least 3 videos. |
| 13:44 | fliebel | Wee, lazy primes. Not as sexy as c.c.lazy-seqs/primes(with wheels and stuff), but it works. https://gist.github.com/795374 |
| 13:45 | amalloy | mrBliss`: yeah it was perfect |
| 13:59 | chouser | amalloy: heh, interesting. unfortunately, both are gone in the current version. |
| 14:00 | chouser | now just use conj instead of conjr, and conjl instead of consl |
| 14:01 | fliebel | chouser: conjl is still a custom function? |
| 14:01 | golevar | what is the recommended editor/IDE for clojure? |
| 14:01 | amalloy | golevar: emacs, mostly |
| 14:01 | golevar | heh, could've figured |
| 14:01 | amalloy | chouser: *sadface* |
| 14:01 | amalloy | though i do prefer conjl to consl |
| 14:01 | ohpauleez | golevar: But there is great support for almost any editor |
| 14:02 | ohpauleez | vim, eclipse, IntelliJ |
| 14:02 | fliebel | Except notepad ;) |
| 14:02 | ohpauleez | For example, I use vim with vimclojure and paredit.vim |
| 14:02 | golevar | what about netbeans? |
| 14:02 | fliebel | ccw |
| 14:02 | fliebel | oh, no |
| 14:02 | fliebel | ccw is eclipse, right? |
| 14:03 | brehaut | fliebel: yes |
| 14:03 | brehaut | enclojure is netbeans? |
| 14:04 | golevar | Yes, enclojure, anyone advising against it? |
| 14:05 | tonyl | did #clojure log stop saving the logs of the day? |
| 14:12 | chouser | fliebel: yeah, conjl is a protocol function that I assume would only make it into core if/when finger trees did |
| 14:13 | fliebel | chouser: Is that a possibility? |
| 14:13 | chouser | tonyl: oh, sorry, that's my fault. the logs are being saved, it's just that the web isn't being updated at the moment. I'll fix that soon. |
| 14:13 | chouser | fliebel: maybe |
| 14:14 | tonyl | chouser: thanks for that service, it is really welcome. :) |
| 14:15 | pdk | (doc if-let) |
| 14:15 | clojurebot | "([bindings then] [bindings then else & oldform]); bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else" |
| 14:16 | chouser | tonyl: thanks -- I always have grand plans for it, and rarely the motivation to put any time into making them happen. :-P |
| 14:19 | fliebel | Is there a way to do (apply concat) to an infinite lazy seq? |
| 14:21 | chouser | apply concat returns a lazy seq |
| 14:23 | mefesto | Raynes: ping |
| 14:23 | Raynes | mefesto: pong |
| 14:23 | fliebel | chouser: It's magic! How can apply stuff an infinite seq into a functions as arguments? |
| 14:23 | mefesto | Raynes: updated the tutorial |
| 14:23 | chouser | fliebel: you answered it yourself -- it's magic |
| 14:24 | mefesto | Raynes: on the repo if you wanna check it out. I don't have a 'Next' link in there yet so at the moment typing 'next' in the REPL will move you to the next screen. |
| 14:24 | fliebel | chouser: Java is not magic, where lies the trick? IN the source of apply or somewhere deep down IFn? |
| 14:24 | chouser | apply will call the function, passing a lazy seq to its & args |
| 14:25 | fliebel | &((fn [& a] (type a)) 1 2 3) |
| 14:25 | sexpbot | ⟹ clojure.lang.ArraySeq |
| 14:26 | Raynes | mefesto: Cool stuff. I'll check it out in a moment. |
| 14:26 | fliebel | I always thought it'd be a vector... |
| 14:26 | chouser | ,(apply (fn [a & b] (type b)) [1 2 3]) |
| 14:26 | clojurebot | clojure.lang.PersistentVector$ChunkedSeq |
| 14:27 | chouser | ,(apply (fn [a & b] (type b)) (range 50)) |
| 14:27 | clojurebot | clojure.lang.ChunkedCons |
| 14:27 | fliebel | I see… Just any ISeq works. |
| 14:27 | chouser | ,(apply (fn [a & b] (second b)) (range)) |
| 14:27 | clojurebot | 2 |
| 14:32 | fliebel | I haven't figured out how and what, but I think Clojure is missing some iterating function. reductions is to reduce as loop is to ??? |
| 14:32 | fliebel | no, wrong thinking... |
| 14:32 | Licenser | aloaeh |
| 14:33 | fliebel | Licenser: hi |
| 14:33 | Licenser | hi fliebel how is live? |
| 14:33 | fliebel | *snif* I got a little cold, but besides that, fine :) you? |
| 14:34 | fliebel | (you'll all get crazy when I type *snif* every time I *snif*) |
| 14:42 | Licenser | heh I am fine, got a little cold too but aside of that I'm great :) |
| 14:42 | amalloy | fliebel: the one that's missing is unfold imo, but i don't think that's what you're looking for |
| 14:44 | chouser | fliebel: lazy-seq? |
| 14:47 | fliebel | chouser: I don't know yet. I jus find myself in situations where I need the flexibility of loop/recur, but have it work like reductions or iterate, or... |
| 14:48 | chouser | I think someone once wrote a macro that looked like loop/recur but returned a lazy seq. |
| 15:01 | hiredman | I have a macro that looks like loop/recur but instead queues up bodies to be run async style |
| 15:12 | amalloy | fliebel: https://gist.github.com/b549634b4d855cde88c2 is how you could use unfold if it existed. is that anything like what you want your loop/reductions hybrid to do? |
| 15:16 | clojurebot | #<RuntimeException java.lang.RuntimeException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated> |
| 15:17 | fliebel | amalloy: I don't know. I'm still trying to understand :) |
| 15:19 | mefesto | Seeking advice. I'm working on an internal json api and would like to transparently handle j.sql.Date and j.sql.Timestamp in a general way. I was thinking of representing them as ["date" year month day] or ["timestamp" year month day hour min sec ms tz] then extending c.c.json. Does this seem reasonable? |
| 15:19 | fliebel | amalloy: I think that is kind of what I was thinking of. |
| 15:19 | amalloy | fliebel: unfold is the opposite of reduce (and reduce is often called fold, so...) |
| 15:20 | pdk | (doc unfold) |
| 15:20 | clojurebot | Titim gan éirí ort. |
| 15:21 | amalloy | pdk: clojure doesn't have unfold. that's why my gist implements it |
| 15:22 | zippy314 | I'm getting this error: |
| 15:22 | zippy314 | java.lang.IllegalArgumentException: No matching method found: printStackTrace for class java.lang.RuntimeException |
| 15:22 | zippy314 | Shouldn't RuntimeException allways have printStackTrace? |
| 15:22 | amalloy | zippy314: you're probably calling it with arguments, when it should have none |
| 15:22 | zippy314 | I only get that if I've set *er* to dev null |
| 15:23 | zippy314 | (catch Exception e |
| 15:23 | zippy314 | (.printStackTrace e *err*) |
| 15:23 | zippy314 | (str "ERROR: " e) |
| 15:23 | zippy314 | ))) |
| 15:23 | hiredman | *err* is not of the right type to pass to .printStackTrace |
| 15:23 | amalloy | &(class *err*) |
| 15:23 | sexpbot | ⟹ java.io.OutputStreamWriter |
| 15:24 | zippy314 | in my tests i'm: |
| 15:24 | zippy314 | (binding [*err* (writer "/dev/null")] |
| 15:24 | amalloy | it wants a printwriter, not a streamwriter |
| 15:24 | zippy314 | ahh |
| 15:24 | amalloy | http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Throwable.html#printStackTrace%28java.io.PrintStream%29 |
| 15:26 | zippy314 | is there a way to create a printwriter through clojure.contrib.io? |
| 15:27 | zippy314 | because actually it's working until I do the binding [*err* (writer "/dev/null")] which overrides the standard err |
| 15:27 | amalloy | zippy314: looks like no |
| 15:28 | amalloy | but ##(java.io.PrintWriter. (writer "some file")) should work (but i think sexpbot doesn't allow it |
| 15:28 | sexpbot | java.lang.Exception: Unable to resolve symbol: writer in this context |
| 15:31 | fliebel | Hrm, how comes these infinite cons constructions( ##(source take-nth) ) don't blow the stack, and mine does? https://gist.github.com/795374 |
| 15:31 | sexpbot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 15:32 | fliebel | &(clojure.repl/source take-nth) |
| 15:32 | sexpbot | java.lang.ClassNotFoundException: clojure.repl |
| 15:32 | Raynes | fliebel: Foiled by sexp! |
| 15:33 | tonyl | $source take-nth |
| 15:33 | sexpbot | take-nth is http://is.gd/N1aIyC |
| 15:33 | Raynes | That wont work either. |
| 15:34 | tonyl | why? it gave me the right source |
| 15:34 | Raynes | Oh, take-nth. |
| 15:34 | Raynes | I thought you looked up the source to source. |
| 15:34 | defn | (require 'clojure.contrib.seq) |
| 15:34 | tonyl | oh never tried that |
| 15:34 | tonyl | $source source |
| 15:34 | sexpbot | Source not found. |
| 15:35 | amalloy | fliebel: because the lazy seqs generated by take-nth are simple |
| 15:35 | defn | &(require '[clojure.contrib.seq :as s]) |
| 15:35 | sexpbot | java.io.FileNotFoundException: Could not locate clojure/contrib/seq__init.class or clojure/contrib/seq.clj on classpath: |
| 15:36 | fliebel | amalloy: Please clarify. Does that mean that if I do take-nth on big enough numbers, ti will fail as well, or does it mean my cal is maintaining some stack space somewhere, while take-nth doesn't? |
| 15:36 | amalloy | fliebel: sorry, i was working on a clarification |
| 15:37 | fliebel | Take your time :) |
| 15:39 | amalloy | fliebel: basically, i think, the issue is the remove. you wind up building a chain of (remove (remove (remove (remove ...)))) and realizing them all at once? |
| 15:40 | fliebel | Bit take-nth is building chains of (drop (drop (drop))), so I'm not to sure about that. |
| 15:41 | amalloy | tbh it's still sorta black magic to me, and it *looks* like yours should work (cf the drop chain you mention), but my experience has taught me that remove/filter are usually to blame when a lazy-seq blows the stack |
| 15:42 | amalloy | do you get a stack trace? it should be fairly clear what element is repeating |
| 15:43 | fliebel | Yea, I had these stacking lazy problems before. But it seems stacks of something is the only way to make use of cons. I'm looking for the trace now |
| 15:45 | fliebel | amalloy: Yea, stack trace dominated by filter: at clojure.core$filter$fn__3714.invoke(core.clj:2130) |
| 15:45 | fliebel | at clojure.lang.LazySeq.sval(LazySeq.java:42) |
| 15:45 | fliebel | at clojure.lang.LazySeq.seq(LazySeq.java:56) |
| 15:48 | fliebel | I don't care to much about why my version explodes, but I wonder why other functions *do* work. |
| 15:49 | amalloy | &(nth (take-nth 1 (range)) 1e5) |
| 15:49 | sexpbot | ⟹ 100000 |
| 15:49 | amalloy | &(nth (take-nth 1 (range)) 1e6) |
| 15:49 | sexpbot | ⟹ 1000000 |
| 15:49 | fliebel | I tried up to 1e8 |
| 15:49 | amalloy | just testing that this is in fact the case |
| 15:50 | fliebel | Can we see a stack trace of a non-exploding function? |
| 15:51 | fliebel | 1e9 is running now ;) |
| 15:51 | amalloy | &(map #(if (= 1e5 %) (throw (Exception.)) %) (range)) |
| 15:51 | sexpbot | java.lang.Exception |
| 15:51 | amalloy | fliebel: ^ for a stacktrace |
| 15:52 | fliebel | amalloy: But I'd have to raise the exception inside of cons to see what happens there. |
| 15:54 | fliebel | It seems to consume stack up to sval, and that's it. |
| 15:54 | fliebel | at clojure.lang.LazySeq.sval(LazySeq.java:47) |
| 15:54 | fliebel | at clojure.lang.LazySeq.seq(LazySeq.java:56) |
| 15:54 | fliebel | at clojure.lang.RT.seq(RT.java:450) |
| 15:54 | fliebel | at clojure.core$seq.invoke(core.clj:122) |
| 15:54 | fliebel | at clojure.core$drop$step__3728.invoke(core.clj:2177) |
| 15:54 | fliebel | at clojure.core$drop$fn__3731.invoke(core.clj:2181) |
| 15:54 | fliebel | at clojure.lang.LazySeq.sval(LazySeq.java:42) |
| 15:54 | fliebel | ... 25 more |
| 16:16 | raek | sometimes, strategically placed 'doall' calls can solve the (f (f (f (f (f ...))))) problem |
| 16:17 | brehaut | raek: say what |
| 16:17 | raek | they eat stack because one forcing of a lazy seq element triggers another |
| 16:21 | raek | hrm, I can't find fliebel's old mail list thread... |
| 16:22 | raek | ,(nth (iterate #(map inc %) [1 2 3]) 1000000) |
| 16:23 | clojurebot | Execution Timed Out |
| 16:23 | raek | results in a stack overflow for me |
| 16:23 | raek | ,(nth (iterate #(doall (map inc %)) [1 2 3]) 1000000) |
| 16:23 | clojurebot | (1000001 1000002 1000003) |
| 16:24 | raek | the only difference here is that now, forcing the first element of the seq does not tigger a cascade of realizations |
| 16:25 | raek | I hope this made more sense... .-) |
| 16:25 | brehaut | raek: yeah it does |
| 16:26 | brehaut | thats quite a sneaky gotcha really |
| 16:30 | raek | yup |
| 16:52 | shortlord | how can I get a vector that is like another vector with one element somewhere in the middle removed? |
| 16:52 | shortlord | there must be a better way than using 'into' and to subvecs, right? |
| 16:53 | raek | shortlord: this cannot be done in constant time. in the worst case, you need to traverse everything after the removed element (i.e. linear time) |
| 16:53 | raek | shortlord: no, I think that's pretty much it... |
| 16:54 | shortlord | raek: phew, time is not important, the vector always has a length < 20 |
| 16:54 | amalloy | shortlord: finger trees can do this in constant time |
| 16:55 | amalloy | (they are basically 100% magic) |
| 16:55 | shortlord | amalloy: uh, nice, magic is always good |
| 16:56 | amalloy | or maybe they can't? i know they can split into a left tree and a right tree (without the element in the middle) in log time, but maybe stitching those two back together into a single tree takes more time |
| 16:57 | brehaut | shortlord: as an added bonus, the wizard has made video explaing his magic http://clojure.blip.tv/file/4614554/ |
| 16:57 | clojurebot | #<RuntimeException java.lang.RuntimeException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated> |
| 16:58 | hiredman | clojurebot: stop that |
| 16:58 | clojurebot | we can't stop here! this is bat country! |
| 16:58 | amalloy | brehaut: act now and you'll get...? |
| 16:58 | ossareh | lol @ clojurebot |
| 16:58 | brehaut | amalloy: in my case confision |
| 16:59 | brehaut | chouser is clearly a couple orders of magnitude smarter than me |
| 17:00 | shortlord | brehaut: uh, nice. thx :) |
| 17:03 | zippy314 | whats the idiomatic way of getting a subset of a hash, i.e. would be like (subset {:1 1 :2 2 :3 3} [:1 :3]) => {:1 1, :3 3} |
| 17:05 | hiredman | (doc select-keys) |
| 17:05 | brehaut | zippy314: (reduce dissoc myhash keys) ? |
| 17:05 | clojurebot | "([map keyseq]); Returns a map containing only those entries in map whose key is in keys" |
| 17:06 | brehaut | man what was i thinking. thats completely wrong. |
| 17:10 | zippy314 | clojurebot: ? I'm being noob, I don't get it: (def x {:1 2 :3 4}) ([x [:1]]) => Wrong number of args (0) passed to: PersistentVector |
| 17:10 | clojurebot | XmL is case-sensitive |
| 17:11 | hiredman | (doc select-keys) |
| 17:11 | clojurebot | "([map keyseq]); Returns a map containing only those entries in map whose key is in keys" |
| 17:11 | zippy314 | tx |
| 17:15 | tonyl | zippy314: wrapping a vector in parenthesis ([x [:1]]) makes it a function call. vectors are functions of their indexes ##([:a :b :c :d] 2) |
| 17:15 | sexpbot | ⟹ :c |
| 17:16 | zippy314 | tx |
| 17:33 | pdk | ,(boolean nil) |
| 17:33 | clojurebot | false |
| 17:34 | zippy314 | ok, not understanding dosync and alter: |
| 17:34 | zippy314 | (def x (ref {:1 1})) (dosync alter x merge {:2 2}) |
| 17:34 | zippy314 | I would have thought @x should now be {:1 1 :2 2} |
| 17:34 | zippy314 | but it's unchanged. |
| 17:34 | pdk | (dosync (alter x merge {:2 2})) |
| 17:35 | pdk | alter requires its own function call within the dosync |
| 17:35 | zippy314 | zippy314 is slinking away embarassed |
| 17:39 | amalloy | zippy314: btw, if you change your def's to let's, you can use clojurebot/sexpbot to demonstrate to other people what behavior you're not understanding, like ##(let [x (ref {:1 1})] (dosync (alter x merge {:2 2}))) |
| 17:39 | sexpbot | ⟹ {:2 2, :1 1} |
| 17:40 | zippy314 | testing ##(let [x 1] x) |
| 17:40 | sexpbot | ⟹ 1 |
| 17:41 | zippy314 | (let [x 1] x) |
| 17:41 | zippy314 | #(let [x 1] x) |
| 17:41 | zippy314 | ##(let [x 1] x) |
| 17:41 | sexpbot | ⟹ 1 |
| 17:41 | zippy314 | Cool! |
| 17:41 | amalloy | zippy314: specifically, messages starting with , or & are interpreted by clojurebot and sexpbot respectively |
| 17:41 | amalloy | and ## can be used anywhere in a message to activate sexpbot |
| 17:41 | zippy314 | &(let [x 1] x) |
| 17:41 | sexpbot | ⟹ 1 |
| 17:41 | zippy314 | ,(let [x 1] x) |
| 17:41 | clojurebot | 1 |
| 17:42 | zippy314 | whats the difference between cojurebot and sexpbot? |
| 17:42 | amalloy | different authors, different feature sets, different... |
| 17:42 | zippy314 | ah |
| 17:43 | brehaut | the biggest difference is that clojure-bot is part of big brother and hes recording everything you type |
| 17:43 | amalloy | $sed brehaut s/recording.*/watching over you |
| 17:43 | sexpbot | <> $sed brehaut s/watching over you |
| 17:43 | hiredman | well, actually my log is recording everything |
| 17:43 | amalloy | damn, i can never remember how that works |
| 17:43 | hiredman | and piping into sqs |
| 17:44 | amalloy | $help sed |
| 17:44 | sexpbot | amalloy: Simple find and replace. Usage: sed [-<user name>] s/<regexp>/<replacement>/If the specified user isn't found, it will default to the last thing said in the channel. Example Usage: sed -boredomist s/[aeiou]/#/Shorthand : s/[aeiou]/#/ |
| 17:44 | amalloy | $sed -brehaut s/recording.*/watching over you |
| 17:44 | sexpbot | <brehaut> the biggest difference is that clojure-bot is part of big brother and hes watching over you |
| 17:45 | brehaut | hah |
| 17:46 | hiredman | https://github.com/hiredman/Howler |
| 17:47 | brehaut | hiredman: my immediate question is: Black Company? |
| 17:48 | hiredman | what about it? |
| 17:48 | brehaut | is that where the name is from? |
| 17:48 | hiredman | nope |
| 17:49 | joegallo | Maybe an x-files reference? http://x-files.wikia.com/wiki/Unruhe |
| 17:50 | hiredman | nope |
| 17:50 | hiredman | it Howls at you over growl |
| 17:50 | brehaut | hah awesome |
| 17:51 | joegallo | I've got it, you're a big fan of the Pittsburgh bar scene. http://howlerscoyotecafe.com/ |
| 17:51 | hiredman | joegallo: fine, I admit it, you caught me |
| 17:51 | joegallo | :) |
| 17:55 | Scriptor | does anyone know the name of the datastructure Clojure uses for hashmaps? |
| 17:56 | raek | persistent hash trie, iirc |
| 17:56 | brehaut | bagwell trie |
| 17:56 | Scriptor | ah, thanks! |
| 17:56 | raek | http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/ |
| 17:57 | raek | that one mentions "Array-mapped hash trie" |
| 17:57 | brehaut | also, doesnt the clojure implementation change the concrete type depending on the size of the map? |
| 17:57 | raek | in clojure-land, it is most often refered to as "persistent hash map" |
| 17:58 | raek | yes |
| 17:58 | raek | array-map vs hash-map |
| 17:59 | Scriptor | so the O(log32(N)) comes from the fact that it's stored as a sort of tree? |
| 17:59 | raek | yes. |
| 18:00 | Scriptor | man, I need to finish reading functional data structures |
| 18:00 | raek | if you won't read Krukow's articles, at least take a look at the pictures. they are pretty informative, I think... :-) |
| 18:01 | pdk | where are these articles |
| 18:01 | pdk | i know okasaki's book though this is news |
| 18:02 | Scriptor | hmm, I only have okasaki's thesis |
| 18:02 | raek | http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/ and http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/ |
| 18:03 | Scriptor | raek: thanks! |
| 18:11 | dnolen | http://lampwww.epfl.ch/papers/idealhashtrees.pdf |
| 18:33 | arohner | has anyone tried reading from *in* or System/in when using slime? |
| 18:35 | amalloy | arohner: yes, it is known to be hard |
| 18:35 | arohner | amalloy: is there a solution? |
| 18:35 | amalloy | i don't know, actually |
| 18:41 | edoloughlin | Any ideas appreciated: I've run into the same issue with clj-record and clojureQl when trying to insert a record containing an int value. I get a classCastException and a message: "transaction rolled back: java.lang.Integer cannot be cast to clojure.lang.IFn". |
| 18:42 | hiredman | clojurebot: english? |
| 18:42 | clojurebot | English is the official language of the universe |
| 18:44 | raek | edoloughlin: does the stack trace tell you that the exception is thrown from within clj-record/clojureQl or from your own code? |
| 18:45 | edoloughlin | raek: By the time the exception gets caught in my code the stacktrace is null. I'm pretty sure it's not in my code. |
| 18:46 | raek | edoloughlin: null? have you tried to look at the causes of the exception? |
| 18:46 | edoloughlin | raek: it's null. |
| 18:46 | pdk | ,(for [i nil] (inc i)) |
| 18:46 | clojurebot | () |
| 18:46 | raek | I don't understand. |
| 18:46 | raek | ,(throw nil) |
| 18:46 | clojurebot | java.lang.NullPointerException |
| 18:47 | raek | you cannot even throw null |
| 18:47 | edoloughlin | That's makes two of us. I get a ClassCastException with a message and no cause. |
| 18:47 | raek | what IDE? |
| 18:47 | edoloughlin | Eclipse/CounterClockwise |
| 18:48 | edoloughlin | Line-by-line debugging is difficult in this environment |
| 18:48 | raek | ok, I'm an emacs guy, but have you tried (.printStackTrace *e) in the repl? |
| 18:49 | edoloughlin | I need to figure out how to get a REPL when debugging - new to this :( |
| 18:49 | raek | (perhaps that only works if you eval the expression in the repl, I don't know) |
| 18:50 | edoloughlin | Thanks anyway. I'll set some breakpoints in contrib.sql and see what I can find. At least it's not an obvious noob mistake... |
| 18:51 | raek | you should be able to get more details from the exception somehow |
| 18:51 | raek | it should indicate the source lines for each call in the call stack |
| 18:52 | edoloughlin | Driving me nuts. Everything was tickety-boo until I tried to insert an int. |
| 18:53 | raek | you will get the same kind of exception if you do something like this: |
| 18:53 | raek | ,(1 :a :b :c) |
| 18:53 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 18:54 | edoloughlin | Hmm. Don't think I've done anything that silly. Will have a quick check |
| 18:57 | raek | if you can launch your code from the repl, (.printStackTrace *e) should be sufficient to get the whole stack trace |
| 18:58 | raek | the info you are looking for is without doubt in the stack trace |
| 18:58 | edoloughlin | Might be a bit tricky. It's all buried in ring/compojure |
| 18:59 | edoloughlin | Is there a way I can invoke the repl from my code? |
| 19:00 | raek | edoloughlin: have you tried this? http://clojuredocs.org/ring/ring.middleware.stacktrace/wrap-stacktrace |
| 19:00 | raek | edoloughlin: yes. calling your handler function directly. |
| 19:00 | edoloughlin | Ok. Will try. Thanks for the help |
| 19:02 | raek | (my-handler {:uri "/foo/bar", :request-method :get, :headers {}}) ; something like this maybe |
| 19:02 | raek | oh, read your utterance backwards. that would anser the question "Is there a way I can invoke my code from the repl?" |
| 19:07 | edoloughlin | Think I've isolated the code. It's choking on what looks like a valid record. |
| 19:11 | edoloughlin | raek: Found it. Noob mistake. Had (def someval 1) and was doing (assoc somerec :field (someval)) |
| 19:12 | edoloughlin | raek: Sorry for wasting your time with something so dumb. |
| 19:24 | nishant | is this the right place for questions on clojure-hadoop? |
| 19:25 | amalloy | nishant: i don't think there's a better place, but clojure-hadoop is not very up-to-date last i checked |
| 19:25 | amalloy | oh, or maybe it is and i was thinking of clojure-cassandra. don't take my advice :P |
| 19:27 | nishant | amalloy: the version I'm using (1.3.1-SNAPSHOT) seems to work, I was able to build it, and also run the example 1 from a java command line, but I am running into problems when I try to run a job from a slime repl. |
| 19:56 | nishant | can I start "lein swank" with logging? |
| 20:09 | zakwilson | Mongo or Postgres... that is the question. Should I flip a coin? |
| 20:18 | danlarkin | zakwilson: that is a ridiculous question. do you choose between sandals and snow boots? |
| 20:18 | danlarkin | no, you use each when appropriate |
| 20:19 | zakwilson | Well, if I don't really know what the weather's going to be like and probably won't until I've been walking for a while.... |
| 20:20 | danlarkin | there's your first mistake |
| 20:20 | danlarkin | how can you expect to make correct decisions then? |
| 20:21 | hiredman | ~google seattle weather |
| 20:21 | clojurebot | First, out of 2460000 results is: |
| 20:21 | clojurebot | Seattle, Washington (98101) Conditions & Forecast : Weather ... |
| 20:21 | clojurebot | http://www.wunderground.com/US/WA/Seattle.html |
| 20:22 | zakwilson | I don't expect to make correct decisions. I think the best I can hope for is a lower probability of being wrong. |
| 20:24 | danlarkin | zakwilson: well if you want to just go hacking around then it doesn't really matter what you choose, does it? But if you want input on your decision (and I assume you do, since you asked in this public forum), then you really should be putting more thought into what data you want to model |
| 20:24 | david` | ,(let [ab-adder (partial concat [:a :b])] (ab-adder [:c :d])) |
| 20:24 | clojurebot | (:a :b :c :d) |
| 20:28 | zakwilson | Well, most of what I have to store will be in Clojure maps, for which MongoDB looks to be a good fit. I guess my real question is how good the respective Clojure libraries are. Both ClojureQL and CongoMongo look good at a glance with the former appearing a bit more mature. |
| 20:30 | danlarkin | well if your sole criteria is maturity then I don't think you can beat jdbc |
| 20:33 | symuyn | Does anyone know off the top of their head what the hash-function of vectors is? |
| 20:35 | zakwilson | It isn't. Fitting naturally with Clojure is a major criterion. The importance of maturity isn't linear; I don't mind something fairly new, but I don't want breaking changes every weak or significant unreliability. |
| 20:37 | danlarkin | then my (admittedly biased) opinion is to stay away from flavor-of-the-week datastores like mongro |
| 20:38 | danlarkin | and depending on your durability needs, you can just use clojure datastructures in memory |
| 20:38 | danlarkin | or contrib.datalog |
| 20:42 | zakwilson | I can do most of the interesting stuff with Clojure data structures in memory, but I want a place to put them, queries without loading everything in to memory, indexing... |
| 20:43 | hiredman | https://github.com/richhickey/sdb |
| 20:43 | hiredman | if you are just hacking around, why bother with keeping your own database? |
| 20:45 | zakwilson | I'm building an API to provide a text classifier as a web service. I don't want it tied to a specific hosting platform though I can see where SimpleDB would save effort. |
| 20:53 | david` | did Stuart's clojure conj talk ever get posted? |
| 21:03 | danlarkin | zakwilson: you should check out http://www.infoq.com/presentations/Enterprise-NoSQL |
| 21:03 | zakwilson | danlarkin: thanks |
| 21:16 | mec_ | If I have a regex that matches (.*=)?... is there a way to just return .* as in ((.*)=)? without the extra return in there as well |
| 21:18 | mefesto | (?:(.*)=) |
| 21:18 | mefesto | mec_: non-capturing outer group but capturing the inner group |
| 21:19 | mefesto | ,(re-find #"(?:(.*)=)" "key=val") |
| 21:19 | clojurebot | ["key=" "key"] |
| 21:21 | mec_ | interesting so (?...) is non capturing group? |
| 21:21 | mefesto | (?:) |
| 21:21 | mec_ | ah, thank you |
| 21:21 | mefesto | np |
| 21:36 | brehaut | david`: stuart halloway? |
| 21:37 | brehaut | david`: http://www.infoq.com/presentations/Clojure-Java-Interop ? |
| 21:47 | symuyn | If I have a map whose keys are vectors, do the performances of assoc or get depend on the size of the vector keys? |
| 21:52 | tomoj | you have to compute the hash once for each vector to do those, I think? |
| 21:53 | tomoj | and that requires hashing every element? |
| 21:53 | tomoj | if you keep hold of the same keyset, the hash will always be cached |
| 21:54 | symuyn | Already, that makes sense |
| 21:54 | symuyn | I mean, alright |
| 21:55 | tomoj | I don't know if that hashing actually takes long enough to matter anyway |
| 21:56 | symuyn | I'm thinking about the cost of memoization |
| 21:56 | symuyn | Of a sort |
| 21:56 | symuyn | (And by "of a sort", I mean "of a kind", not "of an ordering", heh heh) |
| 22:09 | mec_ | ,(reduce (partial apply assoc) {} (map list [:a :b :c] [1 2 3])) |
| 22:09 | clojurebot | {:c 3, :b 2, :a 1} |
| 22:09 | mec_ | is there a better way? there just has to be. |
| 22:10 | mefesto | ,(zipmap [:a :b :c] [1 2 3]) |
| 22:10 | clojurebot | {:c 3, :b 2, :a 1} |
| 22:11 | mec_ | well then, thats not at all what i thought that did |
| 22:11 | brehaut | mec_: is it possible you thought it was like haskell's zip but for maps? |
| 22:12 | mec_ | I thought it had something to do with zippers, not sure why i didnt do a (doc) on it, i did on all the other map functions |
| 22:13 | brehaut | mec_: the reduce portion of your code is roughly 'into' btw |
| 22:14 | brehaut | ,(into {} [[1 2] [3 4]]) |
| 22:14 | clojurebot | {1 2, 3 4} |
| 22:14 | brehaut | thanks clojurebot |
| 22:14 | mec_ | ah nice |
| 22:14 | brehaut | super handy |
| 22:15 | mec_ | i forgot about conj over assoc too |
| 22:16 | mec_ | al look at that into is even defined as (reduce conj) |
| 22:16 | brehaut | i live in fear of someone looking at some of my publicly available clj code and saying 'why did you do [big long mess]; you could just use [stdlib fn]) |
| 22:16 | mec_ | exactly, therefore my main assumption is there is always a better way to do whatever im doing |
| 22:16 | brehaut | mec_: yeah, + a transient |
| 22:16 | brehaut | yup |
| 23:23 | brehaut | being able to define monads dynamically is awesome |
| 23:24 | tomoj | are there monads in aleph? |
| 23:25 | brehaut | ive never looked at aleph |
| 23:25 | brehaut | thats the event driven concurrency lib right? |
| 23:28 | replaca | david`: I don't think it's up yet. They're working their way through the two days in order |