Re: using take-while with pred function that has state
On Mon, Sep 3, 2012 at 10:36 PM, Aaron Cohen aa...@assonance.org wrote: It wouldn't even be all that insane if you had 1000 otherwise idle cores sitting around and an expensive enough predicate. Touché (perhaps up to a factor of n). (Though I suspect you need more assumptions given that the specific algorithm has the predicate being called on the 1000n computed elements in reverse order.) But, of course, you might not have all those cores/such an expensive predicate---after all, we keep regular old map around even in the presence of pmap. Even in the parallel case, it seems that what's important isn't that pred be free of side-effects sans phrase, but that the order pred is called on the elements of call not matter. If pred is pure, then the condition is met, but pred can have side-effects while still meeting that condition. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
As for contains? behavior on lists, it is fixed (CLJ-932https://github.com/clojure/clojure/commit/3acb6ee7ec5c295ae14de861d03a5efd115a5968) in Clojure 1.5, some 17 days ago: = (contains? '(1 2 3) 2); IllegalArgumentException contains? not supported on type: clojure.lang.PersistentList ... I wonder if get is also going to be fixed? = (get [1 2 3] 2) 3 = (get '(1 2 3) 2) nil On Monday, September 3, 2012 1:03:07 PM UTC+2, Goldritter wrote: I use Clojure 1.4.0 and wanted to use 'contains?' on a vector and get following results: = (contains? [1 2 3] 3) false = (contains? [1 2 3] 2) true As it seems 'contains?' does not check for the last entry in the vector. And an other question. Why does contains? returns everytime 'false' when used on a list? = (contains? (list 1 2 3) 1) false = (contains? (list 1 2 3) 2) false = (contains? (list 1 2 3) 3) false -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
I think this is not a bad idea. ;) At all, a method/function name should describe what it does. And if 'contains?' only looks for keys, then 'contains-key?' would be a better descriptor for it. Am 03.09.2012 13:29, schrieb Jim - FooBar();: this is probably the single most confusing name in clojure! :-) why can't we make it contains-key? ? Jim On 03/09/12 12:14, Goldritter wrote: Ah ok. So I need to transform a vector and/or a list into a set first. Thanks. Am Montag, 3. September 2012 13:05:52 UTC+2 schrieb Ambrose Bonnaire-Sergeant: 'contains?' tests if a key is in a collection. Vector is an associative data structure, with keys being indexes. A vector of length 3 has the key 2, but not key 3. Thanks, Ambrose On Mon, Sep 3, 2012 at 7:03 PM, Goldritter marcus.goldr...@googlemail.com javascript: wrote: I use Clojure 1.4.0 and wanted to use 'contains?' on a vector and get following results: = (contains? [1 2 3] 3) false = (contains? [1 2 3] 2) true As it seems 'contains?' does not check for the last entry in the vector. And an other question. Why does contains? returns everytime 'false' when used on a list? = (contains? (list 1 2 3) 1) false = (contains? (list 1 2 3) 2) false = (contains? (list 1 2 3) 3) false -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
I wanted to use it to select a random element in a collection (set, vector or list) where I can define elements which should not be selected. The function I now use is: (defn select-random [collection unselect] (select-random collection unselect) selects a random element from the specified 'collection'. It will ignore any element which is specified in 'unselect'. If none elements are specified in 'unselect', then any element from the specified 'collection' may be chosen. ( let [predicate #(contains? (set unselect) %1)] (rand-nth (remove predicate collection Eventually this can be optimized for better reading and/or performance. It might be also a good idea to add some preconditions to it like {pre: [(coll? collection)] }. Am 03.09.2012 13:29, schrieb Tassilo Horn: Goldritter marcus.goldritter.lind...@googlemail.com writes: Ah ok. So I need to transform a vector and/or a list into a set first. No, not really. All clojure collections implement java.util.Collection, so you can always use (.contains your-coll something) to check if your-coll contains something. However, keep in mind that this does a linear search for lists, sequences or vectors. So if your algorithm relies on containment checks, you might be better off using sets directly. Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
Instead of (let [predicate #(contains? (set unselect) %1)] ...) I would write (let [predicate (set unselect)] ...) On Tuesday, September 4, 2012 11:10:04 AM UTC+2, Marcus Lindner wrote: I wanted to use it to select a random element in a collection (set, vector or list) where I can define elements which should not be selected. The function I now use is: (defn select-random [collection unselect] (select-random collection unselect) selects a random element from the specified 'collection'. It will ignore any element which is specified in 'unselect'. If none elements are specified in 'unselect', then any element from the specified 'collection' may be chosen. ( let [predicate #(contains? (set unselect) %1)] (rand-nth (remove predicate collection Eventually this can be optimized for better reading and/or performance. It might be also a good idea to add some preconditions to it like {pre: [(coll? collection)] }. Am 03.09.2012 13:29, schrieb Tassilo Horn: Goldritter marcus.goldr...@googlemail.com javascript: writes: Ah ok. So I need to transform a vector and/or a list into a set first. No, not really. All clojure collections implement java.util.Collection, so you can always use (.contains your-coll something) to check if your-coll contains something. However, keep in mind that this does a linear search for lists, sequences or vectors. So if your algorithm relies on containment checks, you might be better off using sets directly. Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: genuine help needed to speed up minimax algorithm!
everything is working fine...see the post from yesterday called 'when looking for performance consider cheating' for an up to date explanation of how and where i cheated to speed it up... Jim On 04/09/12 04:42, Bill Robertson wrote: Did you figure out what was going on? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
On 04/09/12 02:06, Mark Engelberg wrote: This email is also my way of bumping the thread and bringing it again to everyone's attention. This is something I'd very much like to see resolved. +1 ... this thread should not die! Jim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reporting function inputs as part of exceptions
you want the exception thrown to report the arguments or 'capture them' (as you say) in the actual Exception object so you can use them outside the try-catch scope? the former is very straight forward you just use your arguments...the latter is more fuss as you have to gen-class your own exception type and and pass the arguments to its constructor so they can be stored internally...at least this is what i understand from your question... Jim p.s: I just realised you can simply return a map (defn foo [x y] (try (doSomething x y) (catch Exception e {:e e :inputs [x y]}))) ;;return the map (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e (do (println oops!) {:e e :inputs (vec ~args)} On 04/09/12 05:03, Timothy Pratley wrote: I'm working on a project where it would be quite convenient to have the input values to the function reported in any exceptions that get thrown. I'm guessing the way to do this would be to create a replacement defn which had a try catch and threw a new error with the inputs captured. Has anyone tried this, know of a better way, or a library that helps in this way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
London Clojure Dojo 11 September
Fellow Clojurians, To those of you who have shown restraint and allowed others to sign up to the dojo on 11 September at Forward I extend my heartfelt thanks. :-D I think everyone has been given enough time to sign up and come to the dojo. There are still plenty of places left. The sign up is here: http://mid-september-2012-ldnclj-dojo.eventbrite.co.uk/ I hope to see you all there! Also, don't forget about our event tonight (4 September) at Skills Matter. 2 lightning talks and 1 main talk followed up by beer in the Slaughtered Lamb. The sign up and details for that is here: http://skillsmatter.com/event/clojure/london-clojurians-user-group-1487 cheers, Bruce -- @otfrom | CTO co-founder @MastodonC | mastodonc.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reporting function inputs as part of exceptions
oops gensym mistake! (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e# (do (println oops!) {:e e# :inputs (vec ~args)} Jim On 04/09/12 12:20, Jim - FooBar(); wrote: you want the exception thrown to report the arguments or 'capture them' (as you say) in the actual Exception object so you can use them outside the try-catch scope? the former is very straight forward you just use your arguments...the latter is more fuss as you have to gen-class your own exception type and and pass the arguments to its constructor so they can be stored internally...at least this is what i understand from your question... Jim p.s: I just realised you can simply return a map (defn foo [x y] (try (doSomething x y) (catch Exception e {:e e :inputs [x y]}))) ;;return the map (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e (do (println oops!) {:e e :inputs (vec ~args)} On 04/09/12 05:03, Timothy Pratley wrote: I'm working on a project where it would be quite convenient to have the input values to the function reported in any exceptions that get thrown. I'm guessing the way to do this would be to create a replacement defn which had a try catch and threw a new error with the inputs captured. Has anyone tried this, know of a better way, or a library that helps in this way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reporting function inputs as part of exceptions
I'm so sorry... this one works! (defmacro capture-inputs [f args] `(try (~f ~@args) (catch Exception e# (do (println oops!) {:e e# :inputs (vector ~@args)} Jim On 04/09/12 12:23, Jim - FooBar(); wrote: oops gensym mistake! (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e# (do (println oops!) {:e e# :inputs (vec ~args)} Jim On 04/09/12 12:20, Jim - FooBar(); wrote: you want the exception thrown to report the arguments or 'capture them' (as you say) in the actual Exception object so you can use them outside the try-catch scope? the former is very straight forward you just use your arguments...the latter is more fuss as you have to gen-class your own exception type and and pass the arguments to its constructor so they can be stored internally...at least this is what i understand from your question... Jim p.s: I just realised you can simply return a map (defn foo [x y] (try (doSomething x y) (catch Exception e {:e e :inputs [x y]}))) ;;return the map (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e (do (println oops!) {:e e :inputs (vec ~args)} On 04/09/12 05:03, Timothy Pratley wrote: I'm working on a project where it would be quite convenient to have the input values to the function reported in any exceptions that get thrown. I'm guessing the way to do this would be to create a replacement defn which had a try catch and threw a new error with the inputs captured. Has anyone tried this, know of a better way, or a library that helps in this way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
personally I've gotten used to it but it seems that every couple of weeks someone else will be confused and try to use contains? as it would be used in Java...the docs are clear but unfortunately not everyone consults the docs beforehand! at least not for such a semantically clear name as contains?... Jim On 04/09/12 10:01, Marcus Lindner wrote: I think this is not a bad idea. ;) At all, a method/function name should describe what it does. And if 'contains?' only looks for keys, then 'contains-key?' would be a better descriptor for it. Am 03.09.2012 13:29, schrieb Jim - FooBar();: this is probably the single most confusing name in clojure! :-) why can't we make it contains-key? ? Jim On 03/09/12 12:14, Goldritter wrote: Ah ok. So I need to transform a vector and/or a list into a set first. Thanks. Am Montag, 3. September 2012 13:05:52 UTC+2 schrieb Ambrose Bonnaire-Sergeant: 'contains?' tests if a key is in a collection. Vector is an associative data structure, with keys being indexes. A vector of length 3 has the key 2, but not key 3. Thanks, Ambrose On Mon, Sep 3, 2012 at 7:03 PM, Goldritter marcus.goldr...@googlemail.com javascript: wrote: I use Clojure 1.4.0 and wanted to use 'contains?' on a vector and get following results: = (contains? [1 2 3] 3) false = (contains? [1 2 3] 2) true As it seems 'contains?' does not check for the last entry in the vector. And an other question. Why does contains? returns everytime 'false' when used on a list? = (contains? (list 1 2 3) 1) false = (contains? (list 1 2 3) 2) false = (contains? (list 1 2 3) 3) false -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Found bug in contains? used with vectors.
The naming of contains? is one of Clojure's small warts. Almost everyone seems to stumble over it when they're starting out. I know I did. Naming it contains-key? would have prevented a great deal of confusion, but I guess that ship has sailed... *shrug* // ben On Tue, Sep 4, 2012 at 1:35 PM, Jim - FooBar(); jimpil1...@gmail.com wrote: personally I've gotten used to it but it seems that every couple of weeks someone else will be confused and try to use contains? as it would be used in Java...the docs are clear but unfortunately not everyone consults the docs beforehand! at least not for such a semantically clear name as contains?... Jim On 04/09/12 10:01, Marcus Lindner wrote: I think this is not a bad idea. ;) At all, a method/function name should describe what it does. And if 'contains?' only looks for keys, then 'contains-key?' would be a better descriptor for it. Am 03.09.2012 13:29, schrieb Jim - FooBar();: this is probably the single most confusing name in clojure! :-) why can't we make it contains-key? ? Jim On 03/09/12 12:14, Goldritter wrote: Ah ok. So I need to transform a vector and/or a list into a set first. Thanks. Am Montag, 3. September 2012 13:05:52 UTC+2 schrieb Ambrose Bonnaire-Sergeant: 'contains?' tests if a key is in a collection. Vector is an associative data structure, with keys being indexes. A vector of length 3 has the key 2, but not key 3. Thanks, Ambrose On Mon, Sep 3, 2012 at 7:03 PM, Goldritter marcus.goldr...@googlemail.com wrote: I use Clojure 1.4.0 and wanted to use 'contains?' on a vector and get following results: = (contains? [1 2 3] 3) false = (contains? [1 2 3] 2) true As it seems 'contains?' does not check for the last entry in the vector. And an other question. Why does contains? returns everytime 'false' when used on a list? = (contains? (list 1 2 3) 1) false = (contains? (list 1 2 3) 2) false = (contains? (list 1 2 3) 3) false -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
multimethod table watch ?
I'm looking for a way to get notified when a new method of multimethod is installed and associated with a new dispatch function, kind of like the add-watch function. Are there any ways of achieving this without polling with clojure.core/methods ? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reporting function inputs as part of exceptions
You want this on every single fn you define? in this case, yes you would need a tweaked 'defn' form...something like this perhaps: (defmacro defn-capt [name [ args] code] `(defn ~name [~@args] (try ~@code (catch Exception e# {:exception e# :origin ~name :inputs (vector ~@args)} (defn-capt foo [a b] (/ a b)) (foo 1 0) = {:inputs [1 0], :exception #ArithmeticException java.lang.ArithmeticException: Divide by zero, :origin #user$foo user$foo@4dbf98eb} Jim On 04/09/12 12:31, Jim - FooBar(); wrote: I'm so sorry... this one works! (defmacro capture-inputs [f args] `(try (~f ~@args) (catch Exception e# (do (println oops!) {:e e# :inputs (vector ~@args)} Jim On 04/09/12 12:23, Jim - FooBar(); wrote: oops gensym mistake! (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e# (do (println oops!) {:e e# :inputs (vec ~args)} Jim On 04/09/12 12:20, Jim - FooBar(); wrote: you want the exception thrown to report the arguments or 'capture them' (as you say) in the actual Exception object so you can use them outside the try-catch scope? the former is very straight forward you just use your arguments...the latter is more fuss as you have to gen-class your own exception type and and pass the arguments to its constructor so they can be stored internally...at least this is what i understand from your question... Jim p.s: I just realised you can simply return a map (defn foo [x y] (try (doSomething x y) (catch Exception e {:e e :inputs [x y]}))) ;;return the map (defmacro capture-inputs [f args] `(try (apply ~f ~@args) (catch Exception e (do (println oops!) {:e e :inputs (vec ~args)} On 04/09/12 05:03, Timothy Pratley wrote: I'm working on a project where it would be quite convenient to have the input values to the function reported in any exceptions that get thrown. I'm guessing the way to do this would be to create a replacement defn which had a try catch and threw a new error with the inputs captured. Has anyone tried this, know of a better way, or a library that helps in this way? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN Pallet 0.7.2
Pallet is a library for infrastructure management, covering provisioning, configuration management and deployment. Pallet 0.7.2 is mainly a bug fix release. It addresses a number of issues around the usage of the lein plugin which were causing problems for some people following the first steps instructions. The first step instructions have also been extended to cover more of basic pallet usage. Release notes: https://github.com/pallet/pallet/blob/support/0.7.x/ReleaseNotes.md First steps: http://palletops.com/doc/first-steps/ Documentation: http://palletops.com Updates are posted on Twitter @palletops -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN lein-set-version 0.2.0
lein-set-version is a Leiningen plugin to update your project version. Apart from updating project.clj, you can configure the update of other project files, such as the README. lein-set-version also updates versions of sub-projects in :dependencies when run with lein-sub. Usage and configuration documented at https://github.com/pallet/lein-set-version Hugo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
I have created a dev page for this issue. It isn't a JIRA ticket because it isn't clear to me yet exactly what the changes should be. http://dev.clojure.org/display/design/Allow+duplicate+map+keys+and+set+elements A couple of questions there for people that dislike the current behavior. You can always construct sets that quietly allow duplicates as follows. Is that good enough? Or perhaps the issue is that you prefer to use #{} notation for constructing sets, and do not want to have to use a different method if you want the silent-duplicate-elimination behavior? If so, I can understand that. I'm just trying to get the argument for change as clearly as possible. (set [a b]) The story for creating maps that quietly use the later duplicate keys in preference to the earlier ones isn't as clean: both hash-map and array-map throw an exception on duplicate keys, although sorted-map does not for some reason (probably an oversight when the duplicate key checks were added?). The following works, but is a bit clunky: (assoc {} a 5 b 7) Thanks, Andy On Sep 3, 2012, at 7:49 PM, Sean Corfield wrote: On Mon, Sep 3, 2012 at 6:06 PM, Mark Engelberg mark.engelb...@gmail.com wrote: I don't know what the path is now. I feel that in the past year, there have been several times where people have raised meaningful issues about Clojure and received no official response. It's hard to know whether this is an intentional rejection through ignoring, or whether it's just that those messages happened to slip beneath the radar. Maybe Rich didn't see them, and without his go-ahead, no one moved forward with them. My understanding is the sort of discussion you are referring to has moved to clojure-dev by necessity because of the volume of posts on this list. http://clojure.org/contributing hints as much. My understanding is also that anyone can open an issue in JIRA for something they believe is a bug. In any case, there was a great deal of useful discussion about the set issue, and then... silence. Open an issue in JIRA. Ask the folks here who agreed with your point of view to vote on the issue. All issues get raised on clojure-dev one way or another (esp. if they have a patch attached). example, on whitehouse.gov, you can start a petition and if enough people sign the petition within a given length of time, the president's office will issue an official statement about it. That's the kind of thing I'm thinking That would seem to match the voting on JIRA issues point above. 2. There was significant support for my suggestion to revert set behavior back to 1.2 and solve the problem which motivated the change by bringing array-maps into accord with the behavior of the other maps and sets. This email is also my way of bumping the thread and bringing it again to everyone's attention. This is something I'd very much like to see resolved. Again, open an issue in JIRA with a patch (you have a signed CA on file so there's no obstacle). That will guarantee the issue gets reviewed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using take-while with pred function that has state
On Mon, Sep 3, 2012 at 1:58 PM, Stephen Compall stephen.comp...@gmail.com wrote: On Sun, 2012-09-02 at 23:02 -0700, Ben Wolfson wrote: Can you say what this means (the note about take-while being called in coll order)? Does it mean that it's not a guarantee of the API that the predicate passed to take-while be called *successively* on the items in the collection passed in? Yes, that's what it means. Sorry I was not more clear. Stephen, could you elaborate on this? My reading of the side-effect-free restriction was just that the predicate may be called on more elements than end up in the result, perhaps due to chunking or whatever. I'm not sure I see where there's any indication that take-while might call the predicate in a non-linear order - or is just one of those 'guilty by omission' situations? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
the issue here is that behaviour should be *consistent* across all forms of ctor functions, so programmers don't have to remember which one allows what or don't thus limiting code breaks...the literal syntax is just too elegant to give up! I don't think anyone is against consistency... Jim ps: IMO sets should always remove duplicates quietly...that is the whole point of using them programmatically! On 04/09/12 17:30, Andy Fingerhut wrote: I have created a dev page for this issue. It isn't a JIRA ticket because it isn't clear to me yet exactly what the changes should be. http://dev.clojure.org/display/design/Allow+duplicate+map+keys+and+set+elements A couple of questions there for people that dislike the current behavior. You can always construct sets that quietly allow duplicates as follows. Is that good enough? Or perhaps the issue is that you prefer to use #{} notation for constructing sets, and do not want to have to use a different method if you want the silent-duplicate-elimination behavior? If so, I can understand that. I'm just trying to get the argument for change as clearly as possible. (set [a b]) The story for creating maps that quietly use the later duplicate keys in preference to the earlier ones isn't as clean: both hash-map and array-map throw an exception on duplicate keys, although sorted-map does not for some reason (probably an oversight when the duplicate key checks were added?). The following works, but is a bit clunky: (assoc {} a 5 b 7) Thanks, Andy On Sep 3, 2012, at 7:49 PM, Sean Corfield wrote: On Mon, Sep 3, 2012 at 6:06 PM, Mark Engelberg mark.engelb...@gmail.com wrote: I don't know what the path is now. I feel that in the past year, there have been several times where people have raised meaningful issues about Clojure and received no official response. It's hard to know whether this is an intentional rejection through ignoring, or whether it's just that those messages happened to slip beneath the radar. Maybe Rich didn't see them, and without his go-ahead, no one moved forward with them. My understanding is the sort of discussion you are referring to has moved to clojure-dev by necessity because of the volume of posts on this list. http://clojure.org/contributing hints as much. My understanding is also that anyone can open an issue in JIRA for something they believe is a bug. In any case, there was a great deal of useful discussion about the set issue, and then... silence. Open an issue in JIRA. Ask the folks here who agreed with your point of view to vote on the issue. All issues get raised on clojure-dev one way or another (esp. if they have a patch attached). example, on whitehouse.gov, you can start a petition and if enough people sign the petition within a given length of time, the president's office will issue an official statement about it. That's the kind of thing I'm thinking That would seem to match the voting on JIRA issues point above. 2. There was significant support for my suggestion to revert set behavior back to 1.2 and solve the problem which motivated the change by bringing array-maps into accord with the behavior of the other maps and sets. This email is also my way of bumping the thread and bringing it again to everyone's attention. This is something I'd very much like to see resolved. Again, open an issue in JIRA with a patch (you have a signed CA on file so there's no obstacle). That will guarantee the issue gets reviewed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[ANN] clojure-encog has a new name and repo
Hi all, just wanted to let you know that I renamed 'clojure-encog' to *enclog* ...release 0.5.0 does not add anything but several 'library coding standards' that i was previously not aware of, have been addressed... I created a brand new repo here : https://github.com/jimpil/enclog and a new jar here: https://clojars.org/enclog https://clojars.org/clojure-encog I also added a simple example of KMeans clustering and soon I will have the famous TSP problem solved... cheers, Jim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: Ragtime 0.3.0
I've recently released Ragtime 0.3.0, a library for managing migrations. I've been working on it on-and-off for a while, and it's now ready for more general use. Ragtime abstracts migrations in the same way that Ring abstracts web applications. Ragtime doesn't specify how migrations are generated or what they do, only that they follow a specific format. A list of migrations are taken from a source, and Ragtime applies them to a database, recording which migrations have been applied. The project comes with a implementation for applying a directory of SQL scripts to a JDBC database. The project website is here: https://github.com/weavejester/ragtime And there's a getting started guide here: https://github.com/weavejester/ragtime/wiki/Getting-Started - James -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
But what if they all consistently throw exceptions when encountering duplicates, including (set [5 5])? That doesn't sound like what you want. Also, it seems from this discussion that at least some people like the error-catching aspects of the current behavior. Stuart Halloway mentioned the idea of having two kinds of set/map constructor functions, one kind which quietly eliminates duplicates, another which throws an exception on duplicates. That still leaves open the question of what the set and map literals should do with duplicates. What if the default behavior for set map literals were to quietly allow duplicates, with a new compiler option like the following that would give the error, for those that like it? (set! *error-on-duplicates* true) Perhaps it is starting to look like feature creep, but I thought I'd throw out the idea to see what happens. Andy On Sep 4, 2012, at 10:08 AM, Jim - FooBar(); wrote: the issue here is that behaviour should be *consistent* across all forms of ctor functions, so programmers don't have to remember which one allows what or don't thus limiting code breaks...the literal syntax is just too elegant to give up! I don't think anyone is against consistency... Jim ps: IMO sets should always remove duplicates quietly...that is the whole point of using them programmatically! On 04/09/12 17:30, Andy Fingerhut wrote: I have created a dev page for this issue. It isn't a JIRA ticket because it isn't clear to me yet exactly what the changes should be. http://dev.clojure.org/display/design/Allow+duplicate+map+keys+and+set+elements A couple of questions there for people that dislike the current behavior. You can always construct sets that quietly allow duplicates as follows. Is that good enough? Or perhaps the issue is that you prefer to use #{} notation for constructing sets, and do not want to have to use a different method if you want the silent-duplicate-elimination behavior? If so, I can understand that. I'm just trying to get the argument for change as clearly as possible. (set [a b]) The story for creating maps that quietly use the later duplicate keys in preference to the earlier ones isn't as clean: both hash-map and array-map throw an exception on duplicate keys, although sorted-map does not for some reason (probably an oversight when the duplicate key checks were added?). The following works, but is a bit clunky: (assoc {} a 5 b 7) Thanks, Andy On Sep 3, 2012, at 7:49 PM, Sean Corfield wrote: On Mon, Sep 3, 2012 at 6:06 PM, Mark Engelberg mark.engelb...@gmail.com wrote: I don't know what the path is now. I feel that in the past year, there have been several times where people have raised meaningful issues about Clojure and received no official response. It's hard to know whether this is an intentional rejection through ignoring, or whether it's just that those messages happened to slip beneath the radar. Maybe Rich didn't see them, and without his go-ahead, no one moved forward with them. My understanding is the sort of discussion you are referring to has moved to clojure-dev by necessity because of the volume of posts on this list. http://clojure.org/contributing hints as much. My understanding is also that anyone can open an issue in JIRA for something they believe is a bug. In any case, there was a great deal of useful discussion about the set issue, and then... silence. Open an issue in JIRA. Ask the folks here who agreed with your point of view to vote on the issue. All issues get raised on clojure-dev one way or another (esp. if they have a patch attached). example, on whitehouse.gov, you can start a petition and if enough people sign the petition within a given length of time, the president's office will issue an official statement about it. That's the kind of thing I'm thinking That would seem to match the voting on JIRA issues point above. 2. There was significant support for my suggestion to revert set behavior back to 1.2 and solve the problem which motivated the change by bringing array-maps into accord with the behavior of the other maps and sets. This email is also my way of bumping the thread and bringing it again to everyone's attention. This is something I'd very much like to see resolved. Again, open an issue in JIRA with a patch (you have a signed CA on file so there's no obstacle). That will guarantee the issue gets reviewed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
+1 consistency, whether it throws an exception or not, removes complexity from the language. (because the programmer don't have to know the complex rules which literal notation behaves which way On Tue, Sep 4, 2012 at 10:02 PM, Andy Fingerhut andy.finger...@gmail.comwrote: But what if they all consistently throw exceptions when encountering duplicates, including (set [5 5])? That doesn't sound like what you want. Also, it seems from this discussion that at least some people like the error-catching aspects of the current behavior. Stuart Halloway mentioned the idea of having two kinds of set/map constructor functions, one kind which quietly eliminates duplicates, another which throws an exception on duplicates. That still leaves open the question of what the set and map literals should do with duplicates. What if the default behavior for set map literals were to quietly allow duplicates, with a new compiler option like the following that would give the error, for those that like it? (set! *error-on-duplicates* true) Perhaps it is starting to look like feature creep, but I thought I'd throw out the idea to see what happens. Andy On Sep 4, 2012, at 10:08 AM, Jim - FooBar(); wrote: the issue here is that behaviour should be *consistent* across all forms of ctor functions, so programmers don't have to remember which one allows what or don't thus limiting code breaks...the literal syntax is just too elegant to give up! I don't think anyone is against consistency... Jim ps: IMO sets should always remove duplicates quietly...that is the whole point of using them programmatically! On 04/09/12 17:30, Andy Fingerhut wrote: I have created a dev page for this issue. It isn't a JIRA ticket because it isn't clear to me yet exactly what the changes should be. http://dev.clojure.org/display/design/Allow+duplicate+map+keys+and+set+elements A couple of questions there for people that dislike the current behavior. You can always construct sets that quietly allow duplicates as follows. Is that good enough? Or perhaps the issue is that you prefer to use #{} notation for constructing sets, and do not want to have to use a different method if you want the silent-duplicate-elimination behavior? If so, I can understand that. I'm just trying to get the argument for change as clearly as possible. (set [a b]) The story for creating maps that quietly use the later duplicate keys in preference to the earlier ones isn't as clean: both hash-map and array-map throw an exception on duplicate keys, although sorted-map does not for some reason (probably an oversight when the duplicate key checks were added?). The following works, but is a bit clunky: (assoc {} a 5 b 7) Thanks, Andy On Sep 3, 2012, at 7:49 PM, Sean Corfield wrote: On Mon, Sep 3, 2012 at 6:06 PM, Mark Engelberg mark.engelb...@gmail.com wrote: I don't know what the path is now. I feel that in the past year, there have been several times where people have raised meaningful issues about Clojure and received no official response. It's hard to know whether this is an intentional rejection through ignoring, or whether it's just that those messages happened to slip beneath the radar. Maybe Rich didn't see them, and without his go-ahead, no one moved forward with them. My understanding is the sort of discussion you are referring to has moved to clojure-dev by necessity because of the volume of posts on this list. http://clojure.org/contributing hints as much. My understanding is also that anyone can open an issue in JIRA for something they believe is a bug. In any case, there was a great deal of useful discussion about the set issue, and then... silence. Open an issue in JIRA. Ask the folks here who agreed with your point of view to vote on the issue. All issues get raised on clojure-dev one way or another (esp. if they have a patch attached). example, on whitehouse.gov, you can start a petition and if enough people sign the petition within a given length of time, the president's office will issue an official statement about it. That's the kind of thing I'm thinking That would seem to match the voting on JIRA issues point above. 2. There was significant support for my suggestion to revert set behavior back to 1.2 and solve the problem which motivated the change by bringing array-maps into accord with the behavior of the other maps and sets. This email is also my way of bumping the thread and bringing it again to everyone's attention. This is something I'd very much like to see resolved. Again, open an issue in JIRA with a patch (you have a signed CA on file so there's no obstacle). That will guarantee the issue gets reviewed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that
Re: using take-while with pred function that has state
On Tue, 2012-09-04 at 09:48 -0700, Sean Corfield wrote: Stephen, could you elaborate on this? Requiring pred to be free of side effects provides many invariants about it to the `take-while' implementation; the legality of out-of-order calling is just one of them. My reading of the side-effect-free restriction was just that the predicate may be called on more elements than end up in the result, perhaps due to chunking or whatever. I don't know what the original intent of the docstring was. Perhaps it was merely written that way because it was shorter; perhaps a precise explanation of how pred would be called was considered too much for doc purposes. It might mean something somewhere in between. I am basing this only on what the docstring says. [1] I can imagine a few alternative `take-while's that could effectively exploit out-of-order calling. [2] But even aside from reordering, I can't even name every potentially useful freedom we have given `take-while' by making pred pure, much less every way of using those freedoms. I cannot say what new ideas may be incorporated into take-while in the future by taking advantage of purity. But I _can_ imagine my frustration, painstakingly tracking down bugs in my own software, induced by nothing but my own failure to follow this documented contract as a take-while caller. or is just one of those 'guilty by omission' situations? If that is what you mean by this, then yes. [1] I can, however, say that the documented invariant was added in Rich Hickey's a8307cc8, back in 2008. [2] Describing such examples would be rather esoteric for this thread, I feel. -- Stephen Compall ^aCollection allSatisfy: [:each | aCondition]: less is better than -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
An instance of an abstract class in the repl?
So I'm working on developing a Clojure api for a distributed data analysis framework. A key part of that has to be the ability to pass functions as parameters into various map, reduce, filter, groupBy, etc. functions. Since this a framework developed in Scala, these function parameters eventually become Scala Function1 or Function2. What I really want is to be able to use this framework interactively from the Clojure repl, much as it can already be done from the Scala repl. For example, it is possible in the Scala repl to do something like: aDataSet.map(n = n + 1) which, of course, increments every element in the data set by 1. What I am eventually working toward is being able to do the equivalent to the above Scala interaction in Clojure: user= (framework-map #(+ % 1) aDataSet) but as an intermediate step, I'm trying to get named function-like parameters working before tackling anonymous functions. So, I'd be happy right now with: user= (def f (...)) #'user/f user= (framework-map f aDataSet) I can actually get this to work if I use the Java api to the framework and use gen-class to AOT compile a class and then create an instance equivalent to: FrameworkFunctionInteger, Integer f = new FrameworkFunctionInteger, Integer() {public Integer call(Integer n) {return (n + 1)}} But needing to jump through all of the AOT hoops every time the user needs to pass a function as a parameter would put a major hitch in the interactive giddyup, so this isn't really an acceptable solution (although it does appear to work fine to statically create batch jobs for the framework, or to create a library of pre-defined functions that can passed in from the repl.) I haven't really tried to use the underlying Scala api directly from the Clojure repl, so if someone sees a way to make that work, then I'll gladly use less wrapper layers. Using the Java api from the Clojure repl mostly works, but my major hangup is with not being able to get a useful instance of the abstract FrameworkFunction class (and similar classes.) I can use proxy to create an instance that works equivalently directly within the repl to an instance of an AOT class, so I can do: user= (.call f 2) 3 regardless of whether f is an instance of a concrete AOT class extending FrameworkFunction or f is a proxy extending FrameworkFunction. But trying to pass the proxy as a parameter leads to trouble when the framework tries to do things with the .class file. For example, when the following chunk of Scala code is hit: private def getClassReader(cls: Class[_]): ClassReader = { logInfo(attempted class name: + cls.getName.replaceFirst(^.*\\., ) + .class) new ClassReader(cls.getResourceAsStream( cls.getName.replaceFirst(^.*\\., ) + .class)) } the attempt to generate an ASM class reader from Function$0.class fails when using the proxy (IOException Class not found org.objectweb.asm.ClassReader.a (:-1)), but works fine using the AOT instance. So, the upshot of all of this is that I am wondering how I should go about creating in the repl instances of this FrameworkFunction abstract class that can be passed into the framework HOFs. Even better would be if someone could explain to me how in the repl to convert Clojure functions into Scala functions so that I could then pass them directly into the framework with less need for the Java wrapper. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: An instance of an abstract class in the repl?
On Tue, 2012-09-04 at 14:34 -0700, Mark Hamstra wrote: What I am eventually working toward is being able to do the equivalent to the above Scala interaction in Clojure: user= (framework-map #(+ % 1) aDataSet) but as an intermediate step, I'm trying to get named function-like parameters working before tackling anonymous functions. I believe it will actually be easier to get going with functions. You should be able to write these functions with `reify' or `deftype' on scala.FunctionN or `proxy' on scala.AbstractFunctionN: (defn scala-function1 Convert a one-argument Clojure function to a scala.Function1. [f] (reify scala.Function1 (apply [_ x] ...) ...other methods...)) (defn scala-function2 ...and so on The next step is to build a `scala-function' that picks the right FunctionN interface to implement based on arities of the IFn you get as input. private def getClassReader(cls: Class[_]): ClassReader = { logInfo(attempted class name: + cls.getName.replaceFirst(^.*\ \., ) + .class) new ClassReader(cls.getResourceAsStream( cls.getName.replaceFirst(^.*\\., ) + .class)) } That assumes that this craziness doesn't get in the way. The trick here is that by putting your reify/deftype/proxy *once*, AOTing that, you'll reuse the same Scala function class for every Clojure function. That depends, of course, on the Clojure functions *not* dropping into this nonsense. -- Stephen Compall ^aCollection allSatisfy: [:each | aCondition]: less is better than -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using take-while with pred function that has state
On Tue, Sep 4, 2012 at 2:23 PM, Stephen Compall stephen.comp...@gmail.com wrote: On Tue, 2012-09-04 at 09:48 -0700, Sean Corfield wrote: Stephen, could you elaborate on this? Requiring pred to be free of side effects provides many invariants about it to the `take-while' implementation; the legality of out-of-order calling is just one of them. But that is a hypothetical, yes? You're not suggesting that take-while actually does that, right? It might mean something somewhere in between. I am basing this only on what the docstring says. [1] That commit also added pred must be free of side-effects to `filter` and replaced lazy-cons with lazy-seq (which suggests lazy-seq changed its semantics along the way since (lazy-seq :a [:b]) just yields (:b) these days but clearly needed to behave more like cons back then?). I think calling `pred` out of linear order is a far less likely intended freedom than those of calling `pred` more than once on a given element or calling `pred` on more elements that strictly needed. Either way, it's all a bit of a moot point: the docstring says - for take-while and filter - that the predicate should be free of side-effects and I think that makes it clear that using a predicate with side-effects can legally lead to undesirable behavior (such as being called more times than you might expect). So the OP should consider that possibility in their code. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
redefining multimethods at the repl
I'm trying to write exercises for multimethods. Book readers will be working at the repl. Multimethods are stateful in a bad way, as shown below. Is there some sort of trick to using multimethods at the repl, or should I just give up on exercises using them? ;; Two types: user= (defn ship [name] (with-meta {:name name} {:type :ship})) user= (defn asteroid [name] (with-meta {:name name} {:type :asteroid})) ;; The dispatch function and defmulti user= (def classify-colliding-things (fn [thing1 thing2] [(type thing1) (type thing2)])) user= (defmulti collide classify-colliding-things) ;; Actually, since the arguments can come in any order, it'd be better to sort the types: user= (def classify-colliding-things (fn [thing1 thing2] (sort [(type thing1) (type thing2)]))) ;; And let's redefine the multimethod to use the new comparison function. user= (defmulti collide classify-colliding-things) ;; OK, now we define the methods. user= (defmethod collide [:asteroid :ship] [ things] collide asteroid to ship) ;;; And use them with great confidence: user= (collide (ship Space Beagle) (asteroid Malse)) IllegalArgumentException No method in multimethod 'collide' for dispatch value: [:ship :asteroid] clojure.lang.MultiFn.getFn (MultiFn.java:121) ;;; The redefinition didn't take - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Occasional consulting on Agile Writing /Functional Programming for the Object-Oriented Programmer/: https://leanpub.com/fp-oo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using take-while with pred function that has state
On Tue, 2012-09-04 at 15:24 -0700, Sean Corfield wrote: But that is a hypothetical, yes? You're not suggesting that take-while actually does that, right? Right. As of right now. -- Stephen Compall ^aCollection allSatisfy: [:each | aCondition]: less is better than -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: redefining multimethods at the repl
On Tue, 2012-09-04 at 17:31 -0500, Brian Marick wrote: user= (defmulti collide classify-colliding-things) If you're okay with a little handwaving, how about (defmulti collide #'classify-colliding-things) Now there is no need to rerun defmulti. -- Stephen Compall ^aCollection allSatisfy: [:each | aCondition]: less is better than -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: redefining multimethods at the repl
user= (defmulti collide classify-colliding-things) You want (defmulti collide #'classify-colliding-things) Binding to the var instead of the value will allow it to be udpated. jack. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[ANN] Shoreleave 0.2.2 - a library for production-ready ClojureScript
Shoreleave is a collection of libraries for building robust, production-ready ClojureScript applications. It was created in parallel while making production ClojureScript applications and is running systems in the wild. Shoreleave includes: * idiomatic interfaces for browser functionality and HTML5 feature sets * cooperative client/server remoting * security for-free (CSRF protection, XSS protection, etc) * wrappers for common 3rd party services (Google Maps) * reactive CLJS via a Pub/Sub abstraction and bus The launching place for Shoreleave is: https://github.com/ohpauleez/shoreleave All code is under the Shoreleave github organization: https://github.com/organizations/shoreleave A community-created demo can be found (thanks Robert Stuttaford // ro_st): https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote The current Shoreleave version is 0.2.2 and can be added with lein: [shoreleave 0.2.2] [shoreleave/shoreleave-remote-noir 0.2.2] Thanks! Paul (ohpauleez) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: redefining multimethods at the repl
Binding to the var instead of the value will allow it to be udpated. Alternatively you could ns-unmap the multimethod before redefining it. U -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: when looking for performance, consider 'cheating' !
On Mon, Sep 03, 2012 at 02:03:14PM +0100, Jim - FooBar(); wrote: Hi all, this is basically a continuation of my previous thread Functional performance vs imperative complexity...for those of you who are still interested here is what I learnt during the process. I should note that i finally got the performance I was after without sacrificing any immutability at all! so , how did I do that after all that moaning and complaining? well, if I'm honest I *cheated* !!! Thanks for sharing! Indeed, I'm finding similarly that a decent amount of pre-processing and data-massaging can go a long way (as well as applying YAGNI to algorithmic evaluations). If you haven't already, I think this would make a good series of blog posts too! Cheers, Josh -- Joshua Ballanco ELC Technologies™ 1771 NW Pettygrove Street, Suite 140 Portland, OR, 97209 jballa...@elctech.com P +1 866.863.7365 F +1 877.658.6313 M +1 646.463.2673 T +90 533.085.5773 http://www.elctech.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure / RootBeer / CUDA / GPU
Hi Jules, I've just been hacking on OpenCL a bit the last few days[1] - Rootbeer was an inspiration after seeing it a few weeks back. I'm not trying to go down the Rootbeer route myself, but the idea of having (cl-map f ...) is one direction one can take it (I've been looking a bit at Haskell's Accelerate[2]). I've mainly been trying to get my head around the programming model, at this point there's only a few simple macros that compile Clojure to OpenCL and pushes sequences back and forth. cheers, Hakan [1] https://github.com/hraberg/sleipnir [2] http://www.cse.unsw.edu.au/~chak/project/accelerate/ On Sunday, 2 September 2012 23:48:29 UTC+1, Jules wrote: Guys, Has anyone read about RootBeer - https://github.com/pcpratts/rootbeer1 My understanding is that it can compile Java bytecode - CUDA GPU code. A Java class that you want to run on your CUDA GPU must subclass the RootBeer Kernel interface. So, I wondering what would happen if I 1) implement Kernel with some simple Clojure code that just e.g. adds a couple of numbers, get the class out onto disc, compile it with the Rootbeer compiler and try running the result on my GPU. 2) Pull the RootBeer compiler into a running Clojure image and figure out how to do the same thing on-the-fly. 3) Write e.g. (cuda-map f coll) which embeds f in a Kernel, copies the contents of coll and the new kernel up to your CUDA GPU and executes f on the contents of coll in parallel producing a new coll which is copied back into Clojure world and returned... Of course, there are lots of things to be resolved here, I have only had time today to Compile up the CUDA download, clone the RootBeer git repo, compile it and try to run the example program - ArraySumApp. I got an error which I am thinking indicates that RootBeer doesn't like my 1.7.0_03-icedtea-mockbuild_2012_06_13_11_56-b00 - the current version of Java on my Fedora16 box, but... think how much fun I could have with this little project :-). Anyway, I thought I would just announce my intentions to play with this on the list, in case anyone else was interested or already doing so and fancied collaborating or, maybe someone will be able to tell me why it will never work and save me the effort :-) all the best, Jules -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure / RootBeer / CUDA / GPU
Hi Jules, I've just been hacking on OpenCL a bit the last few days[1] - Rootbeer was an inspiration after seeing it a few weeks back. I'm not trying to go down the Rootbeer route myself, but the ideas of having (cl-map f ...) is one direction one can take it. I've been mainly trying to get my head around the programming model, at this point there's only a few simple macros that compile Clojure to OpenCL and pushes sequences back and forth. cheers, Hakan [1] https://github.com/hraberg/sleipnir On Sunday, 2 September 2012 23:48:29 UTC+1, Jules wrote: Guys, Has anyone read about RootBeer - https://github.com/pcpratts/rootbeer1 My understanding is that it can compile Java bytecode - CUDA GPU code. A Java class that you want to run on your CUDA GPU must subclass the RootBeer Kernel interface. So, I wondering what would happen if I 1) implement Kernel with some simple Clojure code that just e.g. adds a couple of numbers, get the class out onto disc, compile it with the Rootbeer compiler and try running the result on my GPU. 2) Pull the RootBeer compiler into a running Clojure image and figure out how to do the same thing on-the-fly. 3) Write e.g. (cuda-map f coll) which embeds f in a Kernel, copies the contents of coll and the new kernel up to your CUDA GPU and executes f on the contents of coll in parallel producing a new coll which is copied back into Clojure world and returned... Of course, there are lots of things to be resolved here, I have only had time today to Compile up the CUDA download, clone the RootBeer git repo, compile it and try to run the example program - ArraySumApp. I got an error which I am thinking indicates that RootBeer doesn't like my 1.7.0_03-icedtea-mockbuild_2012_06_13_11_56-b00 - the current version of Java on my Fedora16 box, but... think how much fun I could have with this little project :-). Anyway, I thought I would just announce my intentions to play with this on the list, in case anyone else was interested or already doing so and fancied collaborating or, maybe someone will be able to tell me why it will never work and save me the effort :-) all the best, Jules -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure on an Erlang-vm-os on Xen?
There was an old Sun project to run the JVM directly on Xen[1] without a heavyweight OS inbetween. It looks like it never got beyond research stage, but in theory it would be possible to run Clojure on it. I'm afraid I have no idea if it actually works though! [1]: http://labs.oracle.com/projects/dashboard.php?id=185 On Friday, 13 July 2012 18:15:18 UTC+1, FrankS wrote: Just became aware of this effort: http://erlangonxen.org/; which shows off some impressive properties: * Startup time of a new instance is 100ms * Instances are provisioned after the request arrival - all requests get handled * No instances are running waiting for requests - the cloud footprint is zero * the size of infrastructure is proportional to the maximum load - 8 servers may be enough * … All that begs the Q: would Clojure on an Elang-VM be feasible and make sense? -FrankS. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Create dynamic vars programmatically
(doseq [s '(a b c)] (intern *ns* s 0)) creates non-dynamic var's. However, how could I produce *dynamic* var's. I tried with-meta but failed. In other words, what does (def ^:dynamic a) internally do? *Thanks in advance, Marc* -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How create dynamic var programmatically
(intern *ns* 'a 0) creates a non-dynamic var. However, how do I create a dynamic one like (def ^:dynamic a) does? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problems with Leiningen and Clojure 1.4
By the way, Lein2 uses the local maven repository to cache dependencies. You can find the clojure jar(s) used by your lein2-managaed project in ~/.m2/repository/org/clojure/clojure https://github.com/technomancy/leiningen/wiki/Upgrading (In the Gotchas section) On Friday, August 31, 2012 10:38:59 AM UTC-7, Martin wrote: Hi Im having problems using Leiningen together with Clojure 1.4 (and 1.3) on Windows 7. Using Leiningen version 1.5.2 I can create a new project and use lein deps to download clojure version 1.2.1. However if I change dependencies in project.clj to org.clojure/clojure 1.4.0, I run into trouble. Running lein deps downloads clojure-1.4.0.jar to lib. Running lein repl gives: Warning: *classpath* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic *classpath* or change the name. (NO_SOURCE_PATH:1) REPL started; server listening on localhost:50497. It starts up and gives me a prompt, but whatever I write at the prompt (even just enter) freezes the program, forcing me to exit with ctrl-c. I also tried using Leiningen 2.0.0. It automatically creates a project with Clojure 1.3.0 as dependency. Running lein deps gives no error but I cant find Clojure 1.3.0 downloaded anywhere. There is a .lein folder in C:\Users\Martin which contains a couple of jars but not the main Clojure one. Running lein repl starts clojure 1.3.0 without errors, but as above, as soon as I type anything it freezes. Any ideas? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Routing HTTP/ JSON in clojure
Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Routing HTTP/ JSON in clojure
On Tue, Sep 4, 2012 at 1:52 PM, David Dawson david.daw...@dawsonsystems.com wrote: Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! Hi David, have you looked at Ring + Compojure? -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Routing HTTP/ JSON in clojure
Hiya! I saw the names, but then was swamped by moustache, noir and others that at first glance appear to be in similar spaces. I found it a bit difficult to pick out the various specialisms or layers each library is aiming at tbh. So, I thought it best to look for some guidance if possible from people who know what they're doing ... :-) david On Wednesday, 5 September 2012 00:24:46 UTC+1, Russell Whitaker wrote: On Tue, Sep 4, 2012 at 1:52 PM, David Dawson david@dawsonsystems.com javascript: wrote: Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! Hi David, have you looked at Ring + Compojure? -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
On 04/09/12 21:02, Andy Fingerhut wrote: But what if they all consistently throw exceptions when encountering duplicates, including (set [5 5])? That doesn't sound like what you want. of course not...this also goes against set/map semantics from a mathematics point of view...the mathematical guarantees of set ('there will be no duplicates') are imposed by the set itself and not by the person/program/whatever using it! the same with map... since the ctor fns are considered the correct way of initialising sets/maps then I assume the dev team agrees with this simply because these versions do behave like true sets and impose the guarantees themselves. why not the literals? Stuart Halloway mentioned the idea of having two kinds of set/map constructor functions, one kind which quietly eliminates duplicates, another which throws an exception on duplicates. Is this not a source of inconsistency? are there performance issues involved? why not the correct thing on both/all cases? What if the default behavior for set map literals were to quietly allow duplicates, with a new compiler option like the following that would give the error, for those that like it? Now that sounds reasonable...of course the default I think should be the correct (no runtime exceptions)... Perhaps it is starting to look like feature creep, but I thought I'd throw out the idea to see what happens. well, yes you're not wrong on this, but I feel this is more serious/important than other dynamic vars in the clojure runtime (there are a lot !)...to be honest i don't think i would never turn this on so i would eventually forget that knob existed...again, assuming there are no dramatic performance improvements from doing so...having said that, i thought i would never use unchecked-math either but my board-game engine has unchecked math in most namespaces! ok, the quest for performance almost turned that project into a freakshow but at the end of the day i did use that knob. Jim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
On 05/09/12 00:53, Jim - FooBar(); wrote: of course not...this also goes against set/map semantics from a mathematics point of view...the mathematical guarantees of set ('there will be no duplicates') are imposed by the set itself and not by the person/program/whatever using it! the same with map... since the ctor fns are considered the correct way of initialising sets/maps then I assume the dev team agrees with this simply because these versions do behave like true sets and impose the guarantees themselves. why not the literals? in other words: how useful are sets that cannot impose the guarantees of set? if you, the programmer, has to know there are no duplicates, why not use a vector? no, you want that feeling of security that *there will be no duplicates* no matter what! and obviously a RTE is scary and doesn't really give you that feeling of security does it? people use literals all over the place (including me)... Jim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Routing HTTP/ JSON in clojure
On Tue, Sep 4, 2012 at 4:45 PM, David Dawson david.daw...@dawsonsystems.com wrote: Hiya! I saw the names, but then was swamped by moustache, noir and others that at first glance appear to be in similar spaces. I found it a bit difficult to pick out the various specialisms or layers each library is aiming at tbh. So, I thought it best to look for some guidance if possible from people who know what they're doing ... :-) Some of us are only ahead of you by relative measures: I myself had to _remove_ noir noir-async from a project today because of some reloading issues introduced by the latter; see today's (4 Sep 2012) clojure IRC log: http://clojure-log.n01se.net/ Russell david On Wednesday, 5 September 2012 00:24:46 UTC+1, Russell Whitaker wrote: On Tue, Sep 4, 2012 at 1:52 PM, David Dawson david@dawsonsystems.com wrote: Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! Hi David, have you looked at Ring + Compojure? -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Create dynamic vars programmatically
2012/9/4 mdzaebel mdzae...@web.de (doseq [s '(a b c)] (intern *ns* s 0)) creates non-dynamic var's. However, how could I produce *dynamic* var's. I tried with-meta but failed. In other words, what does (def ^:dynamic a) internally do? You can use clojure.lang.Var.setDynamic https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L116 kind regards -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
On Sep 4, 2012, at 4:53 PM, Jim - FooBar(); wrote: On 04/09/12 21:02, Andy Fingerhut wrote: Stuart Halloway mentioned the idea of having two kinds of set/map constructor functions, one kind which quietly eliminates duplicates, another which throws an exception on duplicates. Is this not a source of inconsistency? are there performance issues involved? why not the correct thing on both/all cases? I think the question arises more naturally for maps than for sets. If someone types in the literal map {:a 5 :b 10 :c 13 :a -5}, what is the correct thing? Some people might be thinking the correct thing is I want the last key :a's value, -5, to win always, no matter if the key :a occurs more than once. I never want an error for code like this. Others might be thinking Oh, that is obviously a typo in my source code. I never intentionally want to specify the same key twice in any literal map. I want the compiler to flag that as an error so I don't have to spend lots of testing/debugging time to find that typo. Personally, I can see both of those points of view as reasonable. Either there needs to be a configurable knob to select the behavior, or one group of people is happy, and the other are not. Andy -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Create dynamic vars programmatically
Beware however, that interning vars programmatically is not recommended. If you need fresh vars during runtime, use with-local-vars, which also produces dynamic vars. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
2012/9/5 Andy Fingerhut andy.finger...@gmail.com If someone types in the literal map {:a 5 :b 10 :c 13 :a -5}, what is the correct thing? Some people might be thinking the correct thing is I want the last key :a's value, -5, to win always, no matter if the key :a occurs more than once. I never want an error for code like this. Others might be thinking Oh, that is obviously a typo in my source code. I never intentionally want to specify the same key twice in any literal map. I want the compiler to flag that as an error so I don't have to spend lots of testing/debugging time to find that typo. Why not _only_ throw, if the keys are provably identical? The _reader_ can decide this on a purely syntactic basis. So {:a 1 :a 2}, would throw. (let [a :a] {a 1 a 2}) would also throw. (let [a1 :a a2 :a] {a1 1 a2 2}) would eliminate the duplicate key with last one in wins behavior, as it was before. Maybe it could print a warning, doing so. As it happens, this catches all the obvious cases, like config-maps (where it has already saved me once), while leaving more involved semantics alone. Can I cast a vote that this is the most desirable behavior? I'll start with +1 for throwing on _syntactic_ duplicates -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Routing HTTP/ JSON in clojure
We do all of the things you mention (minus the replay, but that would be trivial) in Clojure where I work, and it is remarkably easy. We use: * ring + compojure and an embedded jetty server to create lightweight webservers * the Cheshire JSON encoding/decoding library for all JSON purposes (https://github.com/dakrone/cheshire) * we wrote our own small wrapper around rabbitmq - but there are several available now (such as https://github.com/michaelklishin/langohr) * for mongo we use: http://clojuremongodb.info/ We also found that when processing JSON messages, multimethods can be extremely useful as a dispatch mechanism if the shape of the JSON data dictates what should happen to it. I would certainly recommend Clojure for what you describe, I think you will be pleasantly suprised how straightforward it is :) On Tue, Sep 4, 2012 at 7:05 PM, Russell Whitaker russell.whita...@gmail.com wrote: On Tue, Sep 4, 2012 at 4:45 PM, David Dawson david.daw...@dawsonsystems.com wrote: Hiya! I saw the names, but then was swamped by moustache, noir and others that at first glance appear to be in similar spaces. I found it a bit difficult to pick out the various specialisms or layers each library is aiming at tbh. So, I thought it best to look for some guidance if possible from people who know what they're doing ... :-) Some of us are only ahead of you by relative measures: I myself had to _remove_ noir noir-async from a project today because of some reloading issues introduced by the latter; see today's (4 Sep 2012) clojure IRC log: http://clojure-log.n01se.net/ Russell david On Wednesday, 5 September 2012 00:24:46 UTC+1, Russell Whitaker wrote: On Tue, Sep 4, 2012 at 1:52 PM, David Dawson david@dawsonsystems.com wrote: Hiya, So, I'm a clojure newbie... and I've been asked to evaluate a few different technology options for a project I've been handed. The end result will need to be a 'router' that accepts JSON messages over HTTP, store them into some datastore (ideally one of the ones available on cloudfoundry, postgres mongo etc), then forward the message onto one or more end points. Forwarding will probably be either dropping into rabbitmq or posting on with HTTP. (or both). There also needs to be a replay capability, so you can tell the router to scoop up the historical messages from the datastore and forward them all on (in order) to a particular end point. I'm totally open to any tech, prebuilt (and commercial) or development required but given that the system needs some algorithmic routing rules, clojure seemed a really nice conceptual fit over the languages I normally work with (imperative jvm ones, essentially) So, I'm really interested in any suggestions on how this might best be approached in the clojure world! Hi David, have you looked at Ring + Compojure? -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Russell Whitaker http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/ http://www.linkedin.com/pub/russell-whitaker/0/b86/329 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN Spyglass 1.0.2
Spyglass is a very fast Memcached and Couchbase client built on top of SpyMemcached. Spyglass 1.0.2 is a bug fix release: * Prevents clojurewerkz.spyglass.client from breaking namespaces that use gen-class Change log: https://github.com/clojurewerkz/spyglass/blob/1.0.x-stable/Changelog.md Documentation guides: http://clojurememcached.info New developments and releases are announced on Twitter @clojurewerkz. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
On Tue, Sep 4, 2012 at 9:30 AM, Andy Fingerhut andy.finger...@gmail.comwrote: I'm just trying to get the argument for change as clearly as possible. The major bullet points: 1. It's a bug that should be fixed. The change to throw-on-duplicate behavior for sets in 1.3 was a breaking change that causes a runtime error in previously working, legitimate code. Looking through the history of the issue, one can see that no one was directly asking for throw-on-duplicate behavior. The underlying problem was that array-maps with duplicate keys returned nonsensical objects; surely it would be more user-friendly to just block people from creating such nonsense by throwing an error. This logic was extended to other types of maps and sets. It's not entirely clear the degree to which the consequences of these changes were considered, but it seems likely that there was an implicit assumption that throw-on-duplicate behavior would only come into play in programs with some sort of syntactic error, when in fact it has semantic implications for working programs. When a new feature causes unintentional breakage in working code, this is arguably a bug and needs to be reconsidered. 2. The current way of doing things is internally inconsistent and therefore complex. (def a 1) (def b 1) (set [a b]) - good (hash-set a b) - error #{a b} - error (sorted-set a b) - good (into #{} a b) - good The cognitive load from having to remember which constructors do what is a bad thing. 3. Current behavior conflicts with the mathematical and intuitive notion of a set. In math, {1, 1} = {1}. In programming, sets are used as a means to eliminate duplicates. Many people have +1'd and reiterated variations of the above arguments. Now let's summarize the arguments that have been raised here in support of the status quo. 1. Changing everything to throw-on-duplicate would be just as logically consistent as changing everything to use-last-in. True, but that doesn't mean that both approaches would be equally useful. It's readily apparent that an essential idea of sets is that they need to be able to gracefully absorb duplicates, so at least one such method of doing that is essential. On the other hand, we can get along just fine without sets throwing errors in the event of a duplicate value. So if you're looking for consistency, there's really only one practical option. 2. I like the idea that Clojure will protect me from accidentally from this kind of syntax error. Clojure, as a dynamically typed language, is unable to protect you from the vast majority of data-entry syntax errors you're likely to make. Let's say you want to type in {:apple 1, :banana 2}. Even if Clojure can catch your mistake if you type {:apple 1, :apple 2}, there's no way it's ever going to catch you if you type {:apple 1, :banano 2}, and frankly, the latter error is one you're far more likely to make. This is precisely why there's little evidence that anyone was asking for this kind of syntax error protection, and little evidence that anyone has benefited significantly from its addition -- its real-world utility is fairly minimal and dwarfed by the other kinds of errors one is likely to make. 3. Maybe we can do it both ways. It's laudable to want to make everyone happy. The danger, of course, is that such sentiment paints a picture that it would be a massive amount of work to please everyone, and therefore, we should do nothing. Let's be practical about what is easily doable here with the greatest net benefit. The current system has awkward and inconsistent semantics with little benefit. Let's focus on fixing it. The easiest patch -- revert to 1.2 behavior, but bring array-map's semantics into alignment with the other associative collections. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Question about sets
+1 on Mark's most recent reply, that is: * Revert to 1.2 behaviour. * Consistency is good, but must be in favour of not throwing RTEs. * No knobs. It's clear that there's lots of directions that could be taken here, but getting caught up on trying to find a solution that pleases everyone 100% is, IMO, both a non-starter and inconsistent with Clojure's generally opinionated approach. The pre-1.2 behaviour was sensible, consistent (both in terms of API and Clojure design idioms IMO) and didn't raise any complaints (as Mark has pointed out, the motivation behind the original change was actually for something unrelated). Mark's arguments on the relative value of RTE/no-RTE behaviour are also sound IMO. My 2c: let's try not to over-analyse this thing. Revert the behaviour, and let's move on to more interesting ways of moving the language forward :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en