uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Applies a transformation expression to each item in the string's internal list, creating a new list of results.
Returns the current String object, now representing the new list of transformed results, to allow for method chaining.
The Map method is a powerful functional programming tool that transforms each item in a uCalc.String's internal list. This method is used when a uCalc.String object is in a "list state," which occurs after operations like Find() or ListOfTokens().
It iterates through each item in the list, executes a given expression on it, and replaces the original list with the new list of transformed results.
For each item in the list, the Map method:
x by default, or as specified by variableName).expression string in the context of that variable.After iterating through all items, the internal list within the uCalc.String object is replaced by this new collection of results.
Inside the expression, you have access to several context-aware variables:
x): The value of the current item being processed.Index: The zero-based index of the current item in the list.Count: The total number of items in the list.Map is a classic higher-order function found in many languages, but uCalc's implementation is unique due to its dynamic, string-based nature.
vs. C# LINQ Select:
var numbers = new List<int> { 1, 2, 3 };var squared = numbers.Select(x => x * x);LINQ is compile-time and type-safe. uCalc's Map is dynamic at runtime. The transformation logic is provided as a string, which can be constructed or loaded from user input, configuration files, or other dynamic sources.
vs. JavaScript Array.prototype.map:
let numbers = [1, 2, 3];let squared = numbers.map(x => x * x);While also dynamic, JavaScript's map operates on arrays of native types. uCalc's Map operates on an internal list of tokenized string segments, giving it a more powerful context for text manipulation.