Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bu.edu!wang!wdr From: wdr@wang.com (William Ricker) Newsgroups: comp.lang.apl Subject: Re: Forks, Hooks and With in J Message-ID: Date: 5 Jun 91 18:55:23 GMT References: Organization: Wang Labs, Lowell MA, USA Lines: 49 rockwell@socrates.umd.edu (Raul Rockwell) writes: [in answer to a question on representing a DAG with fork, hook, and &] >Forks and hooks are types of verb phrases. ... [expressions like] > v1 v2 v3 [is] a fork [and] v2 v3 [is] a hook [.] >& are neither forks nor hooks (0 is a noun and & is an adverb). 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. >The "underlying functionality" of & is, roughly, that of binding an >object to a function. If you bind a noun to a verb, as above, you >create an intransitive verb derived from the transitive form of the >original verb. If you bind a verb to a verb v1&v2 then the >intransitive form of v2 is used as a preprocessor for v1 (the >distinction between the transitive and intransitive form for v1 is >determined from context). 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 & instransitive) also seems to be determined by context. 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. This can be solved by & "with" and sufficient use of ()'s, or by the identity combinator ] to make hook forcing the verb v1 to monadic case : (]v1). the & tree constructor is the natural translation, but the ] option is the only method I've found so far to mark a verb usage as monadic case. 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. So I can do: ftrim=. #~ (-. &(=&' ')) or, if I really want to do it with hooks, ftrim=. #~ ((]-.)' '&=) -- /s/ Bill Ricker wdr@wang.wang.com "The Freedom of the Press belongs to those who own one." *** Warning: This account is not authorized to express opinions. ***