Softanza
StartFrançais
Softanza
Research · narration

Unlocking the Power of Lists-in-Strings with Softanza

It’s a calm day in the development lab, and you’re faced with an intriguing problem: you need to work with lists hosted inside strings. Maybe you’re designing a code generator, parsing user input, or crafting an interactive tool where lists are passed around as strings.

by Mansour Ayouni · in the repository since 2024-12-06 · feature essay · area Collections & objects

Softanza Lists-in-Strings, by Microsoft Image Create AI
Softanza Lists-in-Strings, by Microsoft Image Create AI

Softanza Lists-in-Strings, by Microsoft Image Create AI

Fear not! Softanza is here, with its robust stzString utilities. Let’s dive into a hands-on exploration of this amazing feature, step by step.


First, let's load the library:

Haro
load "stzlib.ring"

illustration

Step 1: Is It a List in a String?

You start with a string that looks suspiciously like a list. Is it really a list? Let Softanza figure that out for you:

Haro
? StzStringQ('[1,2,3]').IsListInString()		#--> TRUE
? StzStringQ('1:3').IsListInString()			#--> TRUE
? StzStringQ(' "A":"C" ').IsListInString()		#--> TRUE
? StzStringQ(' "ا":"ج" ').IsListInString()		#--> TRUE

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

Softanza isn’t just smart—it’s multilingual! It can recognize lists using standard syntax like [1,2,3], short syntax like 1:3, and even Unicode-based ranges such as "ا":"ج".

“Great,” you think, “but I wonder how these lists are structured?”

NOTE 1: The Q in StzStringQ(str) simplifies creating an stzString object by eliminating the need for explicit instantiation. Instead of writing oStr = new stzString(str), you can achieve the same result more concisely with Q(str).

NOTE 2: We would be able to use Q(str) directly and get the same result. But, using StzStringQ(str) enforces the intent to handle the input as a string, reducing ambiguity in cases like "[1, 2, 3]", which could be misinterpreted as a list rather than a string representing a list.

Step 2: Normal or Short Form?

With a glance, Softanza tells you if the list is in normal or short form:

Haro
? StzStringQ('[1,2,3]').IsListInNormalForm()		#--> TRUE
? StzStringQ('1:3').IsListInShortForm()			#--> TRUE
? StzStringQ(' "A":"C" ').IsListInShortForm()		#--> TRUE
? StzStringQ(' "ا":"ج" ').IsListInShortForm()		#--> TRUE

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

Now, you know whether you're dealing with a detailed list or a compact range. This is perfect for applications where the syntax style matters!

Step 3: Are the Elements Contiguous?

Let’s check if the elements form a contiguous range (either numeric or character-based). A simple call does the trick:

Haro
? StzStringQ('[1,3]').IsContiguousListInString()	#--> FALSE
? StzStringQ('1:3').IsContiguousListInString()		#--> TRUE
? StzStringQ(' "A":"C" ').IsContiguousListInString()	#--> TRUE
? StzStringQ(' "ا":"ج" ').IsContiguousListInString()	#--> TRUE

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

Softanza even considers the Unicode ordering of characters when determining contiguity. For example, "ا" to "ج" is contiguous in Arabic script.

Step 4: Transforming Forms

Sometimes, you need to switch between forms. Softanza makes this effortless with ToListInShortForm() and ToListInNormalForm():

Haro
? @@( StzStringQ('[1,2,3]').ToListInShortForm() )	#--> "1 : 3"
? @@( StzStringQ('1:3').ToListInNormalForm() )		#--> "[1, 2, 3]"
? StzStringQ(' ["A","B","C","D"] ').ToListInShortForm()	#--> "A" : "D"
? StzStringQ(' "ا":"ج" ').ToListInShortForm()		#--> "ا" : "ج"

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

Whether you're debugging, formatting data, or preparing a string for transmission, these transformations simplify the process.

Step 5: Evaluating Lists at Runtime

Finally, when you're ready to convert the string back to a vibrant Haro list for further computation, just call ToList():

Haro
? StzStringQ('1:3').ToList()	   	#--> [1, 2, 3]
? StzStringQ(' "A":"C" ').ToList() 	#--> ["A", "B", "C"]
? StzStringQ(' "ا":"ج" ').ToList() 	#--> ["ا", "ب", "ة", "ت", "ث", "ج"]

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

This is where the magic happens. A list-in-string becomes a living, breathing Haro list, ready for loops, computations, or any operation you desire.

Step 6: Bonus – The Shortform Shortcut

If you’re a fan of compact syntax, Softanza offers a sleek shortcut: ToListInStringSF():

Haro
? @@( StzStringQ('[1,2,3]').ToListInStringSF() )		#--> "1 : 3"
? StzStringQ(' ["A","B","C","D"] ').ToListInStringSF()		#--> "A" : "D"
? StzStringQ(' [ "ا", "ب", "ة", "ت" ] ').ToListInStringSF()+ NL	#--> "ا" : "ت"

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

This feature is perfect for quick conversions without sacrificing clarity.

Step 7: Bonus – The Magic of Q()

Tired of typing StzStringQ() every time? Softanza introduces the Q() function, a concise utility that elevates your data to the appropriate Softanza object. For our case, it conveniently wraps your string into an stzString object:

Haro
? Q('[1,2,3]').IsListInString()		#--> TRUE
? Q('1:3').ToListInString()			#--> [1, 2, 3]
? Q(' "ا":"ج" ').ToListInShortForm()	#--> "ا" : "ج"
? Q(' "A":"C" ').IsContiguousListInShortForm()	#--> TRUE

run on 2026-10-08 20:43 at commit 4a184e6f0: kept its promise

With Q(), your workflow becomes smoother and more natural. It’s like a universal adapter that streamlines the process, letting you focus on what matters—building great software!


Final Thoughts

With these tools, Softanza equips you to: - Analyze strings for list content. - Distinguish between list forms and structures. - Transform and evaluate lists seamlessly. - Simplify your coding experience with Q().

Whether you’re parsing, debugging, or creating innovative tools, Softanza's StzString utilities (and the Q() function!) open up a world of possibilities. So, go ahead—unleash the power of lists-in-strings and let your creativity soar!

Cite

Mansour Ayouni. "Unlocking the Power of Lists-in-Strings with Softanza". Softanza narrations, 2024. https://mayouni.github.io/stzsite/en/narrations/stzlist-in-strings-narration.html

Run in Haro's name on 2026-10-08 20:43 inside the library at commit 4a184e6f0, block after block in one process: 7 of 8 blocks kept their promise; the others are illustrations. The code of the articles is Haro code. Where an article was written before the language took its present name, the name was changed and nothing else. Genre, area and series read from the file's name, the year from its first commit: derived, until the article carries its own header. The file on GitHub(opens in a new tab)