Bond: (&) rather than rewrite existing help files: change dyadic verb into a monadic verb in j for c: http://www.jsoftware.com/docs/help701/jforc/compound_verbs.htm#_Toc191734373
In chapter 3 of Learning J you'll find explanations of both & and commute (~) http://www.jsoftware.com/docs/help701/learning/03.htm I've observed KEI's wonderful foresight in that the opportunities for reflexive use of ~ to use the same data as both arguments to a verb are far more plentiful than I had first thought they'd be. Hook: (v0 v1) I had great difficulty learning hooks. I suspect your difficulty understanding the filtering hook idiom (#~ monadic_fork_returning_boolean) stems from misunderstanding the hook rather than misunderstanding ~ . It's valid and useful---but not a filter---if the monadic fork returns copy (#) arguments other than boolean (integral or "integral complex"). In this clearly I'm allowing a monadic verb as a fork. Well, it's got an odd number of verbs, one. (verb fork) y is the same as y (verb fork) y is the same as y verb (fork) y is the same as (verb fork)~ y And the dyadic hook x (verb fork) y is the same as x verb (fork) y Explicit to tacit A verb to select prime numbers greater than 9 could be expressed as ((9 < y) *. (1 p: y)) # y NB. straight forward y #~ (9 < y) *. (1 p: y) NB. commute to remove paren pair y #~ (9&< *. 1&p:) y NB. inserted bond and monadic fork (#~ (9&< *. 1&p:)) y NB. expressed as a hook w/ explicit fork (#~ 9&< *. 1&p:) y NB. The monadic fork is implicit 13 : '((9 < y) *. (1 p: y)) # y' NB. j writes the tacit verb ] #~ (9 < ]) *. 1 p: ] NB. 13 : always writes forks to faithfully reproduce the NB. verb even when used as a dyad. On Fri, 2011-07-08 at 21:12 +0800, [email protected] wrote: > Date: Fri, 8 Jul 2011 14:14:47 +0100 > From: David Vaughan <[email protected]> > Subject: Re: [Jprogramming] Checking permutations > To: Programming forum <[email protected]> > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > I've found that method to be pretty simple in the end, using 10^i.9 > Could you explain in: > (#~ 1&p:) i. 50 > What's going on, particularly the role of ~ as I find that adverb > confusing. > I know that p:y can be used to find the yth prime, but I don't > understand why it tests for primes when 1& precedes it. > Thanks. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
