Sequence Operators

In Glee, sequences are a way of collecting dissimilar things into an ordered object. See the tutorial for additional examples.

Commentary     Op Code Result
Commentary M > Enclose '<1>---------'$; 1 2 3 %** $; '<2>---------'$; 1 2 3> %** $; '<3>---------'$; 'abc' %** $; '<4>---------'$; 'abc'> %**$;
'<5>---------'$; 1 'a' %** $; '<6>---------'$; 1 'a' > %** $;
<1>---------
Num[I78R1C3:I]1 2 3
<2>---------
Seq[I104R1C1T:K]:
[1]Num[I100R1C3:I]1 2 3
<3>---------
String[I114R2C3:C]abc
<4>---------
Seq[I130R1C1T:K]:
[1]String[I126R2C3:C]abc
<5>---------
Seq[I149R1C2T:K]:
[1]Num[I140R1C1:I]1
[2]String[I142R2C1:C]a
<6>---------
Seq[I174R1C1T:K]:
[1]Seq[I170R1C2T:K]:
*[1]Num[I161R1C1:I]1
*[2]String[I163R2C1:C]a
Commentary M < Disclose '<1>---------'$;
1 2 3 > %** $;
'<2>---------'$;
1 2 3 > < %** $;
'<3>---------'$;
'abc' > %** $;
'<4>---------'$;
'abc'> < %** $;
'<5>---------'$;
1 'a' > %** $;
'<6>---------'$;
1 'a' > < %** $;
'<7>---------'$;
1 'a' > < < < < %** $;
'<8>---------'$;
(1 2 3>)(4 5 6>) %** $;
'<9>---------'$;
(1 2 3>)(4 5 6>)< %** $;
<1>----------------
unodosunknown
<2>----------------
Seq[I391R1C3T:K]:
[1]Seq[I561R2C1T:K]:
*[1]Seq[I694R1C1T:K]:
**[1]String[I695R1C3:C]uno
[2]Seq[I821R2C1T:K]:
*[1]Seq[I22R1C1T:K]:
**[1]String[I23R1C3:C]dos
[3]Seq[I149R2C1T:K]:
*[1]String[I301R1C7:C]unknown
<3>----------------
uno dos unknown
<4>----------------
uno
dos
unknown<1>---------
Seq[I967R1C1T:K]:
[1]Num[I964R1C3:I]1 2 3
<2>---------
Num[I993R1C3:I]1 2 3
<3>---------
Seq[I17R1C1T:K]:
[1]String[I14R2C3:C]abc
<4>---------
String[I33R2C3:C]abc
<5>---------
Seq[I62R1C1T:K]:
[1]Seq[I59R1C2T:K]:
*[1]Num[I56R1C1:I]1
*[2]String[I58R2C1:C]a
<6>---------
Seq[I81R1C2T:K]:
[1]Num[I78R1C1:I]1
[2]String[I80R2C1:C]a
<7>---------
Seq[I104R1C2T:K]:
[1]Num[I101R1C1:I]1
[2]String[I103R2C1:C]a
<8>---------
Seq[I184R1C2T:K]:
[1]Seq[I154R1C1T:K]:
*[1]Num[I151R1C3:I]1 2 3
[2]Seq[I183R2C1T:K]:
*[1]Num[I180R1C3:I]4 5 6
<9>---------
Seq[I261R1C2T:K]:
[1]Num[I225R1C3:I]1 2 3
[2]Num[I254R2C3:I]4 5 6
Commentary M ** Depth 'abc' ** %** $;
1'a' ** %** $;
1'a' > ** %** $;
1'a' > > > > ** %** $;
Num[I919R1C1:I]0
Num[I935R1C1:I]1
Num[I953R1C1:I]2
Num[I977R1C1:I]5
Commentary M <** Disclose Deep '<1>---------'$;
1 2 3 'a' =>a %** $;
'<2>---------'$;
a > > > => b %** $;
'<3>---------'$;
b < %** $;
'<4>---------'$;
b <** %** $;
<1>---------
Seq[I515R2C2T:K]:
[1]Num[I506R1C3:I]1 2 3
[2]String[I508R1C1:C]a
<2>---------
Seq[I560R2C1T:K]:
[1]Seq[I558R1C1T:K]:
*[1]Seq[I556R1C1T:K]:
**[1]Seq[I555R1C2T:K]:
***[1]Num[I506R2C3:I]1 2 3
***[2]String[I508R2C1:C]a
<3>---------
Seq[I558R2C1T:K]:
[1]Seq[I556R1C1T:K]:
*[1]Seq[I555R1C2T:K]:
**[1]Num[I506R2C3:I]1 2 3
**[2]String[I508R2C1:C]a
<4>---------
Seq[I624R1C2T:K]:
[1]Num[I506R3C3:I]1 2 3
[2]String[I508R3C1:C]a
Commentary D >** Set Depth '<1>----------'$;
'a' >** 5 %** $;
'<2>----------'$;
1'a' >** 3 %** $;
'<3>----------'$;
1'a' >** 0 ** %** $;
<1>----------
Seq[I588R1C1T:K]:
[1]Seq[I587R1C1T:K]:
*[1]Seq[I586R1C1T:K]:
**[1]Seq[I585R1C1T:K]:
***[1]Seq[I584R1C1T:K]:
****[1]String[I580R1C1:C]a
<2>----------
Seq[I614R1C1T:K]:
[1]Seq[I613R1C1T:K]:
*[1]Seq[I609R1C2T:K]:
**[1]Num[I600R1C1:I]1
**[2]String[I602R1C1:C]a
<3>----------
Num[I642R1C1:I]1
Commentary M \ Segment CRLF '<1>---------'$;
$R***
$rNow is the time
for all good men to
come to the aid of
their country.***
=>text;
text %** $;
'<2>---------'$;
text \ %** $;
<1>---------
S..:C]Now is the time for all good men to come to the aid of their country.
<2>---------
Seq[I788R1C4T:K]:
[1]S..:C]Now is the time

[2]S..:C]for all good men to

[3]S..:C]come to the aid of

[4]S..:C]their country.
Commentary M \~ Segment CRLF and Eat '<1>---------'$;
$R***
$rNow is the time
for all good men to
come to the aid of
their country.***
=>text; text %** $;
'<2>---------'$;
text \~ %** $;
<1>---------
String[S816R3C72:C]Now is the time for all good men to come to the aid of their country.
<2>---------
Seq[I869R1C4T:K]:
[1]S..:C]Now is the time
[2]S..:C]for all good men to
[3]S..:C]come to the aid of
[4]S..:C]their country.
Commentary D \| Segment Delimiter 'a;b,c:d.' \| ";:." %** Seq[I133R2C3T:P]:
[1]String[I134R1C2:C]a;
[2]String[I135R1C4:C]b,c:
[3]String[I136R1C2:C]d
Commentary D \|~ Segment Delimiter and eat 'a;b,c:d.' \|~ ";:." %** Seq[I903R2C3T:P]:
[1]String[I904R1C1:C]a
[2]String[I905R1C3:C]b,c
[3]String[I906R1C1:C]d
Commentary M \& Segment words $R____$r To be or not to be; that is the question. ____ =>text;
text \& =>w;
(w#) ' total words' $;
(w & => u#) ' unique words' $;
'UNIQUE WORDS ARE: ' u ,,$;
'<1>----------------------'$;
w ``& =>aggr;
aggr /# =>cnts;
'Words Used Once:'
  (cnts *= 1 \+) $;
'<2>----------------------'$;
'Word Counts:'$;
aggr[cnts ``<]=> aggr;
:for(aggr){aggr< => idx;
  idx# =>n;
  w[idx <-]':' n
  ' time'('s'[n>1])(13#asc)} $;
10 total words
8 unique words
UNIQUE WORDS ARE:
be is not or question that the To
<1>----------------------
Words Used Once:6
<2>----------------------
Word Counts:
be:2 times
To:2 times
is:1 time
not:1 time
or:1 time
question:1 time
that:1 time
the:1 time
Commentary D \ Segment on index mark '<1>-----------'$;
'Now^is^the^time'=>text;
text *| '^'=>b %** $;
'<2>-----------'$;
text \ b %** $;
<1>-----------
Bit[..15:B]00010010 0010000
<2>-----------
Seq[I345R1C4T:K]:
[1]String[I346R1C4:C]Now^
[2]String[I347R1C3:C]is^
[3]String[I348R1C4:C]the^
[4]String[I349R1C4:C]time
Commentary D \ n Segment on field index ("Name:"<- 10),
("Addr:"<- 20),
("City:"<- 10),
("State:"<- 2),
("Zip:"<-5)=>rec;
rec \(11 31 41 43)%** $;
Seq[I190R1C5T:K]:
[1]String[I191R1C10:C]Name:     
[2]String[I192R1C20:C]Addr:              
[3]String[I193R1C10:C]City:    
[4]String[I194R1C2:C]St
[5]String[I195R1C5:C]Zip: 
Commentary D \~ Segment on index and eat '<1>-----------'$;
'Now^is^the^time'=>text;
text *| '^'=>b %** $;
'<2>-----------'$;
text \~ b %** $;
'<3>-----------'$;
'1001Smith Alan'=>rec;
1 5 11=>layout;
rec \| layout %** $;
<1>-----------
Bit[...15:B]00010010 0010000
<2>-----------
Seq[I460R1C4T:K]:
[1]String[I461R1C3:C]Now
[2]String[I462R1C2:C]is
[3]String[I463R1C3:C]the
[4]String[I464R1C4:C]time
<3>-----------
Seq[I551R1C3T:K]:
[1]String[I552R1C4:C]1001
[2]String[I553R1C6:C]Smith
[3]String[I554R1C4:C]Alan
Commentary M , Ravel '<1a>-----------------'$;
'a'1 > > %** $;
'<1b>-----------------'$;
'a'1 > > , %** $;
'<2a>-----------------'$;
1 2 3 %** $;
'<2b>-----------------'$;
1 2 3, %** $;
'<3a>-----------------'$;
'abc' %** $;
'<3b>-----------------'$;
'abc', %** $;
'<4a>-----------------'$;
1'a' %** $;
'<4b>-----------------'$;
1'a', %** $;
<1a>-----------------
Seq[I986R1C1T:P]:
[1]Seq[I983R1C1T:P]:
*[1]Seq[I980R1C2T:P]:
**[1]String[I971R1C1:C]a
**[2]Num[I973R1C1:I]1
<1b>-----------------
Seq[I19R1C2T:P]:
[1]String[I2R1C1:C]a
[2]Num[I4R1C1:I]1
<2a>-----------------
Num[I50R1C3:I]1 2 3
<2b>-----------------
Seq[I83R1C1T:P]:
[1]Num[I79R1C3:I]1 2 3
<3a>-----------------
String[I99R1C3:C]abc
<3b>-----------------
Seq[I123R1C1T:P]:
[1]String[I119R1C3:C]abc
<4a>-----------------
Seq[I148R1C2T:P]:
[1]Num[I139R1C1:I]1
[2]String[I141R1C1:C]a
<4b>-----------------
Seq[I179R1C2T:P]:
[1]Num[I166R1C1:I]1
[2]String[I168R1C1:C]a
Commentary M ,| Make Column "<1>-----"$;1..3 ,| ,,\ $;
"<2>-----"$;10 'abc' ,| ,,\ $;
<1>-----
1
2
3
<2>-----
10
abc
Commentary D ,| Catenate Columns 1..3 ,| 'ab' ,| ('xx'>) %** Seq[I79R1C3T:K]:
[1]Seq[I58R1C3T:K]:
*[1]Num[I51R1C1:I]1
*[2]String[I55R1C1:C]a
*[3]String[I75R4C2:C]xx
[2]Seq[I59R1C3T:K]:
*[1]Num[I52R1C1:I]2
*[2]String[I56R2C1:C]b
*[3]String[I75R4C2:C]xx
[3]Seq[I60R1C3T:K]:
*[1]Num[I53R1C1:I]3
*[2]String[I56R2C1:C]b
*[3]String[I75R4C2:C]xx
Commentary M ,, Expose w/space-lf separators '<1a>---------------'$;
1 2 3 =>a;'abc'=>b;
(a b)(a b>) $;
'<1b>---------------'$;
(a b)(a b>)(a b > >),, $;
<1a>---------------
1 2 3abc1 2 3abc
<1b>---------------
1 2 3

abc

1 2 3
abc

1 2 3 abc
Commentary M ,,\ Expose w/lf-lf separators 'abc'> *->3 > *->2 ,,\ $; abc
abc
abc

abc
abc
abc
Commentary D ,, Expose w/supplied separators '<1a>---------------'$;
1 2 3 =>a;'abc'=>b;
(a b)(a b>) $;
'<1b>---------------'$;
(a b)(a b>)(a b > >)
  ,, ('<1>''<2>') $;  
<1a>---------------
1 2 3abc1 2 3abc
<1b>---------------
1 2 3<2>abc<2>1 2 3<2>abc<2>1 2 3<1>abc
Commentary D ^& Contains
'<1a>---------------'$;
'abcde''ABC''cde'=>l;'abc'=>r ;
l ^& r $;
'<1b>---------------'$;
l @& ^& r $;
'<1c>---------------'$;
l @& ^& r < $;
'<2c>---------------'$;
l @== @& ^& r < $;
<1a>---------------
1
<1b>---------------
110
<1c>---------------
110
<2c>---------------
100
  D ~ Without '<1>----------'$;
'Abcdef''Abc''abc'=>seq;
seq ~ 'Abc' %** $;
'<2>----------'$;
seq @& ~ 'Abc' %** $;
<1>----------
Seq[I824R1C1T:K]:
[1]String[I780R2C6:C]Abcdef
<2>----------
Seq[I853R1C3T:K]:
[1]String[I856R1C3:C]def
[2]String[]
[3]String[]
  D *| Mark Any 'Abcdef''Abc''xYz''abc'=>seq;
'<1>-----'$;
seq *| ('Abc''xyz') %** $;
'<2>-----'$;
seq @== *| ('Abc''xyz') %** $;
<1>-----
Bit[R1C4:B]0111
<2>-----
Bit[R1C4:B]0100
  D *& Mark All '<1>==========='$;
'Abcdef''Abc''abc''ABC'=>seq;
seq *& ('Abc''abc') %** $;
seq @> *& ('Abc''abc') %** $;
'<2>==========='$;
seq @== *& ('Abc''abc') %** $;
seq @== @> *& ('Abc''abc') %** $;
<1>===========
Bit[R1C4:B]0110
Bit[R1C4:B]0011
<2>===========
Bit[R1C4:B]0100
Bit[R1C4:B]0010
  D ` Index Of 'Abcdef''Abc''abc'=>seq;
'<1>==========='$;
seq ` 'Abc' $;
'<2>==========='$;
seq @== ` 'abc' $;
<1>===========
2
<2>===========
3
  D `` Indices Of '<1>----------'$;
'Abcdef''Abcxbc''bc''BC'=>seq;
seq `` 'bc' %** $;
'<2>----------'$;
seq @== `` 'bc' %** $;
<1>----------
Num[I788R1C2:I]3 4
<2>----------
Num[I829R1C1:I]3
  M & Unique '<1>----------'$;
'a''b''c''A''B''C'=> x;
x & ,, $;
'<2>----------'$;
x @== & ,, $;
<1>----------
a b c
<2>----------
a A b B c C
  D & Intersect 'a' 10 'x' 5 6 'b' =>l;
'c''a' 10 11 5 'B' =>r;
'<1>----'$;
l & r %** $;
'<2>----'$;
l @== & r %** $;
<1>----
Seq[I946R1C4T:K]:
[1]Num[I942R1C1:I]5
[2]Num[I943R1C1:I]10
[3]String[I944R1C1:C]a
[4]String[I945R1C1:C]b
<2>----
Seq[I127R1C3T:K]:
[1]Num[I124R1C1:I]5
[2]Num[I125R1C1:I]10
[3]String[I126R1C1:C]a
  D | Union 'a' 10 'x' 5 6 'b' =>l;
'c''a' 10 11 5 'B' =>r;
'<1>----'$;
l | r ,, $;
'<2>----'$;
l @== | r ,, $;
<1>----
5 6 10 11 a b c x
<2>----
5 6 10 11 a B b c x
  D ~ Without 'a' 10 'x' 5 6 'b' =>l;
'c''a' 10 11 5 'B' =>r;
'<1>----'$;
l ~ r ,, $;
'<2>----'$;
l @== ~ r ,, $;
<1>----
x 6
<2>----
x 6 b
  D *= Elements Equal ('abc'> >) 1 'B-c'=>x;
('Abc'> >)1 'B C'=>y;
x *= y $;
x @== *= y $;
111
010
  M @& At Each '< "count" each item >' $;
(1 2 3)('abcd') @& # < $;
'< "contains" on each item >' $;
(1 2 3)('abcd') @& ^&'abcd' < $;
"< simple obj to sequence >" $;
1 2 @& %** $;
'ab' @& %** $;
"< process sequence items >" $;
1 2 @& => x; 3 4 @& => y;
(x @&) + (y @&) %** $;
< "count" each item >
3 4
< "contains" on each item >
01
< simple obj to sequence >
Seq[I28R1C2T:P]:
[1]Num[I29R1C1:I]1
[2]Num[I30R1C1:I]2
Seq[I45R1C2T:P]:
[1]String[I46R1C1:C]a
[2]String[I47R1C1:C]b
< process sequence items >
Seq[I181R1C2T:P]:
[1]Num[I104R2C1:I]4
[2]Num[I105R2C1:I]6