Algosim documentation: reverse

reverse

Returns an object with its elements reversed.

Syntax

Description

If X is any ordered container, then reverse(X) returns X with its elements in the reverse order.

X can be a string, a vector, a matrix, a list, a pixmap, a sound, or a binary data object. For two-dimensional objects (matrix and pixmap), row-major order is used.

Examples

L ≔ '("ERISED", ❨1, 2, 3❩, ❨❨1, 2❩, ❨3, 4❩❩, '("cat", "dog"))
ERISED
(1, 2, 3)
((1, 2), (3, 4))
(cat, dog)
reverse(L @ reverse)
(dog, cat)
((4, 3), (2, 1))
(3, 2, 1)
DESIRE
L ≔ compute(n^2, n, 1, 1000000);
pick(L, n ↦ (s ≔ string(n); s = reverse(s)))
1
4
9
121
484
676
10201
12321
14641
40804
44944
69696
94249
698896
1002001
1234321
4008004
5221225
6948496
100020001
102030201
104060401
121242121
123454321
125686521
400080004
404090404
522808225
617323716
942060249
10000200001
10221412201
12102420121
12345654321
40000800004
637832238736
bm ≔ ComputePixmap(200, 200, x, y, rgb(x/199, y/199, 0.5))

Image 1

reverse(bm)

Image 2

reverse(ExampleData("London"))

See also