2008-11-18
| 02:29 | Pupeno | Good morning! |
| 03:52 | askentasken | is clojure for concurrency or parallellism or both? |
| 03:52 | askentasken | it is really a fun language, i will keep using it for personal projects |
| 03:55 | cwyang | ho |
| 03:55 | cwyang | (typo) |
| 03:57 | Lau_of_DK | askentasken: both I'd say, theyre somewhat interconnected |
| 04:12 | leafw_ | rhickey__: http://clojure.org/special_forms#let contains an extra semicolon ';' that creates confusion, after the third paragraph. |
| 04:13 | leafw_ | rhickey__: in a Clojure code example I mean. |
| 04:14 | leafw_ | rhickey__: happens because the code is inside a <pre ..></pre> block, but the & is present as & |
| 04:14 | leafw_ | rhickey__: there is a second insance of the same a few lines below it. |
| 04:15 | leafw_ | rhickey__: ... actually, in many. |
| 04:18 | Lau_of_DK | leafw_: By browser doesnt render it like that, to me it looks squeaky clean, Firefox3 |
| 04:22 | H4ns | leafw_: what browser is it that you're using? |
| 04:23 | H4ns | (ie also renders & correctly inside <pre>, and i think that the behavior is completely correct) |
| 04:25 | leafw_ | H4ns: firefox 3.0 |
| 04:26 | H4ns | leafw_: wfm |
| 04:26 | leafw_ | wfm ? |
| 04:27 | H4ns | wfm == works for me, but in fact it does not |
| 04:27 | H4ns | hm. |
| 04:27 | H4ns | (at least chrome also screws up) |
| 04:28 | leafw_ | something is werid, perhaps the css tag is doing something to the pre |
| 04:28 | H4ns | true. tomhickey is who would take care of that. |
| 04:28 | leafw_ | if you can reach him please do |
| 04:29 | H4ns | it is not the css, it is the javascript colorizer that screws up. |
| 04:29 | H4ns | you can see that the rendering is correct when the browser first loads the page, but then the beautifier makes the extra semicolon appear. |
| 04:30 | H4ns | tomhickey: ^ you may want to read the log until here :) |
| 05:22 | askentasken | is there a java-lib for permutations? |
| 06:01 | Lau_of_DK | askentasken: Probably, but there is also one in Clojure.contrib.lazy_seqs |
| 06:02 | Lau_of_DK | Although, I dont think it follows the correct formulae for permutations, so they are not (imo) produced in the correct sequence, but still all possible permutations are turned out |
| 06:08 | leafw_ | anybody uses chimp for ViM? What does "Supply <chim.id> to the glue functions" mean? What/where are these glue functions? |
| 06:15 | askentasken | Lau: ok order is not important for my task |
| 06:16 | askentasken | how do i get contrib? |
| 06:18 | askentasken | perms xs = [(h:t) | h <- xs, t <- perms $ delete h xs] |
| 06:18 | askentasken | anyone can trnslate that to clojure? |
| 06:22 | askentasken | do i just import clojure-contrib to user? or it is a ajr? |
| 06:22 | askentasken | jar |
| 06:28 | Lau_of_DK | I think they've made a jar, which you just put on the classpath |
| 06:28 | Lau_of_DK | Otherwise just download the source to your clojure dir and (require 'clojure.contrib.lazy_seqs) if I remember correctly |
| 06:29 | Lau_of_DK | The code you posted, which language is it in ? |
| 06:30 | Chousuke | looks like haskell |
| 06:32 | Pupeno | Lau_of_DK: was it you who was playing with Qt? |
| 06:36 | Lau_of_DK | Pupeno: Yes, I was one of the players |
| 06:36 | askentasken | is the paste-to clojure not working anymore? |
| 06:36 | Lau_of_DK | lisppaste8: url |
| 06:36 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 06:37 | Lau_of_DK | If you use that, it should work - If it doesnt, then you answered your own question :) |
| 06:37 | askentasken | http://paste.lisp.org/display/70635 |
| 06:37 | askentasken | naive and not wokring |
| 06:37 | askentasken | is there already discard-val and discard-at ? |
| 06:41 | Lau_of_DK | See filter / remove |
| 06:48 | hoeck | askentasken: do you want to remove the first occurence of val in coll or every occurence of val in coll? |
| 07:03 | askentasken | first |
| 07:15 | hoeck | askentasken: there is split-whith, which takes a predicate and returns 2 seqs |
| 07:16 | askentasken | not exactly what iw ant |
| 07:16 | askentasken | anyway i have my won so it sok |
| 07:17 | askentasken | did perms like this: (defn perms [coll] |
| 07:17 | askentasken | (if (nil? coll) |
| 07:17 | askentasken | [[]] |
| 07:17 | askentasken | (for [h coll t (perms (discard-val h coll))] |
| 07:17 | askentasken | (conj t h)))) |
| 07:17 | askentasken | perhaps naive implementation but works |
| 07:20 | hoeck | or see: http://paste.lisp.org/display/70635#1 |
| 07:20 | askentasken | is count O(1) for everything? lists and vectors? |
| 07:21 | Chousuke | it is for most things. |
| 07:21 | Chousuke | but not all seqs |
| 07:28 | askentasken | for vectors? |
| 07:28 | askentasken | for lists? |
| 07:28 | askentasken | (count [1 2 3 4 5]) O(1)? |
| 07:28 | askentasken | (count '(1 2 3 4 5)) ? |
| 07:28 | hoeck | yes |
| 07:28 | hoeck | O(1) |
| 07:28 | askentasken | is vector genera�lly preferred over lists? they seem easier to work with |
| 07:28 | hoeck | they are in fact some kind of trees to make copying cheap |
| 07:28 | askentasken | you dont have to reverse your recursive calls either(which you often have to with lists) |
| 07:29 | hoeck | vectors are good for appending stuff |
| 07:29 | hoeck | lists are good for code |
| 07:31 | askentasken | lol i was writing discard-val -all but then thats obv filter... |
| 07:31 | askentasken | code? |
| 07:31 | askentasken | code as in lispcode? |
| 07:31 | askentasken | macros' |
| 07:33 | hoeck | askentasken: yeah, expressions |
| 07:41 | askentasken | hmm could it be possible to inmplement python-like splicing with a nice macro? |
| 07:41 | askentasken | a = [1,2,3,4,5] |
| 07:41 | askentasken | a[2:4] _> [3,4] |
| 07:41 | askentasken | but how do i define a macro using infix? is that possible? |
| 07:41 | askentasken | to do that i need access to the clojure parser? or everything you can do with amcros that you can with the parser? |
| 07:42 | askentasken | hmm wait i already ahve take-between |
| 07:45 | hoeck | askentasken: for vectors, there is also subvec |
| 07:49 | hoeck | askentasken: you could create your own subclass of vector and implement invoke so that ([1 2 3 4] [2 4]) returns the subvector [3 4] |
| 08:01 | duck1123 | that would be very confusing |
| 08:02 | askentasken | subvec is what iw ant and i almost always use vectors not lists anyway, veyr good |
| 08:04 | duck1123 | It would be cool to have an index macro of some sort (#[2 4] [1 2 3 4 5]) => (3 4) |
| 08:06 | duck1123 | although subvec is pretty easy to write and clearer |
| 08:07 | askentasken | is there any way to make the errorsreports shorter and better. like now when i dom something wrong it jus flushes the screen, quite annoying and the error-messages are nt that help ful. |
| 08:07 | askentasken | it doesnt even tell me where in the program it happened, usually jsut in some .java module |
| 08:08 | askentasken | yeah that was what i wanted but subvec is ok |
| 08:08 | askentasken | but something combinable liek pythons, [-x:] [x:y] etc... |
| 08:09 | duck1123 | askentasken: are you working directly with the repl, or are you using some editor? (emacs, vim, netbeans) |
| 08:09 | duck1123 | I know with slime (emacs) it initially only shows a few lines of the trace on errors |
| 08:10 | askentasken | emacs + repl |
| 08:10 | askentasken | not slime though |
| 08:10 | askentasken | just the first clojure-mode |
| 08:10 | askentasken | that came |
| 08:12 | hoeck | just installed a new slime version, and now its possible to throw the causing exception, which shows you at least the function name where stuff went wrong |
| 08:12 | hoeck | i mean a new swank-clojure |
| 08:15 | askentasken | rhickey: what is your opinion on Python anyway? |
| 08:16 | leafw_ | any chim or gorilla user in Vim? I can't get it to work |
| 08:19 | leafw_ | and the documentation is, unfortunately, pitiful |
| 08:23 | MarkVolkmann | Revision 1109 doesn't build for me. I get an IllegalArgumentException related to precomile.clj. |
| 08:24 | askentasken | is there concat for vector? |
| 08:25 | askentasken | i dont want lists it seems athere is a lot of arbitrary type-conversion which i dont like, or am just doing it wrong :) |
| 08:26 | hoeck | askentasken: (reduce conj v1 v2) |
| 08:28 | MarkVolkmann | Has anyone done an svn update and run ant this morning? |
| 08:29 | hoeck | MarkVolkmann: me, but it works, at least it builts correctly |
| 08:29 | rhickey | askentasken: Python is ok, I had fun the few times I used it |
| 08:30 | rhickey | MarkVolkmann: worked for me (pulled and working in different office today) |
| 08:30 | rhickey | MarkVolkmann: did you clean? |
| 08:30 | hoeck | just made the transition from pre-AOT to AOT, and it worked fine |
| 08:30 | _deepfire | rhickey, is there some description for future direction of Clojure? |
| 08:30 | MarkVolkmann | No clean ... I'm trying that now. |
| 08:31 | MarkVolkmann | Doing a clean fixed it. Thanks! |
| 08:31 | rhickey | askentasken: Python doesn't fit my mental model for some reason |
| 08:31 | gnuvince | hello |
| 08:33 | rhickey | _deepfire: not a formal one - we discuss things often on the group, I respond to community needs and my own inclinations, most of what's to come will probably be in libraries, that's been true for a while, other than AOT, which really didn't change the language model |
| 08:35 | rhickey | _deepfire: there's a todo here: http://richhickey.backpackit.com/pub/1597914 which will probably move to a more formal tracker soon |
| 08:42 | askentasken | http://paste.lisp.org/display/70639 |
| 08:42 | askentasken | anyone good with permutations ^^ |
| 08:42 | askentasken | it sort of works |
| 08:42 | askentasken | but to many [] and () :) |
| 08:52 | _deepfire | rhickey, thank you! |
| 09:03 | askentasken | how can i do ona map get-with-default |
| 09:05 | askentasken | ah i found it |
| 09:06 | Chousuke | still working on the tic-tac-toe thing? or something else? :) |
| 09:08 | MarkVolkmann | askentaken: In your code paste, where is the discard-val function defined? |
| 09:21 | askentasken | Chousuke: other stuff but i will add minmax later |
| 09:36 | tomhickey | H4ns & leafw_: fixed the with the code highlighter & issue on the site. thanks for the heads up. |
| 09:37 | H4ns | tomhickey: looks good now, thanks! |
| 09:40 | askentasken | my head is spinnging trying to implement fibonacci with memoization. anyone seen a solution for that? |
| 09:45 | askentasken | can i ahve ordered maps? ie maps that preserve input order? |
| 09:45 | askentasken | if i want a Map but want several keys of th same value, what datastructure is then most suited? |
| 09:48 | Chouser | askentasken: array-map maintains original input order |
| 09:51 | Chouser | askentasken: not sure about a Map with multiple same-val keys, but one option might be to use a vector as the key, with your "real" key as the first item, and some unique identifier as the second. |
| 09:56 | askentasken | yes that could work, didnt know that was allowed, cool |
| 09:57 | Chouser | yep, one of the many benefits of immutable collections is they work great as Map keys. |
| 09:58 | Chouser | also, vectors sort with their first item as the most significant, next item the next, and so on. That can be useful too, such as for sorted-set s. |
| 10:19 | askentasken | can i do (sort-map (on-key-2) somemap) somehow? |
| 10:20 | askentasken | without writing ym won... |
| 10:20 | askentasken | own |
| 10:21 | rhickey_ | askentasken: sort-by |
| 10:24 | askentasken | clojure/sort-by |
| 10:24 | askentasken | ([keyfn coll] [keyfn comp coll]) |
| 10:25 | askentasken | i have a map a= {[4 4] 8, [1 1] 3, [2 2] 1, [3 3] 2} |
| 10:25 | askentasken | and i want to sort by the second key-val |
| 10:26 | rhickey_ | askentasken: not sure what you mean by "second key-val" |
| 10:26 | rhickey_ | user=> (sort-by val {[4 4] 8, [1 1] 3, [2 2] 1, [3 3] 2}) |
| 10:26 | rhickey_ | ([[2 2] 1] [[3 3] 2] [[1 1] 3] [[4 4] 8]) |
| 10:26 | Chouser | askentasken: you want a seq or a new map? |
| 10:28 | askentasken | a seq |
| 10:29 | askentasken | [2 2] 1 means nbr 2 order 2 value 1 |
| 10:29 | askentasken | i want to sort by order |
| 10:29 | askentasken | im doing a compress-function |
| 10:30 | askentasken | (compress-with-info [1 1 1 2 3 3 4 4 4 4 4 4 4 4]) |
| 10:30 | askentasken | {[4 4] 8, [1 1] 3, [2 2] 1, [3 3] 2} |
| 10:30 | askentasken | user=> |
| 10:30 | askentasken | so i want to sort it and return : [[1 1] 3, [2 2] 1 etc |
| 10:31 | askentasken | sortby key sorts on the first item in key, i want to sort on the second |
| 10:31 | Chouser | (sort-by #(second (key %)) coll) |
| 10:32 | Chouser | but if you reverse the order of your key vectors, you can just use sort which should run faster. |
| 10:33 | rhickey_ | askentasken: or structurally, each entry will be [[n o] v], so sort-by (fn [[[n o] v]] o) |
| 10:34 | _sk | hi, i have a question regarding gen-class, is there a way so that we could use the 'this' reference while defining methods? |
| 10:35 | Chouser | pretty-print is a surprisingly fuzzy operation. |
| 10:35 | rhickey_ | Chouser: what's not precise about "pretty" ? |
| 10:35 | Chouser | rhickey_: :-P |
| 10:36 | Chouser | _sk: the first arg passed to each method is the "this" value |
| 10:37 | askentasken | yes i did that |
| 10:44 | askentasken | what happened to paste to clojure? |
| 10:44 | askentasken | http://paste.lisp.org/display/70648 |
| 10:44 | askentasken | ^^ my compress function, any tips on improvements? |
| 10:50 | Chouser | should be able to say just (sort acc) instead of (sort-by key acc) |
| 10:50 | Chouser | it's more idiomatic to say (if x b a) than (if (nil? x) a b) |
| 10:51 | _sk | thx, from the example in genclass.clj it seems we have to explicitly pass in the whole object as an argument to methods, thus it looks a bit unfamiliar |
| 10:51 | Chouser | but either way, that will only process coll up through the first nil value in the coll, which is probably not what you want. |
| 10:53 | Chouser | _sk: you mean like (.methodName whole-object arg1 arg2) ? |
| 10:53 | Chousuke | _sk: in java, the object is just moved from inside the parentheses to before the dot, like so: (.method obj a b) -> obj.method(a b); :) |
| 10:53 | Chousuke | oh |
| 10:53 | Chousuke | +, :P |
| 10:54 | Chouser | heh |
| 10:54 | Chouser | hm... (.method obj, a b) ? |
| 10:54 | Chousuke | no, in the java |
| 10:55 | Chousuke | obj.method(a,b); |
| 10:55 | Chouser | yeah, I know, but what about (.method obj, a b) ? better or worse? |
| 10:56 | _sk | Chousuke: yes, exactly :) |
| 10:56 | Chousuke | I can't say I like that better. |
| 10:56 | Chousuke | but I guess you could do that :P |
| 10:56 | Chouser | yeah, me neither. nm. |
| 10:57 | _sk | another question, in java, let's say we have a constructor for an object, and in this constructor we use the 'this' value for some purpose, is that possible in clojure? |
| 10:59 | Chouser | _sk: I don't think so, though rhickey_ may want to weigh in. But you shouldn't need to -- the value you return from your init fn becomes the state for you gen-class object. |
| 10:59 | Chouser | You can do anything you want with that value before you return it, including passing it to functions. |
| 11:00 | _sk | hmm, in fact we can do whatever we want with it, just not the java way =) |
| 11:00 | _sk | thanks a lot |
| 11:00 | Chouser | _sk: yes. Generally, gen-class is used only for interop with existing Java libs. |
| 11:01 | askentasken | I just keep thinking I must be able to make my compress-function shorter |
| 11:01 | askentasken | cant I use reduce somehow? |
| 11:01 | Chouser | It allows you to build a little adapter class, but Clojure expects you to do most of your real algorithm and application work using Clojure collections, fn, namespaces instead of building new Java classes. |
| 11:03 | Chouser | askentasken: the whole (let [sorted...]) expression is run just once at the end, right? That could be moved outside your loop, which might help you see other ways of reducing it. |
| 11:05 | Chouser | askentasken: that's doing a sort of run-length encoding? |
| 11:09 | askentasken | yes it preserves order and count |
| 11:10 | askentasken | how would i move it outside? i still need a basecase |
| 11:12 | askentasken | i can switch to (if x...) and then swithc order of that foc |
| 11:12 | askentasken | ofc |
| 11:13 | Chouser | askentasken: http://paste.lisp.org/display/70648#1 |
| 11:15 | askentasken | can i have if-elses anywhere? |
| 11:15 | Chouser | you can use cond |
| 11:16 | askentasken | ah, very nice :) |
| 11:16 | Chouser | hm, I didn't even use xs -- that wastes a line |
| 11:17 | Chouser | ah, well, you get the idea |
| 11:19 | askentasken | yes very nice, thanks |
| 11:22 | askentasken | and no tailrecursion wont be a problem? |
| 11:22 | Chouser | askentasken: correct, because of lazy-cons |
| 11:23 | Chouser | lazy-cons doesn't actually evaluate with of its args, but returns a new object. So anything that walks the resulting sequence acts like a sort of iterator, not recursive at all from Java's point of view. |
| 11:23 | askentasken | is that never as in NEVER or never as probably never(like with laziness in haskell where the thunks blows the stack instead)) |
| 11:23 | askentasken | ok |
| 11:24 | Chouser | alternatively, you could use loop/recur or reduce and pass along an accumulator -- that would get you a non-lazy version that also would not blow the stack. |
| 11:25 | Chouser | but you were on to something -- replacing lazy-cons with cons would give you a non-lazy fn that would threaten the stack. |
| 11:38 | askentasken | (defn uncompress [coll] (map #(take (second %) (repeat (first %))) coll)) |
| 11:39 | askentasken | returns a list of lists |
| 11:39 | Chouser | try mapcat |
| 11:41 | askentasken | lol wait i didnt even see that |
| 11:47 | askentasken | http://paste.lisp.org/display/70648#2 |
| 11:47 | askentasken | Chouser: are those both O(n)? |
| 11:49 | Chouser | askentasken: I think so. |
| 11:50 | Chouser | split-with touches every val of coll from the front through the split-point twice, so that's O(n) |
| 11:51 | Chouser | the remainder b is passed in again so that should all be O(n) |
| 11:51 | Chouser | the reduce version is probably faster by a constant, though. |
| 11:53 | duck1123 | there should be metadata attached to each function describing what kind of performance it has |
| 11:53 | duck1123 | although you couldn't be sure you could trust it, it would be interesting to have as part of the docs |
| 11:55 | rhickey_ | Chouser: did you see: http://groups.google.com/group/clojure/browse_frm/thread/79d07b898b2a0fde |
| 11:55 | Chouser | 100000 item seq: cmprss -> 20.734263 msecs, compress -> 16.119936 msecs |
| 11:56 | Chouser | rhickey_: yes, thanks. replying now. |
| 11:59 | askentasken | how do you time? |
| 12:01 | askentasken | wait fi do (Math/round (* (rand) 8) that doesnt evenly distribute between all numbers right? because 8 only has 7.5 and up will 7 has 6.5 tp 7.49 |
| 12:01 | Chousuke | I'm getting some kind of an error from that thread :/ |
| 12:01 | Chouser | askentasken: http://paste.lisp.org/display/70648#3 |
| 12:01 | Chousuke | it says there are no messages and that they may have expired or been deleted :P |
| 12:02 | Chouser | Chousuke: I didn't like the competition, so I, uh... took care of it. |
| 12:02 | Chousuke | hah |
| 12:03 | askentasken | Chouser:what do you mean? i dont see anything added |
| 12:03 | Chouser | askentasken: you may have to shift-reload |
| 12:04 | gnuvince | The thread is no longer there |
| 12:05 | Chouser | weird. I just replied to the thread, and it says "2 messages" but only mine is visible. |
| 12:05 | tWip | has with-in-str changed? I'm now getting errors about with-open requiring a vector for bindings |
| 12:07 | Chouser | tWip: with-in-str appears to be out-of-date with the new with-open. Probably my fault, sorry. |
| 12:07 | tWip | okay, I'll work around until it is fixed |
| 12:08 | Chousuke | Chouser: I noticed a potential problem with with-open a while ago. the new binding syntax allows multiple bindings but it seems with-open will only close the first binding :/ |
| 12:11 | Chouser | rhickey_: quick patch available: http://groups.google.com/group/clojure/browse_thread/thread/127081d85fb1b4bf |
| 12:14 | Chousuke | arbitrary destructuring is probably overkill for with-open but it'd be nice if with-open worked correctly with multiple bindings (like [a b, c d, e f]), which is not too difficult; *or* at least threw an error. :/ |
| 12:14 | Chouser | Chousuke: yeah, the general problem of unhandled extra bindings was mentioned on the google group. |
| 12:15 | Chouser | rhickey_ didn't want the extra error-handling code, but I can imagine that it'd be nice to have several things closed in a single scope. |
| 12:15 | Chousuke | that's one of the reasons I tried to write my bound-names function, but in the end I'm not sure it works for all the corner cases :/ |
| 12:15 | Chouser | Chousuke: oh, I see. Interesting. |
| 12:16 | askentasken | (take 100 (repeatedly (corner-move))) |
| 12:16 | Chousuke | with something like it you could write ~@(map (memfn close) (bound-names bindings)) or something, which would be nice |
| 12:16 | askentasken | (take 100 (repeatedly (corner-move))) , why doesn that work java.lang.ClassCastException but why? |
| 12:17 | Chouser | askentasken: does calling corner-move return "a function of no args, presumably with side effects"? |
| 12:18 | Chouser | askentasken: perhaps you mean (repeatedly corner-move) |
| 12:19 | askentasken | yes |
| 12:19 | askentasken | ah! |
| 12:19 | Chousuke | maybe with-open should just use let* directly to disallow misuse of destructuring. |
| 12:20 | Chousuke | it'd still allow multiple simple bindings though, but those are pretty easy to deal with |
| 12:22 | Chouser | .close already gets mad if you try to use destructuring in with-open |
| 12:23 | Chouser | so there's just the multiple-bindings issue. |
| 12:25 | askentasken | is there no builtin for assoc with defualt? |
| 12:26 | Chouser | default for what? |
| 12:28 | askentasken | (defn assoc-with [m k v] |
| 12:28 | askentasken | (if (contains? m k) |
| 12:28 | askentasken | (assoc m k (+ v (get m k))) |
| 12:28 | askentasken | (assoc m k v))) |
| 12:28 | askentasken | something like that? |
| 12:28 | askentasken | i couldnt find in the docs so |
| 12:28 | askentasken | that nos so general though |
| 12:28 | askentasken | v should b a function perhaps |
| 12:32 | wwmorgan | askentasken: I think you want update-in |
| 12:32 | Chouser | or perhaps merge-with |
| 12:37 | askentasken | neither |
| 12:40 | Chouser | (merge-with + {:a 1} {:a 1}) ==> {:a 2} |
| 12:40 | Chouser | (merge-with + {:a 1} {:b 1}) ==> {:b 1, :a 1} |
| 12:41 | Chouser | (defn assoc-with [m k v] (merge-with + m {k v})) |
| 12:46 | wwmorgan | (defn assoc-with [m k v] (update-in m [k] #(+ (or % 0) v))) --- not as nice as chouser's |
| 12:48 | askentasken | not expensive? |
| 12:48 | askentasken | merge-with i mean? |
| 12:51 | askentasken | http://paste.lisp.org/display/70661 |
| 12:52 | gnuvince | I finally finished the second part of my little Clojure tutorial. The first draft is available here: http://fornost.homeip.net:81/vince/clojure-comics2.html. Comments can be sent at vfoley at gmail dot com. Thank you. |
| 12:52 | askentasken | doing permutations and it is pissing me off |
| 13:03 | Chouser | askentasken: spoilers clojure.contrib.lazy-seqs |
| 13:20 | Chousuke | hm |
| 13:23 | askentasken | im stoopid i dont get where to download from: http://sourceforge.net/projects/clojure-contrib |
| 13:23 | Chousuke | checkout the SVN instead and use that |
| 13:23 | Chousuke | or use some git mirror. |
| 13:24 | Chousuke | SVN checkouts take ages. |
| 13:27 | Chousuke | git handles local changes better too. :/ I include the .clj files in the jar for slime, but that modification is in its own branch so tracking master is easy :) |
| 13:27 | askentasken | is there a unique or nub function? |
| 13:28 | Chouser | I like git-svn, so I can pull changes immediately, but maintain local branches. |
| 13:28 | Chouser | askentasken: (doc distinct) |
| 13:29 | gnuvince | askentasken: distinct I think |
| 13:29 | gnuvince | Oh |
| 13:34 | lisppaste8 | Chouser pasted "permutations using sets" at http://paste.lisp.org/display/70662 |
| 13:34 | Chouser | oh, lisppaste8! welcome back |
| 13:38 | rhickey_ | Chouser: I thought I had fixed with-in-str already |
| 13:40 | askentasken | how do i do doc-strings? |
| 13:41 | Chouser | rhickey_: oh, indeed you have. sorry. |
| 13:41 | rhickey_ | np |
| 13:41 | askentasken | Chouser: how did u paste directly to the channel? |
| 13:43 | tWip | so with-in-str should work in latest (1109)? |
| 13:43 | Chouser | tWip: as of 1108, yes |
| 13:44 | tWip | I thought I was using 1108, oh well |
| 13:45 | tWip | It does indeed work now, thanks. |
| 13:53 | Chouser | askentasken: just choose "#clojure" from the channel list. It hasn't been working for the past couple days. |
| 13:54 | askentasken | RHickey: couldnt it be changed or added so docstrings could be between [argument] and function-body? instead of between f-name and args |
| 13:54 | Chouser | askentasken: functions can have multiple arg lists, but only one docstring. |
| 13:55 | Chouser | (defn my-inc "add 1 or more" ([x] (inc x)) ([x y] (+ x y))) |
| 13:56 | askentasken | uh, why and how does that work? |
| 13:56 | Chousuke | you can overload functions. |
| 13:56 | Chouser | allows different definitions based on number of arguments passed in. |
| 13:58 | Chousuke | note that there's an extra pair of parentheses if you want multiple definitions. Sometimes that results in non-obvious error messages if you have mismatched parentheses when defining a function |
| 14:07 | askentasken | from where cna i pull contrib with git? |
| 14:07 | Chousuke | http://github.com/kevinoneill/clojure-contrib/tree/master |
| 14:08 | Chousuke | an unofficial mirror, but it is kept up-to-date with reasonable latency |
| 14:19 | rhickey_ | It's alive - AOT/gen-class |
| 14:19 | tomhickey | now you can breathe again! ;) |
| 14:20 | rhickey_ | now I have to write docs :( |
| 14:20 | tomhickey | lol |
| 14:20 | Chousuke | is the interface still the same or improved? |
| 14:20 | rhickey_ | gen-and-save/load are gone |
| 14:20 | rhickey_ | use a :gen-class clause in your ns form |
| 14:21 | Chousuke | can you still generate classes dynamically? |
| 14:22 | rhickey_ | Chousuke: only via proxy, dynamic named classes are an oxymoron in some ways |
| 14:22 | rhickey_ | Chouser: not up yet, hang tight |
| 14:22 | Chouser | :-) |
| 14:23 | lisppaste8 | rhickey pasted "AOT/gen-class syntax" at http://paste.lisp.org/display/70665 |
| 14:24 | blackdog_ | and the - prefix is a method? |
| 14:24 | rhickey_ | note how you don't need any quotes any more, also Java names for primitives are supported, and fns for class can use class |
| 14:25 | Chouser | nice. |
| 14:25 | rhickey_ | blackdog_: these are real fns, -blah is a naming convention whereby the method can find the fn |
| 14:25 | blackdog_ | ok |
| 14:26 | Chouser | all classes mentioned need to be available at compile time? |
| 14:26 | rhickey_ | you can edit this and reload while instances are running as long as you don't change the signatures |
| 14:26 | kotarak | o.O cool |
| 14:26 | kotarak | How do I specify the name? |
| 14:27 | rhickey_ | Chouser: yes, for now - I can ease that in the future but it requires some retooling in the compiler - right now everything is done off of reflection |
| 14:27 | Chouser | kotarak: the namespace name is the class name |
| 14:27 | rhickey_ | kotarak: the ns is the name |
| 14:27 | rhickey_ | must be |
| 14:27 | rhickey_ | If you leave out the :gen-class, you get support for main only |
| 14:27 | kotarak | Hmmm.. Are capitals allowed? From the Java side, my.Hello is probably expected, no? |
| 14:28 | rhickey_ | kotarak: sure |
| 14:28 | kotarak | rhickey_: this is awesome! :) |
| 14:29 | cemerick | rhickey_: is the gen-class fn usefully callable still? Of course, I'm thinking of the road ahead for my genbean concoction. |
| 14:29 | rhickey_ | with the stand-alone compiler Stuart and Steve are working on, the workflow looks like this: |
| 14:29 | rhickey_ | Macintosh:clojure rich$ java -server -cp ./classes:./src/clj:clojure.jar clojure.compile classes my.helloCompiling 1 libs to classes |
| 14:29 | rhickey_ | Macintosh:clojure rich$ java -server -cp ./classes:./src/clj:clojure.jar my.hello fooHello foo World! |
| 14:29 | rhickey_ | 42 |
| 14:29 | rhickey_ | erm |
| 14:30 | rhickey_ | like this: |
| 14:30 | rhickey_ | java -server -cp ./classes:./src/clj:clojure.jar clojure.compile classes my.hello |
| 14:30 | rhickey_ | Compiling 1 libs to classes |
| 14:30 | rhickey_ | java -server -cp ./classes:./src/clj:clojure.jar my.hello foo |
| 14:30 | rhickey_ | Hello foo World! |
| 14:30 | rhickey_ | 42 |
| 14:30 | Chousuke | the constructors syntax and the init function still look weird. :/ |
| 14:31 | Chousuke | meaning my intuition can't figure out why they look like that :P |
| 14:32 | rhickey_ | cemerick: right now I haven't worked through stand-alone use of gen-class, it ends up you need 2 classes to do this right, if you look after I put this up, you'll see an my.hello__init.class as well. Essentially I had to automate the 2 part work everyone was doing manually |
| 14:34 | cemerick | rhickey_: actually, I may not need access to gen-class itself, if the options provided to genclass are hanging off the namespace somewhere... |
| 14:34 | rhickey_ | this lets the body se the class being defined, but means the stub generated by gen-class tries to load the __init class |
| 14:36 | cemerick | yeah, in fact, I'm sure of that, and not having to conjure up the parameters to gen-class will make my work a whole lot easier in that context, anyway |
| 14:37 | cemerick | now I just need to figure out how to best generate BeanInfo classes *ech* |
| 14:44 | askentasken | where should i place contrib src? can i link to the whole folder from user.clj? |
| 14:45 | Chouser | just add clojure-contrib/src to your java classpath |
| 14:45 | Chouser | Then you can use 'require' or 'use' in your .clj |
| 14:47 | askentasken | how do i add to my java-classpath? |
| 14:47 | rhickey_ | ok, rev 1110 adds AOT gen-class |
| 14:50 | Chouser | askentasken: java -cp clojure.jar:...../clojure-contrib/src clojure.lang.Repl foo.clj |
| 14:51 | Chouser | proxy works as-is for now? |
| 14:51 | rhickey_ | Chouser: I hope so |
| 14:52 | askentasken | Caused by: java.lang.Exception: Can't take value of a macro: #'user/assoc! |
| 14:52 | askentasken | (defmacro assoc! [map_ k v] |
| 14:52 | askentasken | `(def ~map_ (assoc ~map_ ~k ~v))) |
| 14:52 | rhickey_ | I haven't really advertised much a subgoal in this, as I'm not there yet, but it is the elimination of the need for a custom classloader when precompiling |
| 14:52 | askentasken | why? the macro works... |
| 14:53 | Chouser | askentasken: what would you do with a reference to a macro if you had one? |
| 14:53 | rhickey_ | that will require some AOT support for proxy |
| 14:54 | Chouser | oh, so custom classloader is currently required with AOT even if you're not using proxy? |
| 14:54 | askentasken | Chouser: in .emacs? |
| 14:55 | rhickey_ | Chouser: There are still remnants, I haven't gone after that specifically yet |
| 14:55 | Chouser | rhickey_: ok. That's probably what you were trying to tell me about applets yesterday. |
| 14:55 | askentasken | Chouser: with a ref to one? well (macroexpand-1 assoc!) i also tired calling it. |
| 14:56 | rhickey_ | Chouser: right - applets and Android are the targets for that |
| 14:56 | Chousuke | askentasken: write a macro that produces a macro call form and do (macroexpand-1 (assoc!)) |
| 14:56 | Chouser | askentasken: that's not how macroexpand works. try: (macroexpand-1 '(assoc! foo bar baz)) |
| 14:56 | johnwayn` | rhickey_: Is there anything like proxy-super for overridden methods using :gen-class? |
| 14:56 | rhickey_ | askentasken: what you are trying to do with that macro is not worth doing |
| 14:57 | rhickey_ | askentasken: and no one should help you do it :) |
| 14:58 | rhickey_ | (a macro for destructive re-def) |
| 14:58 | johnwayner | Oh, and of course swank breaks again :) |
| 14:59 | danlei | jup |
| 14:59 | rhickey_ | johnwayner: not exactly, as the 2 use different mechanisms. |
| 14:59 | rhickey_ | does swank use gen-class? |
| 14:59 | danlei | yes |
| 14:59 | rhickey_ | interesting |
| 14:59 | johnwayner | java.lang.Exception: No such var: swank.util/gen-and-load-class (core.clj:39) |
| 15:00 | rhickey_ | uh, oh, gen-and-load... |
| 15:00 | rhickey_ | never should have existed |
| 15:01 | cemerick | eliminating the custom classloader should also simplify things in osgi, going to .NET, etc. |
| 15:02 | Chouser | I hope in all this AOT-fun, nobody loses track of how fantastic the dynamic REPL is. I care about that so much more than AOT. |
| 15:02 | Chousuke | askentasken: def'd names should in many cases be treated with the same care as global variables. you wouldn't reassign a value into a global variable in C without a *very* good reason, would you? :) |
| 15:02 | rhickey_ | Chouser: what's great is you get both, for delivery AOT means a lot |
| 15:02 | askentasken | rhickey: it already works muaahaha, im just testing macroexpand but it doesnt work. how do i use macroexpand? |
| 15:03 | rhickey_ | But after you;ve got stubs, you still get repl bugfixing on the fly etc |
| 15:03 | kotarak | (macroexpand '(foo-macro with args)) |
| 15:03 | rhickey_ | askentasken: pass the form as data - i.e. quote it |
| 15:03 | askentasken | Caused by: java.lang.IllegalArgumentException: Wrong number of args passed to: assoc-BANG- |
| 15:03 | Chouser | askentasken: I already gave you an example. |
| 15:04 | askentasken | ah |
| 15:06 | H4ns | lisppaste8: url |
| 15:06 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 15:06 | H4ns | does lisppaste8 feel well again? |
| 15:07 | Chouser | H4ns: last I checked, yes |
| 15:07 | askentasken | i saw fiex |
| 15:07 | askentasken | fixed |
| 15:07 | askentasken | i dont use that macro i just created it to learn macros |
| 15:08 | H4ns | Chouser: ok |
| 15:09 | askentasken | (load-file "C:/clojure_20080916/progs/oo/oo4.clj") |
| 15:09 | askentasken | is in my user.clj now, can i do load-dir "C:/clojure/contrib"? |
| 15:11 | Chouser | rhickey_: any chance of getting the breaking-change to doto in? |
| 15:12 | Chouser | http://groups.google.com/group/clojure/browse_thread/thread/d668c590c6cf982b |
| 15:48 | Wodin | Hi. On the 19th of September I tried out using dcm4che-2.0.15 from Clojure: http://clojure-log.n01se.net/date/2008-09-19.html . I tried first with the June release and got "No matching method found" error. Then I tried with the September release and it worked. I've just tried now again with r1109 and it failed again! |
| 15:49 | Wodin | I've bisected it back to the changes in r1047 and 1048. |
| 15:49 | Wodin | If I back out those changes then it works again. |
| 15:50 | Wodin | i.e. r1046 works, r1047 and later give the "No matching method found" error. |
| 15:50 | duck1123 | Wodin: You probably need to move the libraries to match the new locations |
| 15:50 | Wodin | duck1123: If I just revert r1047 and 1048 without changing anything else then it works. |
| 15:51 | Wodin | It's a few lines in src/jvm/clojure/lang/Reflector.java |
| 15:51 | Wodin | The log message for those revisions is: hardwired JDK 6 StringBuilder workaround to StringBuilder |
| 15:53 | shoover_ | askentasken: no, but check out (doc ns) for ways to make a lib load other things it needs. or if you really want to you could write a load-dir using file-seq or the listFiles method in java.io.File |
| 16:00 | lisppaste8 | Wodin pasted "dcm4che2" at http://paste.lisp.org/display/70670 |
| 16:03 | Wodin | duck1123_: Any other ideas? :) |
| 16:05 | duck1123_ | If I'm referencing a Java class inside a macro, but I'm calling that macro from within a different namespace, do I have to do an import in the calling file, or is there a way to just import it in the defining file? |
| 16:05 | duck1123_ | Wodin: unfortunately, no |
| 16:05 | Wodin | duck1123_: OK thanks. |
| 16:06 | Chouser | Wodin: which line gives you the error? |
| 16:07 | duck1123_ | which line are you getting the error on? |
| 16:07 | Wodin | Chouser: It's the getString call. |
| 16:08 | Wodin | Exception in thread "main" java.lang.IllegalArgumentException: No matching method found: getString (dinfo.clj:0) |
| 16:08 | Wodin | Not sure why it says it's line 0, though. |
| 16:08 | Chouser | which jar file(s) do I need to test this? |
| 16:08 | Wodin | Same error as I got in September with the June release of Clojure: http://clojure-log.n01se.net/date/2008-09-19.html |
| 16:08 | Chouser | ah, core? |
| 16:09 | Wodin | I'm using dcm4che-core-2.0.15.jar, log4j.jar, slf4j-api-1.2.jar, slf4j-log4j12-1.2.jar |
| 16:09 | Wodin | Chouser: core? I don't know what you mean. |
| 16:10 | Wodin | Chouser: Oh, dcm4che-core? Yes. |
| 16:11 | Chouser | ok, i've got your error |
| 16:11 | Wodin | Chouser: So if I revert revisions 1047 and 1048 then it works with r1110. |
| 16:13 | mehrheit | what would be the equivalent of expt (from, for example, scheme) in clojure? |
| 16:13 | Chouser | mehrheit: dunno what that is, sorry. |
| 16:13 | Wodin | i.e.: svn up; svn diff -r1046:1048 | patch -p0 -R |
| 16:13 | Chouser | mehrheit: what does it do? |
| 16:13 | mehrheit | Chouser: raises a number to a power |
| 16:13 | Wodin | Chouser: expt is like x to the power of y. |
| 16:13 | Hun | iirc (.pow ) |
| 16:14 | Hun | or Math.pow |
| 16:14 | Hun | something like that |
| 16:14 | mehrheit | Math/pow works on doubles |
| 16:14 | mehrheit | something more generic would be better |
| 16:15 | Hun | that's pretty hard if one doesn't write a full numeric tower (which again is pretty hard if you want to cooperate with java) |
| 16:16 | Chouser | mehrheit: BigInteger has a .pow: (.pow 2M 10) |
| 16:16 | Chouser | BigDecimal, sorry |
| 16:18 | mehrheit | Chouser: yes, that will do |
| 16:19 | mehrheit | Hun: but don't *, +, etc. already work on all numeric types and automatically promote big results to BitIntegers or similar? |
| 16:20 | Hun | they are implemented inside clojure. but the more mathy stuff comes from java and is pretty hard to integrate (note that i'm just estimating. i'm not an implementor) |
| 16:20 | Chouser | Wodin: looks like you're going to have to take it up with rhickey_. The method you want isBridge (whatever that means), but the class is not StringBuilder, thus Clojure's not letting you get to that method. |
| 16:20 | Chouser | Wodin: I don't understand the purpose of that logic. |
| 16:22 | lisppaste8 | Wodin annotated #70670 with "Exception with r1110" at http://paste.lisp.org/display/70670#1 |
| 16:23 | Wodin | Chouser: OK thanks. |
| 16:23 | Chouser | Wodin: There may be a (very ugly) workaround though. hang on... |
| 16:25 | Chouser | (. dcm getString 0x00100010) is supposed to return a string? |
| 16:26 | gnuvince | Did anyone have time to review my draft? |
| 16:26 | Chouser | might it sometimes return nil? |
| 16:27 | Wodin | Chouser: I think it could return nil. I haven't looked at the code, but I seem to remember it being able to return nil. |
| 16:27 | djpowell | anyone figured out the new aot gen-class yet? - looks interesting |
| 16:28 | Wodin | Chouser: You said in September: (. (new org.dcm4che2.data.BasicDicomObject) getString 1234) <-- works for me (very recent version of clojure) It returns nil and doesn't throw an exception. |
| 16:28 | askentasken | can i use cond and let together? |
| 16:29 | lisppaste8 | Chouser annotated #70670 with "ugly workaround" at http://paste.lisp.org/display/70670#2 |
| 16:30 | askentasken | im back on my tictactoe, wirting a simple AI. i need to cond a bunch of stuff but can i di cond (let [...] and then have a local let? |
| 16:30 | Chouser | Wodin: but even if that works for you, take it up with rhickey_ either here or on the google group. |
| 16:30 | Wodin | Chouser: Don't understand it, but I agree it looks ugly :) |
| 16:30 | Chousuke | who has commit access to clojure-contrib? I think it's pretty ugly that the numbers.clj bigdec test throws an exception. |
| 16:30 | Chouser | I don't know what the logic should be for finding the right method, but clearly it's not right. |
| 16:31 | Chouser | Wodin: the first line uses reflection to dig out a Method named "getString" that takes an int |
| 16:31 | rottcodd | drewc: fwiw, I don't like the derivative names either, preferring something like project.clojure.org or clojure.net |
| 16:31 | Chouser | Wodin: the second line builds up the argument array and invokes the Method. |
| 16:32 | Wodin | Chouser: OK, I see. Thanks. |
| 16:32 | Chouser | you ought to be able to bundle all that in your print-tag fn and encapsulate the ugliness |
| 16:32 | drewc | rottcodd: i registered 'projecture.net' yesterday, as it seemed to be the most agreeable. I could still be swayed by a compelling argument though :) |
| 16:33 | Wodin | Chouser: Yes, but I'd prefer not to if I don't need to. By the way, that's basically my first Clojure "program". Is it terrible? :) |
| 16:34 | Chouser | right, I provided the workaround so that you could continue working on your program. It's not acceptible as a long-term solution, and I'm sure rich would agree. |
| 16:35 | Chouser | Wodin: your bug writeup is pretty good. you might include a link to the javadoc for the getString method you're trying to call. |
| 16:35 | Chouser | Wodin: then just whine about it until Rich fixes it. :-) |
| 16:36 | rottcodd | drewc: no arguments here, thanks for providing the service |
| 16:36 | Wodin | Chouser: Thanks. Bed time now, though. I'll send a bug report to the Google group tomorrow. |
| 16:36 | Chouser | Wodin: the program's not terrible at all. |
| 16:36 | Chouser | Wodin: ok, good night. |
| 16:37 | Wodin | Thanks for the help. |
| 16:39 | duck1123_ | drewc: projecture was the best out of the names offered |
| 16:48 | blarf | (cond (let [mov (do-stuff)] mov... is that legal? |
| 16:49 | Chousuke | I don't see why not. |
| 16:50 | Chousuke | Though I can't think of a reason to do that. |
| 16:53 | lisppaste8 | asken pasted "tictactoeAI" at http://paste.lisp.org/display/70677 |
| 16:53 | blarf | Chousuke ^^ |
| 16:53 | blarf | java.lang.IllegalArgumentException: Key must be integer |
| 16:54 | Chouser | ah, you want a sort of cond-let |
| 16:54 | blarf | yes |
| 16:55 | Chousuke | blarf: oh, like that. |
| 16:55 | Chouser | clojure.contrib.cond has cond-let |
| 16:55 | blarf | it compiles fine |
| 16:55 | blarf | but i get a runtimeerror as shown above, first version works, second is the problem |
| 16:57 | Chousuke | in that case your "cond" test actually ends up being (assoc brd mov 3) |
| 16:57 | Chouser | blarf: cond still requires separate 'test' and 'expr' -- putting them both into a single 'let' won't work. |
| 16:59 | Chousuke | your code nests pretty deep |
| 17:00 | Chousuke | to me that usually is a sign that you should be looking for an alternate way to express what you want :) |
| 17:00 | blarf | yes, so how would you do? |
| 17:01 | gnuvince_ | hi |
| 17:04 | nsinghal | ;destucturing bind question |
| 17:04 | nsinghal | (def *defaults* {:a 1 :b 2}) |
| 17:04 | nsinghal | (def args {:a 3}) |
| 17:04 | nsinghal | (let [{:keys [a b]} (merge *defaults* args)] [a b]) >>> [3 2] |
| 17:04 | nsinghal | (defn test-fn [{:keys [a b] :or *defaults*}] [a b]) |
| 17:04 | nsinghal | (test-fn args) >>> [3 nil] |
| 17:04 | nsinghal | How can i write a function where i can define the default values in a map? |
| 17:04 | gnuvince_ | Chouser: can I borrow you for a few minutes? |
| 17:04 | Chouser | gnuvince_: you can try. :-) |
| 17:06 | Chouser | nsinghal: to use a var like that in a destructuring form probably requires a macro |
| 17:06 | Chouser | nsinghal: normally none of the pieces in a fn arg list are eval'ed |
| 17:07 | gnuvince_ | Chouser: I wrote the second part of my comic fetcher tutorial. Can I interest you in reviewing language and code? |
| 17:07 | kotarak | then a macro doesn't help. The macro has no access to the value of a Var. |
| 17:08 | Chouser | kotarak: oh, I guess you're right, at least without doing the resolve stuff manually as rhickey discourages. |
| 17:09 | kotarak | right |
| 17:09 | Chouser | gnuvince_: perhaps later this evening. |
| 17:09 | nsinghal | thanks for answering - that make sense |
| 17:10 | gnuvince_ | Chouser: sure. I'm in no hurry to post, but I like to make sure that what I post is accurate. |
| 17:11 | lisppaste8 | chousuke annotated #70677 with "simplified (untested)" at http://paste.lisp.org/display/70677#1 |
| 17:11 | Chousuke | blarf: ^^ |
| 17:12 | Chousuke | actually, I wonder if the recur works |
| 17:12 | Chousuke | I'm not sure about multimethods |
| 17:14 | Chouser | Chousuke: that is interesting. I'd guess it recurs without going through dispatch again. |
| 17:14 | Chousuke | actually the (and mov is not needed either, since that's guaranteed to be non-nil |
| 17:15 | Chouser | yep, that's what it does. |
| 17:16 | Chousuke | the boolean operators are nice in that they return the actual value of the test instead of a boring boolean :) |
| 17:18 | Chousuke | so when you need to do "get foo, if not found, get bar, if not found, get something else" becomes just a nice (or (get-foo) (get-bar) :something-else) |
| 17:27 | blarf | Chou: thanks, nice. but lets say all those functions are expensive, does it evaluate them lazily or does it execute them all? |
| 17:28 | Chousuke | or returns the first thing that returns non-false |
| 17:28 | blarf | yes but will the functions be executed even if the first is true? |
| 17:28 | Chousuke | no |
| 17:28 | blarf | or that what u meant? it quites a ssoon as something is true? |
| 17:28 | Chousuke | yes. |
| 17:29 | Chousuke | try it yourself: (or nil 1 (println "oops")) |
| 17:31 | Chousuke | also (and (println "hello") (println "not-seen")) :) (println returns nil) |
| 17:36 | blarf | how do i get integer-division? |
| 17:36 | gnuvince_ | quot |
| 17:37 | gnuvince_ | (quote 4 3) => 1 |
| 17:37 | gnuvince_ | err |
| 17:37 | gnuvince_ | (quot 4 3) |
| 17:37 | gnuvince_ | sorry |
| 17:40 | Chousuke | hm |
| 17:41 | Chousuke | was there a function that takes a function and returns a lazy seq of ((f), (f), (f)...) ? |
| 17:42 | kotarak | maybe something like repeatedly? |
| 17:42 | Chousuke | ah, exactly that |
| 17:42 | Chousuke | I only tried repeat |
| 17:46 | blarf | but if find-move ir true and so id find-move 2, but the move is not valid, then it "backtracks" or takes next in the or thsat is true? |
| 17:46 | blarf | anyway it works |
| 17:47 | Chousuke | I'm assuming find-move only returns valid moves. |
| 17:47 | Chousuke | otherwise, that can end up in an infinite loop |
| 17:49 | Chousuke | if the first find-move doesn't find a valid move, it should return nil, in which case the second find-move is run |
| 17:49 | Chousuke | and if that doens't find a move, then one is generated |
| 17:50 | Chousuke | if the generation returns nil, your app should be crashing anyway :P |
| 17:50 | Chousuke | you could optimise it somewhat by looping the generation and valid-move? but simplicity first :) |
| 18:00 | blarf | the minlambda s using # only have one var right? |
| 18:03 | Chousuke | blarf: no. #(+ %1 %2) :) |
| 18:03 | Chousuke | blarf: you can't mix using just % and %n notation though. |
| 18:06 | johnwayner | Don't suppose anyone here uses Vista with GitHub? |
| 18:06 | johnwayner | I've got a fix for swank-clojure but can't get git to clone my fork |
| 18:07 | johnwayner | due to key file permission problems |
| 18:09 | MarkVolkmann | If I use (import '(java.util Date)) then I can create a Date object with (new Date) or (Date.). |
| 18:09 | MarkVolkmann | Can I create a Date object without doing an import by providing the full class name? |
| 18:10 | johnwayner | user> (java.util.Date.) |
| 18:10 | johnwayner | #<Date Tue Nov 18 17:09:08 CST 2008> |
| 18:10 | johnwayner | seems like it |
| 18:14 | gnuvince_ | kotarak: (import '(java.util Date)) |
| 18:14 | kotarak | I know, but (use 'foo.bar.baz), (require 'foo.bar.baz), but (import '(foo.bar Baz)) |
| 18:15 | gnuvince_ | kotarak: that would make importing more than one thing from a package longer |
| 18:15 | gnuvince_ | (import '(java.io BufferedReader InputStreamReader)) |
| 18:15 | gnuvince_ | vs (import 'java.io.BufferedReader 'java.io.InputStreamReader) |
| 18:16 | kotarak | gnuvince_: ??? (require '(foo.bar baz frob)) (import '(foo.bar Baz Frob)) |
| 18:16 | kotarak | import does not allow both forms, require and use do. Inconsistent. |
| 18:20 | StartsWithK | what is happening here, and why does this code work? http://pastebin.com/m18d128e2 |
| 18:21 | albino | are use, require, and import effectively doing the same thing? |
| 18:21 | albino | why isn't there only one way to do that? |
| 18:21 | cooldude127 | does use actually work with java classes? |
| 18:21 | cooldude127 | isn't import the only one that does that? |
| 18:22 | kotarak | albino: require just loads a library, use "require"s a library and refers it in the namespace, import makes Java classes available. |
| 18:22 | cooldude127 | there we go |
| 18:23 | kotarak | (require 'foo) => (foo/bar), (use 'foo) => (bar), (new foo.Bar) (import '(foo Bar)) => (new Bar) |
| 18:24 | cooldude127 | kotarak: we need that in some docs somewhere |
| 18:24 | kotarak | (doc require), IIRC |
| 18:24 | cooldude127 | oh |
| 18:24 | albino | hmm |
| 18:25 | albino | kotarak: thanks for the description |
| 18:25 | kotarak | np |
| 18:28 | Chousuke | StartsWithK: you're defining x a function that returns a function |
| 18:29 | cooldude127 | #() creates one function |
| 18:29 | cooldude127 | then the fn form creates another |
| 18:29 | Chousuke | the curious thing is using % as the parameter |
| 18:29 | StartsWithK | yes |
| 18:29 | Chousuke | I guess it's not captured by the #() |
| 18:29 | Chousuke | but the fn instead |
| 18:30 | StartsWithK | isn't that (fn [1] 1) |
| 18:30 | StartsWithK | and that should fail, but even so, why when called it return (inc 2) not (inc 1) |
| 18:30 | cooldude127 | (def x (fn* [p1__1111] (fn [p1__1111] (inc p1__1111)))) |
| 18:30 | cooldude127 | is the macroexpansion |
| 18:31 | Chousuke | looks like the inner binding hides the outer one. |
| 18:32 | StartsWithK | so 1 is ignored and replaced with replaced with (gensym)? |
| 18:32 | cooldude127 | evidently |
| 18:34 | Chousuke | the outer function binds the name p1_1111 to whatever, but the inner one rebinds it, and so the parameter passed to the outer function is never seen. |
| 18:36 | hiredman | http://www.thelastcitadel.com/clojure/arithmetic-mean <-- arithmatic mean using reduce |
| 18:38 | StartsWithK | cooldude127, Chousuke thanks for explaining this, looked realy strange |
| 18:41 | cooldude127 | no problem |
| 18:41 | cooldude127 | if you have trouble with stuff like that again, this is what i did in the repl |
| 18:41 | cooldude127 | (macroexpand '(def x #(fn [%] (inc %)))) |
| 18:41 | cooldude127 | that'll show you what's going on |
| 20:00 | cwyang | There are two basic styles of implementing such a construct: http://paste.lisp.org/display/70665 |
| 20:01 | Chousuke | hm? |
| 20:07 | cooldude127 | cwyang: what's this? |
| 20:16 | MarkVolkmann | How can I take a string like "one two" and get a collection containing the strings "one" and "two"? |
| 20:17 | Chouser | (.split "one two" " ") |
| 20:17 | MarkVolkmann | This is close. (split-with (fn [x] (not= x \space)) "one two") |
| 20:17 | cooldude127 | i like chouser's :) |
| 20:17 | MarkVolkmann | Definitely! Thanks |
| 20:17 | cooldude127 | uses the java string api |
| 20:19 | MarkVolkmann | How can I take a list of strings and get a single string that concatenates all the strings together with a space between each? |
| 20:19 | MarkVolkmann | I thought (str list) would do it, but no. |
| 20:19 | gnuvince_ | Chouser: can I send you that link? |
| 20:20 | Chouser | gnuvince_: yes |
| 20:20 | hiredman | MarkVolkmann: maybe interpose |
| 20:20 | hiredman | then str |
| 20:20 | gnuvince_ | Chouser: here or email? |
| 20:20 | Chouser | hiredman: thanks, I can never think of the word interpose |
| 20:20 | Chouser | (apply str (interpose " " ["one" "two" "three"])) |
| 20:20 | Chouser | There's also clojure.contrib.str-utils that has some of these |
| 20:21 | Chouser | gnuvince_: email I guess, and I'll reply with comments. |
| 20:22 | gnuvince_ | Chouser: sent. |
| 20:22 | gnuvince_ | Thanks |
| 20:53 | MarkVolkmann | I'm confused about how to use things in clojure-contrib. Suppose I want to use the str-join function in str-utils. I start with (require 'clojure.contrib.str-utils). What else do I need to do to make the str-join function known in the current namespace? |
| 20:53 | vagif | Hello, anyone using compojure web framework ? |
| 20:54 | Chouser | if you say (require '[clojure.contrib.str-utils :as util]), then you can say (util/str-join ...) |
| 20:54 | Chouser | or (require '[clojure.contrib.str-utils :only (str-join)]), and (str-join ...) |
| 20:56 | vagif | compojure comes with jetty, but i want to integrate it into my existing application which is on tomcat. |
| 20:56 | vagif | anyone done that ? |
| 20:56 | Chouser | MarkVolkmann: sorry, that's (use '[clojure.contrib.str-utils :only (str-join)]) |
| 20:57 | Chouser | vagif: I haven't, sorry. I haven't used compojure yet, but I think that question has come up |
| 20:58 | Chouser | vagif: did you search the clojure and compojure google groups? |
| 20:58 | vagif | yes i searched both groups |
| 20:58 | Chouser | ok, well I guess your best bet would be to ask there. |
| 21:18 | blbrown | pjb3: did you just twitter me |
| 21:18 | pjb3 | blbrown: I did |
| 21:18 | blbrown | hehe |
| 21:19 | pjb3 | You said you bought the Clojure book, that means you are worth following :) |
| 21:19 | blbrown | I got the beta PDF, apparently, there are a lot of sections missing |
| 21:32 | candera | Stu should have Beta 2 of the book out before too long |
| 21:32 | candera | Presumably you'll get an updated copy when he does - no idea how that works. |
| 21:32 | candera | Although I suspect that even Beta 2 will still not have every chapter completed. |
| 21:33 | blbrown | the first part is all I need anyway. I got a good first 100 pages or so. |
| 21:37 | gnuvince_ | hmmm |
| 21:37 | gnuvince_ | Steve Yegge mentioned Clojure in his latest blog post. |
| 21:37 | gnuvince_ | Do you think that's good or bad? |
| 21:37 | Chouser | how could it be bad? |
| 21:38 | albino | was he comparint it to NBL? |
| 21:38 | albino | s/comparint/comparing |
| 21:38 | gnuvince_ | albino: no, he just mentioned it in passing in his Ejacs post |
| 21:38 | cooldude127 | yeah i saw that |
| 21:38 | cooldude127 | i think what he said was mildly positive |
| 21:38 | hiredman | it's about time he mentioned it, it seems like it should be right up his alley, dynamic and on the jvm |
| 21:38 | cooldude127 | he's still in love with javascript tho |
| 21:39 | hiredman | yeah, well, ok |
| 21:39 | pjb3 | It's funny about Steve Yegge, I actually first heard about Clojure from people commenting on his blog |
| 21:40 | cooldude127 | hehe |
| 21:40 | pjb3 | Might have been the NBL post, I just remember a lot of comments about Scala and Clojure |
| 21:40 | pjb3 | I hadn't heard of either of those languages until then |
| 21:40 | Chouser | But Yegge doesn't actually like JavaScript. He likes what he's planning on turning JavaScript into. |
| 21:40 | cooldude127 | what is he turning it into? |
| 21:41 | gnuvince_ | NBL |
| 21:41 | cooldude127 | that's a tad abstract |
| 21:41 | Chouser | Because I agreed with so much of what he said, I started trying to do projecteuler problems in Rhino. It was terrible. He's extended it in a bunch of ways. |
| 21:41 | gnuvince_ | I think he really liked EcmaScript 4 before it was gutted |
| 21:41 | cooldude127 | oh |
| 21:42 | gnuvince_ | Rhino was not fun |
| 21:42 | cooldude127 | lol |
| 21:43 | gnuvince_ | With Clojure, I've had nothing but fun :) |
| 21:43 | hiredman | mmmmm |
| 21:43 | albino | well from reading his blog posts it was JS2 he liked |
| 21:44 | gnuvince_ | albino: JS2 is EcmaScript 4 |
| 21:44 | albino | gnuvince_: as the different browser vendors see it or what? |
| 21:46 | johnwayner | I forked Jochu's swank-clojure and patched it to work with SVN 1110: |
| 21:46 | johnwayner | http://github.com/johnwayner/swank-clojure/tree/master |
| 21:47 | johnwayner | I had to hack on it a bit, so hopefully it works. |
| 21:47 | cooldude127 | johnwayner: what has changed in 1110 from, say, 1107? |
| 21:48 | cooldude127 | cuz i have SVN1107 and swank-clojure working together |
| 21:48 | johnwayner | The removal of gen-and-load* |
| 21:48 | cooldude127 | shittttt |
| 21:48 | cooldude127 | that sounds important ;) |
| 21:48 | johnwayner | moved into (ns (:gen-class |
| 21:48 | cooldude127 | oh |
| 21:48 | johnwayner | so yeah, "removal" not the right word I guess :) |
| 21:48 | cooldude127 | FAT ASS API CHANGE |
| 21:48 | cooldude127 | is more like it ;) |
| 21:49 | johnwayner | This is a crazy time.... should be pretty much smooth sailing soon. |
| 21:49 | cooldude127 | hopefully |
| 21:50 | Chouser | I hope doto gets broken soon too. |
| 21:50 | cooldude127 | in what way? |
| 21:50 | mattrepl | hmm, is there a write-up on what replaces gen-and-load-class post-AOT compilation? |
| 21:51 | cooldude127 | mattrepl: apparently it's part of namespaces now? |
| 21:51 | johnwayner | mattrepl: this: http://paste.lisp.org/display/70665 |
| 21:51 | johnwayner | mattrepl: and the irc log from earlier today |
| 21:51 | hiredman | crazy |
| 21:51 | mattrepl | thanks |
| 21:52 | hiredman | defn- -main |
| 21:52 | hiredman | weird looking |
| 21:52 | cooldude127 | yeah wtf? |
| 21:52 | Chouser | why would you make main private? |
| 21:53 | cooldude127 | i'm not totally sure i'm on board with this |
| 21:53 | Chouser | cooldude127: http://groups.google.com/group/clojure/browse_thread/thread/d668c590c6cf982b |
| 21:53 | cooldude127 | Chouser: k i remember that thread |
| 21:54 | johnwayner | Chouser: perhaps it's private in the namespace but not the class? Dunno |
| 21:54 | johnwayner | I don't presume to know better than rhickey :) |
| 21:55 | Chouser | oh, yeah, I didn't notice that in his code. weird. |
| 21:55 | cooldude127 | yeah this code needs mucho examination |
| 21:56 | johnwayner | Any elispers know how to avoid this nasty change? http://github.com/johnwayner/swank-clojure/commit/8f567775360425475df494520083f9023ffe1af1 |
| 22:00 | mattrepl | johnwayner: did you already fix the defexception macro in swank-clojure? |
| 22:00 | johnwayner | mattrepl: I removed it |
| 22:01 | johnwayner | mattrepl: I just added the one class that was being created as a .clj file and compiled it in swank-clojure.el |
| 22:02 | johnwayner | mattrepl: This is probably just a hack to get it working. It doesn't really seem correct. |
| 22:02 | mattrepl | that's such a hassle just to give a typed exception |
| 22:02 | mattrepl | *nod* and I meant the new namespaces -> classes, not your change |
| 22:03 | johnwayner | yeah, I have a feeling we are quite done with changes in the area :) |
| 22:03 | johnwayner | are *not* |
| 22:06 | mattrepl | thanks for making it work, now I can get back to thesis writing. =) |
| 22:06 | johnwayner | np. :) |
| 22:14 | dms | hello..anybody know how to set up slime file name translations for connecting with a remote swank server? (or is it even possible currently?) |
| 22:16 | drewc | dms: see segv's annotation here : http://paste.lisp.org/display/32153 |
| 22:16 | johnwayner | dms: You want to edit the remote files via Tramp? |
| 22:19 | dms | johnwayner: yes. i could connect slime to a remote swank but M-. doesn't work. I saw the reference about tramp via google, but didn't really know how to set it up. |
| 22:19 | dms | drewc: thanks. I will try it out. |
| 22:20 | drewc | dms i have made it work in CL, and it's all on the elisp side AFAIK, so it should just-work. |
| 22:32 | dms | hmm.. i am connecting to my remote machine via a ssh tunnel, so i really want slime to connect to a local ip and port but still do file name translations.. this is going to take a while. |
| 22:34 | johnwayner | dms: maybe you can trick slime by putting an entry in you /etc/hosts that points to localhost |
| 22:36 | dms | good idea. will try. |
| 22:40 | wwmorgan | I just downloaded svn head and compiled it. When I ran the jar, it yelled at me because Compiler.pushNS is package-private and clojure.core was trying to access it. Making pushNS public solved the problem, apparently. Comments? |
| 22:40 | johnwayner | wwmorgan: did you clean? |
| 22:40 | wwmorgan | possibly nvm. Turns out I wasn't at head |
| 22:41 | wwmorgan | and everything works. Crisis averted! |