On Thu, Apr 7, 2011 at 6:29 PM, Viktor Cerovski <[email protected]> wrote: > This kind of typology is essential to get the things right in Haskell. > Now, > > foldr1 :: (a -> a -> a) -> [a] -> a > > and that's where analogy between foldr1 and / falls through, > because in J not only that we don't have to have all the > elements of the argument y of u/ to be of the same type, > we don't even have to have the return type of u to be the > same as that of the elements of y, or, to paraphrase Roger, > Reduce is a poor name for / because / does not necessarily > reduce anything.
J's / (called "Insert" in the dictionary) could be modeled in Haskell as having type (array -> array -> array) -> array -> array But this strict interpretation would I think only be useful if you were implementing J in Haskell. And I would rather think of modelling instances of J's run-time types relevant to the sentences involved. Representing the "static typing underlying J's types" would be a whole different exercise. >> 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. > > Not really. Let's consider how ,./i. 3 3 works: > > ,./i. 3 3 === 0 1 2 ,. 3 4 5 ,. 6 7 8 > > The right ,. has two arguments of rank 1 and returns > the result of rank 2, namely: > > 3 6 > 4 7 > 5 8 > > Thus, the left ,. has the left argument of rank 1 > and the right argument of rank 2. Ok but I am failing to see where my statement was incorrect. All of the items of the list were rank 1 and this includes that initial element which was also rank 1. The result of the first ,. was not the initial element. (Though, if Haskell defines reduce, I am sure it defines it recursively, which brings in another set of issues -- still, even in Haskell, I think it would be safe to distinguish between the initial case and the inductive case.) Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
