Last night, I have mistakenly replied to Raul rather than to Chat, so I am reposting ...
---------- Forwarded message ---------- From: Boyko Bantchev <[email protected]> Date: 8 April 2011 00:23 Subject: Re: [Jchat] the design of /\ To: Raul Miller <[email protected]> > In other words, you treat J's / like Haskell's foldr if you use > something like a haskel monad to arrange for the types of all the > elements of the list to be consistent. I think I see now what you mean. Indeed, something like a Haskell monad may be useful in J if we want to bend J's / to acting as a foldr. Haskell itself does not need a monadic concept here, as foldr/foldl accept one more argument. As for the length of the result of scanr/scanl, I don't see an issue. Note that scan is defined somewhat differently from J's \ (prefix) and \. (suffix). \ and \. apply to x-fixes of length 1..n, while Haskell scans apply to lengths 0..n. Also, when applied to an empty list, \ and \. return an empty list, while scan returns a list of length 1. The very meaning of fold is slightly different from J's /. The name of / is `insert', and the Dictionary says that it applies a verb _between_ items. Fold is more like `apply to each accumulating'. One consequence is that, if / applies to an empty list, the verb has to possess a neutral value – unlike fold in Haskell. Also, in my reading, the Dictionary is unclear what the result of / on one-item lists should be. On the other hand, \ and \. are different from scanl and scanr in that the verb in \ and \. applies to a list (it is a monad), while in scan it is the same dyadic function that is the argument of fold. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
