Re: apply an higher order function on an arbitrary nested data structure

2010-10-29 Thread Sean Devlin
Does fmap remove enough complexity to warrant it's own fn? Here's what fmap would now look like. (def fmap (partial same map)) Granted, it's probably the #1 use for same, so you might have a point. Sean On Oct 29, 12:44 am, Konrad Hinsen wrote: > On 28.10.2010, at 21:57, Sean Devlin wrote: >

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Konrad Hinsen
On 28.10.2010, at 21:57, Sean Devlin wrote: > Okay, functor is a good idea but a weak implementation. My complaint > is that it only provides functor behavior for the map function. same > is a higher order function that works on anything, and is based on > protocols. Take a look at the test cas

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Sean Devlin
Okay, functor is a good idea but a weak implementation. My complaint is that it only provides functor behavior for the map function. same is a higher order function that works on anything, and is based on protocols. Take a look at the test cases to understand what I'm talking about. http://gith

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Konrad Hinsen
On 28 Oct 2010, at 16:42, Amitava Shee wrote: I would like to apply an higher order function on an arbitrarily nested data structure which yields exactly the same structure but the original values replaced by the result of applying the passed in function. This is somewhat akin to the fmap funct

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Sean Devlin
Okay, you're re-inventing clojure.walk. Please take a look at that namespace. On Oct 28, 11:52 am, "Eric Schulte" wrote: > Without each type specifying where it would like the function applied > the result will be sort of hacky, but here's my hackey attempt at fmap > in clojure. > > It makes som

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Eric Schulte
Without each type specifying where it would like the function applied the result will be sort of hacky, but here's my hackey attempt at fmap in clojure. It makes some assumptions (e.g. you would only want to apply f to the values rather than the keys of a hash). Also I'm not sure what the best wa

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread nicolas.o...@gmail.com
Functor's fmap in Haskell is passed where to apply the function as an (hidden in the type class dictionary) argument. You would need somehow to be more specific about where you want to apply your function in the data-structure. (On predefined position, a la Functor, or on every leaf, with a defini

Re: apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Sean Devlin
Like my same fn or something different? Maybe combine it with prewalk? Sean On Oct 28, 10:42 am, Amitava Shee wrote: > I would like to apply an higher order function on an arbitrarily > nested data structure which yields exactly the same structure but the > original values replaced by the resul

apply an higher order function on an arbitrary nested data structure

2010-10-28 Thread Amitava Shee
I would like to apply an higher order function on an arbitrarily nested data structure which yields exactly the same structure but the original values replaced by the result of applying the passed in function. This is somewhat akin to the fmap function in Functor type class in haskell. I had a bri