How to resolve the algorithm Palindrome detection step by step in the Lasso programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Palindrome detection step by step in the Lasso programming language
Table of Contents
Problem Statement
A palindrome is a phrase which reads the same backward and forward. Write a function or program that checks whether a given sequence of characters (or, if you prefer, bytes) is a palindrome. For extra credit:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Palindrome detection step by step in the Lasso programming language
Source code in the lasso programming language
define ispalindrome(text::string) => {
local(_text = string(#text)) // need to make copy to get rid of reference issues
#_text -> replace(regexp(`(?:$|\W)+`), -ignorecase)
local(reversed = string(#_text))
#reversed -> reverse
return #_text == #reversed
}
ispalindrome('Tätatät') // works with high ascii
ispalindrome('Hello World')
ispalindrome('A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal – Panama!')
You may also check:How to resolve the algorithm Hello world/Web server step by step in the BASIC programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Search a list step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Sorting algorithms/Insertion sort step by step in the VBScript programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the Racket programming language