NB. Array-element selection strategies
NB. Art Anger 2009JAN

   load '~system\packages\misc\primitiv.ijs'

   ] a3=: (100* Integers 2)+Table (10* Integers 3)+Table Integers 5
  0   1   2   3   4
 10  11  12  13  14
 20  21  22  23  24

100 101 102 103 104
110 111 112 113 114
120 121 122 123 124

NB. =========================================================
NB. Selection relative to axes
NB. =========================================================

NB. Selecting (rank-_1 items) by arbitrary position numbers (indices)
   1 From a3
100 101 102 103 104
110 111 112 113 114
120 121 122 123 124

NB. Selecting (rank-1 values) by arbitrary indices
NB.   (arbitrary order and duplication possible)
   2 4 0 4 From"1 a3
  2   4   0   4
 12  14  10  14
 22  24  20  24

102 104 100 104
112 114 110 114
122 124 120 124

NB. Selecting by copy counts
NB.  (no re-ordering)
   0 1 0 2 0 Copy"1 a3
  1   3   3
 11  13  13
 21  23  23

101 103 103
111 113 113
121 123 123

NB. Selecting by count from front/top [back/bottom]
NB.   (result is of same rank, even for count 1 or 0)
   2 Take"2 a3				_2 Take"2 a3
  0   1   2   3   4
 10  11  12  13  14

100 101 102 103 104
110 111 112 113 114

NB. Selecting leading [trailing] value
NB.   (result is one lower in rank)
   Head"2 a3				Tail"2 a3
  0   1   2   3   4
100 101 102 103 104

NB. Selecting all but leading [trailing] value
   Behead"2 a3				Curtail"2 a3
 10  11  12  13  14
 20  21  22  23  24

110 111 112 113 114
120 121 122 123 124


NB. =========================================================
NB. Selection by value comparison
NB. =========================================================

NB. Selecting unique values (in order of first appearance)
   Nub 'antidisestablishmentarianism'
antidseblhmr
   Nub"2 (2 0 2 2 From"2 a3)
 20  21  22  23  24
  0   1   2   3   4

120 121 122 123 124
100 101 102 103 104

NB. =========================================================
NB. Selective function application
NB. =========================================================

NB. All prefix [suffix] subsets (boxed to preserve length)
  Box Prefix Integers 5			Box Suffix Integers 5
┌─┬───┬─────┬───────┬─────────┐
│0│0 1│0 1 2│0 1 2 3│0 1 2 3 4│
└─┴───┴─────┴───────┴─────────┘

NB. All prefix [suffix] subsets (filled to common length)
  Same Prefix Integers 5		Same Suffix Integers 5
0 0 0 0 0
0 1 0 0 0
0 1 2 0 0
0 1 2 3 0
0 1 2 3 4
   Same Prefix 'abcde'
a     
ab    
abc   
abcd  
abcde 

NB. All infix [outfix] subsets (overlapping or not)
   3 Box Infix Integers 5
┌─────┬─────┬─────┐
│0 1 2│1 2 3│2 3 4│
└─────┴─────┴─────┘
   _3 Box Infix Integers 5
┌─────┬───┐
│0 1 2│3 4│
└─────┴───┘
   3 Box Outfix Integers 5
┌───┬───┬───┐
│3 4│0 4│0 1│
└───┴───┴───┘
   _3 Box Outfix Integers 5
┌───┬─────┐
│3 4│0 1 2│
└───┴─────┘

NB. All anti-diagonals of table [apply to transpose for diagonals]
   Box Oblique (0 From a3)
┌─┬────┬───────┬───────┬───────┬─────┬──┐
│0│1 10│2 11 20│3 12 21│4 13 22│14 23│24│
└─┴────┴───────┴───────┴───────┴─────┴──┘

NB. Subsets following/preceding markers (with/without markers)
   train=: '+first-+second-+third-'
   Box Cut 1 train
┌───────┬────────┬───────┐
│+first-│+second-│+third-│
└───────┴────────┴───────┘
   Box Cut _1 train
┌──────┬───────┬──────┐
│first-│second-│third-│
└──────┴───────┴──────┘
   Box Cut 2 train
┌───────┬────────┬───────┐
│+first-│+second-│+third-│
└───────┴────────┴───────┘
   Box Cut _2 train
┌──────┬───────┬──────┐
│+first│+second│+third│
└──────┴───────┴──────┘

NB. =========================================================
NB. Computation of selectors
NB. =========================================================

NB. Specific range of indices
   2+ Integers 2
2 3
   2* Integers 3
0 2 4

NB. Specifier for value equality or threshhold
   12 EQ (0 From a3)
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
   12 LE (0 From a3)
0 0 0 0 0
0 0 1 1 1
1 1 1 1 1

NB. Indices from copy-specifier
   Indices each Box"1 (12 GE (0 From a3))
┌┬─────┬─────────┐
││2 3 4│0 1 2 3 4│
└┴─────┴─────────┘

NB. Values divisible by 3
   0 EQ 3 Residue (0 From a3)
1 0 0 1 0
0 0 1 0 0
0 1 0 0 1

NB. Unique-value finder
   NubSieve 'antidisestablishmentarianism'
1 1 1 1 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0

NB. First-appearance finder
   1 Drop NubSieve 's'EQ ' 'Append 'antidisestablishmentarianism'
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   Head Indices 's'EQ 'antidisestablishmentarianism'
6

NB. Preferred-value finder
   'antidisestablishmentarianism'In 'aeiou'
1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0

NB. Value-sequence finder
   'is'MemberOfInterval 'antidisestablishmentarianism'
0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0

NB. Repeat-value finder
   text=: 'A  silly... phrase'
NB. Aligning originally adjacent values for comparison
   0 Append (1 Drop text)EQ _1 Drop text 
0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0
NB. Implicit argument application/distribution ("fork")
   0 Append (1&Drop EQ _1&Drop) text 
0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0
   (Not 0 Append (1&Drop EQ _1&Drop) text) Copy text
A sily. phrase



