Hi, Alan, I can see that your suggestion will work. The key, as I understand it, is the embedding of functions, thus:
(fix-ize (fix-ou word))) which is indeed a Lisp-y way of doing things. It seems imperatively I miss elegant one-liners such as this. I'm right now close to getting Laurent's approach to work. Thanks much for your help. Tuba On Thu, Jul 28, 2011 at 1:56 PM, Alan Malloy <a...@malloys.org> wrote: > On Jul 28, 12:22 pm, Thorsten Wilms <t...@freenet.de> wrote: > > On 07/28/2011 06:34 PM, Tuba Lambanog wrote: > > > > > The determination of whether a called function will apply is left as a > > > responsibility of the function itself, rather than the calling > > > function. The motivation is that a function may be called from a > > > number of places. Perhaps there's a better way? > > > > The called function cannot decide to not be applied, but it may either > > evaluate to its argument (assuming unary), or a value derived from that > > argument. > > > > I guess pattern matching would be nice here, but even without, you could > > perhaps split the conditions from the actions. Is there any reason to > > test additional rules after one matches, or would it be beneficial to > > stop after a match? That would make it similar to URL routing like e.g. > > Moustache does it. > > > > From your description, it did sound like you want to call the 2nd > > function with the original argument, not the result of the 1st function. > > But how would you accumulate all the results, then? > > You don't need to "change" the original value at all - you just want > to compute a new value, which, as Thorsten says, may be the same as > the original, or not. Then pass that new value to another function > that may decide to change it again, or not, and then... > > > (defn fix-ou [word] > (clojure.string/replace word #"ou" "o")) > > (defn fix-ize [word] > (clojure.string/replace word #"ise" "ize")) > > (defn apply-all-fixes [word] > (fix-ize (fix-ou word))) > > (defn fix-whole-sentence [words] > (for [word words] > (apply-all-fixes word))) > > user> (fix-whole-sentence ["don't" "criticise" "the" "labour" > "party"]) > ("don't" "criticize" "the" "labor" "party") > > -- > 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