How to resolve the algorithm String case step by step in the Amazing Hopper programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm String case step by step in the Amazing Hopper programming language
Table of Contents
Problem Statement
Take the string alphaBETA and demonstrate how to convert it to:
Use the default encoding of a string literal or plain ASCII if there is no string literal in your language. Note: In some languages alphabets toLower and toUpper is not reversable. Show any additional case conversion functions (e.g. swapping case, capitalizing the first letter, etc.) that may be included in the library of your language.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm String case step by step in the Amazing Hopper programming language
Source code in the amazing programming language
#include
#proto swapcase(_X_)
main:
// literal:
String to process = "alphaBETA", {"String to process: ",String to process}println
{"UPPER: ",String to process} upper,println
{"LOWER: ",String to process} lower,println
{"SWAP CASE: "}
s="", let( s := _swap case(String to process)),{s}println
// arrays:
vArray=0, {5,5} new array(vArray), vArray=String to process
{"ARRAY UPPER: \n",vArray} upper,println
{"ARRAY LOWER: \n",vArray} lower,println
[1:2:end,1:2:end]get(vArray),upper, put(vArray)
[2:2:end,2:2:end]get(vArray),lower, put(vArray)
{"INTERVAL ARRAY UPPER/LOWER: \n",vArray},println
exit(0)
.locals
swapcase(_X_)
nLen=0, {_X_}len,mov(nLen)
__SWAPCASE__:
if( [nLen:nLen]get(_X_),{"upper"}!typechar? )
lower
else
upper
end if
put(_X_)
--nLen,{nLen}jnz(__SWAPCASE__)
{_X_} // put processed string into the stack...
back
You may also check:How to resolve the algorithm Dynamic variable names step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Pascal matrix generation step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Find palindromic numbers in both binary and ternary bases step by step in the Factor programming language
You may also check:How to resolve the algorithm Forest fire step by step in the Clojure programming language
You may also check:How to resolve the algorithm Factorial primes step by step in the BASIC programming language