Index   <<   >>

Another fine fix!

Prefix and infix, suffix and outfix, provide for the application of a verb over useful partitions of an array. For example

   a=. 2 3 5 7 11
   <\a   NB. increasingly lower prefixes
┌─┬───┬─────┬───────┬──────────┐
│2│2 3│2 3 5│2 3 5 7│2 3 5 7 11│
└─┴───┴─────┴───────┴──────────┘
   */\a NB. prefix produce scan
2 6 30 210 2310
   +/\a NB. prefix sum scan
2 5 10 17 28
   2<\a  NB. infixes of length 2
┌───┬───┬───┬────┐
│2 3│3 5│5 7│7 11│
└───┴───┴───┴────┘
   2 -~/\ a NB. Differences of infixes of length 2
1 2 2 4
   <\.a NB. increasingly shorter suffixes
┌──────────┬────────┬──────┬────┬──┐
│2 3 5 7 11│3 5 7 11│5 7 11│7 11│11│
└──────────┴────────┴──────┴────┴──┘
   */\.a  NB. suffix product scan
2310 1155 385 77 11
   
   x=. 6
   roots=. 1 3 4
   ]factors =. x - roots
5 3 2
   */ factors NB. Value of polynomial
30
   1 <\. factors NB. outfixes with length 1 item removed
┌───┬───┬───┐
│3 2│5 2│5 3│
└───┴───┴───┘
   1 */\. factors NB. Derivatives wrt roots
6 10 15