<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.memcp.org/index.php?action=history&amp;feed=atom&amp;title=Associative_Lists_%2F_Dictionaries</id>
	<title>Associative Lists / Dictionaries - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.memcp.org/index.php?action=history&amp;feed=atom&amp;title=Associative_Lists_%2F_Dictionaries"/>
	<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Associative_Lists_/_Dictionaries&amp;action=history"/>
	<updated>2026-04-24T17:00:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>https://www.memcp.org/index.php?title=Associative_Lists_/_Dictionaries&amp;diff=226&amp;oldid=prev</id>
		<title>Aiagent: Created page with &quot;= Associative Lists / Dictionaries =  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:  * &#039;&#039;&#039;Dictionary filtering&#039;&#039;&#039;: Functions to filter dictionaries based on key-value conditions (filter_assoc) * &#039;&#039;&#039;Dictionary mapping&#039;&#039;&#039;: Transform dictionary values while preserving keys (map_assoc) * &#039;&#039;&#039;Dictionary reduction&#039;&#039;&#039;: Aggregate dictionary data into single values (reduce_asso...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Associative_Lists_/_Dictionaries&amp;diff=226&amp;oldid=prev"/>
		<updated>2025-08-25T16:48:26Z</updated>

		<summary type="html">&lt;p&gt;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;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Associative Lists / Dictionaries =&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* &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)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Dictionary mapping&amp;#039;&amp;#039;&amp;#039;: Transform dictionary values while preserving keys (map_assoc)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Dictionary reduction&amp;#039;&amp;#039;&amp;#039;: Aggregate dictionary data into single values (reduce_assoc)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Dictionary queries&amp;#039;&amp;#039;&amp;#039;: Check for key existence and extract data (has_assoc?, extract_assoc)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Dictionary modification&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be filtered&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;condition&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be mapped&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;map&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 3–3&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be reduced&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;reduce&amp;#039;&amp;#039;&amp;#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;
* &amp;#039;&amp;#039;&amp;#039;neutral&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): initial value for the accumulator&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be checked&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;key&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): key to test&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 2–2&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;): dictionary that has to be checked&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;map&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 3–4&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict&amp;#039;&amp;#039;&amp;#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;
* &amp;#039;&amp;#039;&amp;#039;key&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;): key that has to be set&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): new value to set&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;merge&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 2–3&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;dict1&amp;#039;&amp;#039;&amp;#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;
* &amp;#039;&amp;#039;&amp;#039;dict2&amp;#039;&amp;#039;&amp;#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;
* &amp;#039;&amp;#039;&amp;#039;merge&amp;#039;&amp;#039;&amp;#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;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;list&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
</feed>