2009-07-29
| 04:02 | AWizzArd | Hi cgrand |
| 04:05 | lbj | AWizzArd: You did work on JavaFX right? |
| 04:06 | cgrand | Hi AWizzArd! |
| 04:40 | angerman | I cannot just drop an item from a vector, can I ? |
| 04:41 | angerman | e.g. [1 2 3 4] -> [1 2 4] |
| 04:42 | angerman | ,(let [x [1 2 3 4]] (subvec x 3)) |
| 04:42 | clojurebot | [4] |
| 04:42 | angerman | ,(let [x [1 2 3 4]] (subvec x 0 3) (subvec x 3)) |
| 04:42 | clojurebot | [4] |
| 04:42 | angerman | ,(let [x [1 2 3 4]] (conj (subvec x 0 3) (subvec x 3))) |
| 04:42 | clojurebot | [1 2 3 [4]] |
| 04:42 | angerman | ,(let [x [1 2 3 4]] (conj (subvec x 0 3) @(subvec x 3))) |
| 04:42 | clojurebot | java.lang.ClassCastException: clojure.lang.APersistentVector$SubVector cannot be cast to clojure.lang.IDeref |
| 04:44 | angerman | ,(let [x [1 2 3 4]] (reduce conj (subvec x 0 3) (subvec x 3))) |
| 04:44 | clojurebot | [1 2 3 4] |
| 04:44 | angerman | ,(let [x [1 2 3 4]] (reduce conj (subvec x 0 2) (subvec x 3))) |
| 04:44 | clojurebot | [1 2 4] |
| 04:44 | angerman | ,(let [x [1 2 3 4]] (reduce conj (subvec x 0 1) (subvec x 2))) |
| 04:44 | clojurebot | [1 3 4] |
| 04:45 | hiredman | uh |
| 04:45 | angerman | that doesn't seemto be the best solution :/ |
| 04:45 | lbj | angerman: Cosider using remove? |
| 04:45 | lbj | +n |
| 04:45 | Raynes | ,(remove #(= 3 %) [1 2 3 4 5]) |
| 04:45 | clojurebot | (1 2 4 5) |
| 04:46 | hiredman | ,((comp vec drop-nth) 2 [1 2 3 4]) |
| 04:46 | clojurebot | java.lang.Exception: Unable to resolve symbol: drop-nth in this context |
| 04:46 | angerman | hmm ok. joined with nth thtat could vork |
| 04:47 | hiredman | huh |
| 04:47 | angerman | (let [x [1 2 3 4]] (remove #(= (nth x 3) %) x)) |
| 04:47 | angerman | ,(let [x [1 2 3 4]] (remove #(= (nth x 3) %) x)) |
| 04:47 | clojurebot | (1 2 3) |
| 04:48 | Fossi | o_O |
| 04:48 | angerman | but it's not a vector after that anymore ... |
| 04:48 | Raynes | angerman: Call vec on it. |
| 04:48 | angerman | hmm yea. |
| 04:49 | lbj | or (into [] ...) |
| 04:49 | angerman | hmm into... |
| 04:49 | hiredman | ,((comp vec (fn f [n m] (lazy-seq (if (zero? n) (rest m) (cons (first m) (f (dec n) (rest m))))) 2 [1 2 3 4]) |
| 04:49 | clojurebot | EOF while reading |
| 04:49 | lbj | But this might be the best thing after all: (apply str (map char (remove #(= 555 %) [555 97 112 112 108 97 555 117 555 100 32 82 97 555 121 110 101 115]))) |
| 04:49 | hiredman | bah |
| 04:50 | hiredman | ,((comp vec (fn f [n m] (lazy-seq (if (zero? n) (rest m) (cons (first m) (f (dec n) (rest m)))))) 2 [1 2 3 4]) |
| 04:50 | clojurebot | EOF while reading |
| 04:50 | Raynes | hiredman: Clojurebot is kicking your ass. |
| 04:50 | hiredman | ,((comp vec (fn f [n m] (lazy-seq (if (zero? n) (rest m) (cons (first m) (f (dec n) (rest m))))))) 2 [1 2 3 4]) |
| 04:50 | clojurebot | [1 2 4] |
| 04:50 | angerman | ,(let [x [1 2 3 4]] (into (subvec x 0 1) (subvec x 2))) |
| 04:50 | clojurebot | [1 3 4] |
| 04:50 | angerman | ahh :) |
| 04:51 | lbj | OT: Anyone here good at getting logo ideas? |
| 04:52 | angerman | ,(let [x [1 2 3 4] drop-nth (fn [coll n] (into (subvec coll 0 (- n 1)) (subvec coll n))] (drop-nth x 2)) |
| 04:52 | clojurebot | Unmatched delimiter: ] |
| 04:52 | jdz | i personally thing that using clojurebot as a repl for experimentation is antisocial behaviour |
| 04:53 | hiredman | my drop-nth is lazy |
| 04:53 | jdz | think even |
| 04:53 | hiredman | well, keep us updated |
| 04:55 | angerman | hiredman: well i need it for the backing of a JTable |
| 04:55 | lbj | jdz: agreed |
| 04:55 | angerman | so lazynes is not an option as it's being consumed anyway |
| 04:56 | lbj | hiredman: Consider this: Opening access to your sandbox repl from some website, keeping an infinite log, letting people evaluate expressions and logging them next to their nick. That'd be an interesting read in a couple of months time |
| 04:57 | hiredman | lbj: who says I don't log everything sent to clojurebot? |
| 04:57 | Fossi | jdz: lbj zou can actually send him a private message if you must :) |
| 04:58 | jdz | i just brought up a point, it's up for discussion. you're kinda not adding to that discussion really. |
| 04:59 | hiredman | clojurebot: numbers? |
| 04:59 | clojurebot | No entiendo |
| 04:59 | hiredman | clojurebot: numbers is <reply>(pl reverse $ (↕reduce range $ 10 () λxy (↕conj inc $ y x))) |
| 04:59 | clojurebot | c'est bon! |
| 04:59 | angerman | wow. thats that with the up-down arrows and the lambda in there? |
| 05:00 | jdz | that's what you get when you cross clojure and haskell. |
| 05:00 | hiredman | pl is a macro that does some code transforming |
| 05:19 | angerman | ,(replace {3 "x"} ["a" "b" "c" "d" "e"]) ;; what am I doing wrong? |
| 05:19 | clojurebot | ["a" "b" "c" "d" "e"] |
| 05:28 | Chousuke | ,(replace '{a x} '[a b c d e a]); angerman |
| 05:28 | clojurebot | [x b c d e x] |
| 05:35 | rottcodd | angerman: (assoc ["a" "b" "c" "d" "e"] 3 "x") |
| 05:46 | AWizzArd | lbj: I am interested to know how far JavaFX is usable from Clojure. But I am not working on/with it currently. |
| 07:58 | angerman | hmm I think I have a problem again. |
| 07:59 | angerman | I have a map {"A" Class1 "B" Class2 "C" Class3} |
| 07:59 | angerman | now I'd like to do something like (("A" my-map). arg) or (new ("A" my-map) arg) |
| 07:59 | angerman | but I think clojure does not like it that way |
| 08:00 | rhickey | ~jcall |
| 08:00 | clojurebot | Huh? |
| 08:01 | angerman | rhickey: hm. do I have a match x with a b c like statement? then I could just write a dispatch function that returns the an instance of the class with the arg |
| 08:03 | rhickey | angerman: is the problem looking up the Class by string? just switch it to (my-map "A"), or is the question how to create a new instance given the class? Classes with no-arg ctors support newInstance |
| 08:03 | rhickey | ,(.newInstance String) |
| 08:03 | clojurebot | "" |
| 08:04 | rhickey | if the ctors take args you will have to use reflection, or make another plan where the map contains closures and not classes |
| 08:04 | angerman | rhickey: well I have this: {"GET": HttpGet, "POST": HttpPost, ...) |
| 08:04 | angerman | they each take an url as argument |
| 08:05 | angerman | so my idea is to have a function that takes the key and url as arguments and returns an instance |
| 08:05 | angerman | and I think (cond might be a soltion |
| 08:06 | Fossi | rarely the right one though ;) |
| 08:06 | rhickey | maps are faster than cond, what's wrong with using a map? just use (m k) instead of (k m) when your keys are not keywords |
| 08:06 | rhickey | or (get m k) |
| 08:08 | angerman | hmm. yep clojures are fine I think |
| 08:50 | Chouser | ~jcall is http://paste.lisp.org/display/67182 |
| 08:50 | clojurebot | Alles klar |
| 08:50 | Chouser | ~jfn is http://paste.lisp.org/display/67182 |
| 08:50 | clojurebot | 'Sea, mhuise. |
| 08:51 | Chouser | clojurebot: jcall? |
| 08:51 | clojurebot | jcall is http://paste.lisp.org/display/67182 |
| 08:55 | Chouser | apparently wave robots run in a GAE environment, and since they already have a GAE Clojure REPL, I assume it's just a matter of time before there's a clojurebot for wave. |
| 08:59 | rhickey | Chouser: the question is how ambitious will it be? a repl bot is one thing, how about live .clj files? |
| 08:59 | rhickey | code is data is wave |
| 09:02 | Chouser | hm... one namespace per wave, I'd think |
| 09:02 | rhickey | newnew is proving to be a huge pain BTW |
| 09:03 | Chouser | writing it in java, hm? is that the source of the pain? |
| 09:03 | cemerick | it's quite an ambitious project |
| 09:04 | rhickey | compiling calls like (.foo this ...) without runtime reflection means doing so without compile-time reflection either, as the class does not yet exist, but all of the host access compilation code uses reflection - aargh |
| 09:05 | Chouser | that's not required for newnew, is it? an initial version could still use reflection. |
| 09:05 | rhickey | I've done some refactoring so the Java doesn't become a complete mess, but Java is no fun either |
| 09:05 | Fossi | clojure on GAE is just fine |
| 09:05 | Fossi | runtime compiling and all |
| 09:06 | rhickey | Chouser: yes, it could use reflection but would be a sore spot since the whole point is for this to be fast enough for the bottom layer of the system |
| 09:07 | rhickey | that's why I had to pause yesterday and work more on my design for primitive support in IFn, since the creation of these things will be locked inside fns, if the fn required boxing just to get a primitive through to the implemented class you'd get double allocations you are trying to avoid |
| 09:07 | rhickey | everything is interconnected |
| 09:09 | cemerick | I enjoy situations like that, only because of their payoff: eventually, one gets through the dip, and then vast swaths of tangled code just melts away |
| 09:10 | rhickey | so I think I've figured out (but not implemented) everything, one point left is that I am currently not supporting concrete superclasses whose ctors take args - is that too draconian? I've even changed RestFn so it doesn't and can play along |
| 09:12 | cemerick | rhickey: I don't think it's a matter of draconian or acceptable -- if this is a primary piece of interop, it *will* come up. *shrug* |
| 09:13 | rhickey | cemerick: newnew is not an interop feature |
| 09:14 | angerman | hmm ... how do I turn {"a" "b" "c" "d"} into {:a "b" :c "d"}? json-read is not restoring the keywords |
| 09:15 | rhickey | making it so it can only implement interfaces is certainly easiest |
| 09:15 | cemerick | rhickey: in that case, I'm not sure what to say to your (potentially rhetorical?) question :-) |
| 09:15 | rhickey | then there is no question, no superclass |
| 09:15 | angerman | i tried to run (map (fn [[k v]] (keyword k) v) {...}) |
| 09:15 | rhickey | cemerick: I'm practicing my excuses :) |
| 09:15 | Chousuke | angerman: you need to return [(keyword k) v] |
| 09:16 | Chousuke | angerman: and then (into {}) it |
| 09:16 | cemerick | rhickey: you could always go Henry II on people. "There's no sense asking if the air's good when there's nothing else to breathe." :-) |
| 09:16 | rhickey | adding no-ctor concrete superclasses *is* a slippery slope, brings in protected access, calling "super" version |
| 09:17 | rhickey | adding ctors args and fields just blows things up incredibly, with multiple nested scopes |
| 09:17 | angerman | Chousuke: thanks. hmm seems expensive, but i don't have many elements anyway |
| 09:17 | rhickey | cemerick: hah |
| 09:18 | Chousuke | angerman: it's not that expensive. |
| 09:18 | cemerick | rhickey: thinking for a minute, I'm curious as to how you can get around concrete superclasses with ctor args -- tons of that in the std collections right now w/ meta, nevermind PSM |
| 09:19 | Chouser | withMeta after construction |
| 09:19 | rhickey | meta will change, it's been a pain this way anyway |
| 09:20 | rhickey | will just move into leaf classes |
| 09:20 | Chouser | base collection classes will just start empty, I'd guess? |
| 09:20 | rhickey | structs on newnew? |
| 09:21 | rhickey | Chouser: if you look at the ctors there is only metadata being passed to the abstract bases |
| 09:21 | Chouser | Not that I need to understand, but I still don't see why compile-time reflection would require runtime reflection. |
| 09:21 | cemerick | rhickey: what about structs? |
| 09:21 | rhickey | all the java util abstract classes take no args |
| 09:22 | rhickey | Chouser: compile-time reflection needs an existing class (which I don't have yet), but the compiled code would then need no reflection |
| 09:23 | rhickey | cemerick: it would be interesting to build structs on newnew |
| 09:24 | cemerick | rhickey: Oh, I hope so! That's my #1 use case (efficient structs w/ slots defined in interfaces). |
| 09:24 | cemerick | (hopefully with optional map usage as well, but we'll see, I suppose) |
| 09:25 | rhickey | cemerick: so once you are doing that, the question becomes what is faster, multiway conditional (generated per struct) or map lookup + array access? |
| 09:26 | rhickey | my bet is on the former for modest sized structs |
| 09:26 | rhickey | so then you are not reusing a generic lookup strategy but compiling unique code per struct |
| 09:26 | rhickey | and PSM goes away |
| 09:27 | cemerick | ...but with a PHM off to the side when you've got additional, runtime-defined slots, yeah. |
| 09:27 | rhickey | right |
| 09:27 | cemerick | I think your bet is about right, especially as you could probably distill the conditional to a switch (and whatever that boils down to in bytecode) |
| 09:27 | rhickey | struct become a more involved macro |
| 09:28 | rhickey | cemerick: esp since small maps use multiway conditionals anyway (known faster for n <= 9 or so) |
| 09:30 | rhickey | switch a bit sticky since the dispatch values would be keywords |
| 09:30 | rhickey | I'll just leave it to hotspot, if you want the best perf you'll define an interface, that's the whole point |
| 09:31 | Chouser | and (:b foo) --> (.b foo) |
| 09:31 | cemerick | rhickey: I'd think it'd be worthwhile to emit something similar to switch (hash(yourkeyword)) { case 102934827: ... } |
| 09:32 | rhickey | cemerick: I welcome your patch :) |
| 09:33 | cemerick | Chouser: (:b foo) is *always* preferable, so that you can make an object of type Foo functionally into a Bar (suffering real map lookups, but at the very least not worrying about what that thing is going to be used for when you create it) |
| 09:33 | cemerick | rhickey: I'll benchmark the easy way first, but it's something I'd definitely hit ASM for if need be. |
| 09:35 | Fossi | i want to filter a seq with a pred, but also need the others. nicest way to do it? |
| 09:36 | Fossi | found separate |
| 09:37 | Fossi | going through the list twice feels like a waste though |
| 09:38 | rhickey | Fossi: http://paste.lisp.org/display/76458 |
| 09:38 | rhickey | er, http://paste.lisp.org/display/76458,1/raw |
| 09:41 | Chouser | ~unzip-with is http://paste.lisp.org/display/76458,1/raw |
| 09:41 | clojurebot | Alles klar |
| 09:41 | Chouser | so much easier than actually adding it to contrib. :-P |
| 09:41 | rhickey | that focuses on calling the pred only once per and being lazy, one pass would be a different thing |
| 09:42 | Fossi | well, the usecase is for pretty small lists anyway. still trying to get a feel though |
| 09:42 | Fossi | and i wondered that the implementation for "seperate" is so un... i don't know.. cool? |
| 09:43 | Fossi | but then, if i need something more optimal, i prolly want to write a specific version anyway |
| 09:44 | rhickey | what's separate? |
| 09:45 | Fossi | http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/seq_utils.clj#40 |
| 09:53 | lisppaste8 | rhickey pasted "which new form?" at http://paste.lisp.org/display/84374 |
| 09:57 | Chouser | 1 and 3 are actually compatible |
| 09:57 | cemerick | rhickey: #3: typing {:as this} constantly is going to get irritating (unless the 'this' symbol is going to be the default, in which case, +1 on #1) |
| 09:57 | Chouser | well, I suppose all of them are. |
| 09:57 | rhickey | cemerick: no default, same reason as yesterday |
| 09:59 | Chouser | yeah, I like #3 as well |
| 09:59 | rhickey | or a new name like make/instance/obj[ect] |
| 09:59 | rhickey | would allow this-name first |
| 10:00 | Chouser | Not sure 'this' belongs first. (new [SomethingListener] this {} (handleFoo [] ...)) has a pleasant order |
| 10:01 | rhickey | Chouser: I reconsidered the multiple overloads under one name, doesn't work due to ret type is hint on name and might differ |
| 10:01 | rhickey | Chouser: I agree, it's not a new this |
| 10:02 | rhickey | you can leave out both this and the map if you don't need them |
| 10:02 | Chousuke | #3 seems neat. |
| 10:15 | mebaran151 | I'd like to build a lazy sequence n items at a time |
| 10:15 | mebaran151 | is there a good tutorial on writing lazy functions that way |
| 10:15 | mebaran151 | once the user tried to access the n+1 item, it would evaluate a given function |
| 10:16 | Fossi | tried seque? |
| 10:16 | rhickey | pmap |
| 10:16 | Chouser | concat |
| 10:16 | cemerick | mapcat |
| 10:16 | rhickey | all have logic like that |
| 10:16 | Chouser | er, lazy-cat |
| 10:17 | mebaran151 | well I'm looking more for something that thunks |
| 10:17 | mebaran151 | like lazy-cat, except that I could pass a function |
| 10:17 | mebaran151 | let me check these things out |
| 10:19 | Chouser | ,(take 4 (lazy-cat [1 2 3 4] ((fn [] (prn "called") [5 6 7])))) |
| 10:19 | clojurebot | (1 2 3 4) |
| 10:19 | Chouser | ,(take 5 (lazy-cat [1 2 3 4] ((fn [] (prn "called") [5 6 7])))) |
| 10:19 | clojurebot | (1 2 3 4 5) |
| 10:19 | Chouser | hm, clojurebot swallowed my prn? |
| 10:19 | mebaran151 | I'd like to make it an explicit function though |
| 10:19 | mebaran151 | because I have to handle the cursor releasing etc |
| 10:19 | Chouser | (fn [] ...) is an explicit function, isn't it? |
| 10:20 | mebaran151 | oh |
| 10:20 | mebaran151 | tis |
| 10:20 | mebaran151 | got lost in my irc formatting |
| 10:21 | mebaran151 | is there any decent way to pass the last element as an argument to that anonymous function? |
| 10:22 | mebaran151 | I could probably pull something off using binding, but a binding solution never seems elegant |
| 10:22 | Chouser | the last element of what? |
| 10:22 | mebaran151 | the last element of the realized collection |
| 10:23 | mebaran151 | (take (lazy-cat [1 3 4 5] |
| 10:23 | mebaran151 | ) ((fn [5 would go here] ....))) |
| 10:24 | cemerick | mebaran151: that's iterate territory |
| 10:25 | mebaran151 | it is a little bit: what I'm trying to accomplish is a way to make a cursor based hash store look sort of like a lazy list |
| 10:26 | mebaran151 | the thing is, I can't keep my cursors open all the time, so I thought I'd take the first n, then close the cursor, than restart it again if someone "used up" the first results |
| 10:26 | mebaran151 | I need to pass back the last result so I know where to replace my cursor |
| 10:26 | Chouser | ah, interesting idea. |
| 10:27 | Chouser | you really need the last item of the previous series, and not some kind of offset or index? |
| 10:27 | mebaran151 | I really do in a way |
| 10:28 | mebaran151 | I think I can pull it off with a binding |
| 10:28 | Chouser | you shouldn't need binding |
| 10:28 | mebaran151 | whereby the last function would just bind its final result so I know where to restart |
| 10:28 | Chouser | I don't think. They're easy to get wrong when you've got closures nearby. |
| 10:28 | cemerick | mebaran151: something like take-while + mapcat + iterate should get you there |
| 10:29 | Chouser | might actually be easier to do with lazy-seq and close over what you need to do the next part. |
| 10:29 | mebaran151 | yeah, that's what I was originally thinking |
| 10:29 | Chouser | hm, though maybe you could do that with lazy-cat too... |
| 10:29 | rhickey | yes |
| 10:30 | mebaran151 | it's actually coming out to be a pretty cool library |
| 10:31 | mebaran151 | does full text indexing of arbitrarily nested maps on top of bdb |
| 10:31 | mebaran151 | I just want to make the query interface more clojurey |
| 10:32 | mebaran151 | so that users could do things like apply their own custom sorters mapping and the like without having to worry too hard about managing where the cursor is at any giving time |
| 10:37 | cemerick | mebaran151: sounds nifty. Roughly what I need to build this week. We're going with perst, which I'm very happy with so far. |
| 10:39 | mebaran151 | yeah, it's been a two week project: though I've had to work on some other things in the mean ime |
| 10:39 | mebaran151 | how does perst do for replication? |
| 10:40 | cemerick | ostensibly, there's various options, though I've not bothered to look at that much. What's the use case in an embedded environment? |
| 10:40 | mebaran151 | also does perst do phrase matching? (ie maintain word order) |
| 10:41 | cemerick | it has its own full-text indexing which is so-so, but you can also use lucene on top of it. That puts the DB and lucene all in one file, and gives you everything lucene has to offer. |
| 10:42 | mebaran151 | ha |
| 10:42 | mebaran151 | are you going to share this lib or is it strictly commercial only |
| 10:42 | mebaran151 | would be cool to see how they compare :) |
| 10:43 | cemerick | I don't think there's much of a lib to write, honestly. I'm just going to be persisting maps, and then using the lucene API to search over them. |
| 10:43 | cemerick | it's an object database, so there's very little mismatch in the models |
| 10:44 | mebaran151 | ah |
| 10:45 | cemerick | If something interesting does come out of it, I'll certainly share. We don't care much about DB code. |
| 10:46 | cemerick | but honestly, the API is something like (.put object-key-here {:foo 4 :bar "blah" :etc 'sym}) :-) |
| 10:50 | mebaran151 | does it nest? |
| 10:50 | mebaran151 | that was wher most of the current solutions got me down |
| 10:50 | cemerick | nest? |
| 10:51 | mebaran151 | handling nested hashes |
| 10:51 | mebaran151 | {:a {:b [:c [1 2 "my test here" {:d 8}]}} |
| 10:51 | cemerick | yup, and arbitrary java objects |
| 10:52 | cemerick | gotta be careful with those -- all of the niggles of serialization come up there |
| 10:52 | mebaran151 | well if you get nested hashes, arbitrary java objects should be pretty easy |
| 10:52 | cemerick | I do need to define a custom serializer for clojure objects that uses prn. |
| 10:52 | cemerick | but that should take all of about 20 min. |
| 10:53 | mebaran151 | java regexps are locale aware right? |
| 11:01 | AWizzArd | ,(seq? (java.util.ArrayList.)) |
| 11:01 | clojurebot | false |
| 11:01 | AWizzArd | ,(coll? (java.util.ArrayList.)) |
| 11:02 | clojurebot | false |
| 11:02 | cemerick | ,(doc coll?) |
| 11:02 | clojurebot | "([x]); Returns true if x implements IPersistentCollection" |
| 11:03 | stuartsierra | ,(list? (java.util.ArrayList.)) |
| 11:03 | clojurebot | false |
| 11:04 | AWizzArd | is there a truth function which returns true for standard JRE collections AND for the Clojure collections? |
| 11:06 | stuartsierra | (instance? java.util.Collection ...) I guess |
| 11:06 | AWizzArd | yes ok, that would work |
| 11:06 | AWizzArd | thx |
| 11:06 | stuartsierra | np |
| 11:06 | rhickey | j.u.Maps are not j.u.Collections, need to test for both |
| 11:07 | stuartsierra | grr |
| 11:07 | stuartsierra | I always forget that |
| 11:08 | stuartsierra | Did coll? formerly test for j.u.Collection? |
| 11:08 | rhickey | maybe |
| 11:10 | stuartsierra | A non-committal response. :) |
| 11:10 | rhickey | I don't recall |
| 11:10 | stuartsierra | ok |
| 11:14 | cratuki | Having some troublc compiling clojure.contrib. Following instructions at http://riddell.us/tutorial/clojure/clojure.html |
| 11:14 | cratuki | In the ant command I specify a valid jar, but I get java.io.FileNotFoundException: Could not locate clojure/walk__init.class |
| 11:15 | replaca_ | cratuki: you've got a version mosmatch |
| 11:15 | cratuki | It still seems to produce a clojure contrib jar though. Has anyone else seen this? |
| 11:15 | stuartsierra | yep |
| 11:15 | replaca_ | *mismatch |
| 11:15 | cratuki | ahh |
| 11:15 | cratuki | Of course. My brain hasn't adjusted to git yet :) |
| 11:15 | replaca_ | if you're using 1.0 clojure, you should get the 1.0 compat branch of contrib |
| 11:15 | stuartsierra | Either 1) get the latest Clojure from Git, or 2) get the clojure-1.0-compatible branch of contrib |
| 11:16 | cratuki | I used subversion to get trunkclojure - but maybe I should just get 1.0 |
| 11:16 | cratuki | thanks all |
| 11:17 | stuartsierra | Nothing on SVN any more; use github |
| 11:44 | Chouser | eevar: seems like a good idea. |
| 11:50 | cemerick | is there no way to simply eliminate those projects on GC? |
| 11:51 | Chouser | cemerick: a pointer to the new host might be preferrable |
| 11:52 | cemerick | that's already been the case, tho, for clojure, anyway (and people still grab from the GC svn there) |
| 11:52 | rhickey | both home pages have links to github and assembla, nuking the code on gc seems extreme |
| 11:52 | eevar | should point to clojure.org/source (or whatever the url is) imo |
| 11:52 | eevar | rather than github, in case it's ever moved again ;) |
| 11:54 | angerman | how will clojure benefit from JDK 7? |
| 11:54 | Chouser | except people seem to pretty frequently get the old code anyway. |
| 11:54 | eevar | rhickey: the repos show up in searches, tho |
| 11:54 | Chouser | and old blog posts and tutorials, etc. |
| 11:56 | stuartsierra | There may be useful stuff on Google Code, e.g. in the wiki, but this makes it very clear that the current source is on github. |
| 12:22 | angerman | I need some help with macros (again :/) |
| 12:23 | angerman | I think this piece of code qualifies to be macrofied: "(.getMinSelectionIndex (.getSelectionModel (.field this))))" |
| 12:23 | angerman | so I though i'd write (defmacro selection-of [field] `(.getMinSelectionIndex (.getSelectionModel (.field this)))) |
| 12:26 | Chousuke | hmm |
| 12:26 | Chousuke | you can use . directly if you want the field to vary. |
| 12:26 | stuartsierra | it would look like (. this ~field) in your back-quote |
| 12:29 | angerman | stuartsierra: but "this" sould be taken from outer scope right? a macro is (as far as i understand) a simple text-replacement during compiletime |
| 12:30 | Chousuke | it's not text-replacement. |
| 12:30 | Chousuke | clojure code is not text :) |
| 12:31 | replaca_ | stuartsierra (and everyone): most of the doc from google code is now available on github |
| 12:31 | stuartsierra | oh, then "this" should be an argument to your macro |
| 12:31 | replaca_ | (for contrib) |
| 12:31 | stuartsierra | replace_: ok |
| 12:31 | angerman | stuartsierra: can any way to implicitly have it bound? |
| 12:32 | Chousuke | angerman: if this is bound in the scope you call the macro in it should be fine. |
| 12:32 | replaca_ | the exceptions are the wiki pages for datalog and pretty printing/cl-format and they'll be there rsn |
| 12:32 | stuartsierra | If you have "this" locally let-bound, you can requote it. (. ~'this ~field) |
| 12:32 | replaca_ | one thing we need to add to github (if we haven't already) is a list of folks with commit privledges |
| 12:32 | angerman | Chousuke: I call it from withing a function clojure in a proxy |
| 12:33 | stuartsierra | should work |
| 12:35 | angerman | hmm. now it sais it can't find the symbol of the field |
| 12:35 | replaca_ | btw, stuartsierra, thanks for cleaning up GC -> that's been necessary for a while now |
| 12:35 | angerman | e.g. I have (defmacro selection-of [field] `(.getMinSelectionIndex (.getSelectionModel (. ~'this ~field)))) |
| 12:35 | Chousuke | angerman: anyway, thinking of macros as text replacement is wrong. Clojure code is data, and a macro call is part of the data structure that makes up a program. At macro expansion time, the compiler calls the macro function, replacing it with the data structure it returns. |
| 12:35 | angerman | and call it like (selection-of myfield) |
| 12:36 | angerman | Chousuke: ok. So it's intelligent text-replacement. :) |
| 12:36 | angerman | or data-structure replacement |
| 12:36 | Jomyoot | I think we are getting more mainstream |
| 12:36 | stuartsierra | maybe that should be (. ~'this '~field) |
| 12:38 | Chousuke | angerman: I guess. Code being data has some interesting consequences. |
| 12:40 | Chousuke | angerman: but the fact that clojure code is in text files is just a coincidence :P |
| 12:40 | angerman | Chousuke, stuartsierra thank you |
| 12:41 | Chousuke | angerman: I think some lisps have editors that don't work with text files at all; instead, they modify data structures directly. |
| 12:41 | clojurebot | They found no relationship between a programmer’s amount of experience and code quality or productivity. |
| 12:45 | stuartsierra | Chousuke: "Structured editors," I think, but they never caught on. |
| 12:46 | Chousuke | I suppose text is still the most convenient representation. |
| 12:46 | cemerick | Chousuke: that's intriguing. Seems like it'd be pretty straightforward in enclojure. |
| 12:46 | cemerick | angerman: everything dies eventually. |
| 12:48 | stuartsierra | Old languages never die, they just get ported. |
| 12:49 | cemerick | death is just the passing of flesh into memory.....and newer VMs? :-P |
| 12:49 | stuartsierra | Until we all reach that great Garbage Collector in the sky. :) |
| 12:55 | technomancy | is there a command-line arg to clojure.main that can automatically require a given namespace? |
| 12:56 | Chousuke | you can eval things with -e, right? |
| 12:56 | technomancy | right, but I want it to go to the repl after the require |
| 12:56 | Chousuke | I think -e works with the repl too |
| 12:56 | hiredman | -e something -r |
| 12:56 | technomancy | -r is repl? |
| 12:56 | Chousuke | or you can use an initfile with -i |
| 12:57 | technomancy | cool; thanks |
| 12:57 | hiredman | I think -r is repl, but --help will tell you for sure |
| 12:58 | technomancy | right on |
| 12:59 | technomancy | btw; was messing around over the weekend on JRuby/Clojure integration; turns out using STM from Ruby is absurdly easy: http://github.com/technomancy/clojure-gem/tree/master |
| 13:00 | hiredman | technomancy: you ever make it to seafunc? |
| 13:00 | technomancy | ruby blocks can be passed as fn args to alter refs and such; very nice |
| 13:00 | technomancy | hiredman: I've only gone once before, but I plan on going tonight. |
| 13:00 | hiredman | so it's cool? |
| 13:00 | technomancy | if you like geek talk. =) |
| 13:01 | technomancy | it's pretty low-key chatter, people come from quite a variety of backgrounds |
| 13:02 | cemerick | technomancy: so blocks implement callable? |
| 13:03 | technomancy | cemerick: yep. I think seeing that really helped me understand what a good idea interfaces are. |
| 13:03 | hiredman | I am intrigued by the move to chipotle |
| 13:03 | technomancy | cemerick: I was blown away by the fact that everything worked so seamlessly; was expecting it to be a lot more work. |
| 13:04 | cemerick | yeah, JRuby is pretty sane, and it sounds like it's going to get even better |
| 13:04 | mrsolo | oh? |
| 13:04 | stuartsierra | Just pushed new clojure-hadoop, now writes Hadoop jobs with no Java calls. http://github.com/stuartsierra/clojure-hadoop |
| 13:04 | technomancy | cemerick: especially sane compared to the standard 1.8 interpreter. =) |
| 13:05 | cemerick | yeah, I've no use at all for non-jvm stuff at this point. |
| 13:05 | mrsolo | well 1.8 is on its way out.... |
| 13:05 | technomancy | cemerick: you don't need any scripts that have subsecond launch times? =) |
| 13:06 | hiredman | cemerick: operates on the timescale of EONS |
| 13:06 | mrsolo | technomancy: :-) |
| 13:06 | cemerick | I've never done "scripting". |
| 13:06 | cemerick | hiredman: I *AM* Time. |
| 13:07 | Chouser | nearly everything I do is "scripting" |
| 13:07 | cemerick | that's why I never bother with big-O concerns, either: what's quadratic time mean, when you have eternity? ;-) |
| 13:08 | Chouser | I guess that's not quite true. 90% of the "apps" I write (by count) are "scripts". But that's probably 40% of my coding time. |
| 13:09 | hiredman | nailgun! |
| 13:09 | mrsolo | has issues! |
| 13:10 | hiredman | I think jruby ships with nailgun these days |
| 13:10 | mrsolo | heh |
| 13:10 | cemerick | this would be a great stand-up routine :-) |
| 13:10 | technomancy | hiredman: true. it'd be nice to not have to worry about having a server running though. |
| 13:10 | Chouser | surely a server could be started up automatically on demand. |
| 13:10 | mrsolo | well i doubt that will ever get resolved without nailgun type service |
| 13:11 | hiredman | technomancy: @reboot /home/kpd/bin/boot-nailgun in your crontab |
| 13:11 | hiredman | launches nailgun at boot |
| 13:12 | technomancy | hiredman: right, but you still need one ng server per clojure program |
| 13:12 | hiredman | :/ |
| 13:12 | technomancy | not saying it's not good, it's just not quite as nice as an instant-on JVM. |
| 13:21 | Anniepoo | I've got a situation that would be easy to deal with in an OO language, I'm wondering what a good design pattern is in an FP language |
| 13:22 | Anniepoo | I have a structmap that's a model in a GUI editor. it represents an object that will ultimately be uploaded to a virtual world |
| 13:23 | replaca_ | Dumb ant Q: how do I write a task that will exec "markdown foo.markdown > foo.html" for each foo.html in *.html? |
| 13:23 | replaca_ | this seems like it should be really easy, but I'm not seeing it |
| 13:23 | Anniepoo | the upload is modestly expensive/slow so it's only done when the user says |
| 13:24 | Anniepoo | I want to keep a needs-uploading bit and flip it when the object is changed |
| 13:25 | mrsolo | replica: (:require [clojure.contrib.shell-out :as shell]) |
| 13:25 | mrsolo | then (shell/sh .... ) |
| 13:26 | replaca_ | mrsolo: no not in clojure, in ant (thx) |
| 13:26 | technomancy | just feed it through the clojure-to-and compiler. =) |
| 13:26 | technomancy | yay turing-complete XML! |
| 13:27 | replaca_ | technomancy: every time I use ant I feel the motivation to write a clojure-based build system a la rake |
| 13:27 | replaca_ | don't think I'd target ant though |
| 13:28 | technomancy | good. =) |
| 13:28 | Anniepoo | every time I use ant I realize that build systems are just horribly wrong |
| 13:29 | mrsolo | naw success is built on previous mistakes |
| 13:29 | replaca_ | I think I may just end up writing a shell script to transform textile and markdown but that just seems so wrong |
| 13:31 | technomancy | worse than executable XML? |
| 13:32 | replaca_ | well, you'd think that a declarative build system would allow you to specify transformation rules. :-( |
| 13:32 | replaca_ | but at least being able to run a command on a bunch of files one at a time! |
| 13:32 | replaca_ | sigh, but I don't see how to do it. |
| 13:33 | replaca_ | the prob with a shell script is that it means *nix only (which is fine with me, but maybe not so good for all others) |
| 13:34 | replaca_ | oh well, off to a four hour mgmt meeting :-( |
| 13:36 | Anniepoo | hack lancet into what you need |
| 13:38 | replaca_ | Anniepoo: yeah, that's a *big* tangent! |
| 13:39 | lbj | Good evening gentlemen |
| 13:40 | Anniepoo | 8cD |
| 13:40 | Anniepoo | so, replaca, what do I do about my 'setFoo does something else' problem? |
| 13:40 | clojurebot | People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems.... |
| 13:41 | Anniepoo | LOL |
| 13:41 | Anniepoo | I agree with clojurebot |
| 13:41 | technomancy | clojurebot: what is XML? |
| 13:41 | clojurebot | c'est bon! |
| 13:41 | technomancy | clojurebot: XML is like violence; if it doesn't solve your problems, you're not using enough of it. |
| 13:41 | clojurebot | Alles klar |
| 13:41 | Chouser | ~what? |
| 13:41 | clojurebot | what is XML |
| 13:41 | technomancy | doh! |
| 13:42 | Chouser | :-) |
| 13:42 | technomancy | clojurebot: forget what |
| 13:42 | clojurebot | I forgot what |
| 13:43 | lbj | Bests one I heard about XML was something like "XML, reinventing s-exps since 1995" |
| 13:46 | lbj | (fine, pretend that wasnt funny) |
| 13:46 | Anniepoo | it's true |
| 13:46 | Anniepoo | in 96 or so I needed some more accessible way to manipulate the structure of non roman WorldScript fonts |
| 13:47 | Anniepoo | which are nasty huge nested structures |
| 13:47 | Anniepoo | I was actually working with SGML on another project at the time |
| 13:48 | cemerick | whoo, SGML |
| 13:48 | Anniepoo | but sanely decided we'd have a pair of C++ programs that converted to/from an s-expr |
| 13:49 | Anniepoo | There's probably STILL some poor mostly-writing-C++-occasionally-they-let-me-write-lisp programmer |
| 13:49 | Anniepoo | who thanks me every morning |
| 13:52 | lbj | Ah, trusty old ERC |
| 13:52 | Chouser | Hey, *I'm* a mostly-writing-C++-occasionally-they-let-me-write-lisp programmer |
| 13:52 | Chouser | Though I forgot to thank Anniepoo this morning |
| 13:53 | Anniepoo | LOL |
| 13:53 | Anniepoo | do you work for Apple's Text and International? |
| 13:54 | Chouser | do they employ anyone in Fort Wayne, IN? |
| 13:54 | clojurebot | They found no relationship between a programmer’s amount of experience and code quality or productivity. |
| 13:55 | Anniepoo | Don't think so |
| 13:55 | Chouser | well then I guess not. |
| 13:55 | Anniepoo | hey, clojurebot, I don't know who 'they' are, but |
| 13:55 | lbj | What was clojurebots latest quote based on ? |
| 13:57 | Chouser | hm. google finds nothing but clojurebot's brain |
| 13:58 | Anniepoo | anybody else find it a bit bizarre that we're arguing with a bot? |
| 13:58 | Chouser | http://www.codinghorror.com/blog/archives/000072.html |
| 13:58 | lbj | In my personal experience, I could actually find grounds to agree with Clojurebot, but I'd like some documentation behind it :) |
| 14:01 | Anniepoo | certainly I've met lots of programmers who have spent the last 20 years adding crap to one SAS program |
| 14:04 | Anniepoo | The productivity difference can depend on the domain |
| 14:04 | Anniepoo | I think often we undervalue the rather pedestrian virtue of knowing the local language/ide/etc. well |
| 14:04 | Anniepoo | but it's true that a mark of a good programmer over a bad one is that |
| 14:05 | Anniepoo | the good programmer, never having seen C# before and now confronted with writing something in it |
| 14:05 | Anniepoo | will get the job done in a reasonable amount of time |
| 14:06 | Anniepoo | and we spend more of our time learning new technologies than we usually recognize when we discuss how to program |
| 14:08 | hiredman | that they quote is triggered a lot |
| 14:09 | Anniepoo | so, now that more people are on, mind a repeat of my question from before? |
| 14:10 | Anniepoo | I've got a structmap that represents data I update to a virtual world only |
| 14:10 | Anniepoo | when they ask, so I have a dirty bit |
| 14:10 | Anniepoo | (they = user) |
| 14:11 | Anniepoo | in an OO language I'd just flip the bit in the setFoo method |
| 14:11 | technomancy | Anniepoo: sounds like a job for an atom |
| 14:11 | Anniepoo | no, this can be immutable |
| 14:12 | Anniepoo | I have a list of gidgets |
| 14:12 | Anniepoo | each gidget is a structmap with a bunch of keys |
| 14:12 | Anniepoo | the atom is the entire model |
| 14:13 | Anniepoo | (swap! my-model (fn [the-gidgets] (do-something the-gidgets))) |
| 14:15 | mebaran151 | so you want to set the dirty bit clean? |
| 14:15 | Anniepoo | no, I want to make sure that when do-something changes |
| 14:16 | Anniepoo | the value associated with :blah it also sets :dirty true for that gidget |
| 14:16 | hiredman | uh |
| 14:16 | Anniepoo | I have a local GUI editor. I draw up what I want, then upload it to the VW |
| 14:16 | hiredman | well, then whenever you update :blah set :dirty to true |
| 14:16 | Anniepoo | great |
| 14:17 | Anniepoo | now all I need is to have every programmer working on the project |
| 14:17 | Anniepoo | religiously do that without fail |
| 14:17 | Anniepoo | is there no way to encapsulate this? |
| 14:17 | hiredman | Anniepoo: yes |
| 14:17 | hiredman | it's called a "function" |
| 14:18 | Anniepoo | sure, I can make an accessor function |
| 14:18 | hiredman | and you can make an updator function |
| 14:18 | Chousuke | hmm |
| 14:19 | Anniepoo | but the members are public, it's Fred-the-not-so-swift or me-at-3-am that will fail to do it |
| 14:19 | Anniepoo | and just fiddle with the key |
| 14:19 | hiredman | you can group related functions in a namespace |
| 14:19 | Chousuke | Anniepoo: you can have a validator function on refs |
| 14:19 | kotarak | You can make a watch, which changes :dirty if :blah was changed. |
| 14:19 | hiredman | Chousuke: he is not using refs on a fine grained level |
| 14:20 | Anniepoo | kotarak, tell me more |
| 14:21 | Anniepoo | I could, I suppose, keep the last uploaded version of the db and figure out what to upload |
| 14:22 | kotarak | Anniepoo: Chousuke's idea is probably better. But maybe you can do: (def x (atom my-map)) (add-watch x :dirtyfy-watch (fn [x _ old new] (when (not= (:blah old) (:blah new)) (swap! x assoc :dirty true)))) |
| 14:22 | hiredman | Anniepoo: if you define a set of functions in a namespace that act as the interface for your datatype, I don't see what the problem is |
| 14:23 | Anniepoo | ah! |
| 14:23 | Anniepoo | I can make the actual defstruct private somehow? |
| 14:24 | Chousuke | Anniepoo: not really, but you can just tell people not to use the keys directly or things will break :) |
| 14:24 | kotarak | (defstruct #^{:private true} some-struct :a :b) |
| 14:24 | kotarak | Maybe there is a defstruct- in c.c.def. |
| 14:25 | Anniepoo | For some other reasons too uninteresting to go into here the 'keep the uploaded version' solution is a good one for me |
| 14:25 | kotarak | Docstrings are the contract. If they say: Don't use the keys! Well.. then don't use the keys. |
| 14:25 | Anniepoo | but Chousuke, isn't lack of data hiding a major problem as programs become large? |
| 14:26 | Chousuke | well, python does not do it. |
| 14:26 | Chousuke | it's only a problem if programmers try to bypass the API. |
| 14:26 | Anniepoo | ok |
| 14:27 | Anniepoo | so it means we're a little farther down on the drool-proof meter |
| 14:27 | Anniepoo | I can accept that |
| 14:27 | hiredman | Anniepoo: if you really really really want to complete hide the structure of your data you can use a closure |
| 14:27 | hiredman | but I think you should learn to live with encapsulation |
| 14:28 | Anniepoo | ok, cool |
| 14:29 | Chousuke | a watch might be able to do what you need, though. |
| 14:30 | kotarak | Chousuke: Do watches have some delay? That is: can one see the new value before all watches were called? |
| 14:30 | kotarak | If so, a validator is maybe the better idea. |
| 14:30 | Chousuke | hmm, right. |
| 14:30 | Anniepoo | currently I'm using an atom and swap! to access my model |
| 14:31 | Chousuke | every time someone updates the atom, you could go through it and assoc :dirty true to whatever changed. Of course, that will be O(n) so it's probably not that good if you have lots and lots of objects :/ |
| 14:31 | kotarak | And what happens, if one changes the IRef in the watch? I did that above, but I'm not sure it's allowed. |
| 14:31 | Chousuke | then again, you will probably be able to use identical? to check the data structures so *that* should be quick :) |
| 14:31 | Anniepoo | Yah, Chousuke, I'm actually gonna be lazy about it. It's a reasonably small structure |
| 14:32 | Anniepoo | I'll keep the last version uploaded to the VW around |
| 14:32 | Anniepoo | and the upload function will optimize on the fly |
| 14:32 | Anniepoo | 'don't need to upload that, already have one' |
| 14:32 | Anniepoo | because in this case there are several kinds of dirty |
| 14:33 | hiredman | Anniepoo: you could memoize the upload function :P |
| 14:33 | Anniepoo | no, that wouldn't work, I need to do it on a finer grain than that |
| 14:33 | Anniepoo | but I like the separation of concerns of being smart |
| 14:34 | Anniepoo | like, if the label on the gidget changes I have to upload a new texture |
| 14:34 | Anniepoo | which costs about 4 cents |
| 14:34 | Anniepoo | but if the object has just changed size I can just reshape it. |
| 14:37 | Anniepoo | hmm... actually, I do need to keep track. I forgot I'm visually distinguishing what needs uploading |
| 14:37 | Anniepoo | now that I think on it, I'm not so clear why I'm doing that |
| 14:53 | Anniepoo | anybody else using La Clojure? |
| 14:54 | Anniepoo | I'm seeing unreasonable amounts of computation if I try to start a repl and have an editor window tiwh a syntax error in it |
| 14:55 | ataggart | I tried but I couldn't grok IDEA's notion of projects/modules |
| 14:55 | ataggart | the eclipse plugin works well enough |
| 14:56 | Anniepoo | I've used IntelliJ for years, I'd have to pay a high price in lost learning to switch |
| 14:56 | ataggart | fair enough |
| 14:57 | ataggart | there's a forum for the plugin somewhere, might be worth asking Ilya about it |
| 14:57 | Anniepoo | yes, I posted a note |
| 14:59 | angerman | how would I construt an (all (true true true))? |
| 14:59 | Chouser | what's 'all'? |
| 14:59 | hiredman | every? |
| 14:59 | hiredman | ,(doc every) |
| 14:59 | clojurebot | "/;nil; " |
| 15:00 | hiredman | ,(doc every?) |
| 15:00 | clojurebot | "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false." |
| 15:00 | hiredman | I really need to fix that |
| 15:00 | hiredman | ,(every? true? '(true true true)) |
| 15:00 | clojurebot | true |
| 15:01 | angerman | nice |
| 15:01 | angerman | I came up with |
| 15:01 | angerman | ,(reduce #(and % %2) '(true true true)) |
| 15:01 | clojurebot | true |
| 15:01 | angerman | though every is probably better |
| 15:01 | hiredman | eh? |
| 15:01 | ataggart | (apply and '(true true true)) |
| 15:01 | hiredman | and is a macro |
| 15:01 | ataggart | bah |
| 15:01 | stuartsierra | Or if you don't want to accept any non-nil, non-false thing as true, (every? identity ...) |
| 15:01 | ataggart | havent had my coffee |
| 15:03 | angerman | no no. it should be only logical values :) |
| 15:03 | angerman | i'm basically running map over a collection and check if ... ohh that sounds like a stupid idea now. |
| 15:04 | Anniepoo | ,(doc and) |
| 15:04 | clojurebot | "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." |
| 15:04 | Anniepoo | you can and any number of things |
| 15:05 | Anniepoo | ,(apply and '(true true true)) |
| 15:05 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/and |
| 15:05 | hiredman | 12:04 hiredman : and is a macro |
| 15:05 | Anniepoo | 8cD now I know |
| 15:13 | Anniepoo | is there some library thingum that will do this? |
| 15:14 | Anniepoo | (foo pred fun seq) |
| 15:14 | ataggart | which "this" are you referring to? |
| 15:14 | ataggart | ah |
| 15:14 | ataggart | what's going on with that? |
| 15:14 | Anniepoo | where foo returns a seq whose elements are the same as in seq |
| 15:14 | hiredman | uh |
| 15:15 | hiredman | that is the point of that then? |
| 15:15 | kotarak | (map identity seq)? |
| 15:15 | ataggart | lol |
| 15:15 | Anniepoo | if pred (element) is false, and (fun element) if pred is true |
| 15:15 | Anniepoo | I'm writing lots of handlers that do something to my model |
| 15:16 | ataggart | (map #(if (pred %) % (fun %)) seq) |
| 15:16 | hiredman | ,(map #(if (number? %) (inc %) %) [1 :two 3 :four]) |
| 15:16 | clojurebot | (2 :two 4 :four) |
| 15:16 | kotarak | (map #(or (and (pred %) (f %)) %) seq) |
| 15:16 | Chouser | (map #(if (p e) (f e) e) s) |
| 15:16 | kotarak | does that work? |
| 15:16 | Chouser | oops, I said e when I meant % |
| 15:16 | ataggart | my logic was backwards |
| 15:17 | ataggart | but we're all saying the same thing |
| 15:17 | hiredman | mine was perfect |
| 15:17 | ataggart | as always, hiredman |
| 15:17 | Anniepoo | yah, I'm doing what Chouser says, just tired or reading it over and over |
| 15:19 | Chouser | (defn map-if [p f s] (map #(if (p %) (f %) %) s)) |
| 15:19 | Anniepoo | I guess I could make my own |
| 15:19 | Chouser | too late |
| 15:19 | Anniepoo | 8cD |
| 15:19 | Chouser | :-) |
| 15:19 | hiredman | ,(pl (↕map call · (⌽vector 1) $ :two $ 3 $ :four λx (if number? $ x inc $ x x))) |
| 15:19 | clojurebot | java.lang.Exception: Remove at top |
| 15:20 | hiredman | damn |
| 15:20 | hiredman | ,(pl (↕map [1 :two 3 :four] λx (if number? $ x inc $ x x))) |
| 15:20 | clojurebot | (2 :two 4 :four) |
| 15:20 | kotarak | hiredman: are you trying to port Haskell to Clojure? |
| 15:21 | mebaran151 | typed clojure? |
| 15:21 | hiredman | kotarak: the problem with that would be haskell's lazy eval |
| 15:21 | mebaran151 | you could all it Curry.... |
| 15:21 | mebaran151 | *call it |
| 15:33 | cemerick | holy hell, annotations are *insane* |
| 15:33 | Anniepoo | ?? |
| 15:33 | Anniepoo | as in Java annotations? |
| 15:34 | cemerick | yeah |
| 15:34 | ataggart | a terribly misused piece of tech |
| 15:34 | Anniepoo | You know, coming from mostly writing Java over the last ten years |
| 15:34 | Anniepoo | I feel like somebody who'se left a cult |
| 15:34 | Anniepoo | and is thinking 'what was I DOING thinking like that?' |
| 15:35 | mebaran151 | annotations are a bad bandaid for bad syntax |
| 15:35 | cemerick | they're mostly fine for "users" (e.g. throwing a @Whatever on a field is pretty simple, straightforward way to compose functionality), but it's incredibly complex on the back end and the abstraction leaks hard outside of the simple cases. |
| 15:35 | Anniepoo | annotations are mostly used for javadoc, which everybody seems to agree is lame, and |
| 15:36 | ataggart | and there's a tendency for people to abuse annotations beyond metadata, and start using it as configuration |
| 15:36 | angerman | can I have only one additional argument? |
| 15:36 | Anniepoo | and J2EE, which is a bandaid on a piece of horribly broken technology |
| 15:37 | cemerick | Anniepoo: that is probably overly broad. JMS is a pretty fine piece of kit. |
| 15:38 | baetis-fly | i swore I saw a nifty function that would show the source code to another function but now i can't find it. did i imagine that? |
| 15:38 | Anniepoo | =8cO |
| 15:38 | kotarak | baetis-fly: clojure.contrib.repl-utils/source |
| 15:38 | mebaran151 | yep source |
| 15:38 | mebaran151 | it's a fun function |
| 15:39 | ataggart | angerman: you can have multiple arguments (name="value") in an annotation |
| 15:40 | mebaran151 | I often wish clojure had a more general source, like toSource in JS |
| 15:40 | baetis-fly | kotarak, mebaran151: many thanks. didn't think to look in contrib for some reason. |
| 15:40 | mebaran151 | seems like if functions really are data, they should have a printable structure that looks less like comic book swearing and is more generally useful |
| 15:41 | hiredman | well |
| 15:41 | kotarak | It's a two-edged sword. It's easy to rely on the implementation... |
| 15:41 | hiredman | you would need to decompile them |
| 15:41 | Chouser | clojure functions used to be data, until they were compiled |
| 15:42 | mebaran151 | I understand why they're compiled but this is lisp |
| 15:42 | Chouser | and even if you hang onto the pre-compiled forms, you lose formatting, comments, etc. |
| 15:42 | mebaran151 | I was thinking more for something akin to serialization |
| 15:43 | mebaran151 | I wouldn't expect data to keep its superficial representation |
| 15:43 | mebaran151 | they have javascript bytecode interpreters that can uneval |
| 15:43 | clojurebot | http://homepages.inf.ed.ac.uk/kwxm/JVM/codeByNo.html |
| 15:43 | hiredman | clojurebot: good catch |
| 15:43 | clojurebot | Pardon? |
| 15:50 | Anniepoo | hmm... is there a way to get a "serialized" form? As in a string representation of it? |
| 15:50 | Anniepoo | user=> (str (repeat 0 10)) |
| 15:50 | Anniepoo | "clojure.lang.LazySeq@0" |
| 15:51 | lpetit | Hi |
| 15:52 | hiredman | Anniepoo: prn-str |
| 15:52 | Anniepoo | thanks |
| 15:52 | lpetit | Maybe you know this out of your head: do you know if there is an already existing function (in core or contrib), presumably called 'map-keys , which takes a fn, a map, and returns a new map with every value mapped to (fn old-key) (the caller having to ensure that fn is injective, of course) |
| 15:55 | hiredman | ,(let [m {:a :b 2 :c 3}] (reduce #(update-in %1 [%2] inc) m (keys m))) |
| 15:55 | clojurebot | 5 |
| 15:55 | hiredman | bah |
| 15:55 | stuartsierra | hmm, (defn map-keys [f map] (reduce (fn [m [k v]] (assoc m (f k) v)) {} map) |
| 15:55 | hiredman | ,(let [m {:a 1 :b 2 :c 3}] (reduce #(update-in %1 [%2] inc) m (keys m))) |
| 15:55 | clojurebot | {:a 2, :b 3, :c 4} |
| 15:55 | hiredman | there must be something in contrib |
| 15:56 | stuartsierra | oh, wait, just (zipmap (map f (keys m)) (vals m)) |
| 15:56 | stuartsierra | assuming keys and vals return use the same order |
| 15:57 | Chousuke | or (into {} (map (fn [[k v]] [(f k) v]) the-map)) |
| 15:58 | ataggart | woot, my first contribution toclojure-contrib is in github |
| 15:58 | mebaran151 | I wish there were a better way of managing clojure contrib: it seems very hodge podgy |
| 15:58 | mebaran151 | kind of the inspiration for a packaging system: so every one could mix and match in their own contrib |
| 15:59 | Chousuke | if you have suggestions, bring them up on the group. |
| 15:59 | ataggart | we have plenty of suggestions; better would be to write it :) |
| 15:59 | Chousuke | On IRC things tend to just get mentioned and then no-one does anything :) |
| 16:00 | mebaran151 | heh |
| 16:01 | ataggart | if anyone is bored and wants to critique the contrib logging code, please feel free. |
| 16:01 | mebaran151 | a co worker of mine is actually going to test his search stuff against a database clojure libs, both in contrib and out |
| 16:01 | mebaran151 | he was the scheme guy, so he's been spoiled by wacky package management systems |
| 16:02 | baetis-fly | /quit |
| 16:03 | lpetit | Guys, I had a break for some minutes, and you implemented the functions, thanks but it was already done on my side :-) I was just trying to clean my code, and especially trying to not reinvent some clojure or clojure-contrib wheel :-) |
| 16:04 | hiredman | I think there should be more jars |
| 16:05 | hiredman | you should not wait until you have a whole app and roll at all up into one jar |
| 16:05 | hiredman | have a namespace and 10 functions? make a jar |
| 16:05 | lpetit | So map-keys (or whatever better name) is not already in contrib ? |
| 16:05 | rhickey | aargh - google is not helping me find my old message re: seqable?, anyone with better email/rss tools able to do so? |
| 16:06 | hiredman | seems like something for clojure.contrib.map-utils |
| 16:08 | mebaran151 | hiredman, pretty much agreed |
| 16:08 | achim | rhickey: "Re: A nil puzzle" from 2009-01-25 - that one? |
| 16:09 | mebaran151 | he's actually thinking of doing something, indexing packages at the funciton level and tracking imports in the ns declarations |
| 16:09 | mebaran151 | *something cool |
| 16:09 | Anniepoo | Rich, I've been looking for a La Clojure user for a while. It's rumored you're an IntelliJ user |
| 16:09 | mebaran151 | then you could pull only the namespaces that seem to reference things you'd like |
| 16:11 | Chouser | rhickey: dunno if this is the one you're thinking of: http://groups.google.com/group/clojure/msg/ea899cfd965744a8 |
| 16:12 | lpetit | hiredman: you think it's of sufficient general utility to be a contribution (I can make that, little contribution, to get started with the new Assembla stuff I haven't used yet) |
| 16:12 | Chouser | rhickey: I have yet to find better than using google web search to find messages at mail-archive.com, and then trying to find that specific message back over in the google group ui. |
| 16:12 | Raynes | Anniepoo: He's hiding it from us! |
| 16:12 | Anniepoo | LOL |
| 16:12 | Raynes | Anniepoo: Looks like we'll have to break into his house and search his computer. >:) |
| 16:12 | Anniepoo | well, I feel bad - I ask noob questions and the only one who answers is Chris Houser |
| 16:13 | Anniepoo | and now I'm having an IDE problem and the only user of my IDE I can find is Rich Hickey |
| 16:14 | Raynes | I use IntelliJ too, I just don't have it on this computer. I'm not sure which I would use if it was on this computer right now however, now that I'm accustomed to emacs. |
| 16:14 | mebaran151 | Anniepoo, I know it seems like a step down, but you might look at Netbeans |
| 16:14 | mebaran151 | it has a pretty sweet plugin |
| 16:14 | Raynes | The IntelliJ plugin, the last time I checked, was a quite a bit far ahead of the NetBeans plugin. |
| 16:14 | mebaran151 | really? |
| 16:14 | mebaran151 | I actually found the netbeans plugin surprisingly competent |
| 16:14 | rhickey | Chouser, achim: it's older than those, arguing against seqable? with the example that strings were once not |
| 16:15 | Raynes | However, I'm not quite up to date with Enclojure because I can't get it to install on my PHP installation of NB 6.7 |
| 16:15 | mebaran151 | hmmm a php install.... |
| 16:15 | kotarak | rhickey: that's mentioned in the message Chouser posted |
| 16:15 | mebaran151 | I got running on a ruby install of netbeans |
| 16:16 | mebaran151 | it does all the basic things you could ask for, except its code completion leaves a little to be desired |
| 16:16 | Anniepoo | I like the La Clojure plugin, but at times it goes berzerk |
| 16:16 | kotarak | quote: There was a time when Strings weren't |
| 16:16 | kotarak | "seqable", now they are. |
| 16:16 | mebaran151 | then again, I rarely used code completion |
| 16:16 | Anniepoo | I get 100% CPU for a minute or so |
| 16:17 | Anniepoo | Sergey actually owes me a power supply, I burnt one out doing this |
| 16:17 | Anniepoo | LOL |
| 16:17 | Raynes | mebaran151: It seems like, if there is any possibility of a problem emerging, I will find that problem in Enclojure, and no one else will be able to reproduce it. :| |
| 16:17 | mebaran151 | have you tried a Java install of Netbeans |
| 16:17 | rhickey | kotarak: I guess so, it's just such a big discussion otherwise, I know I made that same point earlier in a smaller message |
| 16:17 | mebaran151 | you can add the php stuff later as plugins |
| 16:17 | Raynes | No, too lazy. |
| 16:18 | mebaran151 | try adding the java stuff |
| 16:18 | mebaran151 | enclojure probably needs the java integration to do its job |
| 16:18 | Raynes | It pulls it down automatically, and I tried pulling it down myself, nothing works. |
| 16:18 | hiredman | speaking of php I got my php.lisp "compiler" to generate php function backed objects as closures |
| 16:19 | mebaran151 | that's pretty neato |
| 16:20 | mebaran151 | have you tried hosing your .netbeans dir? |
| 16:20 | mebaran151 | I'm a unix person, so destroying all valuable data is always my first recourse :) |
| 16:21 | Raynes | mebaran151: The only way I can restart netbeans is by nuking the .netbeans dir. |
| 16:21 | Raynes | Otherwise NB wont even say hello. |
| 16:22 | kotarak | rhickey: http://markmail.org/message/56r3eflx4a6tasoe |
| 16:22 | kotarak | maybe? |
| 16:22 | mebaran151 | hah |
| 16:22 | rhickey | kotarak: wins |
| 16:22 | rhickey | thanks |
| 16:22 | kotarak | np |
| 16:24 | rhickey | lead to this which is the one I remembered: http://groups.google.com/group/clojure/msg/fc3cd6e81c9afb8d |
| 16:30 | rhickey | heh, now I can't get the ggroup msg ID of http://markmail.org/message/56r3eflx4a6tasoe |
| 16:30 | rhickey | why is ggroup history so shallow? |
| 16:32 | stuartsierra | funny, google web search finds the markmail URL, but nothing on Groups |
| 16:34 | achim | rhickey: http://groups.google.com/group/clojure/browse_thread/thread/b2aa24dd1a86102f# |
| 16:34 | achim | google should really be better at searching |
| 16:35 | rhickey | achim: thanks, found how? |
| 16:36 | rhickey | I went through my profile, which had a link for that month, but got tired after showing me only 4 pages |
| 16:37 | achim | played with the offset in the url, manual binary search :) |
| 16:37 | rhickey | achim: yikes |
| 16:37 | hiredman | :/ |
| 16:37 | cemerick | I call shenanigans ;-P |
| 16:38 | stuartsierra | I had no idea Google Groups had such crappy search. |
| 16:38 | Chouser | gmail is also surprisingly bad |
| 16:38 | stuartsierra | So the string in the URI is like a hexadecimal timestamp? |
| 16:39 | rhickey | stuartsierra: I think they are just limiting the window of time in the index for ggroups, I could find in my gmail once I used "seq-able?" |
| 16:39 | cemerick | I don't understand why the geek hipsters aren't beating a path to not-google at this point. |
| 16:39 | stuartsierra | But at least gmail doesn't "forget" old messages. |
| 16:39 | stuartsierra | cemerick: It's like Churchill said of democracy, it's the worst system except for all the others. |
| 16:40 | cemerick | *shrug* I've been using yahoo search primarily for about 2 months now with good results. |
| 16:40 | rhickey | it's kind of silly they would keep the index for each gmail user but not the 2200 people sharing the group |
| 16:40 | stuartsierra | yes |
| 16:40 | stuartsierra | But Groups has long been the least reliable of Google services. |
| 16:53 | dysinger | Is this the way things are supposed to go? I imagine this is because byte[] is an Object and object's default equals is =. |
| 16:54 | dysinger | (= (.getBytes "hello") (.getBytes "hello")) |
| 16:54 | dysinger | false |
| 16:54 | dysinger | (= (String. (.getBytes "hello")) (String. (.getBytes "hello"))) |
| 16:54 | dysinger | true |
| 16:54 | dysinger | I am rusty at java :P |
| 16:54 | mebaran151 | I thought Object equals just compared the pointers |
| 16:55 | mebaran151 | whereas strings got special overloadinjg |
| 16:55 | kotarak | I think that's identical? |
| 16:55 | Anniepoo | no, to get proper string compaer in Java you have to use .equals |
| 16:55 | Anniepoo | == won't do it |
| 16:55 | Anniepoo | 8cD A common source of bugs |
| 16:56 | Chouser | but Clojure = uses Java .equals |
| 16:56 | hiredman | ,(= (seq (.getBytes "hello")) (seq (.getBytes "hello"))) |
| 16:56 | clojurebot | true |
| 16:56 | mebaran151 | I thought that Object.equals works on pointer equality |
| 16:56 | Anniepoo | yes |
| 16:56 | hiredman | ,(.equals (.getBytes "hello") (.getBytes "hello")) |
| 16:56 | clojurebot | false |
| 16:56 | rhickey | = uses equals(), which is a value comparison for strings and identity for arrays |
| 16:56 | cemerick | ,(java.util.Arrays/equals (.getBytes "foo") (.getBytes "foo")) |
| 16:56 | clojurebot | true |
| 16:56 | mebaran151 | and you had to override equals to get semantic equals |
| 16:59 | lpetit | What does == add to = since it seems = can also be used with numbers ? |
| 17:00 | cemerick | == is object-identity |
| 17:00 | cemerick | ,(identical? "foo" (str "fo" "o")) |
| 17:00 | clojurebot | false |
| 17:00 | cemerick | (= "foo" (str "fo" "o")) |
| 17:00 | lpetit | ,(== 0 0.0) |
| 17:00 | cemerick | ,(= "foo" (str "fo" "o")) |
| 17:00 | clojurebot | true |
| 17:00 | clojurebot | true |
| 17:00 | Chouser | Clojure == can inline primitive args |
| 17:01 | Chouser | Clojure = always boxes |
| 17:01 | lpetit | So == is optimized for numbers ? Not very clear on the documentation |
| 17:01 | lpetit | ,(doc ==) |
| 17:01 | clojurebot | "([x] [x y] [x y & more]); Returns non-nil if nums all have the same value, otherwise false" |
| 17:02 | cemerick | == returns false if any arg is a non-number, I thought |
| 17:03 | Anniepoo | == is optimized for pointer compare |
| 17:03 | Anniepoo | (sorry, thought u were talking java) |
| 17:04 | lpetit | cemerick: certainly, but as soon as one finds =, reads its doc, sees that it can handle numbers, I'm not sure one will then search again to find something more specific to numbers. Maybe making == and = docs self referencing could be an improvement |
| 17:04 | cemerick | yeah, perhaps |
| 17:04 | dysinger | Yeah the == doesn't say it does anything different than = |
| 17:04 | dysinger | on the website |
| 17:05 | dysinger | it uses value |
| 17:05 | lpetit | Is it worth an issue and a patch ? I can do that |
| 17:05 | rhickey | lpetit: sure |
| 17:06 | dysinger | cemerick: thanks for reminding me about Arrays/equals |
| 17:06 | dysinger | dang I am rusty at teh java |
| 17:06 | cemerick | you can forget all your java. The jvm stuff, on the other hand, is worth knowing as best you can. |
| 17:07 | cemerick | not that I'm a great example of that, but.... |
| 17:08 | Chouser | I'm getting a NPE in a proxy method -- after the object has been called (the object itself is non-null) but outside the appropriate fn. |
| 17:08 | technomancy | = for array identity is news to me |
| 17:08 | technomancy | would not have guessed that |
| 17:10 | Anniepoo | ilyas, are you the creator of La Clojure? |
| 17:11 | lpetit | technomancy: are you talking about arrays or clojure vectors ? |
| 17:11 | lpetit | technomancy: I mean <java> arrays |
| 17:12 | technomancy | lpetit: right, I understand. it just means one more reason to avoid using Java arrays for anything but the closest layer of code that touches Java. |
| 17:13 | lpetit | t> ,(= (into-array String ["la" "clojure"]) (into-array String ["la" "clojure"])) |
| 17:13 | lpetit | ,(= (into-array String ["la" "clojure"]) (into-array String ["la" "clojure"])) |
| 17:13 | clojurebot | false |
| 17:13 | lpetit | technomancy: I would say it also mean use precise terminology and stick with the word "vector" Rich uses all over the clojure doc :-) |
| 17:14 | lpetit | :-p |
| 17:14 | cemerick | heh, just as I open my mouth about how I've been enjoying yahoo search, they go and white-label bing. :-P |
| 17:14 | technomancy | lpetit: yeah, I'm not interchanging the two. |
| 17:15 | lpetit | technomancy: sorry, no offense intended |
| 17:16 | technomancy | of course. =) |
| 17:19 | angerman | how would I split and strip a string? |
| 17:19 | angerman | "foo, bar" -> "foo" "bar" |
| 17:19 | technomancy | angerman: re-split from contrib's str-utils maybe |
| 17:20 | angerman | technomancy: hmm... let's see |
| 17:21 | Chouser | ,(map #(.trim %) (.split " foo , bar " ",")) |
| 17:21 | clojurebot | ("foo" "bar") |
| 17:24 | technomancy | I'm looking at character detection libraries, anyone have thoughts on choosing between jchardet, cpdetector and juniversalchardet? |
| 17:25 | technomancy | juniversalchardet is a port of Mozilla's algorithm, which I'd guess is pretty state-of-the-art |
| 17:25 | angerman | hmm... why are there str-utils and str-utils2? |
| 17:26 | technomancy | angerman: double the fun! |
| 17:38 | Anniepoo | ilyas, are you the creator of La Clojure? |
| 17:39 | Chouser | Caused by: java.lang.NullPointerException at clojure.proxy.my-pkg.MyClass.MyMethod(Unknown Source) |
| 17:39 | dysinger | angerman did you get your answer? |
| 17:39 | Chouser | I guess that's asm-generated code from proxy? |
| 17:40 | dysinger | angerman: here's my fugly one |
| 17:40 | dysinger | user> (let [tokenizer (java.util.StringTokenizer. "hello, there, partner" ",")] |
| 17:40 | dysinger | (for [tokens (range (.countTokens tokenizer))] |
| 17:40 | dysinger | (.trim (.nextToken tokenizer)))) |
| 17:40 | dysinger | |
| 17:40 | dysinger | |
| 17:40 | dysinger | ("hello" "there" "partner") |
| 17:40 | dysinger | user> |
| 17:41 | rhickey | Chouser: looks like proxy code |
| 17:41 | cemerick | Chouser: yeah, but it's probably not a bytecode-generation problem -- I've seen similar things when passing nil when the proxy needs a boxed number. |
| 17:41 | cemerick | (or when it needs to return a boxed number) |
| 17:41 | Chouser | hm... |
| 17:59 | bhurt_ | Have a stupid question: what am I doing wrong: |
| 17:59 | bhurt_ | $ ./repl.sh |
| 17:59 | bhurt_ | Clojure 1.1.0-alpha-SNAPSHOT |
| 17:59 | bhurt_ | user=> (def x 1) |
| 17:59 | bhurt_ | #'user/x |
| 17:59 | bhurt_ | user=> (binding [x 4] (inc x)) |
| 17:59 | clojurebot | x is w |
| 17:59 | bhurt_ | 2 |
| 17:59 | bhurt_ | user=> |
| 18:01 | Chousuke | bhurt_: weird. Works for me. |
| 18:01 | Anniepoo | On the 19th bay area java users sig will be having a clojure hack |
| 18:01 | Chouser | cemerick: you nailed it |
| 18:02 | cemerick | nice |
| 18:02 | Chouser | cemerick: the java method is supposed to return a bool, but my proxy fn was returning nil |
| 18:02 | cemerick | yeah, that's a java beating you around the head and ears. The autoboxing impl is sorta evil on the edges. |
| 18:06 | bhurt_ | Hmm. Looks like a bug in the version of Clojure I have. Unfortunate. But easily fixable. |
| 18:06 | bhurt_ | Grabbed a copy of 1.0 and it works as expected. |
| 18:08 | Chouser | bhurt_: that must be some odd version of clojure you've got there. |
| 18:10 | bhurt_ | Not sure where I got it, but it has -alpha-snapshot in the release name. |
| 18:11 | rhickey | Chouser: you could compile in a call to RT.booleanCast if rtype is boolean instead of gen.unbox, in both gen-class and proxy |
| 18:13 | ataggart | if, during a dosync transaction, I read a value from a ref, will the same value akways be returned if the tx is retried, or will I get whatever is the latest value of the ref? |
| 18:13 | cemerick | not sure about that idea -- silently promoting nil to false seems like a recipe for producing harder-to-find-bugs... |
| 18:13 | rhickey | going to Java normally I can't do that, too many conflicts with overloading, no ambiguity on return |
| 18:14 | rhickey | cemerick: on return, really? |
| 18:15 | rhickey | ataggart: a retry is a new point in time, so things might have changed |
| 18:15 | ataggart | rhickey: thanks |
| 18:19 | ataggart | aaaaand it turns out the concern behind that question was moot, since ref-set doesn't have any effect if the tx is retried. I'm not yet used to *not* worrying about order-of-operations w.r.t. concurrent code. |
| 18:19 | lpetit | While filing the issue for the doc improvement of == and =, I thought : is it ok for == to return false if one of its arguments is not a number ? Shouldn't it be considered a bug from the programmer, and shouldn't we throw an IllegalArgumentException instead ? |
| 18:20 | lpetit | That is (== "hi" 1) would throw IllegalArgumentException, and also (more interesting), (== "hi" "hi") would throw the exception, instead of just returning false (which could then be a rampant bug) |
| 18:20 | ataggart | what woudl you say the answer is in java for ("A" == 5) |
| 18:21 | hiredman | rhickey: did you ever think about lexically scoping namespaces? like (ns same.ns (defn f [x] x)) ? |
| 18:21 | lpetit | hiredman: same as modules in scheme ? |
| 18:21 | ataggart | lpetit: that (== 5 foo) is only true if foo is a number and foo is 5 has no bearing on other values of foo. |
| 18:22 | lpetit | ataggart: the doc of == places an almost explicit pre-condition that arguments must be numbers. Not so for java == |
| 18:22 | hiredman | lpetit: never really used scheme |
| 18:22 | ataggart | the precondition is only for when the result can be "true" |
| 18:22 | ataggart | else everything is false |
| 18:22 | lpetit | hiredman: me too, really, just wondering :-) |
| 18:23 | lpetit | ,(doc ==) |
| 18:23 | clojurebot | "([x] [x y] [x y & more]); Returns non-nil if nums all have the same value, otherwise false" |
| 18:23 | rhickey | lpetit: can't, since equiv is used in scenarios where equals is, and must similarly not fail |
| 18:23 | lpetit | ataggart: "if nums all have" => it's pretty clear to me, args are expected to be nums |
| 18:23 | ataggart | I should be able to do |
| 18:23 | ataggart | ,(filter #(== 5) '("a" 5 "b" 5)) |
| 18:23 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5788$fn |
| 18:23 | ataggart | ,(filter #(== 5 %) '("a" 5 "b" 5)) |
| 18:23 | clojurebot | (5 5) |
| 18:24 | ataggart | I shouldnt be forced to handle an exception there |
| 18:24 | rhickey | lpetit: I think it used to blind cast to Number and throw |
| 18:24 | lpetit | rhickey: what is "equiv", is it the literal name for == ? |
| 18:25 | rhickey | lpetit: follow the source |
| 18:25 | lpetit | rhickey: sorry for my english, literal is not the right word I think |
| 18:27 | lpetit | rhickey: even more weird, look : |
| 18:27 | lpetit | ,(== "hi") |
| 18:27 | clojurebot | true |
| 18:27 | lpetit | ,(== "hi" "hi") |
| 18:27 | clojurebot | false |
| 18:27 | lpetit | :$ |
| 18:28 | lpetit | rhickey: padawan currently following the source |
| 18:28 | lpetit | :) |
| 18:28 | rhickey | the improved docs should make it clear not to do that :) |
| 18:30 | lpetit | rhickey: something like "unspecified behaviour if used with non numbers args" ? |
| 18:30 | rhickey | i.e. == is a numbers op only for when working with known numbers, in all other cases use = |
| 18:31 | rhickey | i.e. in ataggart's case above using == is not a good idea |
| 18:32 | rhickey | lpetit: most of Clojure has unspecified behavior if used incorrectly, I really don't like specifying 'unspecified' |
| 18:32 | lpetit | rhickey: ok. |
| 18:34 | lpetit | rhickey: a last word please: could == benefit from the new precondition machinery, though ? (I'm not volunteering to make a global pass on clojure.core, still just focusing on == :-) ) |
| 18:35 | replaca_ | lpetit: have you digested the stuff I wrote about how pprint works? Did that help? |
| 18:37 | rhickey | lpetit: == returns true if x and y are 2 equivalent numbers, false otherwise |
| 18:38 | lpetit | rhickey: ok. Thanks for all. |
| 18:39 | lpetit | replaca_: I'm so sorry, but I had vacations, and then Howard unveiled a bad performance bug that stuck me. Still on it, since the way to solve it could have deep implications in the current implementation of clojuredev. |
| 18:41 | lpetit | replaca_: but it gave me time to think about it "offline", and I don't think I'm ready to follow this path, finally. At least not in a first implementation. |
| 18:41 | gulagong__ | hi |
| 18:41 | lpetit | We finally have 2 remaining challengers for the new name of clojuredev --> coming soon :-) |
| 18:42 | mebaran151 | how would one functionally transform a Number into a byte array? |
| 18:43 | mebaran151 | I'm thinking of something like 60 bytes per number with 4 bytes or so to describe the mantissa |
| 18:44 | gulagong__ | i just wrote a macro which takes a binding-list and while doing so i discovered that there is some kind of restriction for binding-lists....? |
| 18:44 | hiredman | binding-list? |
| 18:44 | gulagong__ | mom |
| 18:45 | gulagong__ | i post the code... |
| 18:45 | lpetit | rhickey : docs for >=, <=, also state "... non nil" , should I replace it with "true" while I'm at it ? |
| 18:45 | hiredman | lisppaste8: url? |
| 18:45 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 18:46 | lisppaste8 | gulagong__ pasted "matrix multiplication" at http://paste.lisp.org/display/84411 |
| 18:47 | gulagong__ | ok :) |
| 18:47 | replaca_ | lpetit: ok, cool |
| 18:47 | gulagong__ | the problem is, that this is not possible: |
| 18:48 | gulagong__ | (mat-mult '(0 0) matrix #(somefn)) |
| 18:48 | hiredman | well |
| 18:48 | gulagong__ | it will only accept vecs as first argument |
| 18:48 | hiredman | the problem there is you are calling the wrong macro |
| 18:48 | lpetit | replaca_: well, not so cool, I wish I had some more time to work on it, I would surely have followed the pprint path more before making my choice :-( |
| 18:48 | hiredman | the name of the macro you posted is mat-map |
| 18:49 | gulagong__ | d'oh |
| 18:49 | gulagong__ | i mean mat-map |
| 18:49 | gulagong__ | mean.... english.... |
| 18:49 | gulagong__ | i wanted to write mat-map |
| 18:49 | hiredman | gulagong__: what is the exeption that you get? |
| 18:51 | gulagong__ | Unsupported binding form: (k g) |
| 18:51 | hiredman | are you absolutly sure that exception comes frim this macro? |
| 18:51 | hiredman | are there any other macros you are using? |
| 18:52 | gulagong__ | if i do (mat-map '(k g) matrix fn) |
| 18:52 | gulagong__ | nope, just this macro |
| 18:52 | hiredman | I don't see where that exeception could come from in this macro |
| 18:52 | replaca_ | lpetit: yeah, I understand. That's a hard problem, though. At some point, I may do some general framework work in that direction myself. But I don't have the time either now. |
| 18:52 | gulagong__ | this works: (mat-map [k g] matrix fn) but this doesn't: (mat-map '(k g) matrix fn) |
| 18:53 | lpetit | ,(<= 1 2 :a) |
| 18:53 | clojurebot | java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number |
| 18:53 | lpetit | ,(<= 2 1 :a) |
| 18:53 | clojurebot | false |
| 18:53 | hiredman | gulagong__: can you paste the output of (macroexpand-1 '(mat-map '(k g) matrix fn)) |
| 18:54 | gulagong__ | a lot of gensyms ;) |
| 18:54 | gulagong__ | (clojure.core/let [size-y__15045__auto__ (clojure.core/count matrix) size-x__15046__auto__ (clojure.core/count (clojure.core/first matrix)) top-i__15047__auto__ (clojure.core/- size-y__15045__auto__ 1)] (clojure.core/loop [quote (clojure.core/int 0) (k g) (clojure.core/int 0) mat__15048__auto__ matrix] (if (clojure.core/= (k g) size-x__15046__auto__) mat__15048__auto__ (clojure.core/let [zero-i?__15049__auto__ (clojure.core |
| 18:54 | gulagong__ | /= quote top-i__15047__auto__)] (recur (clojure.core/int (if zero-i?__15049__auto__ 0 (clojure.core/inc quote))) (clojure.core/int (if zero-i?__15049__auto__ (clojure.core/inc (k g)) (k g))) (clojure.core/assoc-in mat__15048__auto__ [quote (k g)] (fn (clojure.core/get-in mat__15048__auto__ [quote (k g)])))))))) |
| 18:54 | hiredman | uh |
| 18:54 | hiredman | gulagong__: paste to the pastbin |
| 18:54 | hiredman | not the channel |
| 18:55 | gulagong__ | to paste.lisp.org? |
| 18:55 | hiredman | gulagong__: if you go to your previous paste there is a button at the top of the page "Annote this paste" |
| 18:56 | gulagong__ | hiredman: thanks, i paste some more code so you can see for yourself :) |
| 18:56 | hiredman | for feature reference, always paste to a pastebin |
| 18:56 | hiredman | future |
| 18:57 | lisppaste8 | gulagong__ annotated #84411 "untitled" at http://paste.lisp.org/display/84411#1 |
| 18:57 | hiredman | uh |
| 18:57 | gulagong__ | hiredman: funk takes only one arg |
| 18:57 | hiredman | that is not what I asked for |
| 18:58 | hiredman | anyway, (k j) is litered through out your macro expansion |
| 18:59 | hiredman | I would check to make sure the code you pasted is really what is being run (did you edit the macro and not re-evaluate it) |
| 18:59 | gulagong__ | yap |
| 19:00 | hiredman | I would start from scratch |
| 19:00 | hiredman | that is a complex macro |
| 19:00 | gulagong__ | (mat-map '(i j) (create-matrix (double 0) 3 3) #(+ %1 i j)) |
| 19:00 | gulagong__ | doesn't work |
| 19:00 | hiredman | so start from scratch, testing as you go to make sure the output is correct |
| 19:00 | lpetit | git expert around here? |
| 19:00 | gulagong__ | the macro works... |
| 19:01 | hiredman | gulagong__: if it works then what is your question? |
| 19:01 | gulagong__ | but i don't see why i shouldn't use a list instead of a vector |
| 19:02 | gulagong__ | (mat-map [i j] ..... |
| 19:02 | gulagong__ | works perfect |
| 19:02 | lpetit | I've added a file in the index. I would like to see the diff between the index content and the commit onto which I'm working. git diff doesn't work |
| 19:02 | hiredman | gulagong__: [i j] is valid in side a let |
| 19:03 | hiredman | as a name |
| 19:03 | hiredman | (i j) is not |
| 19:03 | hiredman | so inside your macro something is expand to something like (let [(i j) foo] ) |
| 19:03 | hiredman | which is not valid |
| 19:03 | gulagong__ | no |
| 19:03 | hiredman | Yes |
| 19:03 | gulagong__ | look at the first two lines |
| 19:03 | hiredman | gulagong__: something like! |
| 19:04 | hiredman | something like! |
| 19:04 | hiredman | not exactly that |
| 19:04 | gulagong__ | (let [i (first bindings)] |
| 19:04 | lpetit | Ok, found it : git diff --cached or git diff HEAD in my case |
| 19:04 | hiredman | gulagong__: look at the macro expansion for the macro |
| 19:05 | hiredman | you will see something similar in form to (loop [(x y) something] |
| 19:05 | hiredman | where x and y are some symbols |
| 19:06 | gulagong__ | hiredman: ok, i will try |
| 19:06 | hiredman | clojurebot: destructuring |
| 19:06 | clojurebot | destructuring is http://clojure.org/special_forms#let |
| 19:06 | hiredman | gulagong__: check that out |
| 19:06 | gulagong__ | hiredman: but there are so many gensyms... |
| 19:06 | hiredman | gulagong__: so? |
| 19:07 | gulagong__ | hiredman: i'm no computer ;) |
| 19:07 | hiredman | if you don't want to read macro expansions then don't write macros |
| 19:07 | gulagong__ | hehe |
| 19:07 | hiredman | I am not saying you have to trace the execution of the thing |
| 19:07 | clojurebot | trace is (in contrib) http://github.com/kevinoneill/clojure-contrib/commit/43e4168fc8772225c7f749ffb363b0e2a8f7b84f |
| 19:07 | hiredman | just look at the binding forms |
| 19:08 | hiredman | let, loop, etc |
| 19:08 | Drakeson | how can a namespace export [some] symbols that it USEs or REQUIREs from other namespaces? |
| 19:08 | hiredman | like at the vectors |
| 19:08 | hiredman | ~namespaces |
| 19:08 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 19:08 | gulagong__ | but i never expand the binding except when i pull the two symbols |
| 19:08 | hiredman | gulagong__: the macro expansion says otherwise |
| 19:08 | hiredman | I can believe either you, or the actual code |
| 19:09 | gulagong__ | ;) |
| 19:09 | hiredman | clojurebot: that is not what I wanted |
| 19:09 | clojurebot | Ik begrijp |
| 19:09 | gulagong__ | i'll read |
| 19:09 | hiredman | Drakeson: I am pretty sure you have to re-intern the functions into the new namespace |
| 19:10 | hiredman | http://clojure.org/namespaces |
| 19:12 | gulagong__ | ok, now i'm confused |
| 19:13 | hiredman | gulagong__: I recomend you start from scratch and incrementally write the macro, and as you go check the expansion to make sure it is what you want |
| 19:13 | gulagong__ | inside the macro (first '(i j)) results quote and (second '(i j)) results (i j) |
| 19:14 | lpetit | rhickey : ok, issue 163 created, and ready to test |
| 19:14 | gulagong__ | thanks anyway |
| 19:14 | gulagong__ | on this way (i j) creeps inside the binding form |
| 19:17 | gulagong__ | but i still have no clue how ;I |
| 19:17 | gulagong__ | ;) |
| 19:17 | gulagong__ | but i'm quiet now |
| 19:20 | durka42 | gulagong__: '(i j) means (quote (i j)) |
| 19:20 | durka42 | ,(macroexpand ''(i j)) |
| 19:20 | clojurebot | (quote (i j)) |
| 19:23 | G0SUB | (hello-world!) |
| 19:25 | cemerick | rhickey: sorry, yes, RT.booleanCast would be OK if rtype is boolean |
| 19:28 | lpetit | Drakeson: see immigrate in this thread: http://groups.google.com/group/clojure/browse_thread/thread/180185dfcb88d7ea |
| 19:28 | Drakeson | lpetit: thanks. too late though. I wrote one. ... |
| 19:33 | gulagong__ | durka42: thanks, that explains it.... although i should have known it |
| 19:34 | gulagong__ | than i can't do it with a list |
| 19:34 | gulagong__ | cause (list i j) evals i and j.. |
| 21:02 | rhickey | it's ........ alive |
| 21:03 | rhickey | first object created with new new |
| 21:06 | durka42 | I, for one, accept our new new overlords. |
| 21:13 | Raynes | Cheers! |
| 21:13 | Raynes | A bit late, but I just noticed the message. :> |
| 22:27 | prospero_ | I'm finding references to gen-and-load-class, but it doesn't seem to exist anymore |
| 22:28 | prospero_ | if I want to define a custom exception, what's the preferred way to do it? |
| 22:35 | Chouser | prospero_: you can gen-class (and AOT compile it), or use one of the contrib libs: except, error-kit, or ... |
| 22:35 | Chouser | bah, too slow. |
| 22:56 | eyeris | Is there a way to make test-is/run-tests be verbose? |
| 22:56 | Raynes | Ask it nicely. ;) |
| 22:57 | mebaran151 | Chouser, couldn't you proxy on Throwable? |
| 22:57 | Chouser | mebaran151: yes, but that gets you exactly one new class. |
| 22:57 | mebaran151 | ah |
| 22:57 | Chouser | no matter how many times you proxy it |
| 22:57 | mebaran151 | I see |
| 22:58 | Chouser | and you don't get to name it. end up being a bit silly. |
| 22:58 | Chouser | I guess it depends on why you want a custom exception |
| 22:58 | mebaran151 | ah I do see |
| 22:59 | mebaran151 | I kind of wish that Java was more like Javascript and you could throw anything |
| 23:00 | Raynes | mebaran151: I wouldn't want Java to throw me. :| |
| 23:01 | prospero_ | Chouser: I think I may have been disconnected while you answered my question |
| 23:02 | mebaran151 | Raynes, but then you could be Exceptional (har har) |
| 23:02 | Raynes | ;) |
| 23:02 | Chouser | prospero_: I should probably first ask why you want a custom exception |
| 23:02 | prospero_ | well, I've since decided that I don't |
| 23:02 | Chouser | great! |
| 23:03 | prospero_ | but for the sake of satisfying my curiosity, I was walking a tree, and wanted to throw an exception that would bubble up |
| 23:03 | prospero_ | or rather, bubble up any exceptions that were thrown |
| 23:04 | prospero_ | the easiest way I could think to do that was to wrap any exceptions in a custom exception, and not touch that custom exception on the way up |
| 23:04 | prospero_ | is there a better way than that? |
| 23:05 | Drakeson | liebke: ping |
| 23:05 | liebke | Drakeson: Hey |
| 23:06 | Drakeson | do you have a call to JFreeChart.createBufferedImage() in incanter? |
| 23:06 | Chouser | prospero_: could you just pass fn down (perhaps via a binding) and call it with your exception info? |
| 23:06 | liebke | no, I don't |
| 23:06 | Drakeson | (like, say, when you want to produce a graph in a webserver, and do not save it on disk) |
| 23:07 | Drakeson | (and feed it directly out to the client) |
| 23:07 | liebke | ah, good point |
| 23:07 | liebke | I'll put that on the todo list |
| 23:07 | Drakeson | cool. thanks :) |
| 23:08 | prospero_ | Chouser: that would work, it just seems a little more contrived than what I was trying to do |
| 23:08 | prospero_ | or rather, it would be more contrived if it weren't such a pain to generate a class |
| 23:08 | Drakeson | BTW, thanks again. Incanter is incredible. |
| 23:09 | liebke | Thanks :) |
| 23:09 | Chouser | using exceptions for flow control is discouraged |
| 23:09 | liebke | I've added createBufferedImage to the TODO list. Goodnight all |
| 23:10 | prospero_ | Chouser: I just wanted the exception to contain information about where in the tree the exception occurred |
| 23:12 | Chouser | Won't any ol' exception do for that? |
| 23:13 | prospero_ | well, not if you're trying to capture exceptions at every level in the tree to append more information to them |
| 23:14 | prospero_ | I mean, that would work |
| 23:14 | prospero_ | but it would have potentially a lot more stuff in there than you'd like |
| 23:14 | prospero_ | maybe I'm missing something, though? |
| 23:14 | hiredman | that all sounds like a bad idea |
| 23:14 | prospero_ | like I said, I've since decided against doing any of this |
| 23:15 | prospero_ | this is all an academic discussion at this point |
| 23:16 | hiredman | if it was academic there would be footnotes |
| 23:16 | prospero_ | ha |
| 23:16 | hiredman | and it would be in haskell |
| 23:16 | prospero_ | anyways, it's not a big deal |
| 23:16 | prospero_ | I'll drop it |
| 23:16 | hiredman | zing! |
| 23:17 | Chouser | well, you can certainly create a custom named exception using gen-class and then AOT compiling. |
| 23:19 | prospero_ | yeah, I found the archived discussions of gen-class vs gen-and-load-class |
| 23:20 | prospero_ | on a completely different note, has anyone seen this github recommendation competition? |
| 23:20 | prospero_ | it seems interesting |
| 23:22 | Chouser | link? |
| 23:23 | prospero_ | http://contest.github.com/ |
| 23:23 | eyeris | When I use the <javac> target in my build.xml for my .java files, it always recompiles, even if the .java files haven't been touched since the last compile. Is there a way to prevent this? |