2010-11-16
| 00:05 | tonyl | is the :once value in the metadata map used only for delaying the results? |
| 00:05 | tonyl | or what is it used for |
| 00:09 | KirinDave | How does one define a method with a void return type using gen-interface? |
| 00:10 | tonyl | I think only 1.3 lets you specify a return type |
| 00:10 | KirinDave | For gen-interface? |
| 00:10 | KirinDave | That's definitely not true. |
| 00:10 | tonyl | In general |
| 00:10 | tonyl | I am not sure about gen-interface |
| 00:12 | danlarkin | 1.2 (at least, and probably earlier versions) of gen-class let you have a void return value |
| 00:12 | danlarkin | I have no experience with gen-interface though, sorry :( |
| 00:13 | KirinDave | danlarkin: How do you express it? |
| 00:13 | KirinDave | gen-class's format is very similar to gen-interface |
| 00:13 | danlarkin | KirinDave: https://github.com/danlarkin/subrosa/blob/master/src/subrosa/observable.clj#L9 |
| 00:14 | danlarkin | KirinDave: that is, a vector of 3-vectors: method name, vector of arg types and return type |
| 00:15 | KirinDave | haha, it's just "void" |
| 00:15 | tomoj | wonder why not aleph? |
| 00:15 | KirinDave | THAT IS TOO SIMPLE FOR ME TO HAVE GUESSED ;) |
| 00:15 | danlarkin | KirinDave: it's in the documentation :) |
| 00:16 | KirinDave | danlarkin: Ahh, it is; albeit obliquely |
| 00:16 | KirinDave | "In all subsequent sections taking types, the primitive types can be |
| 00:16 | KirinDave | referred to by their Java names (int, float etc)" |
| 00:16 | KirinDave | danlarkin: Thank you |
| 00:16 | danlarkin | KirinDave: it did take me a few minutes of reading to find it |
| 00:17 | danlarkin | tomoj: a few reasons, but /mostly/ because when I started this code there was no aleph |
| 00:17 | tomoj | ah |
| 00:17 | quizme | i got something like GC memory overhead limit exceeded. how do you increase the memory limit? |
| 00:19 | tomoj | do you think you really should need to? maybe you are holding the head somewhere? |
| 00:19 | tomoj | oh, guess that means you have excessive churn? |
| 00:20 | danlarkin | the default JVM heap size isn't very large, you almost always need to increase it for serious work |
| 00:20 | tomoj | that happened to me when I was creating many many boxed integers and then adding them up and outputting and then throwing away |
| 00:20 | danlarkin | quizme: java -Xmx2048m ... |
| 00:21 | quizme | danlarkin thanks. i'm doing "lein repl" |
| 00:21 | danlarkin | quizme: lein respects JAVA_OPTS |
| 00:21 | quizme | ok cool |
| 00:21 | quizme | thnx |
| 00:22 | KirinDave | And :java_opts in the project.clj file. |
| 00:22 | quizme | awesome dudes thnx |
| 00:22 | tonyl | what is the difference between java -Xmx... and java -Xms.... |
| 00:22 | danlarkin | tonyl: max and min heap size, respectively |
| 00:23 | tonyl | thanks danlarkin |
| 00:24 | quizme | export JAVA_OPTS=-Xmx768m <--- will lein pick that up from env ? |
| 00:24 | danlarkin | quizme: yes |
| 00:24 | quizme | danlarkin tyu |
| 00:25 | LauJensen | Morning all |
| 00:33 | quizme | is it possible to do something like preduce on an atom ? |
| 02:06 | guppy | hello |
| 02:46 | quizme | http://pastie.org/1301932 <--- is there anything obviously wrong with how i'm updating my atom? It didn't change... |
| 02:46 | sandGorgon | I have a 3'rd party java lib that has a "main" function - I need to invoke that from clojure. How do I do that ? |
| 02:47 | hiredman | you're not using reduce correctly |
| 02:48 | quizme | hiredman hmm |
| 02:49 | quizme | hiredman: it takes 3 arguments (reduce f val coll) isn't that what i'm doing ? |
| 03:08 | Chousuke | quizme: I don't think that's a good use of an atom in the first place |
| 03:09 | Chousuke | it's not parallel at least :P |
| 03:11 | quizme | chousuke doesn't pmap parallelize the reduce processes ? |
| 03:12 | quizme | oh... |
| 03:12 | quizme | i think i get it |
| 03:12 | quizme | i see, thanks.... |
| 03:17 | Chousuke | the atom's going to block most of the parallelism anyway. |
| 03:17 | Chousuke | and for pmap to be worth it, the mapped function must be quite expensive |
| 03:19 | Chousuke | and it's not usually a good idea to def lazy seqs, unless you want to keep them in memory forever :) |
| 03:20 | Chousuke | you'll probably get more performance if you use a transient. |
| 03:20 | Chousuke | (without any atoms) |
| 03:21 | Chousuke | though if your data structure is nested, then it becomes somewhat tricky. |
| 04:36 | esj | hello eujurians (and Raynes, who sleeps not) |
| 04:53 | raek | greetings from the realm of smörgåsbord and IKEA |
| 04:57 | esj | raek: :) |
| 05:35 | LauJensen | smörgås means 'butter goose' in danish :P |
| 05:39 | LauJensen | @ raek |
| 05:39 | raek | in swedish too, for some reason |
| 05:40 | raek | but it still is the word for "sandwich" |
| 05:40 | LauJensen | hehe, swedish sets new standards for silly :) |
| 05:42 | esj | LauJensen: not sure on that one - a having "butter goose" as the default for a sandwich sounds pretty awesome where I'm standing |
| 05:43 | AWizzArd | How can I go from a symbol to class? (foo 'String) ==> java.lang.String (<-- this is a class) |
| 05:44 | AWizzArd | resolve? |
| 05:44 | LauJensen | esj: Im just telling you the Rules. Our languages stem from our Germanic Roots, Denmark is closets to the roots, more clear and easier to reason about. Norwegian is a little more distorted, but still understandable, especially in writing. Swedish is terrible distorted (I think because of alchohol abuse), so that its difficult to understand. If we go even further north we have Suomi, which is just.. gone |
| 05:44 | AWizzArd | Or is there something better? |
| 05:45 | imade | LauJensen, what's your take on Estonian, it sounds very similar to Finnish |
| 05:45 | LauJensen | imade: I dont know enough about it |
| 05:45 | esj | LauJensen: ROTFL. I'll have to teach you some Zulu when we meet. The grammar and syntax are such as to make the each sentance rhyme. Now that is awesome. |
| 05:48 | LauJensen | esj: Sounds like a cool challenge, would really take hard work. To learn swedish simply takes a couple of beers |
| 05:49 | esj | I have a problem, previously discussed, where a sufficient quantity of beer allows me to understand and speak German fluently, on the basis that if I just slur in Dutch I figure I'll be fine... |
| 05:50 | xkb | lol |
| 07:12 | AWizzArd | Who has an idea to improve this? |
| 07:12 | AWizzArd | ,(loop [list [10 20 30 40 50], result []] (if (< (count list) 2) result (recur (rest list) (conj result (take 2 list))))) |
| 07:12 | clojurebot | [(10 20) (20 30) (30 40) (40 50)] |
| 07:12 | Tordmor | ,(doc partition) |
| 07:12 | clojurebot | "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a ... |
| 07:13 | Tordmor | ,(let [lst [10 20 30 40 50]] (partition 2 lst 1)) |
| 07:13 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer |
| 07:13 | LauJensen | &(vec (partition 2 1 (range 10 50 10))) |
| 07:13 | sexpbot | ⟹ [(10 20) (20 30) (30 40)] |
| 07:15 | LauJensen | AWizzArd: Did you catch that buddy ? |
| 07:19 | AWizzArd | Ah, partition takes another arg |
| 07:19 | AWizzArd | good, thanks |
| 07:19 | LauJensen | 4 in in total, padding is nice as well |
| 07:19 | LauJensen | &(partition 2 2 [0] [1 2 3]) |
| 07:19 | sexpbot | ⟹ ((1 2) (3 0)) |
| 07:20 | AWizzArd | nice improvements, I missed those, thx |
| 07:21 | LauJensen | np |
| 08:33 | cemerick | stuartsierra: ping |
| 08:40 | sharat87 | Hello, is it ok to use a function with side effects in a call to map? |
| 08:40 | sharat87 | I mean, it will be called on the sequence in order right? |
| 08:41 | noidi | map is lazy, so you'd better use doseq for side effects |
| 08:41 | sharat87 | oh ok thanks |
| 08:55 | sharat87 | is there a better way to turn a keyword into a string (without the :) than (.substring (str :hella) 1) |
| 08:55 | LauJensen | &(name :hello) |
| 08:55 | sexpbot | ⟹ "hello" |
| 08:55 | sharat87 | ah neat, thanks :) |
| 08:55 | LauJensen | &(subs (str :hello) 1) |
| 08:55 | sexpbot | ⟹ "hello" |
| 08:56 | sharat87 | where are these functions I don't find it in the data structures page? |
| 08:56 | LauJensen | Both are better, prefer the first |
| 08:56 | sharat87 | ok |
| 08:56 | LauJensen | sharat87: try the cheat sheet |
| 08:56 | Raynes | Where did subs come from? |
| 08:56 | Raynes | &(doc subs) |
| 08:56 | sexpbot | ⟹ "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive." |
| 08:56 | sharat87 | yeah, there too, the keywords section only has keyword and keyword? |
| 08:57 | LauJensen | oh |
| 08:57 | chouser | Raynes: subs is one of those unexpectedly old ones |
| 08:58 | sharat87 | LauJensen: heh, a Ctrl-F reveals the name function in Other/Misc :) |
| 08:58 | chouser | &(meta #'subs) |
| 08:58 | sexpbot | ⟹ {:ns #<Namespace clojure.core>, :name subs, :file "clojure/core.clj", :line 3940, :arglists ([s start] [s start end]), :added "1.0", :doc "Returns the substring of s beginning at start inclusive, and ending\n at end (defaults to length of string), exclusive.", :tag java.lang.String} |
| 08:58 | chouser | &(:added (meta #'subs) |
| 08:58 | sexpbot | java.lang.Exception: EOF while reading |
| 08:58 | chouser | &(:added (meta #'subs)) |
| 08:58 | sexpbot | ⟹ "1.0" |
| 08:58 | Chousuke | I'm pretty sure subs was there before the first public release :P |
| 08:58 | chouser | yep |
| 08:58 | Raynes | I don't think anybody knows about it. |
| 08:59 | cemerick | subs is substituting a type hint for a fn call :-P |
| 08:59 | chouser | It's included in one of Rich's early presentations, comparing a Python example to an equivalent Clojure example |
| 09:00 | LauJensen | chouser: ah, he put it in there to win the spelling corrector test? :) |
| 09:00 | cemerick | Trying to make things look less hosty, I guess? |
| 09:00 | chouser | I think you're both right. :-) |
| 09:00 | stuartsierra | I think it even predates the (.method obj. ..) sintax |
| 09:00 | stuartsierra | *syntax |
| 09:01 | cemerick | Raynes: Dude, subs couldn't *exist* w/o .substring :-P |
| 09:01 | LauJensen | subs is actually the first building block of clojure, even precedes functions themselves |
| 09:01 | LauJensen | :) |
| 09:01 | cemerick | ha :-) |
| 09:01 | Raynes | cemerick: You have a thing about backends, don't you? |
| 09:01 | chouser | (.method obj) is now so clearly better, it's hard to believe people weren't sure at first |
| 09:02 | Raynes | cemerick: Just like project.clj, it's shorter and does everything that I need at the moment, so why would I ever want to use .substring? ;P |
| 09:02 | cemerick | Raynes: I'm an ass about making sure people don't forget the stature of the giants we sit upon. |
| 09:02 | chouser | Raynes: because if you know about .substring, finding .split is a natural progression |
| 09:02 | chouser | Raynes: if you only know about subs, good luck finding .split or clojure.string/split |
| 09:02 | cemerick | Raynes: The project.clj thing is totally orthogonal, far more meta, and not worth getting into. :-) |
| 09:03 | Raynes | chouser: I'm sure I would have managed. |
| 09:03 | Raynes | java.lang.String is not too far away. |
| 09:03 | Raynes | chouser: Nonetheless, shouldn't subs be in clojure.string? |
| 09:03 | chouser | I mean, I'm exaggerating, but there's a point there. |
| 09:04 | chouser | Raynes: if anywhere, yeah. But is it worth a breaking change to move it? |
| 09:04 | cemerick | chouser: I got your back, man. Exaggerate and hyperbolize away. |
| 09:04 | Raynes | chouser: Sure it is. There can't be more than 3 people using it in practice. |
| 09:05 | Raynes | clojure.string should really be called clojure.redundancy though. |
| 09:06 | stuartsierra | hey |
| 09:08 | Raynes | $seen mmarczyk |
| 09:08 | sexpbot | I have never seen mmarczyk. |
| 09:09 | Raynes | I haven't seen ol' Michal in quite a while. |
| 09:09 | LauJensen | :( |
| 09:09 | Raynes | He must be lurking. He's definitely around, since he watched clojail yesterday. |
| 09:45 | fliebel | morning |
| 09:46 | LauJensen | Morning :) |
| 09:49 | fliebel | Are there any (>= Clojure 50%) companies in Europe? |
| 09:51 | AWizzArd | fliebel: do you mean 50% or 0%? |
| 09:51 | AWizzArd | Any sounds like: (< 0% Clojure) |
| 09:51 | fliebel | AWizzArd: Well, at least anything where some serious Clojure work is happening :) |
| 09:54 | dakrone | fliebel: Forward was one of the conj sponsors, they're out of London I think |
| 09:55 | fliebel | dakrone: I'm googling for them :) |
| 09:55 | dakrone | fliebel: forward.co.uk |
| 10:23 | AWizzArd | fliebel: yes, some companies use Clojure seriously. |
| 10:24 | fliebel | AWizzArd: I'd love to know about a few more. |
| 10:52 | jkdufair | how can i use slime to send an expression to the REPL, copying and eval-ing it in the REPL itself? |
| 10:53 | jkdufair | i'm giving a presentation demo-ing clojure |
| 10:56 | bhenry | jkdufair: i feel like i've seen it in presentations but don't know how to do it myself. if you can't find it make a keyboard macro for C-k C-y C-c-z C-y |
| 10:56 | bhenry | you'd do that from the beginning of the form you want to send to the repl |
| 10:56 | jkdufair | yeah, it's not very useful outside of presentations |
| 11:10 | trybeingarun | Hey guys |
| 11:11 | tonyl | hello |
| 11:11 | trybeingarun | (read-line) is not working in emacs. Any fix available? |
| 11:11 | tonyl | sorry, not an emacs guy |
| 11:11 | trybeingarun | Fyn :) |
| 11:12 | trybeingarun | @tonyl: what editor are you using btw? |
| 11:13 | trybeingarun | not trying to start an editor war btw ;) |
| 11:14 | tonyl | i don't car about those wars |
| 11:15 | tonyl | I use vim, but run clojure with a bash script |
| 11:15 | trybeingarun | me neither. Whatever works fine for the job :) |
| 11:15 | trybeingarun | nice... |
| 11:17 | cemerick | puredanger: Got your back on the ccw keybindings. :-) FYI, Laurent will hopefully have an RC that includes the new REPL stuff this week. |
| 11:18 | puredanger | cemerick: cool, thx |
| 11:18 | trybeingarun | I am new to functional programming and clojure too. Can anybody suggest a good reading material (other than Practical clojure and Programming Clojure books) ? |
| 11:18 | puredanger | cemerick: does that mean just that you agree with me or that you're actually changing it? :) |
| 11:18 | cemerick | puredanger: what prompted you to bounce back and forth? I thought you had settled in with emacs, at least for a little while? |
| 11:19 | puredanger | cemerick: I've been doing more design work where I want to see a lot of stuff at once and I find Eclipse much easier to do that in |
| 11:19 | cemerick | puredanger: I'm all for changing it, but it's Laurent's sandbox. If he says it's a go, and it's just a matter of adding a condition to delegate off to your usual action for text editing in those contexts, then I'll make sure it's in the RC. |
| 11:20 | cemerick | If we don't have the current editing scope handy already, then it may be added to the backlog. |
| 11:21 | puredanger | cemerick: the thing that I find really disorienting about it is the difference in behavior with alt-left (left by word) and alt-shift-left (expand selection to entire string, instead of left by word expanding selection) |
| 11:21 | tonyl | trybeingarun: for me to understand clojure clojure.org helped me out. functional programming helped me just to go along and program some mini programs |
| 11:21 | tonyl | i haven't read any books just coding and reading blog posts |
| 11:21 | pdk | trybeingarun |
| 11:21 | pdk | look into on lisp/ansi common lisp |
| 11:22 | pdk | google sicp and look into haskell and ML (say SML or o'caml) as well |
| 11:22 | trybeingarun | Isn't there appreciable difference between common lisp and clojure? |
| 11:23 | AWizzArd | Is there a test to check if an object is either a Boolean or a primitive boolean? |
| 11:23 | pdk | true but the book can still be helpful for getting a feel for lisp on the whole and it spends some time covering things like what you can do with macros |
| 11:23 | trybeingarun | I mean, would not immutability make significant difference? |
| 11:23 | AWizzArd | other than (or (true? x) (false? x)) |
| 11:23 | pdk | (doc boolean?_ |
| 11:23 | clojurebot | EOF while reading |
| 11:23 | pdk | (doc boolean?) |
| 11:23 | clojurebot | Pardon? |
| 11:23 | pdk | hm |
| 11:24 | pdk | ,(. Integer java_class) |
| 11:24 | clojurebot | java.lang.NoSuchFieldException: java_class |
| 11:24 | cemerick | puredanger: Absolutely, yes. It's fundamentally just an impl detail, as the arrangement makes perfect sense in actual code. |
| 11:24 | pdk | ,(. Integer value_type) |
| 11:24 | clojurebot | java.lang.NoSuchFieldException: value_type |
| 11:25 | pdk | blast |
| 11:25 | trybeingarun | I have the following books with me. Can anybody order in increasing degree of importance/difficulty? |
| 11:25 | AWizzArd | Integer/TYPE exists |
| 11:25 | AWizzArd | Also Boolean/TYPE |
| 11:25 | cemerick | I'll have to scrounge up one of those paredit screencasts to see how the other side does things. |
| 11:25 | pdk | ,(. Integer TYPE) |
| 11:25 | clojurebot | int |
| 11:25 | pdk | hm |
| 11:25 | AWizzArd | ,(instance? Boolean/TYPE (Boolean. true)) |
| 11:25 | clojurebot | false |
| 11:25 | tonyl | Integer/TYPE |
| 11:25 | trybeingarun | 1. Practical Clojure 2. Programming Clojure 3. Practical Common Lisp 4.On lisp 5. PAIP 6. SCIP |
| 11:26 | pdk | ,(. Integer getClass) |
| 11:26 | clojurebot | java.lang.NoSuchFieldException: getClass |
| 11:26 | tonyl | i would say on lisp first then anything else would make sense, if you are new to lisp of course |
| 11:26 | pdk | on lisp makes sense after you've learned the basic stuff |
| 11:26 | pdk | practical clojure is a little sparse |
| 11:27 | pdk | though if you already know java and skimmed through some other lisp tutorials it could be helpful |
| 11:27 | pdk | ,(. (new Integer) getClass) |
| 11:27 | trybeingarun | Also, I have heard great things about SICP. But the fact that it is being recommended heavily by universities itself makes me a bit anxious. |
| 11:27 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer |
| 11:27 | trybeingarun | Will it be too theoritical?? |
| 11:28 | trybeingarun | I know java. |
| 11:28 | pdk | it's probably the first thing people will name if you say you want to learn scheme |
| 11:29 | pdk | i don't see any big reason to worry but if you want to be sure maybe do practical clojure to learn the basic concepts like what a form is, funargs etc |
| 11:30 | trybeingarun | What are you guys using clojure for? I am looking at it just for fun (I mean doing some pet projects) |
| 11:31 | puredanger | trybeingarun: large data integration w/ semantic web tech |
| 11:31 | tonyl | me too |
| 11:31 | tonyl | i am learning some game theory with it too |
| 11:32 | tonyl | and a have a project in the future for a web app |
| 11:32 | trybeingarun | how easy/difficult is it to adapt to pure clojure (FP) mindset. |
| 11:33 | trybeingarun | Of course, it is kind of a stupid question because it cant be quantified |
| 11:33 | puredanger | trybeingarun: anyone that thinks about programming seriously should read SICP imho, regardless of what lang you use. But I'm not sure it's the best way to dabble in FP. |
| 11:33 | trybeingarun | but, more particularly, any pain/pleasure points? |
| 11:33 | trybeingarun | Then I will surely read SICP |
| 11:34 | puredanger | trybeingarun: you might have fun using Clojure Koans https://github.com/functional-koans/clojure-koans |
| 11:34 | trybeingarun | for(int i = 0; i < blah; i++) {printf ("This has been my life so far");} |
| 11:35 | tonyl | trybeingerun: for me there was a learning curve (new to fp, lisp, and jave newbee) but it is worth it |
| 11:36 | tonyl | i see some problems in a different perspective |
| 11:36 | pdk | you could also learn more about fp by looking into books/articles etc on fp in general or other fp languages |
| 11:36 | pdk | say haskell or some variety of ML |
| 11:36 | trybeingarun | tonyl: could you please elaborate? What do you value most? |
| 11:36 | tonyl | change that to ##(doseq [x (range 10)] (prn "This is now how I do it")) |
| 11:36 | sexpbot | ⟹ "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" "This is now how I do it" nil |
| 11:37 | pdk | chris okasaki also has a good phd thesis out there specifically on data structures in fp |
| 11:37 | pdk | later made into a book you could get somewhere say amazon |
| 11:37 | tonyl | pdk: that looks interesting |
| 11:37 | tonyl | http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504 |
| 11:38 | trybeingarun | there is some effort going on to rewrite SICP in clojure, right. Anybody knows what happened to it? |
| 11:39 | pdk | the purely functional retrogames article series is also interesting |
| 11:39 | trybeingarun | sexpbot: funny :) |
| 11:39 | AWizzArd | ,(integer? 9999999999999) |
| 11:39 | clojurebot | java.lang.ExceptionInInitializerError |
| 11:39 | pdk | even if you're not looking at games programming it talks about how to go along doing stuff that you'd think would be prohibitive without imperative programming |
| 11:39 | tonyl | there is a blog that is trying to do that |
| 11:39 | AWizzArd | $(integer? 9999999999999) |
| 11:40 | tonyl | &(integer? 9999999999999) |
| 11:40 | sexpbot | java.lang.Exception: EvalReader not allowed when *read-eval* is false. |
| 11:40 | pdk | and game coding is usually something where we favor doing things highly imperatively |
| 11:40 | trybeingarun | tonyl: Ya. But in some forum I read the author is not responding to any queries and the effort might have halted. (I hope I am wrong :) ) |
| 11:41 | tonyl | maybe, it's been a while since I read those posts |
| 11:41 | tonyl | pdk: where is that series? I am trying to learn to do games in FP |
| 11:41 | trybeingarun | @RH: Blip.tv videos are amazing. Did not sleep during any of your talks :P |
| 11:44 | pdk | http://prog21.dadgum.com/23.html |
| 11:45 | pdk | tonyl |
| 11:45 | pdk | also trybeingarun |
| 11:45 | trybeingarun | pdk: any particular usecase where FP would do much much better than imperative style? |
| 11:45 | pdk | if you're looking into okasaki's book you could also find his phd thesis for free and see if it looks interesting |
| 11:45 | pdk | the book pretty much takes the thesis and expands on it |
| 11:45 | tonyl | thanks pdk |
| 11:46 | pdk | performance wise or in terms of being a more appropriate choice |
| 11:46 | trybeingarun | programming choice |
| 11:47 | pdk | hm that i couldn't answer 100% off the top of my head though folks are advocating it for any sort of highly concurrent coding |
| 11:47 | pdk | if you read on lisp as well it shows how the lisp style macro system can go surprisingly far |
| 11:48 | pdk | doing stuff like defining domain specific languages in terms of lisp macros so those mini languages can sit on top of your app |
| 11:48 | trybeingarun | Was trying out Practical Common Lisp. |
| 11:49 | pdk | on lisp can be had for free in pdf or html as well |
| 11:49 | trybeingarun | The author had developed a primitive unit testing framework in just under 30 lines |
| 11:49 | trybeingarun | ammmmazing |
| 11:49 | pdk | same with pcl |
| 11:49 | trybeingarun | code was beautiful |
| 11:49 | pdk | good thing too since a hardcover on lisp is still like $140 |
| 11:49 | pdk | and who knows why |
| 11:50 | trybeingarun | $140 ??? I am scared |
| 11:50 | Chousuke | I don't remember who it was that said this, but lisp is a language where you can build up the language to suit your problem domain, rather than having to break down your problem into something expressible in the language :) |
| 11:50 | pdk | for a physical copy trybeingarun |
| 11:50 | tonyl | i think that was paul graham |
| 11:50 | pdk | online it can be had for free legitimately |
| 11:50 | pdk | yeah it's a paul graham book |
| 11:50 | Chousuke | tonyl: probably |
| 11:52 | trybeingarun | I just downloaded a copy. Thanks pdf :) |
| 11:52 | trybeingarun | Paul Graham was working on his own language (Arc) right |
| 11:52 | tonyl | yeah |
| 11:52 | trybeingarun | anybody following that? |
| 11:52 | pdk | i'd be surprised if arc is still going |
| 11:53 | tonyl | is there, but there is not much development last time i checked |
| 11:53 | cemerick | pdk: it is, surprisingly. |
| 11:53 | pdk | hm |
| 11:53 | pdk | arclanguage.org has downloads though the site is incredibly sparse |
| 11:53 | cemerick | Nevermind, I'm not suprised :-P |
| 11:53 | trybeingarun | A:P |
| 11:53 | pdk | and it has recent forum posts |
| 11:55 | trybeingarun | Is it true that clojure's Regex support is not as good as perl or ruby's (I think I heard Stuart Halloway saying that in some talk (video)) |
| 11:55 | tonyl | under it it uses Java's |
| 11:55 | cemerick | trybeingarun: Clojure's regex support is as good as Java's, which is to say, very good. |
| 11:55 | cemerick | Not as good as perl's presumably. |
| 11:56 | cemerick | they are PCRE's, after all :-) |
| 11:56 | tonyl | found a bug on the java implementation |
| 11:56 | tonyl | but there are workarounds |
| 11:56 | trybeingarun | tonyl: what bug? |
| 11:56 | pdk | failing that you could just use java regexes anyway :p |
| 11:56 | tonyl | umm let me try ig |
| 11:56 | tonyl | *it |
| 11:57 | tonyl | when you use a [ inside a class group |
| 11:57 | pdk | god knows there's probably been countless projects to reimplement perl regex syntax as a java class either way |
| 11:57 | tonyl | like this #"[[]" |
| 11:57 | tonyl | it throws a matching error |
| 11:58 | technomancy | the literal syntax is nicer in Ruby, but I haven't found anything else problematic with Clojure's |
| 11:58 | technomancy | part from the fact that they're not callable |
| 11:59 | technomancy | *apart |
| 11:59 | tonyl | ruby's syntax is like perl isnt? using /regexp/ |
| 11:59 | technomancy | yeah, more pertinently it supports interpolation and things like /foo/i for case-insensitive |
| 11:59 | tonyl | yeah, that is handy |
| 12:00 | technomancy | case-insensitive in Clojure looks pretty silly: #"(?i)foo" |
| 12:00 | trybeingarun | technomachy: Dude, how is there a fix for emacs' (read-line) issue? (sorry to take to conversation off topic) |
| 12:00 | cemerick | tonyl: that's not a bug? |
| 12:00 | cemerick | &(re-seq #"[\[]" "[") |
| 12:00 | sexpbot | ⟹ ("[") |
| 12:00 | tonyl | &(re-matches #"[[]" "what [] up?") |
| 12:00 | sexpbot | java.util.regex.PatternSyntaxException: Unclosed character class near index 2[[] ^ |
| 12:00 | tonyl | the [ is not supposed to be a special char inside the [] |
| 12:01 | cemerick | tonyl: oh, you mean, a bug re: "perl compatible" |
| 12:01 | amalloy | tonyl: this was discussed in #clojure a week or two ago. java's regex engine, although supposedly PCRE, does that wrong |
| 12:01 | technomancy | trybeingarun: I'm not sure; maybe put your input in the buffer where you launched swank? |
| 12:01 | tonyl | yeah, that's what I meant |
| 12:02 | tonyl | not only perl, but the only doc http://www.regular-expressions.info/charclass.html |
| 12:02 | trybeingarun | technomancy:okay. I will try that |
| 12:02 | amalloy | chouser came up with something weird without using \ that i think worked |
| 12:02 | tonyl | unless there is a specification that I don't know about, and that always happens :P |
| 12:02 | amalloy | &#"[[[]]" maybe |
| 12:02 | sexpbot | java.util.regex.PatternSyntaxException: Unclosed character class near index 4[[[]] ^ |
| 12:03 | tonyl | now I'm intrigued how he did it |
| 12:03 | cemerick | tonyl: to be fair, the javadoc for j.u.Pattern doesn't claim to be perl-compatible *shrug* |
| 12:03 | tonyl | yeah, understandable |
| 12:03 | amalloy | &#"[[]]" |
| 12:03 | sexpbot | java.util.regex.PatternSyntaxException: Unclosed character class near index 3[[]] ^ |
| 12:03 | tonyl | and easy to workaround \ |
| 12:04 | amalloy | feh |
| 12:04 | cemerick | I'll always miss the named groups in python's impl |
| 12:04 | fogus_ | cemerick: until Java7 anyway |
| 12:04 | cemerick | fogus_: oh really? |
| 12:04 | fogus_ | I think I read that somewhere |
| 12:05 | cemerick | That'd be phantabulous. |
| 12:05 | fogus_ | cemerick: http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#groupname |
| 12:05 | tonyl | &(let [[a b c] (re-matches #"([-+]?[0-9]+)/([0-9]+)" "22/7")] [a b c]) |
| 12:05 | sexpbot | ⟹ ["22/7" "22" "7"] |
| 12:06 | cemerick | indeed |
| 12:06 | tonyl | destructuring helps you name the groups |
| 12:06 | cemerick | fogus_: the 6 years were worth the wait! :-P |
| 12:06 | cemerick | Man, matcher destructuring discussed again… |
| 12:09 | defn | hello all |
| 12:09 | fogus_ | well, re-matches returns a vector no? |
| 12:09 | tonyl | here's chousers ##(re-find #"[[]]]" "]") |
| 12:09 | sexpbot | ⟹ "]" |
| 12:10 | fogus_ | ,(re-matches #"(\d) (\d) (\d)" "1 2 3") |
| 12:10 | clojurebot | ["1 2 3" "1" "2" "3"] |
| 12:10 | defn | ##(re-find #"[[]]]" "]") |
| 12:10 | sexpbot | ⟹ "]" |
| 12:10 | defn | did sexpbot change again? |
| 12:10 | defn | -> (+ 1 2) |
| 12:10 | defn | guess so... |
| 12:11 | cemerick | fogus_: true, thought I saw re-matcher |
| 12:11 | fogus_ | cemerick: did you see my tweet about matcher destructuring? it was sick (in a bad way) |
| 12:12 | defn | i saw it. i threw up. |
| 12:13 | amalloy | defn: sexpbot changes a lot, though last i checked -> still worked. weird |
| 12:13 | amalloy | but & is easier to type as a prefix, and ## works anywhere in the message |
| 12:13 | sexpbot | java.lang.Exception: Unable to resolve symbol: works in this context |
| 12:14 | cemerick | fogus_: Hrm, perhaps. |
| 12:14 | amalloy | sexpbot: wtf, i fixed that problem |
| 12:14 | cemerick | I remember seeing matcher destructuring lately somewhere, and being surprised that it was supported at all. |
| 12:14 | cemerick | Side-effecting destructuring? |
| 12:14 | cemerick | etc |
| 12:14 | amalloy | cemerick: what side effects? |
| 12:15 | amalloy | when you destructure a matcher it gives you the groups of the most recent find, without starting a new find |
| 12:16 | fogus_ | amalloy: But you have to start the find in the first place |
| 12:16 | defn | #((\())) |
| 12:16 | defn | ##((\())) |
| 12:16 | sexpbot | java.lang.ClassCastException: java.lang.Character cannot be cast to clojure.lang.IFn |
| 12:16 | amalloy | fogus_: certainly. which is why there are no side effects in the destructuring |
| 12:17 | amalloy | defn: it's actually my code |
| 12:17 | fogus_ | amalloy: I see what you mean |
| 12:17 | fogus_ | http://twitter.com/#!/learnclojure/status/1746438878920704 |
| 12:18 | amalloy | defn: the regex for matching ## 'things is pretty awful tbh |
| 12:18 | sexpbot | ⟹ things |
| 12:19 | amalloy | (and next time he pulls, it won't match words mid-message in case someone wants to talk about channels with two #s) |
| 12:20 | defn | amalloy: i can show you some code that's worse... |
| 12:20 | amalloy | defn: i wouldn't be surprised, but have you looked at the regex? :P |
| 12:21 | defn | amalloy: https://github.com/defn/walton/blob/master/src/walton/core.clj#L38 |
| 12:22 | defn | it was designed to be "fast", and by "fast" i mean "completely incomprehensible" |
| 12:22 | cemerick | amalloy: fair enough, not side-effecting destructuring; rather, side-effectable destructuring :-P |
| 12:22 | amalloy | defn: condp instead of cond would make things a lot more readable |
| 12:23 | amalloy | and personally i'd use a map of {character=>keyword} pairs - surely a hashtable lookup is faster than testing N boolean expressions? |
| 12:24 | defn | amalloy: good point |
| 12:24 | cemerick | oddly enough, the matcher destructuring isn't congruent with re-groups (i.e. doesn't include group 0) |
| 12:24 | amalloy | also, you test for \\ twice in a row |
| 12:24 | Chousuke | amalloy: depends on the number of boolean expressions I guess. |
| 12:24 | defn | amalloy: yeah im re-reading this code now -- i just left it alone once it was done |
| 12:24 | fliebel | How can I read json, and return nil if it fails? This raises an exception, while the doc says it dhould retorn nil, if I'm correct. (read-json-from "" true false nil) |
| 12:25 | fliebel | (hi defn) |
| 12:25 | defn | (hi fliebel) |
| 12:26 | AWizzArd | fliebel: you can embed it into a try/catch |
| 12:26 | fliebel | AWizzArd: try is bulky, and the docs say it should be able to return nil if it find an empty string. |
| 12:27 | trybeingarun | Almost midnight @ India. Bye guys! |
| 12:28 | joegallo | drewr: Maintain radio silence! |
| 12:28 | drewr | joegallo: yessir |
| 12:29 | joegallo | drewr: Heh, we're having seekaret conversations over here. Ssshhh. |
| 12:34 | fliebel | I found a bug in clojure.contrib.json. |
| 12:36 | fliebel | Consider this bit and then try &|(char −1)|& on the REPL. if we are at the end of a file, we're never going to make it to the if statement. https://github.com/richhickey/clojure-contrib/blob/1e3333335334139669fb1e859fb0c3cb77b968df/src/main/clojure/clojure/contrib/json.clj#L116-121 |
| 12:36 | sexpbot | java.lang.Exception: Unable to resolve symbol: −1 in this context |
| 12:37 | fliebel | huh... |
| 12:37 | fogus_ | cemerick: Yeah, it's messed up (technical term). Creating that little snippet of matcher destructuring convinced me to never do it again. |
| 12:37 | Raynes | fliebel: Use ##(char -1) now, btw. |
| 12:37 | sexpbot | java.lang.IllegalArgumentException: Value out of range for char: -1 |
| 12:37 | fliebel | ty |
| 12:39 | cemerick | rhickey: What was the motivation for destructuring of j.u.Matchers? |
| 12:58 | fliebel | Where do I submit bugs and how do I get this contributors agreement to fix things myself? |
| 12:59 | arohner | fliebel: the CA is http://clojure.org/contributing |
| 13:07 | fliebel | arohner: Thanks. Do I really need to send this in for… submitting a bug? |
| 13:08 | arohner | fliebel: I don't think so. I think you only need to for submitting patches |
| 13:08 | amalloy | fliebel: and more power to you if you manage to fix anything. i got my CA in like a month ago, but gave up on changing anything because the instructions are so out-of-date and circular |
| 13:09 | arohner | oh, and bugs go here http://dev.clojure.org/jira/browse/CLJ |
| 13:12 | fliebel | arohner: I thought I red you need to be contributer to be allowed to be on there, but I'm on it right now and everything seems fine. |
| 13:12 | cemerick | fliebel: anyone can submit a bug. The CA is needed only if you're contributing code. |
| 13:13 | jimdagem | hi |
| 13:13 | cemerick | amalloy: I'm guessing the docs haven't been updated to reflect the move to JIRA, but: fix, produce patch, upload? |
| 13:13 | amalloy | cemerick: upload to where? |
| 13:14 | cemerick | amalloy: as an attachment to the corresponding JIRA ticket |
| 13:14 | esj | cemerick: your maven Enforcer just slapped me around for my own good :) Time for maven 3.0.... |
| 13:15 | cemerick | esj: ? |
| 13:16 | jimdagem | How do I properly do what I'm trying to do: http://pastebin.com/zsXSbzS6 |
| 13:16 | esj | I tried to build core.unify with maven. The build, courtesy of the Enforcer Plugin, told me that my Maven v 2.2.0 was no good. Reading through the poms, I'm deciding it must be your fault :) |
| 13:17 | cemerick | esj: Indeed, v2.2.0 won't do :-) |
| 13:17 | clojurebot | #<RuntimeException java.lang.RuntimeException: org.apache.http.conn.HttpHostConnectException: Connection to https://api.del.icio.us refused> |
| 13:17 | zmyrgel | hmm, I'm trying to assoc new value with my state record but it fails with "String cannot be cast to Associative" |
| 13:18 | cemerick | esj: IIRC, v2.2.0 didn't play well with gpg, used for signing artifacts |
| 13:19 | amalloy | jimdagem: (declare fib) (def fib (memoize (fn [x] ...))) is the hack i use |
| 13:19 | esj | cemerick: cool, I should be on the latest stable anyway. Now I just have to figure out how to make clojure:swank come back. |
| 13:20 | jimdagem | amalloy, sweet! |
| 13:20 | zmyrgel | here's the code piece causing the error: http://pastebin.com/c38Lq91F |
| 13:20 | jimdagem | clojure is so neato |
| 13:20 | fliebel | My bug: http://dev.clojure.org/jira/browse/CONTRIB-101 |
| 13:21 | amalloy | zmyrgel: your state is being set to a string instead of a map somehow, is what your error message says |
| 13:21 | amalloy | or your move, i guess |
| 13:22 | fogus_ | pdlogan: You sir are a glutton for painful twitter conversations. ;-) |
| 13:23 | amalloy | although, jimdagem, better still is not to memoize fib at all |
| 13:23 | zmyrgel | hmm, I'll check what gets passed to the function |
| 13:23 | amalloy | jimdagem: http://rosettacode.org/wiki/Fibonacci_sequence#Clojure |
| 13:26 | zmyrgel | ha, my previous function returned a string instead of associating it with a state |
| 14:02 | Phantom_Hoover | ([f xs] (reduce (fn [a x] (+ a (f x))) 0 xs))) |
| 14:03 | Phantom_Hoover | Does Clojure pattern match with vectors? |
| 14:03 | amalloy | Phantom_Hoover: not as far as i know, but i'm not sure i understand what your snippet is supposed to do |
| 14:03 | Phantom_Hoover | Wait, me neither... |
| 14:04 | chouser | heh |
| 14:04 | amalloy | wow, a hit and run |
| 14:04 | esj | grin |
| 14:11 | pdlogan | fogus_: I simply unfollowed him. nevermore. |
| 14:32 | KirinDave | technomancy: I do not understand octo-inc's utility. Is this trololo time or am I yet again too obtuse for this community? :) |
| 14:32 | pppaul | (defn 2d-map [fn 2d-array] |
| 14:32 | pppaul | (map (fn [row] |
| 14:32 | pppaul | (map fn row)) |
| 14:32 | pppaul | 2d-array)) |
| 14:32 | pppaul | is something like that in core? |
| 14:33 | Chousuke | no |
| 14:33 | technomancy | KirinDave: oh man we use oinc all the time. it's like the fibbonacci of sonian. |
| 14:33 | alpheus | Is there something like binding that will work across threads? |
| 14:33 | chouser | alpheus: binding in 1.3 :-/ |
| 14:33 | amalloy | alpheus: ##(doc bound-fn)? |
| 14:33 | sexpbot | ⟹ "Macro ([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place." |
| 14:34 | tonyl | or def ? |
| 14:34 | KirinDave | technomancy: Trololo |
| 14:34 | technomancy | chouser: it's not binding though; it's with-redefs, isn't it? |
| 14:34 | technomancy | KirinDave: exactly. |
| 14:34 | KirinDave | technomancy: Link to isthereaproblem.com |
| 14:34 | chouser | heh. depends on what you want. all these answers are good. |
| 14:35 | KirinDave | chouser: Didn't you have some rationale for not using :use, or using with with blank :onlys or something? |
| 14:35 | KirinDave | chouser: I think I remember you mentioning this, but I can't remember why. it came up the other day. |
| 14:35 | fliebel | Would it be doable/easy/useful to implement things like agents, refs and atoms over a network, for managing state of multiplayer/-user games/applications? |
| 14:35 | alpheus | tonyl: def just changes the root binding, so I don't think that's what I want. |
| 14:36 | amalloy | fliebel: you want the state in a server somewhere, right? if you rely on the clients to keep it, it's easy to cheat |
| 14:36 | chouser | alpheus: with-redefs temporarily changes the root binding, binding in 1.3 automatically passes the dynamic state across 'future' and 'send' calls |
| 14:36 | chouser | alpheus: short of those, see bound-fn |
| 14:37 | alpheus | So, bound-fn for now, then just call future directly in 1.3? |
| 14:38 | chouser | KirinDave: 'use' has a superset of 'require's fetures, plus a bad default. so using :only [] in 'use' means it behaves sanely to start with, and then you can add/remove options as needed without switching to/from 'require' |
| 14:38 | fliebel | amalloy: I'm thinking of keeping the state on the server, but do (swap) or (send) or whatever sortof RMI style. |
| 14:38 | chouser | alpheus: that should do it. |
| 14:38 | ossareh | technomancy: stupid question, why is oinc any different than (+ 8 x) ? |
| 14:38 | KirinDave | ossareh: needs more obfuscation. |
| 14:39 | hiredman | the infamous octo-inc |
| 14:39 | pjstadig | o stands for octo |
| 14:39 | hiredman | well played |
| 14:40 | ossareh | KirinDave: I'm referring to this: http://twitter.com/#!/technomancy/status/4617786731008000 |
| 14:40 | KirinDave | ossareh: So was I |
| 14:40 | ossareh | I'm confused then :) |
| 14:41 | pjstadig | oinc is much cooler than (+ 8 x) |
| 14:41 | technomancy | it's "more functional" |
| 14:41 | technomancy | since it involves more functions. |
| 14:41 | pjstadig | and shorter |
| 14:41 | tonyl | where is this oinc? |
| 14:41 | KirinDave | Lazier |
| 14:41 | ossareh | tonyl: see the link above |
| 14:41 | pjstadig | and we all know short and incomprehensible is better than long and understandable |
| 14:41 | chouser | has a bug |
| 14:41 | fliebel | technomancy: Hoave you seen my awesome function for generating an infinit lazy seq of ones? |
| 14:42 | ossareh | chouser: followed up in the next tweet |
| 14:42 | ossareh | http://twitter.com/#!/technomancy/status/4618155515191296 |
| 14:42 | chouser | oh |
| 14:42 | hiredman | ,(nth (iterate inc 1) 7) |
| 14:42 | clojurebot | 8 |
| 14:43 | fliebel | What is the difference between base and ancestors? |
| 14:43 | ossareh | technomancy, KirinDave: I'm not at the level of foo that I get either the application or the humour behind this :) |
| 14:43 | KirinDave | Well, I heard that you liked function calls |
| 14:44 | KirinDave | So Phil put some function calls in your function calls |
| 14:45 | amalloy | hiredman: i was looking around for your pl macro this morning, but i can't seem to find it |
| 14:46 | fogus_ | ,(let [oinc (fn [n] (reduce + n (map #(%) (repeat 2r000001000 #(*)))))] [(oinc 8) (oinc 32)]) |
| 14:46 | clojurebot | [16 40] |
| 14:48 | technomancy | fogus_: hats off to you sir. |
| 14:48 | pjstadig | holy crap fogus_ |
| 14:48 | amalloy | fogus_: #(*) is comical |
| 14:48 | KirinDave | So what are people using for date handling these days? |
| 14:48 | pjstadig | you have a new presentation for the meetup |
| 14:48 | KirinDave | Just raw-dogging on Joda Time? |
| 14:48 | ossareh | KirinDave: joda |
| 14:49 | KirinDave | Wasn't clj-time gonna start to bite into that? |
| 14:49 | fogus_ | There must be a better way to obfuscate the number 8 than 2r000001000 |
| 14:49 | amalloy | fogus_: (count "fourteen")? |
| 14:49 | fogus_ | oooo, that's pretty cool |
| 14:50 | KirinDave | technomancy: You know, there's got to be something amusing you could do with the way clojure handles arglists. |
| 14:50 | ossareh | KirinDave: http://dev.clojure.org/pages/viewpage.action?pageId=950382 <- this is good. clj-time has some very good work in it. |
| 14:50 | hiredman | clojurebot: transform |
| 14:50 | clojurebot | transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj |
| 14:50 | hiredman | amalloy: somewhere there |
| 14:50 | amalloy | ah, thanks |
| 14:50 | pjstadig | church numerals? |
| 14:51 | fogus_ | pjstadig: need to think of how to fit that into a tweet |
| 14:51 | fliebel | ossareh: How do you do those italic messages you just did? |
| 14:51 | amalloy | fliebel: /me whatever |
| 14:52 | amalloy | and how they show up depends on your client. they don't look italic to me |
| 14:53 | KirinDave | I wonder if you can get an arglist where it does work. |
| 14:56 | fogus_ | This is kinda weird: (defn oinc [num] (reduce + num (map #(%) (repeat (inc (count (str (:arglists (meta oinc))))) #(*))))) |
| 14:57 | amalloy | fogus_: that's horrible. but like, horrible-good |
| 14:58 | ossareh | fwiw, all this obfuscated clojure is somewhat like what I'm working with now: imovie. |
| 14:58 | amalloy | fogus_: ##(first (nth (iterate (fn [[a b]] [b (+ a b)]) [0 1]) 6)) maybe? |
| 14:58 | sexpbot | ⟹ 8 |
| 14:59 | amalloy | cause you might as well compute some fibonacci numbers if you're going to add eight |
| 15:00 | esj | KirinDave: clj-time is built around joda AFAIK |
| 15:05 | fogus_ | I think I'll just stick with this one: (defn oinc "fourteen" [n] (reduce + n (map #(%) (repeat (.length ((keyword (apply str (map char [100 111 99]))) (meta (var oinc)))) #(*))))) |
| 15:06 | fogus_ | 140 chars FTW! |
| 15:07 | chouser | Curious George golf |
| 15:07 | kotarak | What is this oinc stuff about? |
| 15:08 | amalloy | kotarak: there seems to be a competition to come up with the grossest way to write #(+ 8 %) |
| 15:08 | kotarak | oh, ah, |
| 15:08 | Kjellski | ping? |
| 15:08 | clojurebot | PONG! |
| 15:09 | Kjellski | ,(indexed (seq "Where are you")) |
| 15:09 | clojurebot | java.lang.Exception: Unable to resolve symbol: indexed in this context |
| 15:09 | kotarak | ,(map-indexed vector "Here") |
| 15:09 | clojurebot | ([0 \H] [1 \e] [2 \r] [3 \e]) |
| 15:09 | tonyl | &(String/parseInt "3" 10) |
| 15:09 | sexpbot | java.lang.IllegalArgumentException: No matching method: parseInt |
| 15:09 | tonyl | what?! |
| 15:09 | kotarak | ,(Integer/valueOf "3" 10) |
| 15:10 | clojurebot | 3 |
| 15:10 | amalloy | tonyl: Integer/parseInt |
| 15:11 | Kjellski | kotarak: thanks a lot ^^ was looking at the docs, and they´re unfortunately wrong... http://richhickey.github.com/clojure-contrib/seq-utils-api.html |
| 15:11 | Kjellski | kotarak: Or am I? |
| 15:11 | amalloy | Kjellski: neither |
| 15:11 | kotarak | Kjellski: The docs are now at clojure.github.com/clojure-contrib |
| 15:11 | amalloy | that function is in clojure.contrib.seq-utils, not in core |
| 15:12 | amalloy | &(require clojure.contrib.seq-utils) |
| 15:12 | sexpbot | java.lang.ClassNotFoundException: clojure.contrib.seq-utils |
| 15:12 | amalloy | &(require 'clojure.contrib.seq-utils) |
| 15:12 | sexpbot | java.io.FileNotFoundException: Could not locate clojure/contrib/seq_utils__init.class or clojure/contrib/seq_utils.clj on classpath: |
| 15:12 | Kjellski | What a mess, sorry but where do I need to look at if I want to see just the latest docs? |
| 15:12 | amalloy | bah |
| 15:12 | kotarak | Kjellski: http://clojure.github.com/clojure (resp. ....-contrib) |
| 15:13 | Kjellski | kotarak: Thanks in advance for the next years ^^ |
| 15:13 | tonyl | :P |
| 15:13 | kotarak | Kjellski: you are welcome >^.^< |
| 15:23 | tonyl | &(reduce + (map #(Integer/valueOf (str %) 10) (remove #(= % \.) (subs (str Math/PI) 0 4))) |
| 15:23 | sexpbot | java.lang.Exception: EOF while reading |
| 15:23 | tonyl | &(reduce + (map #(Integer/valueOf (str %) 10) (remove #(= % \.) (subs (str Math/PI) 0 4)))) |
| 15:23 | sexpbot | ⟹ 8 |
| 15:26 | amalloy | tonyl: #{\.} is the same as #(= % \.) |
| 15:28 | tonyl | wow |
| 15:29 | tonyl | how if it is a set ... |
| 15:29 | tonyl | &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4))) |
| 15:29 | kotarak | ,(#{\.} \.) |
| 15:29 | clojurebot | \. |
| 15:29 | tonyl | oh man |
| 15:29 | raek | well, a set used as a function will not return true/false, but the-element/nil |
| 15:29 | kotarak | ,(#{\.} \a) |
| 15:29 | clojurebot | nil |
| 15:29 | amalloy | &(map #{:a :b :c} [1 2 3 :a 3 :b]) |
| 15:29 | sexpbot | ⟹ (nil nil nil :a nil :b) |
| 15:30 | raek | but for truthiness, it's requivalent |
| 15:30 | tonyl | i knew that and i can't still wrap my head around the possibilities |
| 15:30 | tonyl | &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4))) |
| 15:30 | sexpbot | java.lang.Exception: EOF while reading |
| 15:30 | raek | :) |
| 15:30 | kotarak | ,(some #{false} [true true false true]) ;:P |
| 15:30 | clojurebot | nil |
| 15:31 | tonyl | &(reduce + (map #(Integer/valueOf (str %) 10) (remove #{\.} (subs (str Math/PI) 0 4)))) |
| 15:31 | sexpbot | ⟹ 8 |
| 15:31 | amalloy | tonyl: my favorite example of using objects as functions: ##(filter (comp #{"david"} :first) [{:first "steve" :last "smith"} {:first "david" :last "roberts"}]) |
| 15:31 | sexpbot | ⟹ ({:first "david", :last "roberts"}) |
| 15:31 | tonyl | composing a set and a keyword |
| 15:32 | tonyl | thanks guys, clojure doesn't stop amazing me |
| 15:34 | Kjellski | Somebody with a fresh install of clojurebox arround? Could you try to define a namespace in a file buffer and use C-c C-c to run? |
| 15:37 | alpheus | kotka has a nice write-up on bound-fn: http://kotka.de/blog/2010/05/Did_you_know_IV.html |
| 15:37 | Kjellski | Right now, C-c C-c over (ns foo.bar) leads to "No such namespace: de.kjellski.games.bagels [Thrown class java.lang.Exception]" ... |
| 15:45 | raek | Kjellski: does the same thing happen with C-x C-e and C-M-x ? |
| 15:45 | raek | (I don't have clojurebox) |
| 15:45 | talios | Morning. |
| 15:46 | Kjellski | raek: Hmmmm, that leads somewhere... it seems to work with C-x C-e when I´m at the end of the whole sexp... |
| 15:48 | Kjellski | raek: And surprisingly the C-c C-c works there as well.... |
| 15:48 | Kjellski | raek: At least a nice workarround, thanks! |
| 15:49 | raek | Kjellski: C-M-x should work "in the middle" |
| 15:50 | Kjellski | raek: There you go, thanks, it works in the middle as well =) |
| 15:51 | Kjellski | raek: =( but I was already used to C-c C-c in the last version of ClojureBox... |
| 15:54 | amalloy | well, i guess he left. but emacs does the same thing for C-c C-c, if you haven't already compiled the whole file once with C-c C-k, in my experience |
| 15:57 | sthuebne_ | I've just noticed technomancy's and cemerick's tweets regarding version ranges. That reminded me to ask, how the DSL for Lein/Maven/anythng is coming along? |
| 16:00 | pppaul | anyone think that something like this would be useful in contrib? |
| 16:00 | pppaul | user=> (def matrix [[1 2][3 4]]) |
| 16:00 | pppaul | user=> (map-2d #(* % 2) matrix) |
| 16:00 | pppaul | ((2 4) (6 8)) |
| 16:00 | pppaul | ((user=> (map-2d #(* %1 %2) matrix matrix) |
| 16:00 | pppaul | ((1 4) (9 16)) |
| 16:02 | pppaul | or something like a function/macro that is a nested map of n depth? |
| 16:03 | pppaul | or, am i nuts? |
| 16:04 | LauJensen | You guys know when you do a SELECT statement in the mysql client, you get a really nicely formatted table as the output? Do we have a pretty printer for that in clojure-land ? |
| 16:05 | pppaul | there is a pprint |
| 16:05 | pppaul | contrib.pprint and core |
| 16:05 | LauJensen | pppaul: I know, but does it handle resultset-seqs ? |
| 16:06 | pppaul | example? |
| 16:06 | clojurebot | examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples |
| 16:06 | kotarak | LauJensen: you can specify format strings on steroids. |
| 16:06 | kotarak | kind a map-like |
| 16:07 | kotarak | (the function map, not the structure map) |
| 16:07 | sthuebne_ | format is voodoo |
| 16:07 | LauJensen | Ah right, format might be the ticket. It would have been in CL thats for sure |
| 16:08 | LauJensen | thanks kotarak |
| 16:08 | LauJensen | kotarak: btw, clojureql 1.0.0-beta1 release is now imminent :) |
| 16:08 | kotarak | you are welcome, my danish friend |
| 16:08 | kotarak | LauJensen: I'm following it. |
| 16:09 | LauJensen | Hopefully tomorrow or the day after at the latest |
| 16:10 | scottj | what did you guys think of clojurize? |
| 16:11 | LauJensen | scottj: is it a movie that just came out? |
| 16:11 | sthuebne_ | LauJensen: BTW: what's the state of affairs regarding DSL for pom/project.clj |
| 16:11 | sthuebne_ | = |
| 16:11 | sthuebne_ | ? |
| 16:11 | LauJensen | sthuebne_: read the google group 'project.clj spec' |
| 16:11 | sthuebne_ | oh |
| 16:11 | sthuebne_ | I wasn't aware of that |
| 16:12 | stuartsierra | The State of Affairs is: Growling and gnashing of teeth |
| 16:12 | scottj | http://anvil.io/2010/10/25/clojurize-the-data-not-the-database.html |
| 16:12 | sthuebne_ | LauJensen: thanks for the pointere! |
| 16:12 | sthuebne_ | Jesus, I miss my keyboard |
| 16:13 | LauJensen | scottj: its not really interesting to me |
| 16:13 | LauJensen | sthuebne_: nps :) |
| 16:13 | scottj | LauJensen: why? it seems very similar to clojureql |
| 16:14 | LauJensen | scottj: Its totally different. Its based on SQL |
| 16:26 | clizzin1 | this is a pretty dumb question, but how do i convert a map to a sorted-map? |
| 16:27 | amalloy | clizzin1: ##(into (sorted-map) {1 2. :a 4}) |
| 16:27 | sexpbot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Keyword |
| 16:27 | amalloy | bleh whatever. do it like that |
| 16:28 | clizzin1 | thanks amalloy! |
| 16:33 | LauJensen | I need the latest artifact for clojure.contrib.sql, where do I find its group/artifact-id ? |
| 16:36 | talios | LauJensen: that |
| 16:36 | kotarak | org.clojure.contrib/sql maybe? |
| 16:36 | talios | that's mentioned in the pom - https://github.com/clojure/clojure-contrib/blob/master/modules/sql/pom.xml - org.clojure.contrib:sql |
| 16:36 | LauJensen | kotarak: I dont need the name itself as much as I need a method for getting that an other artifact names. hudson isnt being very helpful |
| 16:36 | LauJensen | ah right |
| 16:37 | LauJensen | And these modules are only available from 1.3.0 right? |
| 16:37 | talios | I believe so yes. |
| 16:37 | talios | the split up was post 1.2 |
| 16:42 | clizzin1 | if i want to write a custom compare function in clojure for use in sort-by, how do i make it implement java.util.Comparator? |
| 16:43 | sthuebne_ | stuartsierra, LauJensen Now, I'm up-to-date. A clash of philosophies. |
| 16:43 | LauJensen | sthuebne_: What are we talking about now? |
| 16:43 | sthuebne_ | sorry ,-) |
| 16:43 | sthuebne_ | project.clj |
| 16:43 | LauJensen | ooh :) |
| 16:45 | sthuebne_ | What is the goal of a unified DSL for describing builds? |
| 16:47 | LOPP | clizzin all functions are comparators |
| 16:47 | clojurebot | functions are maps |
| 16:47 | sthuebne_ | the existing build tools, that happen to use similar dialects for build specs, work very different. on purpose I suppose |
| 16:47 | LOPP | they will fail to work if they don't have 2 arguments |
| 16:48 | LauJensen | sthuebne_: Ease of implementing these. Right now consumers of project.clj have to make 1 implementation for each build tool |
| 16:48 | LauJensen | Even simple builds fail to run of all 3 tools, which sucks |
| 16:48 | sthuebne_ | I see that. |
| 16:51 | sthuebne_ | it seems, that only simple builds are likely to be portable between the three |
| 16:51 | LauJensen | True |
| 16:52 | sthuebne_ | correct me if I'm wrong, but Lein plugins work very different (on a different level) than Maven plugins. |
| 16:52 | LauJensen | Very differently |
| 16:52 | talios | I think the goal of a unified DSL for builds is good, but fundamentally flawed. |
| 16:53 | sthuebne_ | there might be a chance to align plugin names and to make sure, that plugins exist in both/all three worlds |
| 16:53 | LauJensen | sthuebne_: http://stackoverflow.com/questions/3906276/whats-the-difference-between-cake-and-leiningen - See lancepantz reply |
| 16:53 | sthuebne_ | that provide the same behaviour |
| 16:53 | talios | sthuebne_: really? you're going to implement EVERY SINGLE MAVEN PLUGIN? |
| 16:53 | talios | ejb? xml paring? osgi? |
| 16:53 | sthuebne_ | talios: no! |
| 16:54 | talios | sthuebne_: and thus dies the aim of a cross build that works :( |
| 16:54 | sthuebne_ | I was thinking of the opposite - have maven plugins where Leiningen's plugins are unique |
| 16:54 | sthuebne_ | but that seems sort of stupid as well |
| 16:55 | sthuebne_ | why multiplying efforts |
| 16:55 | talios | true, but given anyone can create lein plugins, and people often do ( such as Brian Marrick's midge plugin ) - it'll be an endless game of rinse and repeat |
| 16:55 | sthuebne_ | exactly |
| 16:55 | technomancy | I don't really understand the motivation. Do you see people wanting to use make to build clojure because they are opposed to greenspunning? |
| 16:55 | talios | unless you mean "core" plugins |
| 16:56 | talios | technomancy: autoconf for the win :-) |
| 16:56 | talios | they don't even use make anymore :) |
| 16:56 | technomancy | talios: I almost said autoconf but didn't want to give anyone the shivers =) |
| 16:57 | talios | you're too nice then. |
| 16:58 | LauJensen | I would really love a Clojurish build tool which plugged into the entire Maven world, plugins going back and forth etc |
| 16:59 | LauJensen | I will call it : Mavadvenjure |
| 17:00 | talios | LauJensen: if it's declaritve only, it could be doable. but the moment you bring in any form of dynamic scripty ness, you lose that two-way round trip. as the DSL builds a model that can't generate itself (only its canonical representation) |
| 17:01 | sthuebne_ | I head a brief chat with Jazon van Zyl earlier this year. I was asking him (since pmaven was new to me back then), whether pmaven would provide anything like a "scriptable" build. |
| 17:01 | talios | which, when you look at things like the maven-release-plugin which update version numbers, could be an issue. |
| 17:01 | talios | sthuebne_ - my origin clojure-pmaven work had full scriptable ness, to generate the model. |
| 17:02 | talios | as does the groovy and scala versions |
| 17:02 | sthuebne_ | yeah, that's what they do - they generate the model |
| 17:03 | talios | that's really all they can do, its also what gradle does |
| 17:03 | sthuebne_ | maybe I didn't understand the current implementation of it, but it seemed to me to be really just a different language to describe the model. how would you add dynamics? |
| 17:04 | LauJensen | I hate to leave in the middle of this, but I have to, goodnight everybody |
| 17:04 | talios | mmm, i see the wiki's not been updated, but in my original code, you could do: (if-not (contains-plugin? main "some.groups:plugin") |
| 17:04 | talios | (add-plugin! main ["some.groups:plugin:1.0" {:configuration {:name "value"}}])) |
| 17:05 | talios | dynamically adding a dependency, you could dynamically modify/update/add plugins etc. |
| 17:05 | talios | I guess the core question to ask is.... what kind of dynamic nature do you want. |
| 17:06 | LOPP | I often see #' in the code |
| 17:06 | LOPP | I forgot...when am I supposed to use that |
| 17:07 | cemerick | LOPP: that give you the named var, rather than its value |
| 17:07 | cemerick | &#'+ |
| 17:07 | sexpbot | ⟹ #'clojure.core/+ |
| 17:07 | cemerick | &+ |
| 17:07 | sexpbot | ⟹ #<core$_PLUS_ clojure.core$_PLUS_@b5f87c> |
| 17:07 | cemerick | same as (var +) |
| 17:07 | LOPP | ok but why do you use that |
| 17:07 | talios | 'lo cemerick |
| 17:08 | cemerick | LOPP: so you can do things with vars instead of their values :-) |
| 17:08 | cemerick | talios: afternoon :-) |
| 17:08 | talios | morning :-) 11:11am here. |
| 17:08 | sthuebne_ | talios: grep doesn't find any "add-plugin" on master |
| 17:08 | cemerick | talios: damn! :-P |
| 17:09 | sthuebne_ | sorry, I've started it. |
| 17:09 | talios | sthuebne_: sadly when antony ported/rewrote my initially implementation he removed all those dsl things ;( |
| 17:10 | sthuebne_ | I was late to the project.clj--spec discussion in the first place |
| 17:10 | sthuebne_ | that's a long time indeed |
| 17:11 | talios | work and the podcast got in the way, along with the realization that it was mostly a futile effort. |
| 17:12 | sthuebne_ | from the current perspective it's just a different language to express the very same thing |
| 17:12 | talios | that looses the two-way roundtrip nature, and breaks the ecosystem. |
| 17:13 | sthuebne_ | realizing that, I was asking myself what the actual point would be, to have a clojure-ish POM |
| 17:14 | talios | XML is evil didn't you know? |
| 17:15 | sthuebne_ | sure, whatever they say |
| 17:17 | stuartsierra | talios: any idea why this fails? |
| 17:17 | stuartsierra | http://build.clojure.org/job/clojure-testbuild/8/console |
| 17:17 | LOPP | is there a reason not to use #'x instead of x? |
| 17:18 | sthuebne_ | its verbose, OK. but honestly, I can write POMs for fairly complex builds by just using nXML in Emacs and nobody ever exposed me to a build tool, that wouldn't force me to write my builds in one or another language myself |
| 17:18 | amalloy | LOPP: they're different things |
| 17:18 | Raynes | &(macroexpand '#'blah) |
| 17:18 | sexpbot | ⟹ (var blah) |
| 17:18 | amalloy | &(#'first first) |
| 17:18 | sexpbot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$first |
| 17:18 | amalloy | &([#'first first]) |
| 17:18 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentVector |
| 17:18 | Raynes | &(macroexpand first) |
| 17:18 | sexpbot | ⟹ #<core$first clojure.core$first@615dc4> |
| 17:18 | amalloy | damn it. whatever |
| 17:18 | amalloy | &[#'first first] |
| 17:18 | sexpbot | ⟹ [#'clojure.core/first #<core$first clojure.core$first@615dc4>] |
| 17:18 | LOPP | &(#'first [1 2]) |
| 17:18 | sexpbot | ⟹ 1 |
| 17:18 | Raynes | #'something is just shorthand for (var something) |
| 17:19 | LOPP | since #'first works just as well as first, why not always use #'? |
| 17:19 | amalloy | LOPP: #' only works for things that *have* vars |
| 17:19 | Raynes | Why would you want to do that in the first place? |
| 17:19 | amalloy | (or are vars, if you prefer) |
| 17:20 | LOPP | because I have code that uses values |
| 17:20 | Raynes | Since (identity (identity (identity 5))) works as well as 5, why not always do that? |
| 17:20 | LOPP | then it turned out I had to use #' in various places for it to work properly |
| 17:20 | LOPP | that got me thinking, why not preemptively use #' everywhere I can |
| 17:20 | LOPP | so far I can see no reason |
| 17:21 | amalloy | LOPP: it's a terrible idea. why not check (foo != null) every time you call a method on foo, just in case it's become null when you weren't looking? |
| 17:21 | amalloy | in both cases, you're better off actually understanding the difference |
| 17:22 | talios | stuartsierra: hmmm, is clojure.java.io.Coercions a .java or .clj file? if the later my guess is the namespace is turning up later in the build path? If you run mvn with -X and get all the debug output we can see the actual command line we're calling |
| 17:22 | stuartsierra | neither, it's a protocol defined in io.clj |
| 17:23 | LOPP | the problem is where I use lists of listener functions subscribed to events |
| 17:23 | LOPP | if I change the function the handler of course doesn't |
| 17:23 | LOPP | but ok |
| 17:23 | LOPP | here's another question |
| 17:23 | LOPP | why is conj '[1 2 3] faster than conj [1 2 3] |
| 17:24 | LOPP | sorry |
| 17:24 | amalloy | LOPP: if you want to change things, my suggestion is to use something with real STM semantics, like an atom, instead of abusing vars |
| 17:24 | stuartsierra | talios: What I don't get is that it works the first time, when it does "mvn clean verify" then fails when it does "mvn deploy" |
| 17:24 | LOPP | the whole map is in a ref |
| 17:24 | LOPP | but it's a map of vectors of sets |
| 17:25 | LOPP | no matter |
| 17:25 | LOPP | &(time (dotimes [n 100000] (conj '[1 2 3] 4))) |
| 17:25 | sexpbot | ⟹ "Elapsed time: 14.451 msecs" nil |
| 17:25 | LOPP | &(time (dotimes [n 100000] (conj [1 2 3] 4))) |
| 17:25 | sexpbot | ⟹ "Elapsed time: 29.008 msecs" nil |
| 17:26 | LOPP | why the difference? |
| 17:26 | amalloy | you want to...what, be able to change the definition of a listener function with a new defn, and have the objects who were tracking those automagically use the new function of the same name? |
| 17:26 | talios | stuartsierra: right - i see no reference to io.clj being compiled before hand in the deploy step, but it does in the first set. thats.... weird. |
| 17:26 | amalloy | i mean, yes, that's kinda what vars are for, but it seems like a weird thing to want |
| 17:27 | LOPP | don't worry, I'm just messing around a bit... don't really need the solution right now |
| 17:27 | Raynes | LOPP: Well, it isn't evaluating anything inside of the vector, for one. |
| 17:28 | Raynes | I'm not exactly sure why it would be faster. |
| 17:28 | LOPP | here's another problem I have a very unelegant solution for: you have a vector of sets and you need to return a vector of sets where all the intersecting sets are combined |
| 17:28 | talios | stuartsierra: if you configure maven to run with -X we can see if the plugins just not telling the compiler to compile io, or if its clojure itself. |
| 17:28 | LOPP | yeah it's weird...I mean, won't it have to evaluate that eventually? |
| 17:29 | amalloy | all the...intersecting sets are combined? what do you mean by "intersecting" and "combined" here? or give a small-scale example? |
| 17:30 | _mst | I remember something (from the clojure group, probably) about the quoted form allowing the reader to create the vector data structure once up front and reuse it for each call |
| 17:30 | LOPP | sure |
| 17:30 | _mst | whereas the unquoted variant would create a new vector for every iteration |
| 17:30 | _mst | but that might be complete rubbish... or I might have dreamt it. I can't find where I read it :) |
| 17:30 | stuartsierra | talios: ok, running now at http://build.clojure.org/job/clojure-testbuild/10/console |
| 17:30 | LOPP | [#{:a :b :c} #{:c :d} #{:e :f}] -> [#{:a :b :c :d} #{:e :f}] |
| 17:31 | LOPP | [#{:a :b} #{:c :d} #{:b :c :e} |
| 17:31 | LOPP | -> [#{:a :b :c :d :e}] |
| 17:31 | amalloy | i see |
| 17:32 | LOPP | I did it but it was ugly as hell |
| 17:32 | LOPP | very javaish |
| 17:33 | amalloy | off the top of my head, it looks like you want to use reduce, some, and update-in to do the heavy lifting |
| 17:33 | stuartsierra | talios: Nuts, same failure, no new information. |
| 17:34 | sthuebne_ | talios, stuartsierra the order clj-files are compiled is completely different in both steps |
| 17:34 | stuartsierra | yes, I think that has something to do with it |
| 17:34 | stuartsierra | but in theory it shouldn't matter |
| 17:36 | stuartsierra | clojure.java.shell declares :use on clojure.java.io, so clojure.java.io should get compiled automatically when you try to compile clojure.java.shell |
| 17:36 | jarpiain | LOPP: (conj '[1 2 3] 4) and (conj [1 2 3] 4) generate exactly same bytecode in 1.3 |
| 17:37 | stuartsierra | wait a minute |
| 17:38 | stuartsierra | "Exception… at clojure.java.shell__init.<clinit>(Unknown Source)" |
| 17:38 | talios | stuartsierra: i thought use didn't alter order, but require did |
| 17:38 | stuartsierra | talios: Nothing alters order, but any ns that loads other namespaces will cause them to be compiled when it is compiled. |
| 17:38 | stuartsierra | *BUT* |
| 17:38 | stuartsierra | In this instance, clojure.java.shell is being loaded from a .class file, not from source. |
| 17:39 | stuartsierra | I don't know why |
| 17:39 | talios | Hrm |
| 17:39 | LOPP | I don't see where I'd use update-in, I have no nesting |
| 17:40 | amalloy | yeah, i'm wrong about that part :P |
| 17:40 | amalloy | i'm writing it now |
| 17:42 | talios | stuartsierra: weird, in the deploy/release phase, that .class shouldn't yet exist as target/checkout/classes should be where it's looking..... *blink* or is the plugin looking at the wrong place and finding the .class from target/classes ( which would explain it ) |
| 17:43 | LOPP | I basically combined each set with other set and compared sizes, if it wasn't the sum of the 2 sets I combined then they intersect. However that only works for 2 individual sets, so I had to do iterations of this and I had to rotate which set I started the iteration with. In the end quite ugly. |
| 17:43 | stuartsierra | There's something screwy going on with directories, that's for sure. |
| 17:43 | talios | odd that -X didnt give the debug info I expected |
| 17:44 | stuartsierra | It's becasue the deployment is being controlled by the Sonatype OSS release parent POM |
| 17:44 | talios | I'll do some digging when I get home tonight |
| 17:44 | stuartsierra | talios: ok, thanks, appreciate it |
| 17:44 | sthuebne_ | talios: it should report the classpath for plugins, shouldn't it? |
| 17:46 | talios | sthuebne_: in this instance its not the classpath of the plugin that's actually the problem, more the directories being configured for it. |
| 17:46 | talios | I suspect I've hardcoded a target/classes reference |
| 17:46 | talios | or more "outputdirectory/classes" |
| 17:47 | sthuebne_ | but that should work in case of "release:perform" a ka deploy as well |
| 17:48 | talios | but in this case, that {outputdir}/classes still has the .class files from the prepare phaze |
| 17:48 | talios | a work around could be release:prepare clean release:perform |
| 17:49 | amalloy | LOPP: https://gist.github.com/0557059ea1585b322cec |
| 17:49 | sthuebne_ | are you shure about that? |
| 17:49 | amalloy | not very elegant, but functional (pun intended) |
| 17:49 | sthuebne_ | release:perform forks a new maven process on a different dir |
| 17:49 | sthuebne_ | which is target/checkout |
| 17:50 | sthuebne_ | so, how could the clojure plugin in that other process get hold of the .class files of the former? |
| 17:51 | talios | i have NO idea :) the clean step would just proove that. it's possible I'm looking at the wrong var and the one I'm looking at it always "target" |
| 17:53 | sthuebne_ | OR does one of the profiles do something fishy with sourceDir/outputDirß |
| 17:55 | LOPP | I'll check it out |
| 17:56 | LOPP | about 3 times shorther than what I wrote |
| 17:56 | LOPP | :) |
| 17:56 | LOPP | make that 5 |
| 17:57 | amalloy | oh, i didn't include it in the gist, LOPP, but you have to (use 'clojure.set) |
| 17:57 | talios | sthuebne_ - not sure, the log says its all looking at target/checkout/target/* so I'm confused. tho I can't look at it just now work. darn day job ;) |
| 17:58 | LOPP | right...what does clojure.set do anyway? |
| 17:58 | amalloy | intersect, union, that sort of stuff |
| 17:58 | LOPP | all those fns are too complicated |
| 17:58 | amalloy | you can write your own union with into, but i assume clojure.set does it better |
| 18:00 | quizme | are the clojure conj videos posted online? |
| 18:01 | LOPP | what's old-form arg in if-let? |
| 18:02 | amalloy | LOPP: something deprecated, don't use it |
| 18:03 | sthuebne_ | talios: well, my day job is starting in about 7hrs. So I say n8 for now |
| 18:03 | chouser | & (if-let a 5 true) |
| 18:03 | sexpbot | java.lang.IllegalArgumentException: if-let requires a vector for its binding |
| 18:05 | mjg123 | Hello - is "init" a special name for clojure in deftype'd types? |
| 18:05 | mjg123 | If I wanted to implement javax.servlet.Servlet#init(ServletConfig), how could I do that? |
| 18:07 | mjg123 | I tried: javax.servlet.Servlet (init [this config] ( ... something ... )) - but no init() method is generated in the .class file |
| 18:07 | amalloy | &(if-let a 5 true false) |
| 18:07 | sexpbot | java.lang.IllegalArgumentException: if-let requires a vector for its binding |
| 18:09 | bhenry | chouser amalloy ??? |
| 18:09 | amalloy | bhenry: trying to figure out how to use the old form of if-let to tell LOPP what not to do. fortunately (i guess?) it's hard |
| 18:10 | LOPP | :D |
| 18:10 | LOPP | yeah :) |
| 18:10 | LOPP | well I won't use it |
| 18:13 | pppaul | can i use cons cells as keys in my hash-map? |
| 18:14 | pppaul | i'm trying and they aren't working... i day or so ago i thought i did some tests that showed i could... maybe they were flawed? |
| 18:15 | pppaul | forest |
| 18:15 | pppaul | {(1 0) :grass, (0 0) :tree, (1 1) :grass, (0 1) :grass} |
| 18:16 | pppaul | that is the hash-map i have, but i have trouble using (get) on it |
| 18:17 | pppaul | oh i was using get wrong (arg pos was in wrong order) |
| 18:17 | dnolen | ,{[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass} |
| 18:17 | clojurebot | {[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass} |
| 18:18 | dnolen | ,((juxt [1 0] [0 0] [1 1] [0 1]) {[1 0] :grass, [0 0] :tree, [1 1] :grass, [0 1] :grass}) |
| 18:18 | clojurebot | java.lang.IllegalArgumentException: Key must be integer |
| 18:18 | dnolen | oops |
| 18:22 | pppaul | cons cells work |
| 18:22 | pppaul | i was using get like this (get :key :map) |
| 18:22 | LOPP | hm amalloy your code for sets doesn't work |
| 18:22 | LOPP | (def sets [#{:a :c :b} #{:d :e} #{:c :e}]) |
| 18:23 | LOPP | (#{:a :c :b :e} #{:d :e}) |
| 18:23 | LOPP | which is wrong result |
| 18:24 | LOPP | I had the same problem, in one pass I only paired the first set with all I could find, but not the others |
| 18:29 | tonyl | LOPP do you need to keep the number of sets in the vector? or can it be just one holding all the results? |
| 18:44 | amalloy | LOPP: ah, right. because it's not going back and filtering in old sets that now match |
| 18:44 | amalloy | tricky |
| 18:45 | LOPP | yes |
| 18:45 | LOPP | that's the thing...by combining sets you get new matches |
| 18:46 | nickik | is there a function to write a vector one value per line into a file |
| 18:46 | amalloy | i did something like this in CL in like...april, i think. but there was a guarantee that the final result would be exactly two sets |
| 18:47 | LOPP | one thing you can do is maybe put iterate around it and check for when the sequence stabilizes |
| 18:47 | amalloy | yeah, i was thinking that too. so gross :P |
| 18:48 | LOPP | in any case this is one devilishly complex problem yet it looks so simple, a human can do it easily |
| 18:48 | amalloy | LOPP: a human can do it easily for small numbers of small sets |
| 18:48 | LOPP | that's true |
| 18:49 | tonyl | nickik: something like (doseq [x myvec] (spit myfile (print-str x \newline)) |
| 18:49 | LOPP | well I did the thing with iterate and the seqence doesn't stabilize, the order of sets keep changing even though the sets themselves don't |
| 18:50 | amalloy | hah |
| 18:50 | tonyl | LOPP: does it have to keep the number of sets in the vector? |
| 18:50 | amalloy | well, that's easy though |
| 18:50 | amalloy | just have it operate on a set instead of a vector |
| 18:51 | tonyl | or can it output all the items in 1 set as a result |
| 18:51 | powr-toc | does anyone know what happened to clojure.contrib.repl-utils/show ? |
| 18:51 | powr-toc | I've just updated to 1.2.0 |
| 18:51 | amalloy | powr-toc: i it's in clojure.repl now, i think |
| 18:51 | powr-toc | amalloy, I can't see it in there |
| 18:51 | amalloy | or maybe not? i always lose it too |
| 18:51 | LOPP | but you want the sets to rotate |
| 18:52 | LOPP | because otherwise you might get stuck as in some cases you keep picking same first set as the starting set |
| 18:52 | LOPP | and you might not progress |
| 18:52 | kjellski | What is the right way to look at wethere a seq contains an element or not? |
| 18:52 | amalloy | kjellski: ##(doc some) |
| 18:52 | sexpbot | ⟹ "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)" |
| 18:53 | amalloy | LOPP: ? every iteration you'll be removing one element |
| 18:53 | kjellski | amalloy: ty |
| 18:53 | powr-toc | has show been removed from contrib? |
| 18:53 | tonyl | &(apply union [#{:a :c :b} #{:d :e} #{:c :e}]) |
| 18:53 | sexpbot | java.lang.Exception: Unable to resolve symbol: union in this context |
| 18:54 | raek | powr-toc: don't think so |
| 18:55 | powr-toc | raek, Then where is it? |
| 18:55 | tonyl | it is not in clojure.contrib.repl-utils/show ? |
| 18:55 | amalloy | tonyl: ##(use 'clojure.set) |
| 18:55 | sexpbot | ⟹ nil |
| 18:55 | tonyl | &(apply union [#{:a :c :b} #{:d :e} #{:c :e}]) |
| 18:55 | sexpbot | ⟹ #{:a :c :b :d :e} |
| 18:56 | raek | &(clojure.contrib.repl-utils/show Object #"toString") |
| 18:56 | sexpbot | java.lang.ClassNotFoundException: clojure.contrib.repl-utils |
| 18:56 | raek | &(require 'clojure.contrib.repl-utils) |
| 18:56 | sexpbot | java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath: |
| 18:56 | tonyl | &*clojure-version* |
| 18:56 | sexpbot | ⟹ {:major 1, :minor 2, :incremental 0, :qualifier ""} |
| 18:56 | raek | well, I used it yesterday |
| 18:57 | amalloy | it's around /somewhere/, but it always takes me ages to find it |
| 18:57 | powr-toc | raek: it seems to have vanished for me too :-\ |
| 18:57 | tonyl | &(find-doc "^show") |
| 18:57 | sexpbot | ⟹ ------------------------- clj-time.format/show-formatters ([] [dt]) Shows how a given DateTime, or by default the current time, would be formatted with each of the available printing formatters. ------------------------- clj-github.gists/show-gist ([auth id file-... http://gist.github.com/702762 |
| 18:57 | powr-toc | surely clojure.repl would be a good place for it |
| 18:57 | raek | powr-toc: which version? |
| 18:57 | powr-toc | 1.2.0 |
| 18:58 | powr-toc | of contrib and clojure |
| 18:58 | tonyl | it is in my local contrib |
| 18:58 | Raynes | raek: Something weird about sandboxes causes *some* contrib things to simply disappear in the sandbox. It appears to happen across all sandboxes. |
| 18:58 | powr-toc | tonyl: is that 1.2.0 though? |
| 18:58 | tonyl | yeah |
| 18:59 | tonyl | both clojure and contrib |
| 18:59 | tonyl | user=> (find-doc "^show") |
| 18:59 | tonyl | ------------------------- |
| 18:59 | tonyl | clojure.contrib.repl-utils/show |
| 19:00 | raek | powr-toc: works in my 1.2 repl |
| 19:00 | amalloy | maybe you need lein deps to pull in contrib? |
| 19:00 | powr-toc | raek: oh right enough it is in repl-utils |
| 19:01 | powr-toc | find-doc wasn't showing it... but I guess I hadn't loaded the namespace |
| 19:02 | tonyl | &(require '[clojure.contrib.repl-utils :as repl-utils]) |
| 19:02 | sexpbot | java.io.FileNotFoundException: Could not locate clojure/contrib/repl_utils__init.class or clojure/contrib/repl_utils.clj on classpath: |
| 19:02 | raek | ah, yes. find-doc will only look at the loaded vars... |
| 19:13 | kjellski | I´ve got a seq of vectors and want to compare the second values in these vectors, what´s the most idiomatic way? |
| 19:15 | amalloy | compare them how? i mean, to get out a seq of the second elements you can just (map second seq-of-vectors) |
| 19:16 | kjellski | amalloy: compare them by = |
| 19:17 | amalloy | kjellski: you're not saying what you want to /do/ with the results of the comparison. do you want to group the vectors by second element, for example? |
| 19:18 | kjellski | I have a sequence like this ([0 \a] [1 \b] ...) and a second one that goes just like this one... now I want to find the position of the elements that are = |
| 19:19 | kjellski | amalloy: the index is already in the first elements by map-indexed.... |
| 19:22 | raek | (map #(= (second %1) (second %2)) seq1 seq2)? |
| 19:23 | raek | ah. just read the rest of the text. neverminf. |
| 19:23 | amalloy | kjellski: sorry, i still don't understand what you're trying to do |
| 19:23 | kjellski | amalloy: just a sec, preparing a snipped ^^ |
| 19:24 | kjellski | amalloy: I´m trying to translate this python function into clojure: https://gist.github.com/702785 |
| 19:24 | pppaul | &(take 2 {:a 1 :b 2 :c 3 :d 4}) |
| 19:24 | sexpbot | ⟹ ([:a 1] [:b 2]) |
| 19:25 | pppaul | how do i feed that into another map using assoc, or something else? |
| 19:25 | amalloy | ah |
| 19:26 | kjellski | pppaul: ##(into {} (take 2 {:a 1 :b 2 :c 3 :d 4})) |
| 19:26 | sexpbot | ⟹ {:a 1, :b 2} |
| 19:26 | amalloy | i think map-indexed is likely just getting in the way, but no matter |
| 19:26 | kjellski | pppaul: where {} is your other map? |
| 19:26 | pppaul | same map |
| 19:27 | pppaul | i want to do some work on a seq, and assoc back into the map |
| 19:27 | amalloy | pppaul: why not use update-in? |
| 19:27 | pppaul | cool, i'll look at that |
| 19:27 | kjellski | amalloy: I´m still trying to find the right way ^^ open for every solution =) |
| 19:28 | pppaul | i'm using this site to help me with the hash-map stuff http://clojure.org/data_structures#Data%20Structures-Maps%20%28IPersistentMap%29 |
| 19:28 | pppaul | is there a better place i should be looking at? |
| 19:30 | amalloy | &(let [[answer guesses :as data] [[1 2 3] [4 2 1]]] (map = data)) |
| 19:30 | sexpbot | ⟹ (true true) |
| 19:31 | amalloy | &(let [[answer guesses :as data] [[1 2 3] [4 2 1]]] (apply map = data)) |
| 19:31 | sexpbot | ⟹ (false true false) |
| 19:31 | amalloy | kjellski: enough to get you headed in the right direction, maybe? |
| 19:32 | kjellski | amalloy: yeah, I hope so... thanks for the start =) |
| 19:55 | KirinDave | Hum |
| 19:56 | KirinDave | Does anyone here use clojure w/ flume? |
| 19:56 | KirinDave | Perhaps have a reference to a library? Google is coming up empty |
| 20:28 | vIkSiT | lo all |
| 20:28 | vIkSiT | anyone here use clojure with hadoop? |
| 20:28 | vIkSiT | I'm looking for pointers on libs/docs to get started.. |
| 20:31 | hiredman | vIkSiT: many do, I don't, but most seem to use cascading and cascalog |
| 20:31 | vIkSiT | hmm, cascalog I guess would mostly be for querying large datasets. |
| 20:32 | vIkSiT | I'll check out cascading, thanks. Looking for something a bit more low level though. |
| 20:42 | tomoj | vIkSiT: I use it, have no pointers |
| 20:42 | tomoj | am looking for pointers myself |
| 20:42 | tomoj | I must not understand clojure-hadoop |
| 20:44 | vIkSiT | tomoj, hehe, you mean you do use clojure-hadoop? |
| 20:44 | vIkSiT | or you dont? (I can't get it to install using lein, for instance) |
| 20:45 | vIkSiT | and get into dependency hell if i use it manually in lib/, since lein deps cleans out the lib dir each time! |
| 20:46 | tomoj | paste your project.clj? |
| 20:47 | vIkSiT | sec |
| 20:47 | tomoj | did you add stuartsierra's maven repo? |
| 20:48 | vIkSiT | hmm |
| 20:48 | vIkSiT | i didnt actually. |
| 20:50 | vIkSiT | tomoj, http://pastebin.com/mMgM2F9d |
| 20:50 | tomoj | :repositories {"stuartsierra-releases" "http://stuartsierra.com/maven2"} |
| 20:50 | vIkSiT | how exactly do I add that maven repo, btw? |
| 20:50 | vIkSiT | wow, I didn't know that format worked in lein. |
| 20:50 | tomoj | you may also need to add [org.apache.hadoop/hadoop-core-with-dependencies "0.18.3"] |
| 20:50 | tomoj | not sure |
| 20:51 | tomoj | so far I jar after every change, it's terrible |
| 20:51 | tomoj | I'm sure there's a better way with clojure-hadoop |
| 20:51 | vIkSiT | hmm. |
| 20:51 | tomoj | but I don't want to be stuck on 0.18.3 either.. |
| 20:52 | vIkSiT | gah. |
| 20:52 | technomancy | we ended up ditching hadoop largely because of problems like this |
| 20:53 | tomoj | for what? |
| 20:53 | technomancy | conduit, through a circuitous route |
| 20:53 | vIkSiT | I'm still stuck with this : http://paste.lisp.org/display/116749 |
| 20:53 | technomancy | granted if you need HDFS there's not really a good alternative. |
| 20:53 | technomancy | but we have lots of small files that we can't afford to keep anywhere but s3 |
| 20:53 | amrk | conduit? i don't think I've heard of that one.. |
| 20:54 | technomancy | clojurebot: google clojure conduit |
| 20:54 | clojurebot | First, out of 235 results is: |
| 20:54 | clojurebot | Stream Processing in Clojure - intensivesystems.net |
| 20:54 | clojurebot | http://intensivesystems.net/tutorials/stream_proc.html |
| 20:54 | technomancy | clojurebot: botsnack |
| 20:54 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 20:54 | tomoj | hmm |
| 20:54 | vIkSiT | tomoj, my project.clj is updated btw. let me refresh that |
| 20:54 | vIkSiT | tomoj, http://paste.lisp.org/display/116749#1 is the project.clj |
| 20:55 | tomoj | vIkSiT: still not working? |
| 20:56 | tomoj | there is no clojure-hadoop 1.2.0, is there? |
| 20:57 | tomoj | 1.2.0-SNAPSHOT is the latest in the repo |
| 20:57 | tomoj | but not published |
| 20:57 | tomoj | (git repo) |
| 20:57 | tomoj | the latest in his maven repo looks like 1.1.0 |
| 20:58 | vIkSiT | oh hmm |
| 20:58 | vIkSiT | argh. I didn't notice that, thanks for the pointer tomoj |
| 21:01 | vIkSiT | tomoj, btw, why is that version of hadoop-core-with-deps at 0.18.3? |
| 21:01 | tomoj | that's the one clojure-hadoop is compatible with |
| 21:04 | vIkSiT | ah I see. |
| 21:04 | vIkSiT | tomoj, I'm pretty sure hadoop can be used directly from clojure too? |
| 21:04 | vIkSiT | rather than have a bunch of wrappers around it? |
| 21:04 | vIkSiT | has anyone tried that here?) |
| 21:09 | tomoj | see in clojure-hadoop |
| 21:09 | tomoj | read the examples in order |
| 21:10 | tomoj | wordcount1 just works directly on the hadoop api |
| 21:10 | tomoj | with some helpers |
| 21:12 | tomoj | if you want to target a more recent version of hadoop I guess you will have to do it raw too |
| 21:12 | vIkSiT | true |
| 21:13 | vIkSiT | tomoj, do you have any public repos of code that works? I've been trying experiments with alexott's clojure-examples/hadoop, but no luck so far.. |
| 21:13 | tomoj | no, I don't have anything I can publish |
| 21:14 | tomoj | did you already try the examples in clojure-hadoop? |
| 21:15 | tomoj | alexott's example looks like it should work |
| 21:16 | tomoj | if you jar it up, you can run it like this: |
| 21:17 | tomoj | java -cp "lib/*:com.example.foo-0.1.0-SNAPSHOT.jar" clojure_hadoop.job -job com.example.foo.jobs/bar -input input/foo -output output/bar |
| 21:17 | tomoj | (but there must be a better way) |
| 21:25 | vIkSiT | tomoj, hmm, looks like clojure-hadoop-job might be a different jar altogether |
| 21:26 | mattmitchell | i have a clojure.lang.PersistentStructMap instance, that looks like this: {:count(*) 521845} -- how do i get the value? |
| 21:27 | hiredman | clojurebot: how can mattmitchell get teh value? |
| 21:27 | clojurebot | Titim gan éirí ort. |
| 21:27 | mattmitchell | i've tried (:count(*) my-struct) but that doesn't do it |
| 21:29 | hiredman | ,(*) |
| 21:29 | clojurebot | 1 |
| 21:29 | hiredman | ,(:count 1 {}) |
| 21:29 | clojurebot | {} |
| 21:29 | tomoj | vIkSiT: huh? clojure_hadoop.job is surely in the clojure-hadoop jar I use |
| 21:30 | tomoj | ,(:count(*) "fnord") |
| 21:30 | clojurebot | "fnord" |
| 21:32 | tomoj | why do you have a struct-map with a "count(*)" field? |
| 21:33 | mattmitchell | tomoj: this is the result from a mysql select |
| 21:33 | tomoj | I see |
| 21:33 | tomoj | maybe munge the keys? |
| 21:34 | mattmitchell | tomoj: this seems to work, but awkward: (last (first (seq (first my-struct)))) |
| 21:34 | tomoj | otherwise you will have to do (def count-* (keyword "count(*)")) (count-* my-struct) or (get my-struct (keyword "count(*"))) |
| 21:34 | hiredman | is it really a keyword? |
| 21:34 | mattmitchell | tomoj: sorry i should've mentioned the struct it wrapped in a list as well |
| 21:35 | tonyl | or query with count(*) AS mycount |
| 21:35 | mattmitchell | tomoj: yeah thanks, the helps |
| 21:35 | dakrone | ,(get {(keyword "count(*)") 1} (keyword "count(*)")) |
| 21:35 | clojurebot | 1 |
| 21:35 | dakrone | ugh, that's ugly |
| 21:36 | tonyl | ${(keyword "count(*)") 343} |
| 21:36 | tonyl | &{(keyword "count(*)") 343} |
| 21:36 | sexpbot | ⟹ {:count(*) 343} |
| 21:36 | tomoj | do you create a new struct for every query? |
| 21:37 | mattmitchell | tomoj: it seems to work that way yes, this is using the sql stuff from clojure contrib |
| 21:37 | tonyl | you can change your query a bit and use it like this SELECT COUNT(*) AS mycount FROM mytable; |
| 21:37 | tomoj | oh |
| 21:37 | tomoj | I'm using the sql stuff from clojure contrib too |
| 21:37 | tonyl | ooh ok |
| 21:37 | tomoj | I hadn't tried counting yet I guess |
| 21:37 | tonyl | haven't used that |
| 21:37 | jweiss_ | anyone know why github won't highlight this code? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj |
| 21:37 | tomoj | I despise c.c.sql |
| 21:38 | hiredman | jweiss_: I think it's too big, the hilighter chokes |
| 21:38 | jweiss_ | ah |
| 21:38 | mattmitchell | tonyl: yeah the "count as" is much better thanks |
| 21:39 | tonyl | I need a help in speed |
| 21:39 | tonyl | in this code: (reduce + (filter even? (take 4e6 (clojure.contrib.lazy-seqs/fibs)))) |
| 21:40 | tonyl | can't make it run any faster when it is 4e5 or higher |
| 21:40 | tonyl | it gives the result back fast when it is 4e4 or less |
| 21:47 | tonyl | freaking computer froze |
| 21:49 | tonyl | &(reduce + (filter even? (take 4e2 (lazy-seqs/fibs)))) |
| 21:49 | sexpbot | java.lang.Exception: No such namespace: lazy-seqs |
| 21:54 | tonyl | can anybody help me to speed up this snippet |
| 21:54 | tonyl | (reduce + (filter even? (take 4e6 fibs))) |
| 21:55 | tonyl | it takes forever (never stops) from 4e5 up |
| 21:56 | tonyl | fibs is a fn: (reduce + (filter even? (take 4e6 (fibs)))) |
| 22:04 | tonyl | Iam guessing the overload is in the filtering, it is pretty high numbers |
| 22:05 | amalloy | tonyl: unlikely. i think it's just in generating (fibs) |
| 22:05 | amalloy | the four millionth fibonacci number is quite large, which means the jvm is doing a lot of math with BigIntegers to get to it |
| 22:05 | amalloy | and that's a /lot/ slower than ints or longs |
| 22:06 | tonyl | yeah i saw a snippet of the fib, those are big numbers |
| 22:09 | amalloy | tonyl: (fib n) grows about as fast as (exp 2 n), so it becomes infeasible after a while |
| 22:11 | tonyl | I'm trying to figure out how to break down the computation than |
| 22:11 | tonyl | I am trying the project euler challenges and I am stuck in number 2 :P |
| 22:11 | pppaul | use the phi equation |
| 22:12 | tonyl | thanks pppaul i'll take a look at it |
| 22:13 | amalloy | tonyl: also don't bother with filter even. no need to do any division/math, when you know every other fib will be even |
| 22:13 | pppaul | (use 'clojure.contrib.math) |
| 22:13 | pppaul | (def PHI (/ (+ 1 (sqrt 5)) 2)) |
| 22:13 | pppaul | (defn fib-double ([n] (/ (- (Math/pow PHI n) (Math/pow (- 1 PHI) n)) (sqrt 5)))) |
| 22:13 | pppaul | (defn fib ([n] (round (fib-double n)))) |
| 22:14 | pppaul | convert that to use bigint and bigdec |
| 22:14 | pppaul | cus i don't know if it'll work due to precision problems |
| 22:15 | tonyl | amalloy: not every other number in the fibs seq is even, but you might be right about filter |
| 22:15 | pppaul | you may be able to get fast functions using def-memo |
| 22:16 | tonyl | pppaul: is round the only function used from c.c.math? |
| 22:16 | pppaul | yes |
| 22:16 | pppaul | can be replaced with (int |
| 22:16 | amalloy | tonyl: oh, i guess you're right. it must go odd-odd-even-odd-odd-even... |
| 22:16 | pppaul | i made it a long long time ago |
| 22:16 | amalloy | so you can take every third |
| 22:17 | amalloy | &(doc take-nth) |
| 22:17 | sexpbot | ⟹ "([n coll]); Returns a lazy seq of every nth item in coll." |
| 22:17 | tonyl | I am going to look at both options, thanks guys |
| 22:18 | pppaul | since it's a series, and fibs are based off of the phi functions, there is probably a simple sum function for fibs |
| 22:18 | pppaul | you could have a constant time fib-sum :) |
| 22:34 | `jstirrell | hi |
| 22:34 | mattmitchell | &(doc seq) |
| 22:34 | sexpbot | ⟹ "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable." |
| 22:36 | `jstirrell | How do you call a function A from function B when function A occurs later in code than function B? |
| 22:36 | tonyl | what do you mean occurs? |
| 22:36 | `jstirrell | like it is defined lower in source |
| 22:37 | tonyl | you can declare it before function A |
| 22:37 | tonyl | (declare fnB) |
| 22:37 | `jstirrell | AH! thanks, I knew it was something easy I just forgot the term |
| 22:37 | tonyl | np |
| 22:41 | pppaul | (declare war) |
| 22:42 | pppaul | &(declare war) |
| 22:42 | sexpbot | java.lang.SecurityException: You tripped the alarm! def is bad!1 |
| 22:42 | pppaul | (source declare) |
| 22:42 | pppaul | &(source declare) |
| 22:42 | sexpbot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 22:42 | tonyl | $source declare |
| 22:42 | sexpbot | declare is http://is.gd/hg4Aa |
| 22:42 | pppaul | &(sorce declare) |
| 22:42 | sexpbot | java.lang.Exception: Unable to resolve symbol: sorce in this context |
| 22:42 | pppaul | &(sauce declare) |
| 22:42 | sexpbot | java.lang.Exception: Unable to resolve symbol: sauce in this context |
| 22:43 | pppaul | $8ball am i getting it? |
| 22:43 | sexpbot | pppaul: You may rely on it. |
| 22:43 | pppaul | $8ball it it it it it? |
| 22:43 | sexpbot | pppaul: Don't count on it. |
| 22:43 | rata_ | hi all |
| 22:43 | pppaul | hi |
| 22:43 | rata_ | hi pppaul |
| 22:44 | pppaul | (inc rata_) |
| 22:44 | sexpbot | ⟹ 1 |
| 22:44 | rata_ | :) |
| 22:50 | rata_ | slyrus: I agree with you now that fnparse 3.x has better names for its functions... it was just a problem getting used to :require and the h/ thing |
| 23:10 | mattmitchell | &(doc doseq) |
| 23:10 | sexpbot | ⟹ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil." |
| 23:36 | livingston | so I have this class being given to me: http://repository.aduna-software.org/docs/info.aduna/api/info/aduna/iteration/Iteration.html |
| 23:36 | livingston | and I'd like to just call seq or iterator-seq on it but it doesn't actually implement iterable, just something almost identical... |
| 23:37 | livingston | presumably there's a clever way to use extend to patch it, but I'm having a hard time finding an example. |
| 23:40 | tonyl | got it (reduce + (take-nth 3 (take-while (partial >= 4e6) (fibs)))) |
| 23:45 | amalloy | livingston: this isn't "almost iterable", but rather "almost an iterator" |
| 23:46 | livingston | amalloy: er right, that |
| 23:47 | livingston | amalloy: right now I just defined sesame-iteration-seq that produces a lazy list - that's probably good enough -- but I was playing around with other protocols tonight |
| 23:55 | slyrus | rata_: ah, good |
| 23:55 | livingston | yeah I was just looking for a clean example of extending an existing java class with the ISeq protocol. |
| 23:55 | slyrus | yeah, I think joshuachoi made it better with fnparse3 |
| 23:59 | slyrus | my only gripe about fnparse is that it makes my previous parsing attempts for the same task look (in CL) look rather lame |
| 23:59 | slyrus | well, ok, probably not my only gripe, but you get the idea |