Decorate-sort-undecorate idiom: Difference between revisions
Content added Content deleted
(More than 5 solutions, promoted to non-draft task) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: change explicit ST to use an arity two comparitor to disable automatic ST. same output) |
||
Line 308: | Line 308: | ||
# explicit schwartzian transform |
# explicit schwartzian transform |
||
dd <Rosetta Code is a programming chrestomathy site>.map({$_=>.chars}).sort({.value}).map({.key});</syntaxhighlight> |
dd <Rosetta Code is a programming chrestomathy site>.map({$_=>.chars}).sort({$^one.value cmp $^the-other.value}).map({.key});</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
( <code>dd</code> is the built in "data-dumper" function; a verbose and explicit representation of an objects contents.) |
( <code>dd</code> is the built in "data-dumper" function; a verbose and explicit representation of an objects contents.) |
||
Line 314: | Line 314: | ||
("a", "is", "Code", "site", "Rosetta", "programming", "chrestomathy").Seq</pre> |
("a", "is", "Code", "site", "Rosetta", "programming", "chrestomathy").Seq</pre> |
||
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]]. |
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|Wren}}== |
=={{header|Wren}}== |