> As written, f should be any of < <:, and g any of > 
> >:.  E.g.
> oo=: ({...@[<]) *. ({:@[>])

You are right.  In that case I'd rewrite the
general pattern to be

({...@[ f ]) *. (] g {:@])  or
({...@[ f ]) *. ({:@[ g~ ])

so that f and g are "in the same direction",
that is, <: and < rather than <: and > .

> But why is using [, ] and @, which you suggest, preferable to
> hooks, which can provide the same but terser, as in

Because I prefer to have the interval end points
as the left argument.

In APL/J, it is generally the case that
the left and right arguments are so defined
that x&f makes a more sensible monad 
than f&y .   The n v1 v2 fork accentuates
this point.



----- Original Message -----
From: Boyko Bantchev <[email protected]>
Date: Thursday, October 29, 2009 15:00
Subject: Re: [Jprogramming] x ∈ [y1,y2)
To: Programming forum <[email protected]>

> Roger Hui:
> 
> > I suggest that as usual, you should write the expression
> > in the "best" way, and then wait for the implementation
> > to catch up.
> >
> > What might the "best" way be?  Perhaps:
> >
> > ({...@[ f ]) *. ({:@[ g ])
> >
> > where f and g are one of < <:
> 
> As written, f should be any of < <:, and g any of > 
> >:.  E.g.
> oo=: ({...@[<]) *. ({:@[>])
> 
> But why is using [, ] and @, which you suggest, preferable to
> hooks, which can provide the same but terser, as in
> 
> oo=: (> {.) *. (< {:)
> oc=: (> {.) *. (<:{:)
> co=: (>:{.) *. (< {:)
> cc=: (>:{.) *. (<:{:)
> 
> or (using other middle verbs)
> 
> oo=: (>{.) > (>:{:)
> oc=: (>{.) > (> {:)
> co=: (<{.) < (< {:)
> cc=: (<{.) < (<:{:)
> 
> For the two semi-closed cases, it is possible to have variants
> that are just as simple but work correctly even when it is not
> known, for an interval (y1,y2), which of y1 and y2 is the larger:
> 
> oc=: (>{.) ~: (>{:)
> co=: (<{.) ~: (<{:)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to