<?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=Lists_and_Objects</id>
	<title>Lists and Objects - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.memcp.org/index.php?action=history&amp;feed=atom&amp;title=Lists_and_Objects"/>
	<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Lists_and_Objects&amp;action=history"/>
	<updated>2026-04-24T12:02:39Z</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=Lists_and_Objects&amp;diff=50&amp;oldid=prev</id>
		<title>Carli at 14:32, 17 May 2024</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Lists_and_Objects&amp;diff=50&amp;oldid=prev"/>
		<updated>2024-05-17T14:32:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:32, 17 May 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l47&quot;&gt;Line 47:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  = 6&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  = 6&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As you see in &amp;lt;code&amp;gt;set_assoc&amp;lt;/code&amp;gt;, we have a pure functional approach here. Objects are not modified in-place like in languages like Java, JavaScript, Python, C++ or such, but rather we have to construct a modified copy of that value and overwrite it to the original value. The Scheme optimizer will detect if an in-place operation would be safe, too and can optimize this corner case but the language itself prioritizes safety.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As you see in &amp;lt;code&amp;gt;set_assoc&amp;lt;/code&amp;gt;, we have a pure functional approach here. Objects are not modified in-place like in languages like Java, JavaScript, Python, C++ or such, but rather we have to construct a modified copy of that value and overwrite it to the original value. The Scheme optimizer will detect if an in-place operation would be safe, too and can optimize this corner case but the language itself prioritizes safety.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Code JITing with List Literals ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;One can construct lists that themselves represent code. You need basically three primitives:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* List Literals&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Symbol Literals&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &amp;lt;code&gt;(cons list [LIST])&amp;lt;/code&gt; to insert a list literal into the code&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;All other primitive values like strings, numbers etc. will just be passed through without interpretation.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &gt; (set my_program &#039;(&#039;print &quot;Hello World&quot;))&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; = (print &quot;Hello World&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &gt; (eval my_program)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; Hello World&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key memcp_wiki-mediawiki-:diff::1.12:old-49:rev-50 --&gt;
&lt;/table&gt;</summary>
		<author><name>Carli</name></author>
	</entry>
	<entry>
		<id>https://www.memcp.org/index.php?title=Lists_and_Objects&amp;diff=49&amp;oldid=prev</id>
		<title>Carli: Created page with &quot;Lists are a powerful feature in Scheme. Lists can express both: Data and Programs.  ==List handling== The following list functions can be used:  &gt; &#039;(1 2 3) &quot;list literal&quot;  = (1 2 3)    &gt; (cons 0 &#039;(1 2 3)) &quot;prepend item to list&quot;  = (0 1 2 3)    &gt; (append &#039;(1 2 3) 4 5) &quot;append items to list&quot;  = (1 2 3 4 5)    &gt; (has? &#039;(1 2 3) 2) &quot;check if item is in list&quot;  = true    &gt; (filter &#039;(1 2 3) (lambda (x) (&lt; x 2))) &quot;filter items that are smaller than 2&quot;  = (1)    &gt; (map &#039;(1 2 3) (l...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Lists_and_Objects&amp;diff=49&amp;oldid=prev"/>
		<updated>2024-05-17T14:27:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Lists are a powerful feature in Scheme. Lists can express both: Data and Programs.  ==List handling== The following list functions can be used:  &amp;gt; &amp;#039;(1 2 3) &amp;quot;list literal&amp;quot;  = (1 2 3)    &amp;gt; (cons 0 &amp;#039;(1 2 3)) &amp;quot;prepend item to list&amp;quot;  = (0 1 2 3)    &amp;gt; (append &amp;#039;(1 2 3) 4 5) &amp;quot;append items to list&amp;quot;  = (1 2 3 4 5)    &amp;gt; (has? &amp;#039;(1 2 3) 2) &amp;quot;check if item is in list&amp;quot;  = true    &amp;gt; (filter &amp;#039;(1 2 3) (lambda (x) (&amp;lt; x 2))) &amp;quot;filter items that are smaller than 2&amp;quot;  = (1)    &amp;gt; (map &amp;#039;(1 2 3) (l...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Lists are a powerful feature in Scheme. Lists can express both: Data and Programs.&lt;br /&gt;
&lt;br /&gt;
==List handling==&lt;br /&gt;
The following list functions can be used:&lt;br /&gt;
 &amp;gt; &amp;#039;(1 2 3) &amp;quot;list literal&amp;quot;&lt;br /&gt;
 = (1 2 3)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (cons 0 &amp;#039;(1 2 3)) &amp;quot;prepend item to list&amp;quot;&lt;br /&gt;
 = (0 1 2 3)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (append &amp;#039;(1 2 3) 4 5) &amp;quot;append items to list&amp;quot;&lt;br /&gt;
 = (1 2 3 4 5)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (has? &amp;#039;(1 2 3) 2) &amp;quot;check if item is in list&amp;quot;&lt;br /&gt;
 = true&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (filter &amp;#039;(1 2 3) (lambda (x) (&amp;lt; x 2))) &amp;quot;filter items that are smaller than 2&amp;quot;&lt;br /&gt;
 = (1)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (map &amp;#039;(1 2 3) (lambda (x) (* x 2))) &amp;quot;double all numbers&amp;quot;&lt;br /&gt;
 = (2 4 6)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (reduce &amp;#039;(1 2 3) + 0) &amp;quot;build sum by starting with 0 and reducing them over (+ 0 value)&amp;quot;&lt;br /&gt;
 = 6&lt;br /&gt;
==Associative Lists (Objects)==&lt;br /&gt;
The following functions can be used:&lt;br /&gt;
 &amp;gt; (set obj &amp;#039;(&amp;quot;a&amp;quot; 1 &amp;quot;b&amp;quot; 2 &amp;quot;c&amp;quot; 3)) /* construct object from a list with alternating key-value */&lt;br /&gt;
 = (&amp;quot;a&amp;quot; 1 &amp;quot;b&amp;quot; 2 &amp;quot;c&amp;quot; 3)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (obj &amp;quot;a&amp;quot;) /* extract a value */&lt;br /&gt;
 = 1&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (set_assoc obj &amp;quot;a&amp;quot; &amp;quot;5&amp;quot;) /* construct a new object with another value */&lt;br /&gt;
 = (&amp;quot;a&amp;quot; &amp;quot;5&amp;quot; &amp;quot;b&amp;quot; 2 &amp;quot;c&amp;quot; 3)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (set obj (set_assoc obj &amp;quot;a&amp;quot; &amp;quot;5&amp;quot;)) /* modify obj */&lt;br /&gt;
 = (&amp;quot;a&amp;quot; &amp;quot;5&amp;quot; &amp;quot;b&amp;quot; 2 &amp;quot;c&amp;quot; 3)&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (filter_assoc obj (lambda (key value) (not (equal? key &amp;quot;c&amp;quot;)))) /* filter an object by a condition */&lt;br /&gt;
 = (&amp;quot;a&amp;quot; 1 &amp;quot;b&amp;quot; 2)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (map_assoc obj (lambda (key value) (* value 2))) /* double all values */&lt;br /&gt;
 = (&amp;quot;a&amp;quot; 2 &amp;quot;b&amp;quot; 4 &amp;quot;c&amp;quot; 6)&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt; (reduce_assoc obj (lambda (accumulator key value) (+ accumulator value)) 0) /* sum up all values */&lt;br /&gt;
 = 6&lt;br /&gt;
As you see in &amp;lt;code&amp;gt;set_assoc&amp;lt;/code&amp;gt;, we have a pure functional approach here. Objects are not modified in-place like in languages like Java, JavaScript, Python, C++ or such, but rather we have to construct a modified copy of that value and overwrite it to the original value. The Scheme optimizer will detect if an in-place operation would be safe, too and can optimize this corner case but the language itself prioritizes safety.&lt;/div&gt;</summary>
		<author><name>Carli</name></author>
	</entry>
</feed>