On Thu, Apr 7, 2011 at 1:48 PM, Aai <[email protected]> wrote:
> Trying to follow you: is in the following expression applied what you mean
> by different types in the folding?
>>
>> Prelude>  foldl (\(x,y) e ->  (y,x+e)) (0,2) [1..5]
>> (8,9)
>
> Which I would translate into J like e.g:
>
>   ;({:@],[+{.@])&.>/(;/1+i.5),<0 2
> 8 9

Yes, that looks like an example, though I am too much of a novice to
say that I have not misunderstood something about that Haskell type
signature.

> I can ask Haskell (GHCi interpreter) what this 'whole thing' is typed like:
>
> Prelude> :t foldl (\(x,y) e -> (y,x+e))
> foldl (\(x,y) e -> (y,x+e)) :: (Num b) => (b, b) -> [b] -> (b, b)
>
> We have an initial element as tupel (a,a), a list [a] which results in a
> tupel (a,a).
> The basic type is here is Num b (Numeric b)  because I apply (+) on b's.
> b can be e.g. of type Int, Integer, Double

So are you saying that Haskell's fold would not be suitable for
something like this:

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

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

?

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

Reply via email to