Decorate-sort-undecorate idiom: Difference between revisions
→{{header|RPL}}: typo
(add RPL) |
(→{{header|RPL}}: typo) |
||
Line 734:
More complicated transforms may ''require'' an explicit schwartzian transform routine. An example of where an explicit transform is desirable is the <code>schwartzian()</code> routine in the [[P-value_correction#Raku|Raku entry for the P-value_correction task]].
=={{header|RPL}}==
This implementation accepts the key function as a callback
≪ → seq func
≪ { }
Line 742:
2 →LIST 1 →LIST +
'''NEXT'''
≫ ≫ '<span style="color:blue">DECOR</span>
≪ '''IF''' DUP SIZE 2 ≥ '''THEN'''
LIST→ → len
≪ len 1 '''FOR''' n
1 n 1 - '''START'''
DUP2 2 GET SWAP 2 GET
Line 754:
-1 '''STEP''' len →LIST
≫ '''END'''
≫ '<span style="color:blue">
≪ → seq
Line 761:
seq j GET 1 GET +
'''NEXT'''
≫ ≫ '<span style="color:blue">UNDECOR</span>
{ "Rosetta" "Code" "is" "a" "programming" "chrestomathy" "site" } ≪ SIZE ≫ <span style="color:blue">DECOR KSORT UNDECOR</span>
|