<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.memcp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aiagent</id>
	<title>MemCP - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.memcp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aiagent"/>
	<link rel="alternate" type="text/html" href="https://www.memcp.org/wiki/Special:Contributions/Aiagent"/>
	<updated>2026-04-24T16:57:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>https://www.memcp.org/index.php?title=Sync&amp;diff=230</id>
		<title>Sync</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Sync&amp;diff=230"/>
		<updated>2025-08-25T16:53:06Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Sync =  The &amp;#039;&amp;#039;&amp;#039;Sync&amp;#039;&amp;#039;&amp;#039; module provides synchronization and concurrency functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Session management&amp;#039;&amp;#039;&amp;#039;: Functions to create threadsafe key-value stores (newsession) * &amp;#039;&amp;#039;&amp;#039;Context handling&amp;#039;&amp;#039;&amp;#039;: Context management with session support (context) * &amp;#039;&amp;#039;&amp;#039;Timing control&amp;#039;&amp;#039;&amp;#039;: Functions to pause execution (sleep) * &amp;#039;&amp;#039;&amp;#039;Function caching&amp;#039;&amp;#039;&amp;#039;: One-time execution wrappers with result caching (once) * &amp;#039;&amp;#039;&amp;#039;Thread synchronizat...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Sync =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Sync&#039;&#039;&#039; module provides synchronization and concurrency functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Session management&#039;&#039;&#039;: Functions to create threadsafe key-value stores (newsession)&lt;br /&gt;
* &#039;&#039;&#039;Context handling&#039;&#039;&#039;: Context management with session support (context)&lt;br /&gt;
* &#039;&#039;&#039;Timing control&#039;&#039;&#039;: Functions to pause execution (sleep)&lt;br /&gt;
* &#039;&#039;&#039;Function caching&#039;&#039;&#039;: One-time execution wrappers with result caching (once)&lt;br /&gt;
* &#039;&#039;&#039;Thread synchronization&#039;&#039;&#039;: Mutex creation for serialized access (mutex)&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for managing concurrent operations, shared state, and synchronization in multi-threaded SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== newsession ==&lt;br /&gt;
&lt;br /&gt;
Creates a new session which is a threadsafe key-value store represented as a function that can be either called as a getter (session key) or setter (session key value) or list all keys with (session)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This function has no parameters.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== context ==&lt;br /&gt;
&lt;br /&gt;
Context helper function. Each context also contains a session. (context func args) creates a new context and runs func in that context, (context &amp;quot;session&amp;quot;) reads the session variable, (context &amp;quot;check&amp;quot;) will check the liveliness of the context and otherwise throw an error&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;args...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): depends on the usage&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== sleep ==&lt;br /&gt;
&lt;br /&gt;
sleeps the amount of seconds&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;duration&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of seconds to sleep&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== once ==&lt;br /&gt;
&lt;br /&gt;
Creates a function wrapper that you can call multiple times but only gets executed once. The result value is cached and returned on a second call. You can add parameters to that resulting function that will be passed to the first run of the wrapped function.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;f&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function that produces the result value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mutex ==&lt;br /&gt;
&lt;br /&gt;
Creates a mutex. The return value is a function that takes one parameter which is a parameterless function. The mutex is guaranteed that all calls to that mutex get serialized.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This function has no parameters.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Parsers&amp;diff=229</id>
		<title>Parsers</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Parsers&amp;diff=229"/>
		<updated>2025-08-25T16:51:54Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Parsers =  The &amp;#039;&amp;#039;&amp;#039;Parsers&amp;#039;&amp;#039;&amp;#039; module provides parsing functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Parser creation&amp;#039;&amp;#039;&amp;#039;: Functions to create custom parsers using grammar syntax (parser) * &amp;#039;&amp;#039;&amp;#039;Grammar support&amp;#039;&amp;#039;&amp;#039;: Support for various parser types including AtomParser, RegexParser, AndParser, OrParser, KleeneParser, ManyParser, MaybeParser, and more * &amp;#039;&amp;#039;&amp;#039;Packrat parsing&amp;#039;&amp;#039;&amp;#039;: Implementation of packrat parsing algorithms for efficient parsing * &amp;#039;&amp;#039;&amp;#039;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Parsers =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Parsers&#039;&#039;&#039; module provides parsing functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Parser creation&#039;&#039;&#039;: Functions to create custom parsers using grammar syntax (parser)&lt;br /&gt;
* &#039;&#039;&#039;Grammar support&#039;&#039;&#039;: Support for various parser types including AtomParser, RegexParser, AndParser, OrParser, KleeneParser, ManyParser, MaybeParser, and more&lt;br /&gt;
* &#039;&#039;&#039;Packrat parsing&#039;&#039;&#039;: Implementation of packrat parsing algorithms for efficient parsing&lt;br /&gt;
* &#039;&#039;&#039;Whitespace handling&#039;&#039;&#039;: Configurable whitespace skipping mechanisms&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for creating custom parsers and processing structured text data in SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== parser ==&lt;br /&gt;
&lt;br /&gt;
creates a parser&lt;br /&gt;
&lt;br /&gt;
SCM parsers work this way:&lt;br /&gt;
&amp;lt;code&amp;gt;(parser syntax scmerresult) -&amp;gt; func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
syntax can be one of:&lt;br /&gt;
* &amp;lt;code&amp;gt;(parser syntax scmerresult)&amp;lt;/code&amp;gt; will execute scmerresult after parsing syntax&lt;br /&gt;
* &amp;lt;code&amp;gt;(parser syntax scmerresult &amp;quot;skipper&amp;quot;)&amp;lt;/code&amp;gt; will add a different whitespace skipper regex to the root parser&lt;br /&gt;
* &amp;lt;code&amp;gt;(define var syntax)&amp;lt;/code&amp;gt; valid inside &amp;lt;code&amp;gt;(parser...)&amp;lt;/code&amp;gt;, stores the result of syntax into var for use in scmerresult&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;quot;str&amp;quot;&amp;lt;/code&amp;gt; AtomParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(atom &amp;quot;str&amp;quot; caseinsensitive skipws)&amp;lt;/code&amp;gt; AtomParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(regex &amp;quot;asdf&amp;quot; caseinsensitive skipws)&amp;lt;/code&amp;gt; RegexParser&lt;br /&gt;
* &amp;lt;code&amp;gt;&#039;(a b c)&amp;lt;/code&amp;gt; AndParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(or a b c)&amp;lt;/code&amp;gt; OrParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(* sub separator)&amp;lt;/code&amp;gt; KleeneParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(+ sub separator)&amp;lt;/code&amp;gt; ManyParser&lt;br /&gt;
* &amp;lt;code&amp;gt;(? xyz)&amp;lt;/code&amp;gt; MaybeParser (if &amp;gt;1 AndParser)&lt;br /&gt;
* &amp;lt;code&amp;gt;(not mainparser parser1 parser2 parser3 ...)&amp;lt;/code&amp;gt; a parser that matches mainparser but not parser1...&lt;br /&gt;
* &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; EndParser&lt;br /&gt;
* &amp;lt;code&amp;gt;empty&amp;lt;/code&amp;gt; EmptyParser&lt;br /&gt;
* &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt; -&amp;gt; use other parser defined in env&lt;br /&gt;
&lt;br /&gt;
For further details on packrat parsers, take a look at https://github.com/launix-de/go-packrat&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;syntax&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): syntax of the grammar (see docs)&lt;br /&gt;
* &#039;&#039;&#039;generator&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): (optional) expressions to evaluate. All captured variables are available in the scope.&lt;br /&gt;
* &#039;&#039;&#039;skipper&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): (optional) string that defines the skip mechanism for whitespaces as regexp&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Vectors&amp;diff=228</id>
		<title>Vectors</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Vectors&amp;diff=228"/>
		<updated>2025-08-25T16:50:41Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Vectors =  The &amp;#039;&amp;#039;&amp;#039;Vectors&amp;#039;&amp;#039;&amp;#039; module provides vector mathematics functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Vector operations&amp;#039;&amp;#039;&amp;#039;: Functions to perform mathematical operations on vectors (dot) * &amp;#039;&amp;#039;&amp;#039;Distance calculations&amp;#039;&amp;#039;&amp;#039;: Support for different distance metrics including DOT, COSINE, and EUCLIDEAN  These functions provide essential tools for working with vectors in mathematical computations, enabling vector analysis and similarity calcul...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Vectors =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Vectors&#039;&#039;&#039; module provides vector mathematics functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Vector operations&#039;&#039;&#039;: Functions to perform mathematical operations on vectors (dot)&lt;br /&gt;
* &#039;&#039;&#039;Distance calculations&#039;&#039;&#039;: Support for different distance metrics including DOT, COSINE, and EUCLIDEAN&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for working with vectors in mathematical computations, enabling vector analysis and similarity calculations in SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== dot ==&lt;br /&gt;
&lt;br /&gt;
produced the dot product&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;v1&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): vector1&lt;br /&gt;
* &#039;&#039;&#039;v2&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): vector2&lt;br /&gt;
* &#039;&#039;&#039;mode&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): DOT, COSINE, EUCLIDEAN, default is DOT&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Date&amp;diff=227</id>
		<title>Date</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Date&amp;diff=227"/>
		<updated>2025-08-25T16:49:35Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Date =  The &amp;#039;&amp;#039;&amp;#039;Date&amp;#039;&amp;#039;&amp;#039; module provides date and time functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Current time&amp;#039;&amp;#039;&amp;#039;: Functions to get the current Unix timestamp (now) * &amp;#039;&amp;#039;&amp;#039;Date parsing&amp;#039;&amp;#039;&amp;#039;: Functions to parse date strings into Unix timestamps (parse_date)  These functions provide essential tools for working with dates and timestamps in SCM programs, enabling time-based operations and date string processing.  ← Back to Full SCM API docume...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Date =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Date&#039;&#039;&#039; module provides date and time functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Current time&#039;&#039;&#039;: Functions to get the current Unix timestamp (now)&lt;br /&gt;
* &#039;&#039;&#039;Date parsing&#039;&#039;&#039;: Functions to parse date strings into Unix timestamps (parse_date)&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for working with dates and timestamps in SCM programs, enabling time-based operations and date string processing.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== now ==&lt;br /&gt;
&lt;br /&gt;
returns the unix timestamp&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This function has no parameters.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== parse_date ==&lt;br /&gt;
&lt;br /&gt;
parses unix date from a string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): values to parse&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Associative_Lists_/_Dictionaries&amp;diff=226</id>
		<title>Associative Lists / Dictionaries</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Associative_Lists_/_Dictionaries&amp;diff=226"/>
		<updated>2025-08-25T16:48:26Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Associative Lists / Dictionaries =  The &amp;#039;&amp;#039;&amp;#039;Associative Lists / Dictionaries&amp;#039;&amp;#039;&amp;#039; module provides key-value data structure operations for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Dictionary filtering&amp;#039;&amp;#039;&amp;#039;: Functions to filter dictionaries based on key-value conditions (filter_assoc) * &amp;#039;&amp;#039;&amp;#039;Dictionary mapping&amp;#039;&amp;#039;&amp;#039;: Transform dictionary values while preserving keys (map_assoc) * &amp;#039;&amp;#039;&amp;#039;Dictionary reduction&amp;#039;&amp;#039;&amp;#039;: Aggregate dictionary data into single values (reduce_asso...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Associative Lists / Dictionaries =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Associative Lists / Dictionaries&#039;&#039;&#039; module provides key-value data structure operations for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Dictionary filtering&#039;&#039;&#039;: Functions to filter dictionaries based on key-value conditions (filter_assoc)&lt;br /&gt;
* &#039;&#039;&#039;Dictionary mapping&#039;&#039;&#039;: Transform dictionary values while preserving keys (map_assoc)&lt;br /&gt;
* &#039;&#039;&#039;Dictionary reduction&#039;&#039;&#039;: Aggregate dictionary data into single values (reduce_assoc)&lt;br /&gt;
* &#039;&#039;&#039;Dictionary queries&#039;&#039;&#039;: Check for key existence and extract data (has_assoc?, extract_assoc)&lt;br /&gt;
* &#039;&#039;&#039;Dictionary modification&#039;&#039;&#039;: Set individual values and merge dictionaries (set_assoc, merge_assoc)&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for working with associative data structures, enabling efficient key-value operations and dictionary manipulation in SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== filter_assoc ==&lt;br /&gt;
&lt;br /&gt;
returns a filtered dictionary according to a filter function&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be filtered&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): filter function func(string any)-&amp;gt;bool where the first parameter is the key, the second is the value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== map_assoc ==&lt;br /&gt;
&lt;br /&gt;
returns a mapped dictionary according to a map function. Keys will stay the same but values are mapped.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be mapped&lt;br /&gt;
* &#039;&#039;&#039;map&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): map function func(string any)-&amp;gt;any where the first parameter is the key, the second is the value. It must return the new value.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== reduce_assoc ==&lt;br /&gt;
&lt;br /&gt;
reduces a dictionary according to a reduce function&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be reduced&lt;br /&gt;
* &#039;&#039;&#039;reduce&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): reduce function func(any string any)-&amp;gt;any where the first parameter is the accumulator, second is key, third is value. It must return the new accumulator.&lt;br /&gt;
* &#039;&#039;&#039;neutral&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): initial value for the accumulator&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== has_assoc? ==&lt;br /&gt;
&lt;br /&gt;
checks if a dictionary has a key present&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be checked&lt;br /&gt;
* &#039;&#039;&#039;key&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): key to test&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== extract_assoc ==&lt;br /&gt;
&lt;br /&gt;
applies a function (key value) on the dictionary and returns the results as a flat list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be checked&lt;br /&gt;
* &#039;&#039;&#039;map&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): func(string any)-&amp;gt;any that flattens down each element&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== set_assoc ==&lt;br /&gt;
&lt;br /&gt;
returns a dictionary where a single value has been changed. This function may destroy the input value for the sake of performance. You must not use the input value again.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–4&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): input dictionary that has to be changed. You must not use this value again.&lt;br /&gt;
* &#039;&#039;&#039;key&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): key that has to be set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): new value to set&lt;br /&gt;
* &#039;&#039;&#039;merge&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): (optional) func(any any)-&amp;gt;any that is called when a value is overwritten. The first parameter is the old value, the second is the new value. It must return the merged value that shall be pysically stored in the new dictionary.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== merge_assoc ==&lt;br /&gt;
&lt;br /&gt;
returns a dictionary where all keys from dict1 and all keys from dict2 are present. If a key is present in both inputs, the second one will be dominant so the first value will be overwritten unless you provide a merge function&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;dict1&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): first input dictionary that has to be changed. You must not use this value again.&lt;br /&gt;
* &#039;&#039;&#039;dict2&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): input dictionary that contains the new values that have to be added&lt;br /&gt;
* &#039;&#039;&#039;merge&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): (optional) func(any any)-&amp;gt;any that is called when a value is overwritten. The first parameter is the old value, the second is the new value from dict2. It must return the merged value that shall be pysically stored in the new dictionary.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Lists&amp;diff=225</id>
		<title>Lists</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Lists&amp;diff=225"/>
		<updated>2025-08-25T16:46:21Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Lists =  The &amp;#039;&amp;#039;&amp;#039;Lists&amp;#039;&amp;#039;&amp;#039; module provides comprehensive list manipulation and processing functions for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;List operations&amp;#039;&amp;#039;&amp;#039;: Basic operations like counting (count), accessing elements (nth), and type checking (list?) * &amp;#039;&amp;#039;&amp;#039;List construction&amp;#039;&amp;#039;&amp;#039;: Building lists with append, cons, and unique operations (append_unique, merge_unique) * &amp;#039;&amp;#039;&amp;#039;List deconstruction&amp;#039;&amp;#039;&amp;#039;: Extracting parts with car (head), cdr (tail), and filtering...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lists =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Lists&#039;&#039;&#039; module provides comprehensive list manipulation and processing functions for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;List operations&#039;&#039;&#039;: Basic operations like counting (count), accessing elements (nth), and type checking (list?)&lt;br /&gt;
* &#039;&#039;&#039;List construction&#039;&#039;&#039;: Building lists with append, cons, and unique operations (append_unique, merge_unique)&lt;br /&gt;
* &#039;&#039;&#039;List deconstruction&#039;&#039;&#039;: Extracting parts with car (head), cdr (tail), and filtering operations&lt;br /&gt;
* &#039;&#039;&#039;Functional programming&#039;&#039;&#039;: Higher-order functions like map, filter, reduce, and produce for advanced list processing&lt;br /&gt;
* &#039;&#039;&#039;List utilities&#039;&#039;&#039;: Searching (has?, contains?), merging, zipping, and flattening operations&lt;br /&gt;
* &#039;&#039;&#039;List generation&#039;&#039;&#039;: Creating sequences and ranges with produce and produceN functions&lt;br /&gt;
&lt;br /&gt;
These functions provide the essential tools for working with lists as the primary data structure in functional programming with SCM.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== count ==&lt;br /&gt;
&lt;br /&gt;
counts the number of elements in the list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): base list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== nth ==&lt;br /&gt;
&lt;br /&gt;
get the nth item of a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): base list&lt;br /&gt;
* &#039;&#039;&#039;index&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): index beginning from 0&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== append ==&lt;br /&gt;
&lt;br /&gt;
appends items to a list and return the extended list. The original list stays unharmed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): base list&lt;br /&gt;
* &#039;&#039;&#039;item...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): items to add&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== append_unique ==&lt;br /&gt;
&lt;br /&gt;
appends items to a list but only if they are new. The original list stays unharmed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): base list&lt;br /&gt;
* &#039;&#039;&#039;item...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): items to add&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== cons ==&lt;br /&gt;
&lt;br /&gt;
constructs a list from a head and a tail list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;car&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): new head element&lt;br /&gt;
* &#039;&#039;&#039;cdr&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): tail that is appended after car&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== car ==&lt;br /&gt;
&lt;br /&gt;
extracts the head of a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== cdr ==&lt;br /&gt;
&lt;br /&gt;
extracts the tail of a list. The tail of a list is a list with all items except the head.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== zip ==&lt;br /&gt;
&lt;br /&gt;
swaps the dimension of a list of lists. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as the components that will be zipped into the sub list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of lists of items&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== merge ==&lt;br /&gt;
&lt;br /&gt;
flattens a list of lists into a list containing all the subitems. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as lists that will be merged into one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of lists of items&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== merge_unique ==&lt;br /&gt;
&lt;br /&gt;
flattens a list of lists into a list containing all the subitems. Duplicates are filtered out.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of lists of items&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== has? ==&lt;br /&gt;
&lt;br /&gt;
checks if a list has a certain item (equal?)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;haystack&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list to search in&lt;br /&gt;
* &#039;&#039;&#039;needle&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): item to search for&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== filter ==&lt;br /&gt;
&lt;br /&gt;
returns a list that only contains elements that pass the filter function&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list that has to be filtered&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): filter condition func(any)-&amp;gt;bool&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== map ==&lt;br /&gt;
&lt;br /&gt;
returns a list that contains the results of a map function that is applied to the list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list that has to be mapped&lt;br /&gt;
* &#039;&#039;&#039;map&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): map function func(any)-&amp;gt;any that is applied to each item&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mapIndex ==&lt;br /&gt;
&lt;br /&gt;
returns a list that contains the results of a map function that is applied to the list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list that has to be mapped&lt;br /&gt;
* &#039;&#039;&#039;map&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): map function func(i, any)-&amp;gt;any that is applied to each item&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== reduce ==&lt;br /&gt;
&lt;br /&gt;
returns a list that contains the result of a map function&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list that has to be reduced&lt;br /&gt;
* &#039;&#039;&#039;reduce&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): reduce function func(any any)-&amp;gt;any where the first parameter is the accumulator, the second is a list item&lt;br /&gt;
* &#039;&#039;&#039;neutral&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): (optional) initial value of the accumulator, defaults to nil&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== produce ==&lt;br /&gt;
&lt;br /&gt;
returns a list that contains produced items - it works like for(state = startstate, condition(state), state = iterator(state)) {yield state}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;startstate&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): start state to begin with&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): func that returns true whether the state will be inserted into the result or the loop is stopped&lt;br /&gt;
* &#039;&#039;&#039;iterator&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): func that produces the next state&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== produceN ==&lt;br /&gt;
&lt;br /&gt;
returns a list with numbers from 0..n-1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;n&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of elements to produce&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== list? ==&lt;br /&gt;
&lt;br /&gt;
checks if a value is a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to check&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== contains? ==&lt;br /&gt;
&lt;br /&gt;
checks if a value is in a list; uses the equal?? operator&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;list&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list to check&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to check&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Streams&amp;diff=223</id>
		<title>Streams</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Streams&amp;diff=223"/>
		<updated>2025-08-25T16:43:42Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Streams =  The &amp;#039;&amp;#039;&amp;#039;Streams&amp;#039;&amp;#039;&amp;#039; module provides stream processing and compression functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Stream creation&amp;#039;&amp;#039;&amp;#039;: Functions to create streams from string content (streamString) * &amp;#039;&amp;#039;&amp;#039;Compression&amp;#039;&amp;#039;&amp;#039;: Stream compression using gzip and xz algorithms * &amp;#039;&amp;#039;&amp;#039;Decompression&amp;#039;&amp;#039;&amp;#039;: Stream decompression using zcat (gzip) and xzcat (xz) functions  These functions enable efficient handling of data streams, file compression, a...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Streams =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Streams&#039;&#039;&#039; module provides stream processing and compression functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Stream creation&#039;&#039;&#039;: Functions to create streams from string content (streamString)&lt;br /&gt;
* &#039;&#039;&#039;Compression&#039;&#039;&#039;: Stream compression using gzip and xz algorithms&lt;br /&gt;
* &#039;&#039;&#039;Decompression&#039;&#039;&#039;: Stream decompression using zcat (gzip) and xzcat (xz) functions&lt;br /&gt;
&lt;br /&gt;
These functions enable efficient handling of data streams, file compression, and decompression operations in SCM programs, particularly useful for processing large datasets and file I/O operations.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== streamString ==&lt;br /&gt;
&lt;br /&gt;
creates a stream that contains a string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;content&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): content to put into the stream&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== gzip ==&lt;br /&gt;
&lt;br /&gt;
compresses a stream with gzip. Create streams with (stream filename)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;stream&#039;&#039;&#039; (&amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;): input stream&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== xz ==&lt;br /&gt;
&lt;br /&gt;
compresses a stream with xz. Create streams with (stream filename)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;stream&#039;&#039;&#039; (&amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;): input stream&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== zcat ==&lt;br /&gt;
&lt;br /&gt;
turns a compressed gzip stream into a stream of uncompressed data. Create streams with (stream filename)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;stream&#039;&#039;&#039; (&amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;): input stream&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== xzcat ==&lt;br /&gt;
&lt;br /&gt;
turns a compressed xz stream into a stream of uncompressed data. Create streams with (stream filename)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;stream&#039;&#039;&#039; (&amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;): input stream&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;stream&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Strings&amp;diff=222</id>
		<title>Strings</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Strings&amp;diff=222"/>
		<updated>2025-08-25T16:35:52Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Strings =  The &amp;#039;&amp;#039;&amp;#039;Strings&amp;#039;&amp;#039;&amp;#039; module provides comprehensive string manipulation and processing functions for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;String validation&amp;#039;&amp;#039;&amp;#039;: Functions to check string types and properties (string?, strlen) * &amp;#039;&amp;#039;&amp;#039;String manipulation&amp;#039;&amp;#039;&amp;#039;: Concatenation (concat), substring extraction (substr), and case conversion (toLower, toUpper) * &amp;#039;&amp;#039;&amp;#039;Pattern matching&amp;#039;&amp;#039;&amp;#039;: Wildcard pattern matching (strlike) and string replacement (replace) *...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Strings =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Strings&#039;&#039;&#039; module provides comprehensive string manipulation and processing functions for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;String validation&#039;&#039;&#039;: Functions to check string types and properties (string?, strlen)&lt;br /&gt;
* &#039;&#039;&#039;String manipulation&#039;&#039;&#039;: Concatenation (concat), substring extraction (substr), and case conversion (toLower, toUpper)&lt;br /&gt;
* &#039;&#039;&#039;Pattern matching&#039;&#039;&#039;: Wildcard pattern matching (strlike) and string replacement (replace)&lt;br /&gt;
* &#039;&#039;&#039;String parsing&#039;&#039;&#039;: Splitting strings (split) and data type simplification (simplify)&lt;br /&gt;
* &#039;&#039;&#039;Encoding/Decoding&#039;&#039;&#039;: URL encoding/decoding, HTML entities, JSON processing, and binary conversion&lt;br /&gt;
* &#039;&#039;&#039;Internationalization&#039;&#039;&#039;: Collation support for natural sorting and language-specific comparisons&lt;br /&gt;
&lt;br /&gt;
These functions provide the essential tools for text processing, data formatting, and string-based operations in SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== string? ==&lt;br /&gt;
&lt;br /&gt;
tells if the value is a string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== concat ==&lt;br /&gt;
&lt;br /&gt;
concatenates stringable values and returns a string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values to concat&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== substr ==&lt;br /&gt;
&lt;br /&gt;
returns a substring&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to cut&lt;br /&gt;
* &#039;&#039;&#039;start&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): first character index&lt;br /&gt;
* &#039;&#039;&#039;len&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): optional length&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== simplify ==&lt;br /&gt;
&lt;br /&gt;
turns a stringable input value in the easiest-most value (e.g. turn strings into numbers if they are numeric&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to simplify&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== strlen ==&lt;br /&gt;
&lt;br /&gt;
returns the length of a string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== strlike ==&lt;br /&gt;
&lt;br /&gt;
matches the string against a wildcard pattern (SQL compliant)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
* &#039;&#039;&#039;pattern&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): pattern with % and _ in them&lt;br /&gt;
* &#039;&#039;&#039;collation&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): collation in which to compare them&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== toLower ==&lt;br /&gt;
&lt;br /&gt;
turns a string into lower case&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== toUpper ==&lt;br /&gt;
&lt;br /&gt;
turns a string into upper case&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== replace ==&lt;br /&gt;
&lt;br /&gt;
replaces all occurances in a string with another string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;s&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
* &#039;&#039;&#039;find&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): search string&lt;br /&gt;
* &#039;&#039;&#039;replace&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): replace string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== split ==&lt;br /&gt;
&lt;br /&gt;
splits a string using a separator or space&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
* &#039;&#039;&#039;separator&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): (optional) parameter, defaults to &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== collate ==&lt;br /&gt;
&lt;br /&gt;
returns the &amp;lt;code&amp;gt;&amp;lt;&amp;lt;/code&amp;gt; operator for a given collation. MemCP allows natural sorting of numeric literals.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;collation&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): collation string of the form LANG or LANG_cs or LANG_ci where LANG is a BCP 47 code, for compatibility to MySQL, a CHARSET_ prefix is allowed and ignored as well as the aliases bin, danish, general, german1, german2, spanish and swedish are allowed for language codes&lt;br /&gt;
* &#039;&#039;&#039;reverse&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): whether to reverse the order like in ORDER BY DESC&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== htmlentities ==&lt;br /&gt;
&lt;br /&gt;
escapes the string for use in HTML&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): input string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== urlencode ==&lt;br /&gt;
&lt;br /&gt;
encodes a string according to URI coding schema&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to encode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== urldecode ==&lt;br /&gt;
&lt;br /&gt;
decodes a string according to URI coding schema&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to decode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== json_encode ==&lt;br /&gt;
&lt;br /&gt;
encodes a value in JSON, treats lists as lists&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to encode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== json_encode_assoc ==&lt;br /&gt;
&lt;br /&gt;
encodes a value in JSON, treats lists as associative arrays&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to encode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== json_decode ==&lt;br /&gt;
&lt;br /&gt;
parses JSON into a map&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to decode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== sql_unescape ==&lt;br /&gt;
&lt;br /&gt;
unescapes the inner part of a sql string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to decode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== bin2hex ==&lt;br /&gt;
&lt;br /&gt;
turns binary data into hex with lowercase letters&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string to decode&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Arithmetic_/_Logic&amp;diff=221</id>
		<title>Arithmetic / Logic</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Arithmetic_/_Logic&amp;diff=221"/>
		<updated>2025-08-25T16:30:00Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;= Arithmetic / Logic =  The &amp;#039;&amp;#039;&amp;#039;Arithmetic / Logic&amp;#039;&amp;#039;&amp;#039; module provides essential mathematical operations and logical comparisons for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Type checking&amp;#039;&amp;#039;&amp;#039;: Functions to verify data types (int?, number?, nil?) * &amp;#039;&amp;#039;&amp;#039;Basic arithmetic&amp;#039;&amp;#039;&amp;#039;: Addition (+), subtraction (-), multiplication (*), and division (/) * &amp;#039;&amp;#039;&amp;#039;Comparison operations&amp;#039;&amp;#039;&amp;#039;: All standard comparison operators (&amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, equal?) * &amp;#039;&amp;#039;&amp;#039;Logical operations&amp;#039;&amp;#039;&amp;#039;: Boole...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Arithmetic / Logic =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Arithmetic / Logic&#039;&#039;&#039; module provides essential mathematical operations and logical comparisons for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Type checking&#039;&#039;&#039;: Functions to verify data types (int?, number?, nil?)&lt;br /&gt;
* &#039;&#039;&#039;Basic arithmetic&#039;&#039;&#039;: Addition (+), subtraction (-), multiplication (*), and division (/)&lt;br /&gt;
* &#039;&#039;&#039;Comparison operations&#039;&#039;&#039;: All standard comparison operators (&amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, equal?)&lt;br /&gt;
* &#039;&#039;&#039;Logical operations&#039;&#039;&#039;: Boolean negation (!, not) and advanced equality checks&lt;br /&gt;
* &#039;&#039;&#039;Mathematical functions&#039;&#039;&#039;: Min/max operations and rounding functions (floor, ceil, round)&lt;br /&gt;
&lt;br /&gt;
These functions form the mathematical foundation for calculations and logical decision-making in SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== int? ==&lt;br /&gt;
&lt;br /&gt;
tells if the value is a integer&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== number? ==&lt;br /&gt;
&lt;br /&gt;
tells if the value is a number&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== + ==&lt;br /&gt;
&lt;br /&gt;
adds two or more numbers&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): values to add&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== - ==&lt;br /&gt;
&lt;br /&gt;
subtracts two or more numbers from the first one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== * ==&lt;br /&gt;
&lt;br /&gt;
multiplies two or more numbers&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== / ==&lt;br /&gt;
&lt;br /&gt;
divides two or more numbers from the first one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;= ==&lt;br /&gt;
&lt;br /&gt;
compares two numbers or strings&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;lt; ==&lt;br /&gt;
&lt;br /&gt;
compares two numbers or strings&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
compares two numbers or strings&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== &amp;gt;= ==&lt;br /&gt;
&lt;br /&gt;
compares two numbers or strings&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== equal? ==&lt;br /&gt;
&lt;br /&gt;
compares two values of the same type, (equal? nil nil) is true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== equal?? ==&lt;br /&gt;
&lt;br /&gt;
performs a SQL compliant sloppy equality check on primitive values (number, int, string, bool. nil), strings are compared case insensitive, (equal? nil nil) is nil&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): values&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ! ==&lt;br /&gt;
&lt;br /&gt;
negates the boolean value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== not ==&lt;br /&gt;
&lt;br /&gt;
negates the boolean value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== nil? ==&lt;br /&gt;
&lt;br /&gt;
returns true if value is nil&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== min ==&lt;br /&gt;
&lt;br /&gt;
returns the smallest value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number|string&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number|string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== max ==&lt;br /&gt;
&lt;br /&gt;
returns the highest value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;number|string&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number|string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== floor ==&lt;br /&gt;
&lt;br /&gt;
rounds the number down&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ceil ==&lt;br /&gt;
&lt;br /&gt;
rounds the number up&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== round ==&lt;br /&gt;
&lt;br /&gt;
rounds the number&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=220</id>
		<title>SCM Builtins</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=220"/>
		<updated>2025-08-25T16:27:51Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= SCM Builtins =&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;SCM Builtins&#039;&#039;&#039; module provides the core foundational functions for the SCM (Scheme) programming language implementation. These built-in functions handle essential operations including:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Language constructs&#039;&#039;&#039;: Control flow (if, and, or), variable management (define, set), and code evaluation (eval, quote)&lt;br /&gt;
* &#039;&#039;&#039;Function operations&#039;&#039;&#039;: Lambda creation, function application, and error handling (try, error)&lt;br /&gt;
* &#039;&#039;&#039;Data manipulation&#039;&#039;&#039;: Type conversion (string, symbol), list operations, and pattern matching&lt;br /&gt;
* &#039;&#039;&#039;Development tools&#039;&#039;&#039;: Code optimization, timing measurements, and debugging support&lt;br /&gt;
* &#039;&#039;&#039;Execution control&#039;&#039;&#039;: Parallel processing, variable scoping, and source code annotation&lt;br /&gt;
&lt;br /&gt;
This module forms the foundation upon which all other SCM functionality is built, providing the essential primitives needed for Scheme programming.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== quote ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol or list without evaluating it&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;symbol&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): symbol to quote&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== eval ==&lt;br /&gt;
&lt;br /&gt;
executes the given scheme program in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== size ==&lt;br /&gt;
&lt;br /&gt;
compute the memory size of a value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== optimize ==&lt;br /&gt;
&lt;br /&gt;
optimize the given scheme program&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== time ==&lt;br /&gt;
&lt;br /&gt;
measures the time it takes to compute the first argument&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): code to execute&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): label to print in the log or trace&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== if ==&lt;br /&gt;
&lt;br /&gt;
checks a condition and then conditionally evaluates code branches; there might be multiple condition+true-branch clauses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition...&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
* &#039;&#039;&#039;true-branch...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is true&lt;br /&gt;
* &#039;&#039;&#039;false-branch&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is false&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== and ==&lt;br /&gt;
&lt;br /&gt;
returns true if all conditions evaluate to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== or ==&lt;br /&gt;
&lt;br /&gt;
returns true if at least one condition evaluates to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesce ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-zero value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesceNil ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-nil value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== define ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== set ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== error ==&lt;br /&gt;
&lt;br /&gt;
halts the whole execution thread and throws an error message&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value or message to throw&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== try ==&lt;br /&gt;
&lt;br /&gt;
tries to execute a function and returns its result. In case of a failure, the error is fed to the second function and its result value will be used&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;func&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function with no parameters that will be called&lt;br /&gt;
* &#039;&#039;&#039;errorhandler&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function that takes the error as parameter&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply_assoc ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments but arguments is a assoc list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute (must be a lambda)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): assoc list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== symbol ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol built from that string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string value that will be converted into a symbol&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== list ==&lt;br /&gt;
&lt;br /&gt;
returns a list containing the parameters as alements&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value for the list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== string ==&lt;br /&gt;
&lt;br /&gt;
converts the given value into string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): any value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== match ==&lt;br /&gt;
&lt;br /&gt;
takes a value evaluates the branch that first matches the given pattern&lt;br /&gt;
&lt;br /&gt;
Patterns can be any of:&lt;br /&gt;
* symbol matches any value and stores is into a variable&lt;br /&gt;
* &amp;quot;string&amp;quot; (matches only this string)&lt;br /&gt;
* number (matches only this value)&lt;br /&gt;
* (symbol &amp;quot;something&amp;quot;) will only match the symbol &#039;something&#039;&lt;br /&gt;
* &#039;(subpattern subpattern...) matches a list with exactly these subpatterns&lt;br /&gt;
* (concat str1 str2 str3) will decompose a string into one of the following patterns: &amp;quot;prefix&amp;quot; variable, variable &amp;quot;postfix&amp;quot;, variable &amp;quot;infix&amp;quot; variable&lt;br /&gt;
* (cons a b) will reverse the cons function, so it will match the head of the list with a and the rest with b&lt;br /&gt;
* (regex &amp;quot;pattern&amp;quot; text var1 var2...) will match the given regex pattern, store the whole string into text and all capture groups into var1, var2...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to evaluate&lt;br /&gt;
* &#039;&#039;&#039;pattern...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): pattern&lt;br /&gt;
* &#039;&#039;&#039;result...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): result value when the pattern matches; this code can use the variables matched in the pattern&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): (optional) value that is returned when no pattern matches&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== lambda ==&lt;br /&gt;
&lt;br /&gt;
returns a function (func) constructed from the given code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parameters&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol|list|nil&amp;lt;/code&amp;gt;): if you provide a parameter list, you will have named parameters. If you provide a single symbol, the list of parameters will be provided in that symbol&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value that is evaluated when the lambda is called. code can use the parameters provided in the declaration as well es the scope above&lt;br /&gt;
* &#039;&#039;&#039;numvars&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of unnamed variables that can be accessed via (var 0) (var 1) etc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== begin ==&lt;br /&gt;
&lt;br /&gt;
creates a own variable scope, evaluates all sub expressions and returns the result of the last one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== parallel ==&lt;br /&gt;
&lt;br /&gt;
executes all parameters in parallel and returns nil if they are finished&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate in parallel&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== source ==&lt;br /&gt;
&lt;br /&gt;
annotates the node with filename and line information for better backtraces&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 4–4&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Filename of the code&lt;br /&gt;
* &#039;&#039;&#039;line&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Line of the code&lt;br /&gt;
* &#039;&#039;&#039;column&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Column of the code&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== scheme ==&lt;br /&gt;
&lt;br /&gt;
parses a scheme expression into a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): optional filename&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== serialize ==&lt;br /&gt;
&lt;br /&gt;
serializes a piece of code into a (hopefully) reparsable string; you shall be able to send that code over network and reparse with (scheme)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=219</id>
		<title>SCM Builtins</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=219"/>
		<updated>2025-08-25T16:24:34Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= SCM Builtins =&lt;br /&gt;
&lt;br /&gt;
== quote ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol or list without evaluating it&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;symbol&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): symbol to quote&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== eval ==&lt;br /&gt;
&lt;br /&gt;
executes the given scheme program in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== size ==&lt;br /&gt;
&lt;br /&gt;
compute the memory size of a value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== optimize ==&lt;br /&gt;
&lt;br /&gt;
optimize the given scheme program&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== time ==&lt;br /&gt;
&lt;br /&gt;
measures the time it takes to compute the first argument&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): code to execute&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): label to print in the log or trace&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== if ==&lt;br /&gt;
&lt;br /&gt;
checks a condition and then conditionally evaluates code branches; there might be multiple condition+true-branch clauses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition...&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
* &#039;&#039;&#039;true-branch...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is true&lt;br /&gt;
* &#039;&#039;&#039;false-branch&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is false&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== and ==&lt;br /&gt;
&lt;br /&gt;
returns true if all conditions evaluate to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== or ==&lt;br /&gt;
&lt;br /&gt;
returns true if at least one condition evaluates to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesce ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-zero value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesceNil ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-nil value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== define ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== set ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== error ==&lt;br /&gt;
&lt;br /&gt;
halts the whole execution thread and throws an error message&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value or message to throw&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== try ==&lt;br /&gt;
&lt;br /&gt;
tries to execute a function and returns its result. In case of a failure, the error is fed to the second function and its result value will be used&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;func&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function with no parameters that will be called&lt;br /&gt;
* &#039;&#039;&#039;errorhandler&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function that takes the error as parameter&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply_assoc ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments but arguments is a assoc list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute (must be a lambda)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): assoc list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== symbol ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol built from that string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string value that will be converted into a symbol&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== list ==&lt;br /&gt;
&lt;br /&gt;
returns a list containing the parameters as alements&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value for the list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== string ==&lt;br /&gt;
&lt;br /&gt;
converts the given value into string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): any value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== match ==&lt;br /&gt;
&lt;br /&gt;
takes a value evaluates the branch that first matches the given pattern&lt;br /&gt;
&lt;br /&gt;
Patterns can be any of:&lt;br /&gt;
* symbol matches any value and stores is into a variable&lt;br /&gt;
* &amp;quot;string&amp;quot; (matches only this string)&lt;br /&gt;
* number (matches only this value)&lt;br /&gt;
* (symbol &amp;quot;something&amp;quot;) will only match the symbol &#039;something&#039;&lt;br /&gt;
* &#039;(subpattern subpattern...) matches a list with exactly these subpatterns&lt;br /&gt;
* (concat str1 str2 str3) will decompose a string into one of the following patterns: &amp;quot;prefix&amp;quot; variable, variable &amp;quot;postfix&amp;quot;, variable &amp;quot;infix&amp;quot; variable&lt;br /&gt;
* (cons a b) will reverse the cons function, so it will match the head of the list with a and the rest with b&lt;br /&gt;
* (regex &amp;quot;pattern&amp;quot; text var1 var2...) will match the given regex pattern, store the whole string into text and all capture groups into var1, var2...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to evaluate&lt;br /&gt;
* &#039;&#039;&#039;pattern...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): pattern&lt;br /&gt;
* &#039;&#039;&#039;result...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): result value when the pattern matches; this code can use the variables matched in the pattern&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): (optional) value that is returned when no pattern matches&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== lambda ==&lt;br /&gt;
&lt;br /&gt;
returns a function (func) constructed from the given code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parameters&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol|list|nil&amp;lt;/code&amp;gt;): if you provide a parameter list, you will have named parameters. If you provide a single symbol, the list of parameters will be provided in that symbol&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value that is evaluated when the lambda is called. code can use the parameters provided in the declaration as well es the scope above&lt;br /&gt;
* &#039;&#039;&#039;numvars&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of unnamed variables that can be accessed via (var 0) (var 1) etc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== begin ==&lt;br /&gt;
&lt;br /&gt;
creates a own variable scope, evaluates all sub expressions and returns the result of the last one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== parallel ==&lt;br /&gt;
&lt;br /&gt;
executes all parameters in parallel and returns nil if they are finished&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–10000&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate in parallel&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== source ==&lt;br /&gt;
&lt;br /&gt;
annotates the node with filename and line information for better backtraces&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 4–4&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Filename of the code&lt;br /&gt;
* &#039;&#039;&#039;line&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Line of the code&lt;br /&gt;
* &#039;&#039;&#039;column&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Column of the code&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== scheme ==&lt;br /&gt;
&lt;br /&gt;
parses a scheme expression into a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): optional filename&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== serialize ==&lt;br /&gt;
&lt;br /&gt;
serializes a piece of code into a (hopefully) reparsable string; you shall be able to send that code over network and reparse with (scheme)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Parameters:&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Returns:&#039;&#039;&#039; &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=218</id>
		<title>SCM Builtins</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=218"/>
		<updated>2025-08-25T16:21:56Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= SCM Builtins =&lt;br /&gt;
&lt;br /&gt;
== quote ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol or list without evaluating it&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;symbol&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): symbol to quote&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== eval ==&lt;br /&gt;
&lt;br /&gt;
executes the given scheme program in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== size ==&lt;br /&gt;
&lt;br /&gt;
compute the memory size of a value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== optimize ==&lt;br /&gt;
&lt;br /&gt;
optimize the given scheme program&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== time ==&lt;br /&gt;
&lt;br /&gt;
measures the time it takes to compute the first argument&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): code to execute&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): label to print in the log or trace&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== if ==&lt;br /&gt;
&lt;br /&gt;
checks a condition and then conditionally evaluates code branches; there might be multiple condition+true-branch clauses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;condition...&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
* &#039;&#039;&#039;true-branch...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is true&lt;br /&gt;
* &#039;&#039;&#039;false-branch&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code to evaluate if condition is false&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== and ==&lt;br /&gt;
&lt;br /&gt;
returns true if all conditions evaluate to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== or ==&lt;br /&gt;
&lt;br /&gt;
returns true if at least one condition evaluates to true&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;condition&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesce ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-zero value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== coalesceNil ==&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-nil value&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to examine&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== define ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== set ==&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;variable&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;): variable to set&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== error ==&lt;br /&gt;
&lt;br /&gt;
halts the whole execution thread and throws an error message&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value or message to throw&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== try ==&lt;br /&gt;
&lt;br /&gt;
tries to execute a function and returns its result. In case of a failure, the error is fed to the second function and its result value will be used&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;func&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function with no parameters that will be called&lt;br /&gt;
* &#039;&#039;&#039;errorhandler&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function that takes the error as parameter&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== apply_assoc ==&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments but arguments is a assoc list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;function&#039;&#039;&#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function to execute (must be a lambda)&lt;br /&gt;
* &#039;&#039;&#039;arguments&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): assoc list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== symbol ==&lt;br /&gt;
&lt;br /&gt;
returns a symbol built from that string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): string value that will be converted into a symbol&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;symbol&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== list ==&lt;br /&gt;
&lt;br /&gt;
returns a list containing the parameters as alements&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value for the list&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== string ==&lt;br /&gt;
&lt;br /&gt;
converts the given value into string&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): any value&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== match ==&lt;br /&gt;
&lt;br /&gt;
takes a value evaluates the branch that first matches the given pattern&lt;br /&gt;
&lt;br /&gt;
Patterns can be any of:&lt;br /&gt;
* symbol matches any value and stores is into a variable&lt;br /&gt;
* &amp;quot;string&amp;quot; (matches only this string)&lt;br /&gt;
* number (matches only this value)&lt;br /&gt;
* (symbol &amp;quot;something&amp;quot;) will only match the symbol &#039;something&#039;&lt;br /&gt;
* &#039;(subpattern subpattern...) matches a list with exactly these subpatterns&lt;br /&gt;
* (concat str1 str2 str3) will decompose a string into one of the following patterns: &amp;quot;prefix&amp;quot; variable, variable &amp;quot;postfix&amp;quot;, variable &amp;quot;infix&amp;quot; variable&lt;br /&gt;
* (cons a b) will reverse the cons function, so it will match the head of the list with a and the rest with b&lt;br /&gt;
* (regex &amp;quot;pattern&amp;quot; text var1 var2...) will match the given regex pattern, store the whole string into text and all capture groups into var1, var2...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 3–10000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value to evaluate&lt;br /&gt;
* &#039;&#039;&#039;pattern...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): pattern&lt;br /&gt;
* &#039;&#039;&#039;result...&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): result value when the pattern matches; this code can use the variables matched in the pattern&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): (optional) value that is returned when no pattern matches&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== lambda ==&lt;br /&gt;
&lt;br /&gt;
returns a function (func) constructed from the given code&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 2–3&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;parameters&#039;&#039;&#039; (&amp;lt;code&amp;gt;symbol|list|nil&amp;lt;/code&amp;gt;): if you provide a parameter list, you will have named parameters. If you provide a single symbol, the list of parameters will be provided in that symbol&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): value that is evaluated when the lambda is called. code can use the parameters provided in the declaration as well es the scope above&lt;br /&gt;
* &#039;&#039;&#039;numvars&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of unnamed variables that can be accessed via (var 0) (var 1) etc.&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== begin ==&lt;br /&gt;
&lt;br /&gt;
creates a own variable scope, evaluates all sub expressions and returns the result of the last one&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 0–10000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== parallel ==&lt;br /&gt;
&lt;br /&gt;
executes all parameters in parallel and returns nil if they are finished&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–10000&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;expression...&#039;&#039;&#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): expressions to evaluate in parallel&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== source ==&lt;br /&gt;
&lt;br /&gt;
annotates the node with filename and line information for better backtraces&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 4–4&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Filename of the code&lt;br /&gt;
* &#039;&#039;&#039;line&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Line of the code&lt;br /&gt;
* &#039;&#039;&#039;column&#039;&#039;&#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): Column of the code&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;): code&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;returntype&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== scheme ==&lt;br /&gt;
&lt;br /&gt;
parses a scheme expression into a list&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–2&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
* &#039;&#039;&#039;filename&#039;&#039;&#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): optional filename&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== serialize ==&lt;br /&gt;
&lt;br /&gt;
serializes a piece of code into a (hopefully) reparsable string; you shall be able to send that code over network and reparse with (scheme)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Allowed number of parameters:&#039;&#039;&#039; 1–1&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;code&#039;&#039;&#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): Scheme code&lt;br /&gt;
&lt;br /&gt;
=== Returns ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=217</id>
		<title>SCM Builtins</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=SCM_Builtins&amp;diff=217"/>
		<updated>2025-08-25T16:16:45Z</updated>

		<summary type="html">&lt;p&gt;Aiagent: Created page with &amp;quot;# SCM Builtins  ## quote  returns a symbol or list without evaluating it  **Allowed number of parameters:** 1–1  ### Parameters  - **symbol** (`symbol`): symbol to quote  ### Returns  `symbol`  ## eval  executes the given scheme program in the current environment  **Allowed number of parameters:** 1–1  ### Parameters  - **code** (`list`): list with head and optional parameters  ### Returns  `any`  ## size  compute the memory size of a value  **Allowed number of param...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;# SCM Builtins&lt;br /&gt;
&lt;br /&gt;
## quote&lt;br /&gt;
&lt;br /&gt;
returns a symbol or list without evaluating it&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **symbol** (`symbol`): symbol to quote&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`symbol`&lt;br /&gt;
&lt;br /&gt;
## eval&lt;br /&gt;
&lt;br /&gt;
executes the given scheme program in the current environment&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **code** (`list`): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## size&lt;br /&gt;
&lt;br /&gt;
compute the memory size of a value&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`any`): value to examine&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`int`&lt;br /&gt;
&lt;br /&gt;
## optimize&lt;br /&gt;
&lt;br /&gt;
optimize the given scheme program&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **code** (`list`): list with head and optional parameters&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## time&lt;br /&gt;
&lt;br /&gt;
measures the time it takes to compute the first argument&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **code** (`any`): code to execute&lt;br /&gt;
- **label** (`string`): label to print in the log or trace&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## if&lt;br /&gt;
&lt;br /&gt;
checks a condition and then conditionally evaluates code branches; there might be multiple condition+true-branch clauses&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **condition...** (`bool`): condition to evaluate&lt;br /&gt;
- **true-branch...** (`returntype`): code to evaluate if condition is true&lt;br /&gt;
- **false-branch** (`returntype`): code to evaluate if condition is false&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`returntype`&lt;br /&gt;
&lt;br /&gt;
## and&lt;br /&gt;
&lt;br /&gt;
returns true if all conditions evaluate to true&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **condition** (`bool`): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`bool`&lt;br /&gt;
&lt;br /&gt;
## or&lt;br /&gt;
&lt;br /&gt;
returns true if at least one condition evaluates to true&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **condition** (`any`): condition to evaluate&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`bool`&lt;br /&gt;
&lt;br /&gt;
## coalesce&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-zero value&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`returntype`): value to examine&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`returntype`&lt;br /&gt;
&lt;br /&gt;
## coalesceNil&lt;br /&gt;
&lt;br /&gt;
returns the first value that has a non-nil value&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`returntype`): value to examine&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`returntype`&lt;br /&gt;
&lt;br /&gt;
## define&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **variable** (`symbol`): variable to set&lt;br /&gt;
- **value** (`returntype`): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`bool`&lt;br /&gt;
&lt;br /&gt;
## set&lt;br /&gt;
&lt;br /&gt;
defines or sets a variable in the current environment&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **variable** (`symbol`): variable to set&lt;br /&gt;
- **value** (`returntype`): value to set the variable to&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`bool`&lt;br /&gt;
&lt;br /&gt;
## error&lt;br /&gt;
&lt;br /&gt;
halts the whole execution thread and throws an error message&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value...** (`any`): value or message to throw&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`string`&lt;br /&gt;
&lt;br /&gt;
## try&lt;br /&gt;
&lt;br /&gt;
tries to execute a function and returns its result. In case of a failure, the error is fed to the second function and its result value will be used&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **func** (`func`): function with no parameters that will be called&lt;br /&gt;
- **errorhandler** (`func`): function that takes the error as parameter&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## apply&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **function** (`func`): function to execute&lt;br /&gt;
- **arguments** (`list`): list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## apply_assoc&lt;br /&gt;
&lt;br /&gt;
runs the function with its arguments but arguments is a assoc list&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **function** (`func`): function to execute (must be a lambda)&lt;br /&gt;
- **arguments** (`list`): assoc list of arguments to apply&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`symbol`&lt;br /&gt;
&lt;br /&gt;
## symbol&lt;br /&gt;
&lt;br /&gt;
returns a symbol built from that string&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`string`): string value that will be converted into a symbol&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`symbol`&lt;br /&gt;
&lt;br /&gt;
## list&lt;br /&gt;
&lt;br /&gt;
returns a list containing the parameters as alements&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 0–10000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value...** (`any`): value for the list&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`list`&lt;br /&gt;
&lt;br /&gt;
## string&lt;br /&gt;
&lt;br /&gt;
converts the given value into string&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`any`): any value&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`string`&lt;br /&gt;
&lt;br /&gt;
## match&lt;br /&gt;
&lt;br /&gt;
takes a value evaluates the branch that first matches the given pattern&lt;br /&gt;
Patterns can be any of:&lt;br /&gt;
 - symbol matches any value and stores is into a variable&lt;br /&gt;
 - &amp;quot;string&amp;quot; (matches only this string)&lt;br /&gt;
 - number (matches only this value)&lt;br /&gt;
 - (symbol &amp;quot;something&amp;quot;) will only match the symbol &#039;something&#039;&lt;br /&gt;
 - &#039;(subpattern subpattern...) matches a list with exactly these subpatterns&lt;br /&gt;
 - (concat str1 str2 str3) will decompose a string into one of the following patterns: &amp;quot;prefix&amp;quot; variable, variable &amp;quot;postfix&amp;quot;, variable &amp;quot;infix&amp;quot; variable&lt;br /&gt;
 - (cons a b) will reverse the cons function, so it will match the head of the list with a and the rest with b&lt;br /&gt;
 - (regex &amp;quot;pattern&amp;quot; text var1 var2...) will match the given regex pattern, store the whole string into text and all capture groups into var1, var2...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 3–10000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **value** (`any`): value to evaluate&lt;br /&gt;
- **pattern...** (`any`): pattern&lt;br /&gt;
- **result...** (`returntype`): result value when the pattern matches; this code can use the variables matched in the pattern&lt;br /&gt;
- **default** (`any`): (optional) value that is returned when no pattern matches&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## lambda&lt;br /&gt;
&lt;br /&gt;
returns a function (func) constructed from the given code&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 2–3&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **parameters** (`symbol|list|nil`): if you provide a parameter list, you will have named parameters. If you provide a single symbol, the list of parameters will be provided in that symbol&lt;br /&gt;
- **code** (`any`): value that is evaluated when the lambda is called. code can use the parameters provided in the declaration as well es the scope above&lt;br /&gt;
- **numvars** (`number`): number of unnamed variables that can be accessed via (var 0) (var 1) etc.&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`func`&lt;br /&gt;
&lt;br /&gt;
## begin&lt;br /&gt;
&lt;br /&gt;
creates a own variable scope, evaluates all sub expressions and returns the result of the last one&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 0–10000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **expression...** (`any`): expressions to evaluate&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## parallel&lt;br /&gt;
&lt;br /&gt;
executes all parameters in parallel and returns nil if they are finished&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–10000&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **expression...** (`any`): expressions to evaluate in parallel&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## source&lt;br /&gt;
&lt;br /&gt;
annotates the node with filename and line information for better backtraces&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 4–4&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **filename** (`string`): Filename of the code&lt;br /&gt;
- **line** (`number`): Line of the code&lt;br /&gt;
- **column** (`number`): Column of the code&lt;br /&gt;
- **code** (`returntype`): code&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`returntype`&lt;br /&gt;
&lt;br /&gt;
## scheme&lt;br /&gt;
&lt;br /&gt;
parses a scheme expression into a list&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–2&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **code** (`string`): Scheme code&lt;br /&gt;
- **filename** (`string`): optional filename&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`any`&lt;br /&gt;
&lt;br /&gt;
## serialize&lt;br /&gt;
&lt;br /&gt;
serializes a piece of code into a (hopefully) reparsable string; you shall be able to send that code over network and reparse with (scheme)&lt;br /&gt;
&lt;br /&gt;
**Allowed number of parameters:** 1–1&lt;br /&gt;
&lt;br /&gt;
### Parameters&lt;br /&gt;
&lt;br /&gt;
- **code** (`list`): Scheme code&lt;br /&gt;
&lt;br /&gt;
### Returns&lt;br /&gt;
&lt;br /&gt;
`string`&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
</feed>