On Thu, Apr 7, 2011 at 11:58 AM, Aai <[email protected]> wrote:
> I don't exactly understand what you mean by different types.
> The initial elem type has to be of the same type as an element of the list 
> i.o.
> to apply
>    f <initial element> <element of the list>

Really? for foldr?

Consider this J example:

M=: 20$0
foldr=:1 :0
:
  X=.<x
  Y=.y <@["u x
  >u&.>/Y,X
)

   M 4 :'1 x} y' foldr 2 3 5 7 11 13 17 19

Here, I have an initial value which is a different type from the
elements of the list.

I can imagine that Haskell would require that the type of the result
of the function which is an argument to foldr would match the type of
the initial value (my x, here), but I do not see the point in
requiring that it match the type of items in the list.  If that were
the case, I would think that it would be simpler and cleaner to
require that the initial value be a member of the list (which is what
J does).

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to