Re: partition-starting-every : yet another partition function
I agree with number 2: it would be very nice to have this in contrib. I needed it last month and rolled my own (less clean) version. Thomas On Sep 10, 10:26 pm, Matt Smith m0sm...@gmail.com wrote: problem: convert a collection [1 2 0 1 2 3 0 1 2 3 0 0 1 2] into partitions like: ((1 2) (0 1 2 3) (0 1 2 3) (0) (0 1 2)) In this case, start each partition on a 0. I looked at the various partition functions but none of them would do the trick without adding unnecessary complexity. Instead I wrote a new function based on partition-by: Solution: (defn partition-starting-every Partition the sequence starting each partition when the f is true. [f coll] (if-let [coll (seq coll)] (let [p (cons (first coll) (take-while (complement f) (rest coll)))] (lazy-seq (cons p (partition-starting-every f (drop (count p) coll))) user=(partition-starting-every zero? [1 2 0 1 2 3 0 1 2 3 0 0 1 2]) ((1 2) (0 1 2 3) (0 1 2 3) (0) (0 1 2)) Questions: 1 - Is there a simpler way to do this using existing partition functions? 2 - If not, is this something people are interested in having contributed? In looking at the partition functions they are very similar. Maybe there is a why to combine them in to a single function. -- 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: Feature idea: meta-macros
On Sep 16, 4:10 pm, Nicolas Oury nicolas.o...@gmail.com wrote: The logged function would have to be already a generic method, no? Yes, and in idiomatic Common Lisp that's not particularly common (pardon the pun). Generic functions are typically only used when dynamic dispatch is actually needed. However, you can achieve what the OP asked by doing something like (untested): (let ((original-fn (symbol-function 'foo))) (setf (symbol-function 'foo) (lambda (rest args) ...whatever... (apply original-fn args which is similar to the alter-var-root solution proposed upthread. Note also that the OP's original example does not require anything more than what defmacro already provides. And turning function calls into macro calls is not a great idea; it won't cover the use of apply and similar. -- 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
clojure eval + records + protocols
I'm able to eval forms and strings defined at the root of a clojure file (example below). Then I extended this pattern to records and protocols. Q: Is this idiomatic clojure? Is there a better pattern for encapsulating data/code in clojure? Q: How would one guard against the brittleness of encapsulating api details like this in the data? As the Protocol and Record implementations are rev'd, how would one make the underlying data flexible to this (backwards compatible?) -Todd - CODE - $ cat context.clj (def dsl-form '(foo bar from dsl-form)) (def dsl-text (foo \bar from dsl-text\)) (defn foo [t] (println foo: t)) (println --) (println direct eval and load-string) (println --) (eval dsl-form) (load-string dsl-text) (println --) (println eval via a record and protocol) (println --) ; This implementation does not work, because there is an implicit 'this' ; implied in the record. ;(defprotocol TestProtocol1 ; (foo [t] test method) ; (process [s] evaluate inpt) ) ; ;(defrecord MyRecord1 [name] ; TestProtocol1 ;(foo [t] (println MyRecord t)) ;(process [s] (eval s))) ; ;(def r1 (MyRecord1. [somename])) ; (doto r1 ;(.process dsl-form) ;(.process dsl-text))) ; ;(def dsl-form2 '(foo this bar from dsl-form)) ;(def dsl-text2 (foo this \bar from dsl-text\)) ; ;(defprotocol TestProtocol2 ; (foo [this t] test method) ; (process [this s] evaluate inpt) ) ; ;(defrecord MyRecord2 [name] ; TestProtocol2 ;(foo [this t] (println MyRecord2 t)) ;(process [this s] (eval s))) ; ;(def r2 (MyRecord2. [somename])) ; ;(doto r2 ; (.process dsl-form2) ; (.process dsl-text2)) (def *record* nil) (def dsl-form3 '(foo *record* bar from dsl-form)) (def dsl-text3 (foo *record* \bar from dsl-text\)) (defprotocol TestProtocol3 (foo [this t] test method) (process [this s] evaluate inpt) ) (defrecord MyRecord3 [name] TestProtocol3 (foo [this t] (println MyRecord3 t)) (process [this s] (binding [*record* this] (eval s (def r3 (MyRecord3. [somename])) (doto r3 (.process dsl-form3) (.process dsl-text3)) - OUTPUT - t...@greenmachine:~/Documents/projects/clojure/lein-test/clojure-cad$ clj.sh context.clj java -server -cp /Users/todd/bin/jline/jline-0_9_5.jar:/Users/todd/bin/clojure/clojure.jar:/Users/todd/bin/clojure/clojure-contrib.jar jline.ConsoleRunner clojure.main context.clj -- direct eval and load-string -- foo: bar from dsl-form foo: bar from dsl-text -- eval via a record and protocol -- Warning: protocol #'user/TestProtocol3 is overwriting function foo MyRecord3 bar from dsl-form -- 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: partition-starting-every : yet another partition function
Finished is a predicate which designates when the seed is exhausted. Because seed is not necessary a sequence, finished is not always empty?. For instance: = (unfold (fn [x] [(* x x) (inc x)]) #( % 10) 0) (0 1 4 9 16 25 36 49 64 81 100) Or the zipmap (zip2) example from the wikipedia page. Although the first example wanders back into territory where the existing sequence functions such as iterate, take-while and for would suffice. -Gijs -- 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: thinking in clojure
On Thu, Sep 16, 2010 at 07:53, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/9/16 Meikel Brandmeyer m...@kotka.de Hi Laurent, On 16 Sep., 15:54, Laurent PETIT laurent.pe...@gmail.com wrote: you don't like my one-liner ? :-) I saw your message only after I sent mine. :) (update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp vec concat) data) Hmm... (comp vec concat) == into? Yep. so this is the killer one : :-) (update-in coll [k] (fnil update-in *default-value*) [:meetings] into data) Awesome, thank you for returning concision to my code! I'd certainly missed the update-in, and related, functions. Cheers Laurent! -- 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: thinking in clojure
(loop [data (sorted-map) collection newData meeting (first collection)] (def key ( )) As a general rule, def should only be used at the top level. You probably want (let [key ...] (if ...) here. Hey, thanks for pointing this out - I was actually just trying to avoid passing these values in the loop signature. Your point is very well taken and I've now replaced those (def)'s with a let inside the loop. (if (not (nil? (next collection) Minor nit: (not (nil? X)) is better spelled (seq? X)) Right! That's actually a standard idiom, except you missed the assoc-in and get-in functions: (assoc-in data key :meetings (conj (get-in data key :meetings) meeting) Thanks for the advice. I've taken Laurent's feedback and ended up with: (update-in data [week-difference] (fnil update-in (struct week title [])) [meetings] into [decorated]) Which certainly reads far better than what I had. Thanks for pointing out get-in, another *key* fn I've missed. The standard library is rather large, I guess this'll take a while. -- 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: thinking in clojure
Meikel, (recur (cond (not (nil? (data key))) (true? true) *ieeck* Please do (cond ... :else default-clause). Not true, or (true? true) or other stuff. Wow, I somehow missed the :else option in cond? I've got that (true? true) stuff scattered all over my code - going to change that right now. Thanks for showing me this. -- 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: inline vs extended types
Thanks for replying, Would definterface be the right thing to do in this case? I'm trying to understand how best to solve similar problems and not this one in particular. sincerely Sidhant -- 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: Feature idea: meta-macros
On Fri, Sep 17, 2010 at 08:50, Alessio Stalla alessiosta...@gmail.com wrote: On Sep 16, 4:10 pm, Nicolas Oury nicolas.o...@gmail.com wrote: Note also that the OP's original example does not require anything more than what defmacro already provides. And turning function calls into macro calls is not a great idea; it won't cover the use of apply and similar. Hmmm, that's odd. Perhaps I've missed a message somehow, but I'm not sure why name-space manipulation isn't the right thing to use. To condense, I want to change the behaviour of (foo ...), is that right? If so, then instead of getting the definition of foo from its usual name space, couldn't I get it from a 'tracing foo' name space or 'wrapping foo in bar' name space? I think I could do this with macros, such that the usual name space that foo comes from is used, but foo is 'redefined' with a macro to do something that masquerades as foo and probably/maybe calls the 'real' foo eventually. Problem is that macros interact with apply, etc. so I'm back to thinking name space manipulations are the right thing, or that I've skimmed too much and don't understand the problem. :-) -Doug -- 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: thinking in clojure
On 17 September 2010 00:56, Michael Ossareh ossa...@gmail.com wrote: Meikel, (recur (cond (not (nil? (data key))) (true? true) *ieeck* Please do (cond ... :else default-clause). Not true, or (true? true) or other stuff. Wow, I somehow missed the :else option in cond? I've got that (true? true) stuff scattered all over my code - going to change that right now. Thanks for showing me this. It's not actually an :else option in cond. Anything that is not false or nil can work there, so :any-arb-keyword would work just as well as :else. But by convention, Clojure programmers tend to use :else. -- Michael Wood esiot...@gmail.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
The failing test cases in c.c.logging
While debugging tests (hudson only failures) in pallet, I noticed that there was some interaction between my tests, as if they were running in parallel. To solve the issues I added binding calls inside each test case, which solved my issues. The c.c.logging test cases failures look similar, so might I suggest adding a binding for log/*logging-agent* inside each of the failing tests. I am unable to explain why there is an interaction. -- Hugo Duncan -- 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: ClassCastException: class to interface
[L... is an array of ..., so it looks like you need to create a Java array to give it. Oh, dear, i could have expected something like that :) But i spent a lot of time, just being clueless. Thank you a lot for your help! and big shout outs to everyone making this language possible! JonnyB -- 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: partition-starting-every : yet another partition function
I was just saying that not returning something that is a pair, for example nil, is good enough. (unfold (fn [x] (when (= x 10) [(* x x) (inc x)])) would work. Both function can be written with each other anyway. And they don't have the same number of args so they are compatible with each other. On Thu, Sep 16, 2010 at 8:05 PM, Gijs S. gijsstuur...@gmail.com wrote: Finished is a predicate which designates when the seed is exhausted. Because seed is not necessary a sequence, finished is not always empty?. For instance: = (unfold (fn [x] [(* x x) (inc x)]) #( % 10) 0) (0 1 4 9 16 25 36 49 64 81 100) Or the zipmap (zip2) example from the wikipedia page. Although the first example wanders back into territory where the existing sequence functions such as iterate, take-while and for would suffice. -Gijs -- 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 -- Sent from an IBM Model M, 15 August 1989. -- 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: partition-starting-every : yet another partition function
(defn unfold ([grow seed] (lazy-seq (if-let [[elt next-seed] (grow seed)] (cons elt (unfold grow next-seed) ([grow finished? seed] (unfold #(when (not (finished? %)) (grow %)) seed))) (unfold (fn [x] [(* x x) (inc x)]) #( % 10) 0) (0 1 4 9 16 25 36 49 64 81 100) (unfold (fn [x] (when (= x 10) [(* x x) (inc x)])) 0) (0 1 4 9 16 25 36 49 64 81 100) I think it can be proved that any sequence can be build with a call to unfold. Which makes it useful and solves the why reduce is not lazy? question. -- 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: Feature idea: meta-macros
On 17 Set, 17:34, Doug Philips douglas.phil...@gmail.com wrote: On Fri, Sep 17, 2010 at 08:50, Alessio Stalla alessiosta...@gmail.com wrote: On Sep 16, 4:10 pm, Nicolas Oury nicolas.o...@gmail.com wrote: Note also that the OP's original example does not require anything more than what defmacro already provides. And turning function calls into macro calls is not a great idea; it won't cover the use of apply and similar. Hmmm, that's odd. Perhaps I've missed a message somehow, but I'm not sure why name-space manipulation isn't the right thing to use. To condense, I want to change the behaviour of (foo ...), is that right? If so, then instead of getting the definition of foo from its usual name space, couldn't I get it from a 'tracing foo' name space or 'wrapping foo in bar' name space? I think I could do this with macros, such that the usual name space that foo comes from is used, but foo is 'redefined' with a macro to do something that masquerades as foo and probably/maybe calls the 'real' foo eventually. Problem is that macros interact with apply, etc. so I'm back to thinking name space manipulations are the right thing, or that I've skimmed too much and don't understand the problem. :-) Hmm. I can't quite understand what you mean by namespace manipulations, because my Clojure-fu is really limited, I'm just lurking here to keep in touch with what happens in the other camp ;) Anyway, I don't think it's *you* the one who gets the definition of foo from the whatever namespace; it's the Clojure system that does. So if you want to make Clojure see a different foo, you have to redefine - or rebind, with the appropriate caveats - foo. Redefining it as a function is sufficient; introducing a macro doesn't buy anything in this case: it forces you to recompile all the code that uses foo, even third-party code, and makes the new foo lose its first- class object status. In general, using a macro to modify the behaviour of existing code is dangerous and smells a little too much like C ;) Just my €.02, Alessio -- 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
Displaying POSTed string from form text-field in Compojure
Hi all, I'm having a problem that may or may not be Compojure specific, so I thought I'd try this group since the answer is probably easy- I am just stuck. I am reading the string through a simple form (defn view-input [] (view-layout [:h2 Enter one datum:] [:form {:method post :action /} [:input.datum {:type text :name my_datum}] [:input.action {:type submit :value Add}]])) where the route for posting is (POST / [a] (view-output a))) I then simply want to display what I entered and submitted (say I typed the string a). (defn view-output [a] (view-layout [:h2 (str This is what you entered: a))) However what I get is this: clojure.core$...@1e731e90 Thanks in advance for your help! Victor -- 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: thinking in clojure
On Fri, Sep 17, 2010 at 08:58, Michael Wood esiot...@gmail.com wrote: On 17 September 2010 00:56, Michael Ossareh ossa...@gmail.com wrote: Meikel, (recur (cond (not (nil? (data key))) (true? true) *ieeck* Please do (cond ... :else default-clause). Not true, or (true? true) or other stuff. Wow, I somehow missed the :else option in cond? I've got that (true? true) stuff scattered all over my code - going to change that right now. Thanks for showing me this. It's not actually an :else option in cond. Anything that is not false or nil can work there, so :any-arb-keyword would work just as well as :else. But by convention, Clojure programmers tend to use :else. Thanks for confirming my thoughts, Michael. Indeed I immediately checked the docs and couldn't find :else referenced. -- 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: Displaying POSTed string from form text-field in Compojure
My *guess* it's somehow connected to the code of view-layout since it shows the representation of the function str. Can place the full code (including view-layout) somewhere? On Sep 17, 12:35 pm, Victor bluestar...@gmail.com wrote: Hi all, I'm having a problem that may or may not be Compojure specific, so I thought I'd try this group since the answer is probably easy- I am just stuck. I am reading the string through a simple form (defn view-input [] (view-layout [:h2 Enter one datum:] [:form {:method post :action /} [:input.datum {:type text :name my_datum}] [:input.action {:type submit :value Add}]])) where the route for posting is (POST / [a] (view-output a))) I then simply want to display what I entered and submitted (say I typed the string a). (defn view-output [a] (view-layout [:h2 (str This is what you entered: a))) However what I get is this: clojure.core$...@1e731e90 Thanks in advance for your help! Victor -- 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
datastore not saving? [appengine-clj]
Greetings, I'm trying to use appengine-clj (http://github.com/r0man/appengine- clj) datastore and having a problem. This is probably not a bug but something I'm missing. I'm trying the following: (defentity User () ((id) (phone))) (save-entity (user {:id 1 :phone 2})) (count (select users)) The last statement return 0, so it looks to me that nothing was saved. What am I doing wrong? Thanks, -- Miki -- 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: datastore not saving? [appengine-clj]
Found it, should be user (singular) On Sep 17, 2:56 pm, Miki miki.teb...@gmail.com wrote: Greetings, I'm trying to use appengine-clj (http://github.com/r0man/appengine- clj) datastore and having a problem. This is probably not a bug but something I'm missing. I'm trying the following: (defentity User () ((id) (phone))) (save-entity (user {:id 1 :phone 2})) (count (select users)) The last statement return 0, so it looks to me that nothing was saved. What am I doing wrong? Thanks, -- Miki -- 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
concurrency example about java x clojure
I'm new to clojure, so sorry if this is a dummie question. Studyng clojure I can understand the syntax and so onbut I would like a real example comparing clojure and java. Do you know some benchmark using first just java and than showing the best results with clojure ? -- 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: practical clojure
I second faenvie's request for applications of Clojure books, especially on AI. AI is the reason I started looking at a Lisp in the first place. I'd also like to see Clojure become *the* language for statistics, though I understand that R statisticians aren't so fond of Lisps. I just bought Practical Clojure and am enjoying it as well. After browsing through an alternative at Barnes and Noble, I was thoroughly confused about Clojure and did not think it a beautiful language. After that, I picked up Practical Clojure and immediately connected with it (and the language). Though it is described as practical, you don't spare us the theory, and I love that. (A detail I really liked is that you save the ugliness that is Java till the end.) The flow is excellent and well-thought-out, and I'm glad you start by describing the Clojure philosophy and don't shirk explanations of its complexity under the hood. For me, this book (so far) feels like The C Programming Language. Well done. On Sep 16, 8:00 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Thanks! Glad you liked the book. -S On Sep 14, 8:37 am, faenvie fanny.aen...@gmx.de wrote: i just emerged from a whirlwind read through 'practical clojure'. i like this book very much. it's a very well structured, carefully written book. kind of a minimalistic approach but minimalistic in the positive sense clojure itself is. so now 'students' have really good choices among 4 high quality introductions and can combine them. for the future: some books about solving state of the art problems with clojure would be nice to come. something like peter norvigs book on AI programming. -- 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: disk-backed memoize?
I highly recommend using redis for this. There is even a clojure redis client. http://github.com/ragnard/redis-clojure On Fri, Sep 17, 2010 at 9:00 PM, David McNeil mcneil.da...@gmail.com wrote: Is there a disk-backed memoize available? I have an application where I would like the cache of values to survive restarts of the app. Thank you. -David McNeil -- Omnem crede diem tibi diluxisse supremum. -- 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: partition-starting-every : yet another partition function
On Fri, Sep 17, 2010 at 10:49 AM, Nicolas Oury nicolas.o...@gmail.com wrote: I was just saying that not returning something that is a pair, for example nil, is good enough. The implement is equivalent, most languages I know that has unfold use your approach(i.e. return Maybee,s or None). This link use the unfold p f g form http://webcache.googleusercontent.com/search?q=cache:ksRX1JVmxFgJ:www.comlab.ox.ac.uk/jeremy.gibbons/publications/unfold.ps.gz+unfold+p+f+gcd=5hl=enct=clnkgl=ca -- 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: Displaying POSTed string from form text-field in Compojure
See http://clojure.pastebin.com/ncaULRbU (works for me). I've changed the POST handler to use *params* and I also think you're not closing the :h2 in view output. On Sep 17, 3:11 pm, Victor Olteanu bluestar...@gmail.com wrote: Sure, here it is: (defn view-layout [ content] (html (doctype :xhtml-strict) (xhtml-tag en [:head [:meta {:http-equiv Content-type :content text/html; charset=utf-8}] [:title Datum]] [:body content]))) This was actually taken from an online tutorial with some changes (http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applica... ) More specifically, in the original tutorial there was an additional intermediate step when the input was parsed: (parse-input a b) with the function (defn parse-input [a b] [(Integer/parseInt a) (Integer/parseInt b)])(parse-input a b) However in my case I'm just dealing with strings, so there's no parseInt involved. So I assumed my input is strings-- which doesn't seem to be the case, and there are no parseString methods that I could use instead. Thank you, Victor On Fri, Sep 17, 2010 at 5:30 PM, Miki miki.teb...@gmail.com wrote: My *guess* it's somehow connected to the code of view-layout since it shows the representation of the function str. Can place the full code (including view-layout) somewhere? On Sep 17, 12:35 pm, Victor bluestar...@gmail.com wrote: Hi all, I'm having a problem that may or may not be Compojure specific, so I thought I'd try this group since the answer is probably easy- I am just stuck. I am reading the string through a simple form (defn view-input [] (view-layout [:h2 Enter one datum:] [:form {:method post :action /} [:input.datum {:type text :name my_datum}] [:input.action {:type submit :value Add}]])) where the route for posting is (POST / [a] (view-output a))) I then simply want to display what I entered and submitted (say I typed the string a). (defn view-output [a] (view-layout [:h2 (str This is what you entered: a))) However what I get is this: clojure.core$...@1e731e90 Thanks in advance for your help! Victor -- 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.comclojure%2bunsubscr...@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
ctrim (with character)
Hi, I'd like to suggest a version trim for clojure.string that can accept a specific character to be trimmed:: (defn ^String ctrim Removes a character from the left side of string. [char ^CharSequence s] (let [slen (.length s) index-left (loop [index (int 0)] (if (= slen index) index (if (= (.charAt s index) char) (recur (inc index)) index))) index-right (loop [index slen] (if (zero? index) index (if (= (.charAt s (dec index)) char) (recur (dec index)) index)))] (.. s (subSequence index-left index-right) toString) )) (N.B. The code above is remashed from the existing triml/r source.) clojure.string/trim could be overloaded to accept either a single parameter (current) or two (proposed above). I'm still new here... what is the common procedure for outsiders to contribute? Fork on github and send link to branch? Like this? Let me know. Thanks, -- Martin -- 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: ctrim (with character)
On Sep 17, 11:18 pm, Martin Blais bl...@furius.ca wrote: I'm still new here... what is the common procedure for outsiders to contribute? Fork on github and send link to branch? Like this? Let me know. Never mind this bit; I found the relevant info on the Clojure website. (Still interested in comments about the code bit above though, thx) -- 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
Using macro to generate part of fn
Hello, In the following contrived example, I get an error when macroexpanding (defn foo ...): (defmacro special-fn-spec [] '([bar baz] (println bar baz))) (defn foo ([bar] (foo bar :default)) (special-fn-spec)) The error is: Parameter declaration special-fn-spec should be a vector [Thrown class java.lang.IllegalArgumentException] I'm a bit confused about the order in which things are happening here. My assumption was that (special-fn-spec) would be evaluated before the fn definition. Is there a way to do something like this? Thanks Stuart -- 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