Re: ANN: Gloss, a byte-format DSL

2010-11-27 Thread zoka
The most general case would be a codec that can have mixture of big and little endian fields, so legacy comms protocols or file formats can be supported. For example: (defcodec mixed (ordered-map :b :int16, :a :float32-le)) ; total 6 bytes, first 2 bytes short in big endian format (JVM default),

Re: Why isn't there a fold-right?

2010-11-27 Thread nicolas.o...@gmail.com
On Fri, Nov 26, 2010 at 5:28 PM, tpeng pengt...@gmail.com wrote: but this foldr can't handle the infinite list, am i right? I doubt there is a foldr that handles the infinite list. To do anything, it would have to read at least one element: the last. Alex nice answer is a foldl. -- You

Re: Why isn't there a fold-right?

2010-11-27 Thread Alex Osborne
nicolas.o...@gmail.com nicolas.o...@gmail.com writes: I doubt there is a foldr that handles the infinite list. To do anything, it would have to read at least one element: the last. Alex nice answer is a foldl. Actually I think you have them backwards. Wikipedia has a pair of diagrams which

struct type info

2010-11-27 Thread Sunil S Nandihalli
Hello, I would like to know if it is possible to find out the name of the structure from its instance. my attempt to use the function class is not giving me any useful info. It kept saying that it is a structmap and nothing more... Regards, Sunil -- You received this message because you are

Re: struct type info

2010-11-27 Thread Chris Perkins
On Nov 27, 6:24 am, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello,  I would like to know if it is possible to find out the name of the structure from its instance. my attempt to use the function class is not giving me any useful info. It kept saying that it is  a structmap and

Re: struct type info

2010-11-27 Thread David Powell
Hello Sunil, Saturday, November 27, 2010, 11:24:58 AM, you wrote: Hello, I would like to know if it is possible to find out the name of the structure from its instance. my attempt to use the function class is not giving me any useful info. It kept saying that it is a structmap and

Exporting FatJar from Eclipse CCW does not work

2010-11-27 Thread Arie van Wingerden
Hi, when trying to use FatJar from Eclipse / CCW I manage to get the fatjar to be generated; however, when I run the jar I get: D:\src\Clojure\Firstjava -jar First_fat.jar Exception in thread main java.lang.UnsupportedOperationException: First.core/- main not defined at

Re: Exporting FatJar from Eclipse CCW does not work

2010-11-27 Thread Gijs S.
Hi, Perhaps it is a typo but you should have (defn -main [] ...) rather than (defn- main [] ...) Note the place of the dash -. defn- yields a non public var (a private declaration) (http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ defn-) -main uses the dash, which is the

Re: struct type info

2010-11-27 Thread Shantanu Kumar
I think you can either use either defrecord or factory-function + metadata: http://bitumenframework.blogspot.com/2010/10/typed-abstractions-in-clojure.html Regards, Shantanu On Nov 27, 4:24 pm, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello,  I would like to know if it is possible

Re: Wolfram: 100 years since Principia Mathematica

2010-11-27 Thread Alec Battles
Thought some Clojure folk might enjoy this: http://blog.stephenwolfram.com/2010/11/100-years-since-principia-mathematica/ Though I don't use Clojure (I follow this list out of curiosity), I have a hard time imagining why anything Wolfram writes is interesting, and furthermore why any a user of

Symbol evaluation error in let

2010-11-27 Thread Eduardo Julian
user= (let [a 'b] (str a)) b user= (let [b 5 a 'b] (eval a)) java.lang.Exception: Unable to resolve symbol: b in this context (repl-1:7) user= (let [a 'b b 5] (eval a)) java.lang.Exception: Unable to resolve symbol: b in this context (repl-1:9) user= (def b 5) #'user/b user= (def a 'b) #'user/a

Partition At True Values Of Predicate

2010-11-27 Thread Asim Jalis
I want to partition a sequence based on the values of a predicate so that every true starts a new sequence in the partition. Here is an example of how partition-with could be used: (partition-when true? '(true false false true false true true)) - '((true false false) (true false) (true) (true))

Re: a macro to debug the let form

2010-11-27 Thread Robert McIntyre
cool! Although I think with-seperator should be spelled with-separator --Robert McIntyre On Thu, Nov 25, 2010 at 9:13 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: I just tried to re-write with-seperator without using the symbol-macros from macro-utils and it seems to work fine ..

Re: ANN: ClojureQL 1.0.0 finally released as public beta

2010-11-27 Thread Janico Greifenberg
First of all, thank you for this awesome library. I'm experimenting with ClojureQL for accessing Postgis, the spacial extender for Postgres. To improve the ClojureQL for this use case, it would be useful to have a way to add custom predicates. For example to find all places whose location column

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
Could do it this way. Use index-filter (borrowed from Programming Clojure) to get the indices where the predicate is true in the sequence. partition-when-true then just calls subvec with pairs of indices to get the subsequences. coll-end is the index just past the end of the collection. This

Re: Partition At True Values Of Predicate

2010-11-27 Thread rob levy
partition-by does exactly what you need. On Sat, Nov 27, 2010 at 3:04 PM, Benny Tsai benny.t...@gmail.com wrote: Could do it this way. Use index-filter (borrowed from Programming Clojure) to get the indices where the predicate is true in the sequence. partition-when-true then just calls

Re: Partition At True Values Of Predicate

2010-11-27 Thread Ken Wesson
Subvec, however, isn't lazy. This is: (defn split-when [pred coll] (let [ipred (complement pred) bits (iterate (fn [[out coll]] (let [[a b] (split-with ipred (rest coll))] [(cons (first coll) a) b])) [nil coll])] (map

Re: Partition At True Values Of Predicate

2010-11-27 Thread Laurent PETIT
2010/11/27 rob levy r.p.l...@gmail.com partition-by does exactly what you need. Nope. partition-by will split each time the value changes. Not each time a particular value is seen. On Sat, Nov 27, 2010 at 3:04 PM, Benny Tsai benny.t...@gmail.com wrote: Could do it this way. Use

Re: Partition At True Values Of Predicate

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 4:00 PM, rob levy r.p.l...@gmail.com wrote: partition-by does exactly what you need. Not quite. user= (take 10 (partition-by #(= 0 (rem % 3)) (iterate inc 1))) ((1 2) (3) (4 5) (6) (7 8) (9) (10 11) (12) (13 14) (15)) At first it seems you can fix this as

Re: Partition At True Values Of Predicate

2010-11-27 Thread rob levy
Something like this? (defn partition-when [f l] (reduce #(if (f %2) (conj %1 (vector %2)) (conj (butlast %1) (conj (last %1) %2))) [] l)) On Sat, Nov 27, 2010 at 4:15 PM, Ken Wesson kwess...@gmail.com wrote: On Sat, Nov 27, 2010 at 4:00

Re: Symbol evaluation error in let

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 10:45 AM, Eduardo Julian eduardo...@gmail.com wrote: user= (let [a 'b] (str a)) b user= (let [b 5 a 'b] (eval a)) java.lang.Exception: Unable to resolve symbol: b in this context (repl-1:7) user= (let [a 'b b 5] (eval a)) java.lang.Exception: Unable to resolve

Re: Partition At True Values Of Predicate

2010-11-27 Thread rob levy
This is more correct, because conj does not preserve the order correctly. I wonder if there is a more idiomatic way to cons things onto the end of the list. (defn partition-when [f l] (reduce #(if (f %2) (concat %1 (vector (vector %2))) (concat (butlast %1)

Re: Partition At True Values Of Predicate

2010-11-27 Thread rob levy
This is clearer to read though: (defn partition-when [f l] (reduce #(if (f %2) (conj %1 (vector %2)) (conj (vec (butlast %1)) (conj (vec (last %1)) %2))) [] (vec l))) On Sat, Nov 27, 2010 at 4:47 PM, rob levy r.p.l...@gmail.com wrote:

Re: Symbol evaluation error in let

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 4:31 PM, Ken Wesson kwess...@gmail.com wrote: On Sat, Nov 27, 2010 at 10:45 AM, Eduardo Julian eduardo...@gmail.com wrote: user= (let [a 'b] (str a)) b user= (let [b 5 a 'b] (eval a)) java.lang.Exception: Unable to resolve symbol: b in this context (repl-1:7) user=

New installation for Emacs clojure-mode, etc.

2010-11-27 Thread Phil Hagelberg
One of the biggest frustrations in maintaining the Emacs libraries for Clojure has been the fact that ELPA, the original package archive for Emacs, is manually curated, so updates can take a very long time to propagate. In Emacs 24 (currently under development), they have bundled the package.el

Re: Autodoc dependencies broken?

2010-11-27 Thread Rayne
If it's helpful, I have a snapshot of autodoc 0.8.0 on clojars that I'm using in cake-autodoc: http://clojars.org/org.clojars.rayne/autodoc On Nov 26, 9:21 pm, James Reeves jree...@weavejester.com wrote: I've investigated this a little further, and it looks like I was misinterpreting the

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
Subvec, however, isn't lazy. That's true. I just realized there's another problem with my approach as well: it does not preserve elements before the first true index. user= (partition-when true? [false true]) ([true]) When the result should probably be: user= (partition-when true? [false

Re: Why isn't there a fold-right?

2010-11-27 Thread tpeng
thanks Alex for this nice foldr. ;-) however this lazy-foldr can only be used when the fn can stop by itself (in this case, it's 'and' which is short-circuited) otherwise lazy-foldr will never get stop. i think for a good foldr, the evaluation of #(lazy-foldr f val xs) should be only forced when

Re: ANN: Durable Clojure - Functions and Closures

2010-11-27 Thread Mark
Hi - I'm surprised your work doesn't generate more interest from folks. I wish I had more time, I would definitely jump in and help. On Nov 24, 3:37 pm, Alyssa Kwan alyssa.c.k...@gmail.com wrote: Extension ofhttp://groups.google.com/group/clojure/browse_thread/thread/7c917e983... Hi

Re: Exporting FatJar from Eclipse CCW does not work

2010-11-27 Thread Arie van Wingerden
Hi Gijs, it wasn't a typo, but lack of knowledge :-) Indeed this is the solution. Thanks for your help! Regards, Arie 2010/11/27 Gijs S. gijsstuur...@gmail.com Hi, Perhaps it is a typo but you should have (defn -main [] ...) rather than (defn- main [] ...) Note the place of the dash

Re: ANN: Durable Clojure - Functions and Closures

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 1:10 PM, Mark markaddle...@gmail.com wrote: Hi - I'm surprised your work doesn't generate more interest from folks.  I wish I had more time, I would definitely jump in and help. Persistence doesn't seem to generate much interest in general. I posted my own stab at a

Ring startup processing?

2010-11-27 Thread Mike Meyer
My simple web app (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has some stuff that needs to happen just once (in this case, opening the serial port). It's not clear how to get this to happen using ring. If I do it inside my ring handler, then it gets run on every request, and I

Re: Partition At True Values Of Predicate

2010-11-27 Thread rob levy
fwiw my folding solution above yields the expected result. On Sat, Nov 27, 2010 at 7:07 PM, Benny Tsai benny.t...@gmail.com wrote: Subvec, however, isn't lazy. That's true. I just realized there's another problem with my approach as well: it does not preserve elements before the first true

Re: Symbol evaluation error in let

2010-11-27 Thread Eduardo Julian
Woah. That's as weird as you can get. Thanks, man. -- 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.

Can clojure.contrib.fnmap.PersistentFnMap have metadata

2010-11-27 Thread Eduardo Julian
I was trying to use the fnmap API at clojure.contrib for some things and I needed to add metadata to the function maps but I got this exception: java.lang.ClassCastException: clojure.contrib.fnmap.PersistentFnMap cannot be cast to clojure.lang.IObj Stuart, can you make PersistentFnMa extend

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
Here's a fixed version that... 1. Is lazy everywhere. 2. No longer loses elements :) (use '[clojure.contrib.seq :only (indexed)]) (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) (defn subsequence [coll start end] (take (- end start)

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
I really dig the succinctness of your folding solutions. On Nov 27, 5:52 pm, rob levy r.p.l...@gmail.com wrote: fwiw my folding solution above yields the expected result. On Sat, Nov 27, 2010 at 7:07 PM, Benny Tsai benny.t...@gmail.com wrote: Subvec, however, isn't lazy. That's

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
If you don't mind, I would love to see your version with lazy-seq and recursion. Seems like that's the idiomatic way of solving problems like this, judging by the source for the partition functions. On Nov 27, 10:02 am, Asim Jalis asimja...@gmail.com wrote: I want to partition a sequence based

Re: Ring startup processing?

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 7:50 PM, Mike Meyer mwm-keyword-googlegroups.620...@mired.org wrote: My simple web app (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has some stuff that needs to happen just once (in this case, opening the serial port). It's not clear how to get this to

Re: Ring startup processing?

2010-11-27 Thread lprefontaine
Hi, Normally this is done use an initialization servlet. You need a separate class inheriting javax.servlet.http.HttpServlet and a entry in your web.xml file to get it executed once at application startup. Look at load-on-startup here:

Re: Ring startup processing?

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 9:19 PM, Ken Wesson kwess...@gmail.com wrote: On Sat, Nov 27, 2010 at 7:50 PM, Mike Meyer mwm-keyword-googlegroups.620...@mired.org wrote: My simple web app (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has some stuff that needs to happen just once (in

Re: Partition At True Values Of Predicate

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 8:35 PM, Benny Tsai benny.t...@gmail.com wrote: Here's a fixed version that... 1. Is lazy everywhere. 2. No longer loses elements :) ... (defn split-when [pred coll]  (let [coll-end (count coll) Er, did you just say is lazy everywhere? :) -- You received this

Re: Symbol evaluation error in let

2010-11-27 Thread Ken Wesson
Caveat: since eval-with-local-vars is a macro you won't be able to directly use it in HOFs. Wrapping it in a closure works, however: user= (let [a 1 b 2] (map #(eval-with-local-vars [a b] %) ['(+ a b) '(* a b)])) (3 2) -- You received this message because you are subscribed to the Google Groups

Understanding clojure bindings

2010-11-27 Thread Andreas Kostler
Hi all, Sorry for my noob question (again). I'm trying to understand clojures binding model. Typing: (def state {:status foo}) (def rule '(if (= (:status sate) foo) (println foo) (println (bar))) (defn fn [] (let [state {:status bar}] (eval rule))) This prints foo. However, I would have

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
That's what I get for coding without taking my afternoon nap :) Try 3. Tweaked 'subsequence' and 'split-when' so that it is no longer necessary to calculate the index for the end of the collection. Also added a check to 'split-when' to return an empty list when called on an empty collection;

Re: Ring startup processing?

2010-11-27 Thread Alex Osborne
Mike Meyer mwm-keyword-googlegroups.620...@mired.org writes: My simple web app (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has some stuff that needs to happen just once (in this case, opening the serial port). It's not clear how to get this to happen using ring. If I do it

Re: Understanding clojure bindings

2010-11-27 Thread Eduardo Julian
You might wanna check out the post I recently made and the answer by Ken Wesson: http://groups.google.com/group/clojure/browse_thread/thread/9b042a2ddb8017aa It's basically the same thing. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: Understanding clojure bindings

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 10:42 PM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hi all, Sorry for my noob question (again). I'm trying to understand clojures binding model. Typing: (def state {:status foo}) (def rule '(if (= (:status sate) foo) (println foo) (println (bar)))

Re: Understanding clojure bindings

2010-11-27 Thread Andreas Kostler
Is this a 'bug' with eval? On 28 November 2010 14:09, Ken Wesson kwess...@gmail.com wrote: On Sat, Nov 27, 2010 at 10:42 PM, Andreas Kostler andreas.koestler.le...@gmail.com wrote: Hi all, Sorry for my noob question (again). I'm trying to understand clojures binding model. Typing:

Re: Partition At True Values Of Predicate

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 11:03 PM, Benny Tsai benny.t...@gmail.com wrote: That's what I get for coding without taking my afternoon nap :) Try 3.  Tweaked 'subsequence' and 'split-when' so that it is no longer necessary to calculate the index for the end of the collection.  Also added a check

Re: Understanding clojure bindings

2010-11-27 Thread Ken Wesson
On Sat, Nov 27, 2010 at 11:15 PM, Andreas Kostler andreas.koest...@leica-geosystems.com wrote: Is this a 'bug' with eval? It seems to be intended, if undocumented* and sometimes awkward, behavior. * In that (doc eval) doesn't say anything about this issue. -- You received this message because

Re: Partition At True Values Of Predicate

2010-11-27 Thread Benny Tsai
Huh, didn't know that about 'distinct'. Thank you for the tip. On Nov 27, 9:18 pm, Ken Wesson kwess...@gmail.com wrote: On Sat, Nov 27, 2010 at 11:03 PM, Benny Tsai benny.t...@gmail.com wrote: That's what I get for coding without taking my afternoon nap :) Try 3.  Tweaked 'subsequence' and

Re: clojure 1.3 alpha3 and swank

2010-11-27 Thread Michael Ossareh
I had no issues with swank-clojure 1.3.0: in project.clj [swank-clojure 1.3.0] I had plenty of issues using other libraries as there are some breaking changes in 1.3. YMMV. On Thu, Nov 25, 2010 at 05:52, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello Everybody, I would like to

Re: Ring startup processing?

2010-11-27 Thread Rob Lachlan
The servlet interface includes the init method for this exact purpose. In java, this would be used by subclassing one of the abstract servlet classes, and filling in the init method with whatever initialization you need. Or by implementing the servlet interface directly. From the javadoc, the

Re: Understanding clojure bindings

2010-11-27 Thread Tim Robinson
This works as I would expect it to. 'rule' brings in 'state' from the global binding into it's scope giving it priority over the outer scope bindings found in the parent function. On Nov 27, 9:15 pm, Andreas Kostler andreas.koest...@leica- geosystems.com wrote: Is this a 'bug' with eval? On

Re: REQUEST for feedback on http://clojure.org

2010-11-27 Thread Tom Faulhaber
Jason, Actually Alex was a little off the mark here. The problem was in the templates that generate the autodoc so they were pretty easy to fix for all versions. The github links are now fixed and I expect to modify the assembla pointers to the new confluence/jira stuff tonight or tomorrow.

Re: Wolfram: 100 years since Principia Mathematica

2010-11-27 Thread Duane Searsmith
I thought his blog had some interesting points. I enjoyed reading it. Do I wish Mathematica was more affordable and/or open source? Yes. So what. That doesn't make Wolfram a lunatic or a fraud. Remember that mathematicians like Mandelbrot where also considered frauds at first. On Fri, Nov

Re: Understanding clojure bindings

2010-11-27 Thread Alex Osborne
Andreas Kostler andreas.koest...@leica-geosystems.com writes: Is this a 'bug' with eval? No, eval is a simply a function and so like any other function it can't see the lexical (local) environment which it was called from. Doing this: (let [a 1, b 2] (eval '(+ a b))) Is similar to doing

Re: Ring startup processing?

2010-11-27 Thread lprefontaine
From http://docstore.mik.ua/orelly/java-ent/servlet/ch03_03.htm - Just like applets, servlets can define init() and destroy() methods. A servlet's init(ServletConfig) method is called by the server immediately after the server constructs the servlet's instance.