Decorate-sort-undecorate idiom: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Add Ruby) |
(Added XPL0 example.) |
||
Line 775: | Line 775: | ||
{{out}} |
{{out}} |
||
<pre>["a", "is", "site", "Code", "Rosetta", "programming", "chrestomathy"]</pre> |
<pre>["a", "is", "site", "Code", "Rosetta", "programming", "chrestomathy"]</pre> |
||
=={{header|XPL0}}== |
|||
<syntaxhighlight lang "XPL0"> |
|||
include xpllib; \for StrLen and StrSort |
|||
int A, Len, I; |
|||
char B; |
|||
[A:= [" Rosetta"," Code"," is"," a"," programming"," chrestomathy"," site"]; |
|||
Len:= 7; |
|||
B:= A; \to access bytes instead of integers |
|||
for I:= 0 to Len-1 do \decorate |
|||
B(I,0):= StrLen(A(I))-1; |
|||
StrSort(A, Len); |
|||
for I:= 0 to Len-1 do |
|||
[B(I,0):= ^ ; \undecorate |
|||
Text(0, A(I)); |
|||
]; |
|||
]</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
a is Code site Rosetta programming chrestomathy</pre> |