Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!haven.umd.edu!socrates.umd.edu!socrates!rockwell From: rockwell@socrates.umd.edu (Raul Rockwell) Newsgroups: comp.lang.apl Subject: Re: Forks, Hooks and With in J Message-ID: Date: 6 Jun 91 03:54:32 GMT References: Sender: rockwell@socrates.umd.edu (Raul Rockwell) Organization: Traveller Lines: 46 In-Reply-To: wdr@wang.com's message of 5 Jun 91 18: 55:23 GMT William Ricker: .. I note that unless the fork or hook is the entire expression, .. to indicate that it is a fork/hook parenthesis will be required, .. else it will just execute left to right. Yeah, there are several different ways of combining functions. .. In the fork and hook, it seems that the distinction between dyadic .. and monadic (which I think is the same as you mean by transitive & .. intransitive) also seems to be determined by context. yeah, that's what I meant by transitive/intransitive. And I don't have a really good feel for cases like: n (f:'' g h) m I think the rules on this got changed on me with one of the J version changes, but I haven't played with it enough to pin it down. .. However, sometimes I want to express (v1 n1) v2 (v3 n2) as n1 (v1 .. v2 v3) n2 but if both v1 and v3 have dyadic interpretations, the .. parser seems to assume I meant: (n1 v1 n2) v2 (n1 v2 n2) which is .. the other fork. Actually, (v1 n1) v2 (v3 n2) isn't a fork, because n1 is a different object than n2. If you mean you want to construct a function f where n1 f n2 computes the same result as (v1 n1) v2 (v3 n2), I'd use f =. v1@[ v2 v3@] .. Example: if I try to re-code a remove-blanks-from-string: .. trim=. '(-. '' ''=y.) # y. ' : '' .. or equivalently .. trim=. 'y. #~ -. '' ''=y. ' : '' .. as an implicit or functional defintion, the "obvious" hook .. ftrim=. #~ (-. ' '&=) .. doesn't work, because although I'm thinking of monadic -. as NOT, .. the parser thinks dyadic set difference; and thus I get a .. double-hook not a hook and composition of two monadics. try ftrim=. #~ -.@(' '&=) Note that v@u always uses the monadic definition of v [two other working solutions by Bill Ricker elided] Raul Rockwell