Algorithms · real, tested code

Reverse a String in Larzscript

Flip a string end to end - one of the smallest real string algorithms, and a good first look at the str package.

str.reverse() builds the reversed string by walking the input back to front - no built-in slice-with-negative-step trick needed.

larzscript pkg install str

Code

import "str" as str_

print(str_.reverse("hello"))
print(str_.reverse("Larzscript"))
Output
olleh
tpircszraL

Why this matters in Larzscript

str is the 'word-game' half of the stack's string helpers - string handles centering/wrapping/casing, str handles palindromes/anagrams/ciphers/reversal.