Jump to content

Decorate-sort-undecorate idiom: Difference between revisions

(add RPL)
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, but uses local named variables.
≪ → seq func
≪ { }
Line 742:
2 →LIST 1 →LIST +
'''NEXT'''
≫ ≫ '<span style="color:blue">DECOR</span>' STO
≪ '''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">SKSORTKSORT</span>' STO
≪ → seq
Line 761:
seq j GET 1 GET +
'''NEXT'''
≫ ≫ '<span style="color:blue">UNDECOR</span>' STO
 
{ "Rosetta" "Code" "is" "a" "programming" "chrestomathy" "site" } ≪ SIZE ≫ <span style="color:blue">DECOR KSORT UNDECOR</span>
1,151

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.