Taming Deep Lists with Softanza
Softanza, Mastering Depths from the Heart.
par Mansour Ayouni · dans le dépôt depuis le 2025-03-20 · essai de fonction · domaine Collections et objets
Cet article est écrit en anglais, comme la bibliothèque.


Deeply nested lists are powerful data structures but can become unwieldy as complexity grows. Softanza, an extension library for the Haro programming language, offers elegant solutions for managing these hierarchical structures. This article walks through practical approaches to common challenges with deep (nested) lists, introducing Softanza's features as they become relevant to solving real problems.
Finding Items Anywhere in Your Structure
One common challenge is finding all occurrences of a specific value within a deep list. With Softanza, this is straightforward:
o1 = new stzList([
"A",
[ "♥", "B", [ "C", "♥", "D", "♥" ], "♥", "E", "♥" ],
"E"
])
? @@NL( o1.DeepFind("♥") )
#--> [
# [ 2, 1 ],
# [ 2, 3, 2 ],
# [ 2, 3, 4 ],
# [ 2, 4 ],
# [ 2, 6 ]
#]exécuté le 2026-10-08 20:41 au commit 4a184e6f0 : a tenu sa promesse
The DeepFind() method traverses the entire structure and returns a list of paths where the item exists. Each path is a list of indices that pinpoints the exact location of the item.
Making Global Changes
Once you've found items, you'll often want to replace them. Softanza makes this simple too:
o1.DeepReplace("♥", :By = "*")
? @@NL( o1.Content() )
#--> [
# "A",
# [ "*", "B", [ "C", "*", "D", "*" ], "*", "E", "*" ],
# "E"
#]exécuté le 2026-10-08 20:41 au commit 4a184e6f0 : a tenu sa promesse
Need to remove items instead? Just as easy:
o1.DeepRemove("*")
? @@NL( o1.Content() )
#--> [ "A", [ "B", [ "C", "D" ], "E" ], "E" ]exécuté le 2026-10-08 20:41 au commit 4a184e6f0 : a tenu sa promesse
These methods operate throughout the entire data structure, making sweeping changes with minimal code.
Working with Specific Paths
But what if you need more precision? What if you want to operate on just part of your data structure? This is where paths come in.
A path in Softanza is simply a list of indices that locates an item. For example, in our list, the path [2, 3, 2] refers to the second item within the third item within the second item of the main list.
Softanza can show you all possible paths in your structure:
o1 = new stzList([
"item1",
[ "item21", [ "item221", "item222" ], "item23" ],
[ "item31", [ "item321" ] ],
"item4"
])
? @@NL( o1.Paths() )
#--> [
# [ 1 ],
# [ 2 ],
# [ 2, 1 ],
# [ 2, 2 ],
# [ 2, 2, 1 ],
# [ 2, 2, 2 ],
# [ 2, 3 ],
# [ 3 ],
# [ 3, 1 ],
# [ 3, 2 ],
# [ 3, 2, 1 ],
# [ 4 ]
#]exécuté le 2026-10-08 20:41 au commit 4a184e6f0 : a tenu sa promesse
With paths, you can access specific items directly:
? o1.ItemAtPath([2, 2, 2]) #--> "item222" ? @@( o1.ItemsAtPaths([ [2, 2, 2], [3, 1], [4] ]) ) #--> [ "item222", "item31", "item4" ]
illustration
Targeting Specific Locations
When you need to focus on particular parts of your data structure, Softanza offers two key approaches: finding at endpoints or along paths.
o1 = new stzList([
"A",
[ "♥", "B", [ "C", "♥", "D", "♥" ], "♥", "E", "♥" ],
"E"
])illustration
To check if a specific item exists at a particular endpoint:
? @@( o1.DeepFindAt("♥", [2, 3, 2]) )
#--> [2, 3, 2] # Returns the path if foundillustration
To find occurrences along a path (from root to endpoint):
? @@( o1.DeepFindIn("♥", [2, 3, 2]) )
#--> [ [2, 1], [2, 3, 2] ] # Returns all paths where "♥" is foundillustration
Similarly, you can make targeted changes:
# Replace only at the endpoint
o1.DeepReplaceAt("★", [2, 3, 2])
? @@NL( o1.Content() )
#--> [
# "A",
# [ "♥", "B", [ "C", "★", "D", "♥" ], "♥", "E", "♥" ],
# "E"
#]illustration
Operations on Specific Items
As your needs grow more sophisticated, you may want to apply changes only to specific items. Softanza uses the "This" indicator for such operations:
# Replace only if the item at the path equals "♥"
o1.DeepReplaceThisAt("♥", "★", [2, 4])
? @@NL( o1.Content() )
#--> [
# "A",
# [ "♥", "B", [ "C", "★", "D", "♥" ], "★", "E", "♥" ],
# "E"
#]
# No change if the item doesn't match
o1.DeepReplaceThisAt("C", "★", [2, 4]) # No effect since "★" is at [2, 4], not "C"illustration
The same principle applies to operations along paths:
# Replace all "♥" symbols along path [2, 3] with "★"
o1.DeepReplaceThisIn("♥", "★", [2, 3])
? @@NL( o1.Content() )
#--> [
# "A",
# [ "♥", "B", [ "C", "★", "D", "★" ], "★", "E", "♥" ],
# "E"
#]illustration
Working with Multiple Paths
When you need to perform the same operation across different locations, the "Many" suffix comes in handy:
# Replace at multiple specific endpoints
o1.DeepReplaceAtMany("◆", [ [2, 1], [2, 6] ])
? @@NL( o1.Content() )
#--> [
# "A",
# [ "◆", "B", [ "C", "★", "D", "★" ], "★", "E", "◆" ],
# "E"
#]illustration
Multiple Item Operations
For more complex transformations involving multiple items, Softanza offers "These" and "Many" variants:
# Replace both "★" and "D" with "△" along path [2, 3] o1.DeepReplaceTheseIn(["★", "D"], "△", [2, 3]) ? @@NL( o1.Content() ) #--> [ # "A", # [ "◆", "B", [ "C", "△", "△", "△" ], "★", "E", "◆" ], # "E" #]
illustration
You can even replace different items with different values:
# Replace "△" with "○" and "C" with "□" along path [2, 3] o1.DeepReplaceManyByManyIn(["△", "C"], ["○", "□"], [2, 3]) ? @@NL( o1.Content() ) #--> [ # "A", # [ "◆", "B", [ "□", "○", "○", "○" ], "★", "E", "◆" ], # "E" #]
illustration
Extended Processing
When dealing with uneven replacement lists, the "XT" suffix enables cycling through replacement values:
# Replace "○", "□" and "★" with cycling through "■" and "▲" o1.DeepReplaceManyByManyInXT(["○", "□", "★"], ["■", "▲"], [2, 3]) ? @@NL( o1.Content() ) #--> [ # "A", # [ "◆", "B", [ "▲", "■", "■", "▲" ], "■", "E", "◆" ], # "E" #]
illustration
Advanced Path Operations
As you become more familiar with paths, Softanza offers tools to help you manage them:
Finding Special Paths
# Find the longest paths ? @@( o1.LongestPaths() ) #--> [ [ 2, 3, 1 ], [ 2, 3, 2 ], [ 2, 3, 3 ], [ 2, 3, 4 ] ] # Find paths at a specific depth ? @@( o1.PathsAtDepth(2) ) #--> [ [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 1 ], [ 3, 2 ] ]
illustration
Understanding Path Relationships
# Check if one path is a subpath of another ? IsSubPathOf([2], [2, 3, 4]) #--> TRUE # Find the common ancestor of multiple paths ? @@( CommonPath([ [2, 1, 3], [2, 1, 4], [2, 1, 5] ]) ) #--> [2, 1]
exécuté le 2026-10-08 20:41 au commit 4a184e6f0 : a tenu sa promesse
Expanding and Focusing
# Expand a path to include all its subpaths ? @@NL( o1.ExpandPath([2, 3]) ) #--> [ # [ 2, 3 ], # [ 2, 3, 1 ], # [ 2, 3, 2 ], # [ 2, 3, 3 ], # [ 2, 3, 4 ] #] # Collapse a path to its parent ? @@( o1.CollapsePath([2, 3, 4]) ) #--> [2]
illustration
Beyond Simple Values
Softanza's tools extend beyond simple replacements. You can apply transformations too:
o1 = new stzList([
"you",
"other",
[ "other", "you", [ "you" ], "other" ],
"you"
])
# Uppercase all occurrences of "other"
o1.DeepUppercaseString("other")
? @@NL( o1.Content() )
#--> [
# "you",
# "OTHER",
# [ "OTHER", "you", [ "you" ], "OTHER" ],
# "you"
#]illustration
Real-World Applications
These features combine powerfully in practical scenarios:
- Configuration Management: Find all settings with
DeepFind(), then modify specific ones withDeepReplaceThisAt(). - Data Transformation: Convert JSON-like structures by replacing values at different depths.
- Content Processing: Search for patterns with
DeepFindIn()and transform them contextually. - Data Cleaning: Remove unwanted items from specific sections using
DeepRemoveThisIn().
The Softanza Advantage
In this section, we compare Softanza to several mainstream languages in the field of deep list and path management.
Legend: - ✅ Full native support - ⚙️ Possible with custom implementation - 🔄 Partial support
| Deep List Feature | Softanza (Haro) | Wolfram Language | Python (jsonpath-ng) |
JavaScript (Lodash) | C# (LINQ/JSON.NET) | Java (Stream API/Jackson) |
|---|---|---|---|---|---|---|
Deep Finding (DeepFind()) |
✅ | ✅ | 🔄 | ⚙️ | 🔄 | 🔄 |
Global Replacement (DeepReplace(:By)) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Deep Removal (DeepRemove()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Path Enumeration (Paths()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Path-Specific Access (ItemAtPath()) |
✅ | ✅ | 🔄 | ✅ | 🔄 | 🔄 |
Multiple Path Operations (ItemsAtPaths()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Targeted Replacement (DeepReplaceAt()) |
✅ | ✅ | ⚙️ | ✅ | ⚙️ | ⚙️ |
Path Traversal Operations (DeepFindIn()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Value-Specific Operations (DeepReplaceThisAt()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Multi-Target Operations (DeepReplaceTheseIn()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Complex Value Mapping (DeepReplaceManyByManyIn()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Cycling Replacements (DeepReplaceManyByManyInXT()) |
✅ | 🔄 | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Path Analysis (LongestPaths(), PathsAtDepth()) |
✅ | 🔄 | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Path Relationships (IsSubPathOf(), CommonPath()) |
✅ | 🔄 | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Path Expansion (ExpandPath(), CollapsePath()) |
✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Deep String Transformations (DeepUppercaseString()) |
✅ | ✅ | ⚙️ | ⚙️ | ⚙️ | ⚙️ |
Key Takeaways: 1. Softanza remains the only solution with full native support for all operations. 2. Wolfram Language is the closest alternative, though it follows a different programming paradigm. 3. Python, JavaScript, C#, and Java require custom implementations for most complex nested operations. 4. C#'s LINQ and Java's Stream API are powerful but not designed for deep list and path manipulation. 5. Most mainstream languages follow this pattern: - Basic path access is available (partially or via libraries). - Deep finding operations have partial or custom support. - Complex operations like targeted replacements, path analysis, and relationship checking require custom implementation.
Conclusion
Softanza transforms complex operations on deep lists from tedious tasks into elegant one-liners. By providing intuitive methods that build on familiar concepts, it lets you focus on what you want to accomplish rather than how to navigate complex structures.
The library's consistent naming patterns make your code more readable and maintainable. As your needs grow from simple searches to complex replacements across multiple paths, Softanza offers just the right tool for each challenge.
Citer
Mansour Ayouni. « Taming Deep Lists with Softanza ». Softanza narrations, 2025. https://mayouni.github.io/stzsite/fr/narrations/stz-managing-deep-lists-narration.html
Exécuté au nom de Haro le 2026-10-08 20:41 dans la bibliothèque au commit 4a184e6f0, bloc après bloc dans un seul processus : 5 bloc(s) sur 19 ont tenu leur promesse ; les autres sont des illustrations. Le code des articles est du code Haro. Là où un article a été écrit avant que la langue prenne son nom actuel, le nom a été changé et rien d'autre. Genre, domaine et série lus dans le nom du fichier, année tirée du premier commit : dérivés, jusqu'à ce que l'article porte son propre en-tête. Le fichier sur GitHub(s'ouvre dans un nouvel onglet)

