Re: problem 58 on 4clojure

2013-12-10 Thread Leon Talbot
Hello Ritchie! I had almost the same: (fn [ fs] (let [f (last fs) r (rest (reverse fs))] (fn [ data] (reduce #(%2 %) (apply f data) r But then I really liked your destructuring, so I'll take it with me: (fn [ fs] (let [[f r] (reverse fs)] (fn [ data]

Re: problem 58 on 4clojure

2012-08-26 Thread Tyler Perkins
It might help to simplify. Whenever you're accumulating over a sequence of things, think of reduce: (let [__ (fn [ fs] ;; Here's the function: (reduce #(fn [x] (%1 (%2 x))) fs)) ] ;; Testing: [ (= 5 ((__ (partial + 3) second) [1 2 3 4])) (= [3 2

Re: problem 58 on 4clojure

2012-08-26 Thread Sam Ritchie
Here's a solution using reduce that handles passing multiple arguments into the rightmost function: (fn [ fns] (fn [ args] (let [[f fns] (reverse fns)] (reduce #(%2 %1) (apply f args) fns On Sun, Aug 26, 2012 at 9:12 AM, Tyler Perkins thinks.outs...@gmail.comwrote: It

problem 58 on 4clojure

2012-08-25 Thread John Holland
This problem is really confusing me. I found a solution online, but I can't understand the solution. Can anyone explain to me why this works? The problem is stated as: Write a function which allows you to create function compositions. The parameter list should take a variable number of

Re: problem 58 on 4clojure

2012-08-25 Thread Bronsa
check out clojure.core/comp, and it's source 2012/8/25 John Holland jbholl...@gmail.com This problem is really confusing me. I found a solution online, but I can't understand the solution. Can anyone explain to me why this works? The problem is stated as: Write a function which allows

Re: problem 58 on 4clojure

2012-08-25 Thread Bronsa
its* 2012/8/25 Bronsa brobro...@gmail.com check out clojure.core/comp, and it's source 2012/8/25 John Holland jbholl...@gmail.com This problem is really confusing me. I found a solution online, but I can't understand the solution. Can anyone explain to me why this works? The problem is

Re: problem 58 on 4clojure

2012-08-25 Thread Erlis Vidal
How can I find the problem # 58? This is something I was looking right now. What's the best order to follow? I know I can sort by complexity but I think there should be a better way to sort them. Thanks On Sat, Aug 25, 2012 at 1:05 PM, Bronsa brobro...@gmail.com wrote: its* 2012/8/25

Re: problem 58 on 4clojure

2012-08-25 Thread Mayank Jain
On Sat, Aug 25, 2012 at 10:54 PM, Erlis Vidal er...@erlisvidal.com wrote: How can I find the problem # 58? http://www.4clojure.com/problem/58 Just modify the parameter to the problem number you want to see. This is something I was looking right now. What's the best order to follow? Start

Re: problem 58 on 4clojure

2012-08-25 Thread Erlis Vidal
Thanks for the link. I didnt notice the problem number in the URL. I've sorted the problems and lost the default order. Thanks again Erlis On Sat, Aug 25, 2012 at 1:29 PM, Mayank Jain firesof...@gmail.com wrote: On Sat, Aug 25, 2012 at 10:54 PM, Erlis Vidal er...@erlisvidal.comwrote: How can

Re: problem 58 on 4clojure

2012-08-25 Thread Denis Labaye
On Sat, Aug 25, 2012 at 6:47 PM, John Holland jbholl...@gmail.com wrote: This problem is really confusing me. I found a solution online, but I can't understand the solution. Can anyone explain to me why this works? The problem is stated as: Write a function which allows you to create

Re: problem 58 on 4clojure

2012-08-25 Thread nicolas.o...@gmail.com
Here's my take: We want to define a function my-comp. It takes n functions and return their composition. We want to return a function of any number of arguments, so let's start by working with a given set of argument args, and returning the value of the composition applied to those arguments. -

Re: problem 58 on 4clojure

2012-08-25 Thread John Holland
Thanks to a for the replies. I will study them later when I am free. On Aug 25, 2012 2:37 PM, nicolas.o...@gmail.com nicolas.o...@gmail.com wrote: Here's my take: We want to define a function my-comp. It takes n functions and return their composition. We want to return a function of any

Re: problem 58 on 4clojure

2012-08-25 Thread John Holland
OK, I think I'm starting to get it now - the idea is a function that accepts x xs , which are functions, and returns a function which has a var-args arity [ args], which is the composition of the xs. Thanks to all for the replies - I still haven't looked at the source to comp but it will be fun