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.
Related
larzstrWord-game string helpers→FizzBuzz in LarzscriptThe classic interview warm-up: print 1 to N, but Fizz for multiples of 3, Buzz for multiples of 5, FizzBuzz for both.→Check if a String is a Palindrome in LarzscriptDetect whether a string reads the same forwards and backwards, ignoring case, spaces and punctuation.→Sort a List in LarzscriptSort a list of numbers - and see exactly how many comparisons and swaps each algorithm actually costs.→