A minor point, but because the dyad - is rank 0, performance will be improved
by using @: rather than @ .
i.e. :
TESTS1 ,: PRICES1 {~ BUCKETS1 (#...@[ <:@:- |....@[ I. ]) TESTS1
Or alternatively:
TESTS1 ,: PRICES1 {~ BUCKETS1 <:@(#...@[ - |....@[ I. ]) TESTS1
> From: R.E. Boss
>
> If I slightly change your BUCKETS, PRICES and TESTS in
>
> BUCKETS1 =: __ , ge , {: lt
>
> PRICES1 =: __ , _ ,~ out
>
> TESTS1=: BUCKETS1 , _
>
> and use a verb which is equivalent to Schott's Idotr and Millers F, I
> get
>
> TESTS1 ,: PRICES1 {~ BUCKETS1 (#...@[ <:@- |....@[ I. ]) TESTS1
> __ 0 0.06 0.11 0.16 0.21 0.26 0.31 0.36 0.41 0.46 0.51 0.56 0.61 0.66
> 0.71
> 0.76 0.81 0.86 0.91 0.96 1.01 _
> __ 0.1 0.18 0.26 0.32 0.38 0.44 0.5 0.54 0.58 0.62 0.66 0.7 0.74 0.78
> 0.82
> 0.86 0.9 0.94 0.98 1 _ _
>
> Is this what you want?
>
>
> R.E. Boss
>
>
> > Van: Dan Bron
> >
> > When using dyad I, how does one control how to handle the various
> edge
> > conditions gracefully (specifically out-of-bounds values and
> > values exactly between intervals)?
> >
> > (1) y is greater or lesser than the head or tail of x
> > (2) y is exactly equal to a value of x, and I want to
> > decide if that means it should fall to the left
> > of the value or to the right.
> >
> > All of this with an eye to performance, of course (I don't want to do
> the
> > equality outer product x=/y to handle edge conditions, for
> > example).
> >
> > For example, how would you solve
> > http://rosettacode.org/wiki/Price_Fraction cleanly? My first quick
> hack
> > is:
> >
> > 'ge lt out'=:ALL=:|: 0 ". ];._2 noun define
> > 0.00 0.06 0.1
> > 0.06 0.11 0.18
> > 0.11 0.16 0.26
> > 0.16 0.21 0.32
> > 0.21 0.26 0.38
> > 0.26 0.31 0.44
> > 0.31 0.36 0.5
> > 0.36 0.41 0.54
> > 0.41 0.46 0.58
> > 0.46 0.51 0.62
> > 0.51 0.56 0.66
> > 0.56 0.61 0.7
> > 0.61 0.66 0.74
> > 0.66 0.71 0.78
> > 0.71 0.76 0.82
> > 0.76 0.81 0.86
> > 0.81 0.86 0.9
> > 0.86 0.91 0.94
> > 0.91 0.96 0.98
> > 0.96 1.01 1
> > )
> >
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm