Rep-string: Difference between revisions
Content deleted Content added
Add C# implementation |
Not a robot (talk | contribs) Add Refal |
||
Line 3,941: | Line 3,941: | ||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
=={{header|Refal}}== |
|||
<syntaxhighlight lang="refal">$ENTRY Go { |
|||
, ('1001110011') ('1110111011') ('0010010010') |
|||
('1010101010') ('1111111111') ('0100101101') |
|||
('0100100') ('101') ('11') ('00') ('1'): e.Tests |
|||
= <Each Show e.Tests>; |
|||
}; |
|||
Each { |
|||
s.F = ; |
|||
s.F t.I e.R = <Mu s.F t.I> <Each s.F e.R>; |
|||
}; |
|||
Show { |
|||
(e.S), <RepString e.S>: e.R = <Prout e.S ' => ' e.R>; |
|||
}; |
|||
RepString { |
|||
() e.S = ; |
|||
(e.R) e.S, <Lengthen (e.R) e.S>: e.S e.X = e.R; |
|||
(e.R s.C) e.S = <RepString (e.R) e.S>; |
|||
e.S, <Lenw e.S>: s.L e.S, |
|||
<First <Div s.L 2> e.S>: (e.F) e.X |
|||
= <RepString (e.F) e.S>; |
|||
}; |
|||
Lengthen { |
|||
(e.A) e.B, <Lenw e.A>: s.LA e.A, |
|||
<Lenw e.B>: s.LB e.B, |
|||
<Compare s.LA s.LB>: '-' |
|||
= <Lengthen (e.A e.A) e.B>; |
|||
(e.A) e.B, <Lenw e.B>: s.LB e.B, |
|||
<First s.LB e.A>: (e.FA) e.RA |
|||
= e.FA; |
|||
};</syntaxhighlight> |
|||
{{out}} |
|||
<pre>1001110011 => 10011 |
|||
1110111011 => 1110 |
|||
0010010010 => 001 |
|||
1010101010 => 1010 |
|||
1111111111 => 11111 |
|||
0100101101 => |
|||
0100100 => 010 |
|||
101 => |
|||
11 => 1 |
|||
00 => 0 |
|||
1 =></pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 1=== |
===version 1=== |