The ZDATR-specific additions are Pos, UC, LC, UCFIRST, Tr, Splat.
% RFC compliant
Sort:
<> == SortSelect:<Options:<sort mode>>
.
% Zdatr internal
SortSelect:
<> == Fail
<num> == SortN:<>
<numeric> == SortN:<>
<boolean> == SortN:<>
<ascii> == SortA:<>
<abc> == SortA:<>.
% RFC compliant
% Fail is builtin by default, but one may redefine it.
% Fail:
% <> == hello friends
% .
% RFC compliant
% Now built-in, for efficiency.
% Idem:
% <> ==
% <$x> == $x <>
%.
% Widely used synonym for Idem
Copy:
<> == Idem
.
% RFC compliant
Reverse:
<> ==
<$x> == <> $x.
% RFC compliant
Rest:
<> == Fail:<'Rest'>
<$x> == Idem:<>
.
% RFC compliant
First:
<> == Fail:<'First'>
<$x> == $x
.
% RFC compliant
Last:
<> == Fail:<'Last'>
<$x> == First:<Reverse>
.
% RFC compliant
Hyphenate:
<> == Fail:<'Hyphenate'>
<$x $y $z> == Hyphen
.
% Zdatr internal
Hyphen:
<$x $z> == $z
<$x $y $z> == $y $x <$x $z>
.
% Zdatr addition
NOT:
<> == Fail
<1> == 0
<0> == 1
.
% RFC compliant
Not:
<> == Idem
<1> == 0 <>
<0> == 1 <>.
% Zdatr addition
AND:
<> == Fail
<0> == 0
<1> == 0
<1 1> == 1
.
% RFC compliant
And:
<> == 1 Idem
<0> == 0 Strip:<>
<1> == And:<>
.
% Zdatr addition
Strip:
<> == Idem
<0> == Strip:<>
<1> == Strip:<>
.
% Zdatr addition
OR:
<> == Fail
<0> == 1
<1> == 1
<0 0> == 0
.
% RFC compliant
Or:
<> == 0 Idem
<1> == 1 Strip:<>
<0> == Or:<>
.
% Zdatr addition
EQ:
<> == 0
<$a $a> == 1
.
% Zdatr addition
EQUAL:
<> == EQ
.
% RFC compliant
Equal:
<> == 0 Idem
<$x $x> == 1 Idem
.
% RFC compliant
Member:
<> == Calc:<Pos:<> '!=' 0 .>
.
% RFC compliant
Ascii:
<> ==
<$a> == Ascii_prim <>
<'NUL'> == 0 <>
<'SOH'> == 1 <>
<'STX'> == 2 <>
<'ETX'> == 3 <>
<'EOT'> == 4 <>
<'ENQ'> == 5 <>
<'ACK'> == 6 <>
<'BEL'> == 7 <>
<'BS'> == 8 <>
<'HT'> == 9 <>
<'NL'> == 10 <>
<'VT'> == 11 <>
<'NP'> == 12 <>
<'CR'> == 13 <>
<'SO'> == 14 <>
<'SI'> == 15 <>
<'DLE'> == 16 <>
<'DC1'> == 17 <>
<'DC2'> == 18 <>
<'DC3'> == 19 <>
<'DC4'> == 20 <>
<'NAK'> == 21 <>
<'SYN'> == 22 <>
<'ETB'> == 23 <>
<'CAN'> == 24 <>
<'EM'> == 25 <>
<'SUB'> == 26 <>
<'ESC'> == 27 <>
<'FS'> == 28 <>
<'GS'> == 29 <>
<'RS'> == 30 <>
<'US'> == 31 <>
<'SP'> == 32 <>
<nul> == 0 <>
<soh> == 1 <>
<stx> == 2 <>
<etx> == 3 <>
<eot> == 4 <>
<enq> == 5 <>
<ack> == 6 <>
<bel> == 7 <>
<bs> == 8 <>
<ht> == 9 <>
<nl> == 10 <>
<vt> == 11 <>
<np> == 12 <>
<cr> == 13 <>
<so> == 14 <>
<si> == 15 <>
<dle> == 16 <>
<dc1> == 17 <>
<dc2> == 18 <>
<dc3> == 19 <>
<dc4> == 20 <>
<nak> == 21 <>
<syn> == 22 <>
<etb> == 23 <>
<can> == 24 <>
<em> == 25 <>
<sub> == 26 <>
<esc> == 27 <>
<fs> == 28 <>
<gs> == 29 <>
<rs> == 30 <>
<us> == 31 <>
<sp> == 32 <>
.
% Zdatr addition, extract prefix of length n
FirstN:
<> == Fail
<0> ==
<0 $a> == % Redundant for -a flag!
<$i $a> == $a <CALC:<$i - 1 .>>
.
% Zdatr addition, omit prefix of length first
SkipN:
<> == Fail
<0> == Idem:<>
<0 $a> == Idem:<$a> % Redundant for -a flag!
<$i $a> == <CALC:<$i - 1 .>>
.
% Zdatr addition, extract suffix of length first
LastN:
<$i> == SkipN:<CALC:<Length:<> - $i .> >
.
% Zdatr addition, replace first at position number second
ReplaceAt:
<$a $i> == FirstN:<Calc:<$i - 1 .>> $a SkipN:<$i>
.
% Zdatr addition, makes a hyphenated atom for database record export
Splat:<> == Implode:<Hyphenate .>
.
% Zdatr addition, sequence position starts with 1
SUBSEQ:
<> == Subseq
<$i> == Subseq:<CALC:<$i - 1 .> >
.