⍝ Generalised iota

    ⎕io←1                           ⍝ index origin.

    iotag 5                         ⍝ Positive Integer
1 2 3 4 5
    iotag ¯3                        ⍝ Negative Integer
¯1 ¯2 ¯3
    iotag 'D'                       ⍝ Uppercase Character
ABCD
    iotag 'g'                       ⍝ Lowercase Character
abcdefg
    iotag 'Ò'                       ⍝ Underscore Character
ÁÂÃÇÈÊËÌÍÎÏÐÒ
    iotag '7'                       ⍝ Digit
01234567
    iotag 'Z'                       ⍝ Equivalent to ⎕A
ABCDEFGHIJKLMNOPQRSTUVWXYZ
    iotag 'z'                       ⍝ Solves problem of ⎕a not being lower case.
abcdefghijklmnopqrstuvwxyz
    iotag 'õ'                       ⍝ Equivalent to ⎕Á
ÁÂÃÇÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝþãìðòõ
    iotag '9'                       ⍝ Equivalent to ⎕D
0123456789
    iotag 2 3
┌───┬───┬───┐
│1 1│1 2│1 3│
├───┼───┼───┤
│2 1│2 2│2 3│
└───┴───┴───┘
    iotag 2 ¯3
┌────┬────┬────┐
│1 ¯1│1 ¯2│1 ¯3│
├────┼────┼────┤
│2 ¯1│2 ¯2│2 ¯3│
└────┴────┴────┘
    iotag 'C5'
┌──┬──┬──┬──┬──┬──┐
│A0│A1│A2│A3│A4│A5│
├──┼──┼──┼──┼──┼──┤
│B0│B1│B2│B3│B4│B5│
├──┼──┼──┼──┼──┼──┤
│C0│C1│C2│C3│C4│C5│
└──┴──┴──┴──┴──┴──┘
     iotag 'BC'
┌──┬──┬──┐
│AA│AB│AC│
├──┼──┼──┤
│BA│BB│BC│
└──┴──┴──┘
    'C' iotag 'F'                   ⍝ Alphabetic Interval
CDEF
    'm' iotag 'r'                   ⍝ Lowercase interval
mnopqr
    'Â' iotag 'Ó'                   ⍝ Underscore interval
ÂÃÇÈÊËÌÍÎÏÐÒÓ
    'P' iotag 'L'                   ⍝ Reverse interval
PONML
    'a' iotag 'F'                   ⍝ ⎕AV Interval
abcdefghijklmnopqrstuvwxyz¯.⍬0123456789⊢¥$£¢∆ABCDEF
    3 iotag 7                       ⍝ Numeric interval (scalar left arg)
3 4 5 6 7
    12 iotag 5                      ⍝ Reverse numeric interval
12 11 10 9 8 7 6 5
    3 iotag 5 .5                    ⍝ Interval with step size
3 3.5 4 4.5 5
    12 iotag 3 3                    ⍝ Reverse interval with step size
12 9 6 3
    ¯5 iotag 6                      ⍝ Negative numbers OK
¯5 ¯4 ¯3 ¯2 ¯1 0 1 2 3 4 5 6
    'ABCDE' iotag 'B'               ⍝ Index of
2
    Beatles←4 6⍴'JOHN  PAUL  GEORGERINGO '      ⍝ Character matrix
    APLers←4 5⍴'STEVEPAUL JOHN PETE '           ⍝ List of names
    Names←4 6⍴'PAUL  STEVE BILL  GEORGE'
    Beatles APLers Names                        ⍝ Show Matrices
┌──────┬─────┬──────┐
│JOHN  │STEVE│PAUL  │
│PAUL  │PAUL │STEVE │
│GEORGE│JOHN │BILL  │
│RINGO │PETE │GEORGE│
└──────┴─────┴──────┘
    APLers iotag 'STEVE'            ⍝ Find name
1
    APLers iotag 'STEVE'            ⍝ Find name
1
    APLers iotag 'STEVE '           ⍝ Ignores trailing blanks
1
    APLers iotag Beatles            ⍝ Two matrices
3 2 5 5
    'PETE' iotag 'PETE'             ⍝ Vector left argument
1 2 3 2

    Rank3←↑APLers Beatles           ⍝ Rank 3 Array
    Rank3 iotag Beatles             ⍝ Find matrix in Rank-3 array
2
    Beatles iotag Rank3             ⍝ Find Vectors in matrix
5 2 1 5
1 2 3 4
    Rank3 iotag ↑Beatles Names
2 3

    ⎕io←0                           ⍝ try with origin 0

    iotag 3
0 1 2
    iotag ¯3
0 ¯1 ¯2
       iotag 'D'                       ⍝ Uppercase Character
ABCD
    iotag 'g'                       ⍝ Lowercase Character
abcdefg
    iotag 'Ò'                       ⍝ Underscore Character
ÁÂÃÇÈÊËÌÍÎÏÐÒ
    iotag '7'                       ⍝ Digit
01234567
    iotag 'Z'                       ⍝ Equivalent to ⎕A
ABCDEFGHIJKLMNOPQRSTUVWXYZ
    iotag 'z'                       ⍝ Solves problem of ⎕a not being lower case.
abcdefghijklmnopqrstuvwxyz
    iotag 'õ'                       ⍝ Equivalent to ⎕Á
ÁÂÃÇÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝþãìðòõ
    iotag '9'                       ⍝ Equivalent to ⎕D
0123456789
    iotag 2 3
┌───┬───┬───┐
│0 0│0 1│0 2│
├───┼───┼───┤
│1 0│1 1│1 2│
└───┴───┴───┘
    iotag 2 ¯3
┌───┬────┬────┐
│0 0│0 ¯1│0 ¯2│
├───┼────┼────┤
│1 0│1 ¯1│1 ¯2│
└───┴────┴────┘
    iotag 'C5'
┌──┬──┬──┬──┬──┬──┐
│A0│A1│A2│A3│A4│A5│
├──┼──┼──┼──┼──┼──┤
│B0│B1│B2│B3│B4│B5│
├──┼──┼──┼──┼──┼──┤
│C0│C1│C2│C3│C4│C5│
└──┴──┴──┴──┴──┴──┘
    'C' iotag 'F'                   ⍝ Alphabetic Interval
CDEF
    'm' iotag 'r'                   ⍝ Lowercase interval
mnopqr
    'Â' iotag 'Ó'                   ⍝ Underscore interval
ÂÃÇÈÊËÌÍÎÏÐÒÓ
    'P' iotag 'L'                   ⍝ Reverse interval
PONML
    'a' iotag 'F'                   ⍝ ⎕AV Interval
abcdefghijklmnopqrstuvwxyz¯.⍬0123456789⊢¥$£¢∆ABCDEF
    3 iotag 7                       ⍝ Numeric interval (scalar left arg)
3 4 5 6 7
    12 iotag 5                      ⍝ Reverse numeric interval
12 11 10 9 8 7 6 5
    3 iotag 5 .5                    ⍝ Interval with step size
3 3.5 4 4.5 5
    12 iotag 3 3                    ⍝ Reverse interval with step size
12 9 6 3
    ¯5 iotag 6                      ⍝ Negative numbers OK
¯5 ¯4 ¯3 ¯2 ¯1 0 1 2 3 4 5 6
    'ABCDE' iotag 'B'               ⍝ Index of
1
    Beatles←4 6⍴'JOHN  PAUL  GEORGERINGO '      ⍝ Character matrix
    APLers←4 5⍴'STEVEPAUL JOHN PETE '           ⍝ List of names
    Names←4 6⍴'PAUL  STEVE BILL  GEORGE'
    Beatles APLers Names                        ⍝ Show Matrices
┌──────┬─────┬──────┐
│JOHN  │STEVE│PAUL  │
│PAUL  │PAUL │STEVE │
│GEORGE│JOHN │BILL  │
│RINGO │PETE │GEORGE│
└──────┴─────┴──────┘
    APLers iotag 'STEVE'            ⍝ Find name
0
    APLers iotag 'STEVE'            ⍝ Find name
0
    APLers iotag 'STEVE '           ⍝ Ignores trailing blanks
0
    APLers iotag Beatles            ⍝ Two matrices
2 1 4 4
    'PETE' iotag 'PETE'             ⍝ Vector left argument
0 1 2 1

    Rank3←↑APLers Beatles           ⍝ Rank 3 Array
    Rank3 iotag Beatles             ⍝ Find matrix in Rank-3 array
1
    Beatles iotag Rank3             ⍝ Find Vectors in matrix
4 1 0 4
0 1 2 3
    Rank3 iotag ↑Beatles Names
1 2

Back to: code

Back to: Workspaces