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). This solution seems like a bit of a cheat but as far as I can tell it fits the problem description. A more difficult problem (I suspect impossible) would be to find a g and b0 that works for any v. That is, Given f and a0 find a g and b0 such that for *any* list of numbers v (reduce f a0 v) = (reduce g b0 (reverse v)) Regards, Mark. -- http://mark.reid.name On Jun 4, 6:42 pm, Daniel Lyons <fus...@storytotell.org> wrote: > On Jun 3, 2009, at 11:23 PM, CuppoJava wrote: > > > > > Hey guys, > > I'm really stuck on this math question, and I'm wondering if you guys > > know of any links that may help me. > > > Given: f(x,y), a0, a list of numbers v. > > Find: g(x,y) and b0 such that: > > > (reduce f a0 v) = (reduce g b0 (reverse v)) > > > Thanks for your help > > What math class is this for and what have you been studying lately in > it? :) > > I couldn't think of any fundamental functions that aren't commutative > besides - and /, which turn out to work like commutative functions if > you use ao = bo. > > My first thought was that if I had a really nasty function I could > maybe use 'flip' to fix it: > > (defn flip [f] > (fn [one two] (f two one))) > > This turned out to be useless. (I was trying with f = #(+ (* %1 %1) > (/ %1 %2)) ). No combination of flip + first/last could make [1 2 3 4 > 5] and [5 4 3 2 1] come out with the same answer that I could see. > > I am quite curious what the final answer turns out to be but I > couldn't come up with it in the ~20 minutes I spent on it. Let us know > when you figure it out! > > — > Daniel Lyonshttp://www.storytotell.org-- Tell It! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---