On Thu, Jun 4, 2009 at 12:27 PM, Mark Reid <mark.r...@gmail.com> wrote:
>
> Hi again,
>
> I misinterpreted the question first time around but here's another
> attempt.
>
> Given f, a0 and v, let b0 = (reduce f a0 v) = f( f( f( f(a0, v[1]), v
> [2]), ...), v[n])
>
> Now define the function g to ignore its second argument and return its
> first. That is, g(x, y) = x.
>
> Then (reduce g b0 (reverse v)) = g( g( g( g(b0, v[n]), v[n-1], ...), v
> [1]) = b0 = x = (reduce f a0 v).

Ah excellent :)

> This solution seems like a bit of a cheat but as far as I can tell it
> fits the problem description.

I think that's probably the correct answer.

> A more difficult problem (I suspect impossible) would be to find a g
> and b0 that works for any v. That is,

This is how I (mis)read the question, so I thought it was impossible.
I should have read it properly after telling you you had misread it ;)

-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to