User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:reversed [2019/04/16 01:47] (current)
l created
Line 1: Line 1:
 +**(reversed:​ // [...Any] //) → //​[[harlowe:​array|Array]]//​**
 +Similar to [[harlowe:​a|(a:​)]],​ except that it creates an [[harlowe:​array|array]] containing the elements in reverse order.
 +=== Example usage: ===
 +''​%%(set:​ $a to (reversed: ...$a, 2))%%''​ sets $a to its reverse, with ''​%%2%%''​ at the start.
 +=== Rationale: ===
 +Having stored items in an array, or obtained a built-in array like [[harlowe:​history|(history:​)]],​ you may want to perform some action using it - maybe assemble them into a single [[harlowe:​string|string]] using [[harlowe:​folded|(folded:​)]] - in the opposite order to which they are stored. (reversed:) allows this reversal to be easily created.
 +=== Details: ===
 +Unlike [[harlowe:​shuffled|(shuffled:​)]],​ which produces an error if one or no elements are given, this does not error if a non-reversible sequence of one or zero is given. This is meant to permit its wider use with data whose length you may not always have control over, such as the [[harlowe:​history|(history:​)]] array.
 +If you wish to specifically reverse the characters in a string, please use [[harlowe:​str-reversed|(str-reversed:​)]].
 +=== See also: ===
 +[[harlowe:​a|(a:​)]],​ [[harlowe:​shuffled|(shuffled:​)]],​ [[harlowe:​rotated|(rotated:​)]],​ [[harlowe:​str-reversed|(str-reversed:​)]]
harlowe/reversed.txt · Last modified: 2019/04/16 01:47 by l