jsoftware / jsource

J engine source mirror
Other
657 stars 90 forks source link

cut to fit #31

Open tangentstorm opened 3 years ago

tangentstorm commented 3 years ago

Similar to an old request of mine, I propose an extension to ;..

The request is for a new application of !.. Fit should apply to monads derived from the cut conjunction such that:

   u;._1!.n  ↔   u;._1 @: (n&,)
   u;._2!.n  ↔   u;._2 @: (,&n)
   u;. 1!.n  ↔   u;. 1 @: (n&,)
   u;. 2!.n  ↔   u;. 2 @: (,&n)

and when u =: < then the respective inverses are:

   [: }.@:; n&,&.>
   [: }:@:; ,&n&.>
      }.@:;
      }:@:;

I'm not sure what do to for inverses of other u, as u^:_1 is probably not what's wanted. (For example, the inverse of < is > but what we want here is ; instead.)

However, that is not a large obstacle, because I think that:

u&.>&.(<;.m!.n)

will mostly cover the ground. Given that, I believe the idiom should be given special consideration and be supported by special code.

The optimization would ideally apply for all u, but it should at least apply to all u which (cut503) already supports in ;@:(<@:u;.1) (viz my previous request). Special code which supports the idioms <@:u;.m and u&.>@:(<;.m) might also be considered for extension.

Motivations and disincentives for implementing this proposal are as detailed in the original Forum message:

Advantages:

though this is "poorly behaved" because it changes the shape of its argument.

-- Dan Bron <2007-10-30T00:19:42Z>