On Thu, Apr 7, 2011 at 12:42 PM, Aai <[email protected]> wrote:
> Sorry, should have sent it also to chatforum.
>
> Whatever complex initial argument you want to start with, applying f on 
> initial
> element and an element of the list should be on the same types, e.g.
>
> Prelude> foldl (\(x,y) e -> (y,x+e)) (0,2) [1..5]
> (8,9)
>
> Here the initial element argument is typed
>  (a,a)
> and the list is typed
>  [a]
>
> The result is typed
>  (a,a)
>
> Note: a means same type.
>
> If not, I do not follow you. Please give an example.


My point was that the initial element and result have a different type
from the type of an element of the list.

In other words: type of initial argument and of result:

   (a,a)

type of an element of the list:

   a

In contrast, in J, the initial element is the rightmost element of the
list, which means it must be the same type as the rest of the list.
This means that we must use something (what a haskell programmer would
call a monad) to have this initial element be a different logical type
from the rest of the list.

Do you disagree with this assessment?  If so, can you give a counter-example?

Or, if you agree, does my initial post in this thread make more sense
now?  Or do you see flaws in it, also?

Thanks,

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

Reply via email to