<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse425s/index.php?action=history&amp;feed=atom&amp;title=SML_Practice_Problems_C</id>
	<title>SML Practice Problems C - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse425s/index.php?action=history&amp;feed=atom&amp;title=SML_Practice_Problems_C"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;action=history"/>
	<updated>2026-11-26T19:25:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1311&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* Code To Implement */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1311&amp;oldid=prev"/>
		<updated>2022-02-09T09:03:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code To Implement&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 09:03, 9 February 2022&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-l2&quot; &gt;Line 2:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 2:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;[https://www.coursera.org/learn/programming-languages/supplement/cVK0L/extra-practice-problems Coursera Week 3 Extra Practice Problems]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;[https://www.coursera.org/learn/programming-languages/supplement/cVK0L/extra-practice-problems Coursera Week 3 Extra Practice Problems]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;=Warming Up=&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Given that warmups are already not strictly required, it seems strange to call these optional warmups.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;It is suggested that you complete the curated warmups first and then move on to these practice problems if you want more.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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 class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Code To Implement=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Code To Implement=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;{{SMLToImplement|practice_c|compose_opt&amp;lt;br&amp;gt;do_until&amp;lt;br/&amp;gt;factorial&amp;lt;br/&amp;gt;fixed_point&amp;lt;br/&amp;gt;map2&amp;lt;br/&amp;gt;app_all&amp;lt;br/&amp;gt;partition&amp;lt;br/&amp;gt;unfold&amp;lt;br/&amp;gt;map&amp;lt;br/&amp;gt;filter&amp;lt;br/&amp;gt;foldl&amp;lt;br/&amp;gt;map_tree&amp;lt;br/&amp;gt;fold_tree&amp;lt;br/&amp;gt;filter_tree|practice_c}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;{{SMLToImplement|practice_c|compose_opt&amp;lt;br&amp;gt;do_until&amp;lt;br/&amp;gt;factorial&amp;lt;br/&amp;gt;fixed_point&amp;lt;br/&amp;gt;map2&amp;lt;br/&amp;gt;app_all&amp;lt;br/&amp;gt;partition&amp;lt;br/&amp;gt;unfold&amp;lt;br/&amp;gt;map&amp;lt;br/&amp;gt;filter&amp;lt;br/&amp;gt;foldl&amp;lt;br/&amp;gt;map_tree&amp;lt;br/&amp;gt;fold_tree&amp;lt;br/&amp;gt;filter_tree|practice_c}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1301&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* fixed_point */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1301&amp;oldid=prev"/>
		<updated>2022-02-08T06:13:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;fixed_point&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:13, 8 February 2022&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-l12&quot; &gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==fixed_point==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==fixed_point==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to write a function &amp;lt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;code&lt;/del&gt;&amp;gt;fixed_point: (''a -&amp;gt; ''a) -&amp;gt; ''a -&amp;gt; ''a&amp;lt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;code&lt;/del&gt;&amp;gt; that given a function &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; and an initial value &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; applies &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; until &amp;lt;code&amp;gt;f x = x&amp;lt;/code&amp;gt;. (Notice the use of '' to indicate equality types.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to write a function &amp;lt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;nowiki&lt;/ins&gt;&amp;gt;fixed_point: (''a -&amp;gt; ''a) -&amp;gt; ''a -&amp;gt; ''a&amp;lt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;nowiki&lt;/ins&gt;&amp;gt; that given a function &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; and an initial value &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; applies &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; until &amp;lt;code&amp;gt;f x = x&amp;lt;/code&amp;gt;. (Notice the use of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;nowiki&amp;gt;&lt;/ins&gt;''&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/nowiki&amp;gt; &lt;/ins&gt;to indicate equality types.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map2==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map2==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b&amp;lt;/code&amp;gt; that given a function that takes &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values to &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values and a pair of &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values returns the corresponding pair of &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b&amp;lt;/code&amp;gt; that given a function that takes &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values to &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values and a pair of &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values returns the corresponding pair of &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1255&amp;oldid=prev</id>
		<title>Dennis.cosgrove at 04:34, 28 January 2022</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1255&amp;oldid=prev"/>
		<updated>2022-01-28T04:34:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 04:34, 28 January 2022&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-l18&quot; &gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list&amp;lt;/code&amp;gt;, so that: &amp;lt;code&amp;gt;app_all f g x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to every element of the list &amp;lt;code&amp;gt;g x&amp;lt;/code&amp;gt; and concatenate the results into a single list. For example, for &amp;lt;code&amp;gt;fun f n = [n, 2 * n, 3 * n]&amp;lt;/code&amp;gt;, we have &amp;lt;code&amp;gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list&amp;lt;/code&amp;gt;, so that: &amp;lt;code&amp;gt;app_all f g x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to every element of the list &amp;lt;code&amp;gt;g x&amp;lt;/code&amp;gt; and concatenate the results into a single list. For example, for &amp;lt;code&amp;gt;fun f n = [n, 2 * n, 3 * n]&amp;lt;/code&amp;gt;, we have &amp;lt;code&amp;gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &amp;lt;code&amp;gt;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http&lt;/del&gt;://&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;sml-family&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;org&lt;/del&gt;/Basis/list.html#SIG:LIST.foldr:VAL List.foldr]&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &amp;lt;code&amp;gt;[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;https&lt;/ins&gt;://&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;smlfamily&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;github.io&lt;/ins&gt;/Basis/list.html#SIG:LIST.foldr:VAL List.foldr]&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1202&amp;oldid=prev</id>
		<title>Dennis.cosgrove at 06:24, 19 January 2022</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=1202&amp;oldid=prev"/>
		<updated>2022-01-19T06:24:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:24, 19 January 2022&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-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;[https://www.coursera.org/learn/programming-languages/supplement/cVK0L/extra-practice-problems Coursera Week 3 Extra Practice Problems]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;[https://www.coursera.org/learn/programming-languages/supplement/cVK0L/extra-practice-problems Coursera Week 3 Extra Practice Problems]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Code To Implement=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Code To Implement=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{SMLToImplement|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;practice3&lt;/del&gt;|compose_opt&amp;lt;br&amp;gt;do_until&amp;lt;br/&amp;gt;factorial&amp;lt;br/&amp;gt;fixed_point&amp;lt;br/&amp;gt;map2&amp;lt;br/&amp;gt;app_all&amp;lt;br/&amp;gt;partition&amp;lt;br/&amp;gt;unfold&amp;lt;br/&amp;gt;map&amp;lt;br/&amp;gt;filter&amp;lt;br/&amp;gt;foldl&amp;lt;br/&amp;gt;map_tree&amp;lt;br/&amp;gt;fold_tree&amp;lt;br/&amp;gt;filter_tree|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;practice3&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;{{SMLToImplement|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;practice_c&lt;/ins&gt;|compose_opt&amp;lt;br&amp;gt;do_until&amp;lt;br/&amp;gt;factorial&amp;lt;br/&amp;gt;fixed_point&amp;lt;br/&amp;gt;map2&amp;lt;br/&amp;gt;app_all&amp;lt;br/&amp;gt;partition&amp;lt;br/&amp;gt;unfold&amp;lt;br/&amp;gt;map&amp;lt;br/&amp;gt;filter&amp;lt;br/&amp;gt;foldl&amp;lt;br/&amp;gt;map_tree&amp;lt;br/&amp;gt;fold_tree&amp;lt;br/&amp;gt;filter_tree|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;practice_c&lt;/ins&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&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-l37&quot; &gt;Line 37:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 37:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Test=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Test=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{SMLUnitTest|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;practice3&lt;/del&gt;|&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;practice3&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;{{SMLUnitTest|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;practice_c&lt;/ins&gt;|&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;practice_c&lt;/ins&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=761&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* Code To Implement */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=761&amp;oldid=prev"/>
		<updated>2020-10-07T11:53:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code To Implement&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 11:53, 7 October 2020&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-l21&quot; &gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Write a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|partition : ('a -&amp;gt; bool) -&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'a list -&amp;gt; 'a list * 'a list|&lt;/del&gt;partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Write a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&lt;/ins&gt;&amp;gt;partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==unfold==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==unfold==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Write a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|unfold : ('a -&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;('b * 'a) option) -&amp;gt; 'a -&amp;gt; 'b list|&lt;/del&gt;unfold : (’a -&amp;gt; (’b * ’a) option) -&amp;gt; ’a -&amp;gt; ’b list that produces a list of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'b|&lt;/del&gt;’b values given a &amp;quot;seed&amp;quot; of type &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'a|&lt;/del&gt;’a and a function that given a seed produces &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|SOME|&lt;/del&gt;SOME of a pair of a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'b|&lt;/del&gt;’b value and a new seed, or &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|NONE|&lt;/del&gt;NONE if it is done seeding. For example, here is an elaborate way to count down from 5: &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|&lt;/del&gt;unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;|unfold (fn n =&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1]&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Write a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&lt;/ins&gt;&amp;gt;unfold : (’a -&amp;gt; (’b * ’a) option) -&amp;gt; ’a -&amp;gt; ’b list&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;that produces a list of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’b&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;values given a &amp;quot;seed&amp;quot; of type &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’a&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and a function that given a seed produces &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;SOME&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;of a pair of a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’b&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;value and a new seed, or &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;NONE&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;if it is done seeding. For example, here is an elaborate way to count down from 5: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&lt;/ins&gt;&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;unfold&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;foldl&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;unfold&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;foldl&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&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-l34&quot; &gt;Line 34:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 34:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map_tree, fold_tree, filter_tree==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map_tree, fold_tree, filter_tree==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Define a (polymorphic) type for binary trees where data is at internal nodes but not at leaves. Define &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|map|&lt;/del&gt;map and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|fold|&lt;/del&gt;fold functions over such trees. You can define &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|filter|&lt;/del&gt;filter as well where we interpret a &amp;quot;false&amp;quot; as meaning the entire subtree rooted at the node with data that produced false should be replaced with a leaf.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Define a (polymorphic) type for binary trees where data is at internal nodes but not at leaves. Define &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;map&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;fold&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;functions over such trees. You can define &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;filter&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;as well where we interpret a &amp;quot;false&amp;quot; as meaning the entire subtree rooted at the node with data that produced false should be replaced with a leaf.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Test=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;=Test=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;{{SMLUnitTest|practice3|practice3}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;{{SMLUnitTest|practice3|practice3}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=760&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* Code To Implement */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=760&amp;oldid=prev"/>
		<updated>2020-10-07T11:50:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code To Implement&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 11:50, 7 October 2020&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-l25&quot; &gt;Line 25:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|unfold : ('a -&amp;gt; ('b * 'a) option) -&amp;gt; 'a -&amp;gt; 'b list|unfold : (’a -&amp;gt; (’b * ’a) option) -&amp;gt; ’a -&amp;gt; ’b list that produces a list of \verb|'b|’b values given a &amp;quot;seed&amp;quot; of type \verb|'a|’a and a function that given a seed produces \verb|SOME|SOME of a pair of a \verb|'b|’b value and a new seed, or \verb|NONE|NONE if it is done seeding. For example, here is an elaborate way to count down from 5: \verb|unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1]|unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|unfold : ('a -&amp;gt; ('b * 'a) option) -&amp;gt; 'a -&amp;gt; 'b list|unfold : (’a -&amp;gt; (’b * ’a) option) -&amp;gt; ’a -&amp;gt; ’b list that produces a list of \verb|'b|’b values given a &amp;quot;seed&amp;quot; of type \verb|'a|’a and a function that given a seed produces \verb|SOME|SOME of a pair of a \verb|'b|’b value and a new seed, or \verb|NONE|NONE if it is done seeding. For example, here is an elaborate way to count down from 5: \verb|unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1]|unfold (fn n =&amp;gt; if n = 0 then NONE else SOME(n, n-1)) 5 = [5, 4, 3, 2, 1].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Use &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|unfold|&lt;/del&gt;unfold and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;$\verb|&lt;/del&gt;foldl&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;|$$ &lt;/del&gt;to implement factorial.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Use &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;unfold&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;foldl&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;to implement &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;factorial&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|map|&lt;/del&gt;map using &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|List.foldr|&lt;/del&gt;List.foldr.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;map&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;using &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;List.foldr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==filter==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==filter==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|filter|&lt;/del&gt;filter using &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|List.foldr|&lt;/del&gt;List.foldr.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;filter&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;using &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;List.foldr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldl==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldl==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|foldl|&lt;/del&gt;foldl using &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|foldr|&lt;/del&gt;foldr on functions. (This is challenging.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;foldl&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;using &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;foldr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;on functions. (This is challenging.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map_tree, fold_tree, filter_tree==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map_tree, fold_tree, filter_tree==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=759&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* foldr */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=759&amp;oldid=prev"/>
		<updated>2020-10-07T11:47:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;foldr&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 11:47, 7 October 2020&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-l18&quot; &gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list&amp;lt;/code&amp;gt;, so that: &amp;lt;code&amp;gt;app_all f g x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to every element of the list &amp;lt;code&amp;gt;g x&amp;lt;/code&amp;gt; and concatenate the results into a single list. For example, for &amp;lt;code&amp;gt;fun f n = [n, 2 * n, 3 * n]&amp;lt;/code&amp;gt;, we have &amp;lt;code&amp;gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list&amp;lt;/code&amp;gt;, so that: &amp;lt;code&amp;gt;app_all f g x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; to every element of the list &amp;lt;code&amp;gt;g x&amp;lt;/code&amp;gt; and concatenate the results into a single list. For example, for &amp;lt;code&amp;gt;fun f n = [n, 2 * n, 3 * n]&amp;lt;/code&amp;gt;, we have &amp;lt;code&amp;gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &amp;lt;code&amp;gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;List.foldr&amp;lt;/code&amp;gt; (see &lt;/del&gt;[http://sml-family.org/Basis/list.html#SIG:LIST.foldr:VAL List.foldr]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;).&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &amp;lt;code&amp;gt;[http://sml-family.org/Basis/list.html#SIG:LIST.foldr:VAL List.foldr]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|partition : ('a -&amp;gt; bool) -&amp;gt; 'a list -&amp;gt; 'a list * 'a list|partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|partition : ('a -&amp;gt; bool) -&amp;gt; 'a list -&amp;gt; 'a list * 'a list|partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=758&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* Code To Implement */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=758&amp;oldid=prev"/>
		<updated>2020-10-07T11:41:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code To Implement&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 11:41, 7 October 2020&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-l16&quot; &gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b&amp;lt;/code&amp;gt; that given a function that takes &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values to &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values and a pair of &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values returns the corresponding pair of &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b&amp;lt;/code&amp;gt; that given a function that takes &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values to &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values and a pair of &amp;lt;code&amp;gt;’a&amp;lt;/code&amp;gt; values returns the corresponding pair of &amp;lt;code&amp;gt;’b&amp;lt;/code&amp;gt; values.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==app_all==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==app_all==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Write a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|app_all : ('b -&amp;gt; 'c list) -&amp;gt; ('a -&amp;gt; 'b list) -&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'a -&amp;gt; 'c list|&lt;/del&gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list, so that: &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|app_all f g x|&lt;/del&gt;app_all f g x will apply &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|f|&lt;/del&gt;f to every element of the list &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|g x|&lt;/del&gt;g x and concatenate the results into a single list. For example, for &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|fun f n = [n, 2 * n, 3 * n]|&lt;/del&gt;fun f n = [n, 2 * n, 3 * n], we have &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]|&lt;/del&gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Write a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&lt;/ins&gt;&amp;gt;app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;, so that: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;app_all f g x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;will apply &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;f&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;to every element of the list &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;g x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and concatenate the results into a single list. For example, for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;fun f n = [n, 2 * n, 3 * n]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;, we have &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==foldr==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Implement &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|List.foldr|&lt;/del&gt;List.foldr (see http://sml-family.org/Basis/list.html#SIG:LIST.foldr:VAL).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Implement &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;List.foldr&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;(see &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;http://sml-family.org/Basis/list.html#SIG:LIST.foldr:VAL &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;List.foldr]&lt;/ins&gt;).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==partition==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|partition : ('a -&amp;gt; bool) -&amp;gt; 'a list -&amp;gt; 'a list * 'a list|partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|partition : ('a -&amp;gt; bool) -&amp;gt; 'a list -&amp;gt; 'a list * 'a list|partition : (’a -&amp;gt; bool) -&amp;gt; ’a list -&amp;gt; ’a list * ’a list where the first part of the result contains the second argument elements for which the first element evaluates to true and the second part of the result contains the other second argument elements. Traverse the second argument only once.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=757&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* Code To Implement */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=757&amp;oldid=prev"/>
		<updated>2020-10-06T02:03:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code To Implement&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 02:03, 6 October 2020&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-l7&quot; &gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;compose_opt : (’b -&amp;gt; ’c option) -&amp;gt; (’a -&amp;gt; ’b option) -&amp;gt; ’a -&amp;gt; ’c option&amp;lt;/code&amp;gt; that composes two functions with &amp;quot;optional&amp;quot; values. If either function returns &amp;lt;code&amp;gt;NONE&amp;lt;/code&amp;gt;, then the result is &amp;lt;code&amp;gt;NONE&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;compose_opt : (’b -&amp;gt; ’c option) -&amp;gt; (’a -&amp;gt; ’b option) -&amp;gt; ’a -&amp;gt; ’c option&amp;lt;/code&amp;gt; that composes two functions with &amp;quot;optional&amp;quot; values. If either function returns &amp;lt;code&amp;gt;NONE&amp;lt;/code&amp;gt;, then the result is &amp;lt;code&amp;gt;NONE&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==do_until==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==do_until==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;do_until : (’a -&amp;gt; ’a) -&amp;gt; (’a -&amp;gt; bool) -&amp;gt; ’a -&amp;gt; ’a&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;do_until f p x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f to x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; again to that result and so on until &amp;lt;code&amp;gt;p x&amp;lt;/code&amp;gt; is false. Example: &amp;lt;code&amp;gt;do_until (fn x =&amp;gt; x div 2) (fn x =&amp;gt; x mod 2 &amp;lt;&amp;gt; 1)&amp;lt;/code&amp;gt; will evaluate to a function of type &amp;lt;code&amp;gt;int-&amp;gt;int&amp;lt;/code&amp;gt; that divides its argument by &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; until it reaches an odd number. In effect, it will remove all factors of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; its argument.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;do_until : (’a -&amp;gt; ’a) -&amp;gt; (’a -&amp;gt; bool) -&amp;gt; ’a -&amp;gt; ’a&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;do_until f p x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f to x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; again to that result and so on until &amp;lt;code&amp;gt;p x&amp;lt;/code&amp;gt; is false. Example: &amp;lt;code&amp;gt;do_until (fn x =&amp;gt; x div 2) (fn x =&amp;gt; x mod 2 &amp;lt;&amp;gt; 1)&amp;lt;/code&amp;gt; will evaluate to a function of type &amp;lt;code&amp;gt;int-&amp;gt;int&amp;lt;/code&amp;gt; that divides its argument by &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; until it reaches an odd number. In effect, it will remove all factors of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; its argument.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==factorial==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Use &amp;lt;code&amp;gt;do_until&amp;lt;/code&amp;gt; to implement &amp;lt;code&amp;gt;factorial&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==fixed_point==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==fixed_point==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Use &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|do_until|&lt;/del&gt;do_until to write a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|&lt;/del&gt;fixed_point: (''a -&amp;gt; ''a) -&amp;gt; ''a -&amp;gt; ''a&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;|fixed_point: (’’a -&amp;gt; ’’a) -&amp;gt; ’’a -&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;’’a &lt;/del&gt;that given a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|f|&lt;/del&gt;f and an initial value &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|x|&lt;/del&gt;x applies &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|f|&lt;/del&gt;f to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|x|&lt;/del&gt;x until &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|f x = x|&lt;/del&gt;f x = x. (Notice the use of '' to indicate equality types.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Use &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;do_until&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;to write a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;fixed_point: (''a -&amp;gt; ''a) -&amp;gt; ''a -&amp;gt; ''a&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&lt;/ins&gt;&amp;gt; that given a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;f&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and an initial value &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;applies &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;f&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;until &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;f x = x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;. (Notice the use of '' to indicate equality types.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map2==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==map2==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Write a function &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|map2 : ('a -&lt;/del&gt;&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'b) -&amp;gt; 'a * 'a -&amp;gt; 'b * 'b|&lt;/del&gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b that given a function that takes &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'a|&lt;/del&gt;’a values to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'b|&lt;/del&gt;’b values and a pair of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'a|&lt;/del&gt;’a values returns the corresponding pair of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\verb|'b|&lt;/del&gt;’b values.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Write a function &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&lt;/ins&gt;&amp;gt;map2 : (’a -&amp;gt; ’b) -&amp;gt; ’a * ’a -&amp;gt; ’b * ’b&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;that given a function that takes &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’a&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;values to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’b&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;values and a pair of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’a&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;values returns the corresponding pair of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;’b&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;values.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==app_all==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==app_all==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|app_all : ('b -&amp;gt; 'c list) -&amp;gt; ('a -&amp;gt; 'b list) -&amp;gt; 'a -&amp;gt; 'c list|app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list, so that: \verb|app_all f g x|app_all f g x will apply \verb|f|f to every element of the list \verb|g x|g x and concatenate the results into a single list. For example, for \verb|fun f n = [n, 2 * n, 3 * n]|fun f n = [n, 2 * n, 3 * n], we have \verb|app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]|app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function \verb|app_all : ('b -&amp;gt; 'c list) -&amp;gt; ('a -&amp;gt; 'b list) -&amp;gt; 'a -&amp;gt; 'c list|app_all : (’b -&amp;gt; ’c list) -&amp;gt; (’a -&amp;gt; ’b list) -&amp;gt; ’a -&amp;gt; ’c list, so that: \verb|app_all f g x|app_all f g x will apply \verb|f|f to every element of the list \verb|g x|g x and concatenate the results into a single list. For example, for \verb|fun f n = [n, 2 * n, 3 * n]|fun f n = [n, 2 * n, 3 * n], we have \verb|app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9]|app_all f f 1 = [1, 2, 3, 2, 4, 6, 3, 6, 9].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=756&amp;oldid=prev</id>
		<title>Dennis.cosgrove: /* compose_opt */</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=SML_Practice_Problems_C&amp;diff=756&amp;oldid=prev"/>
		<updated>2020-10-06T01:58:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;compose_opt&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 01:58, 6 October 2020&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-l6&quot; &gt;Line 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==compose_opt==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Write a function &amp;lt;code&amp;gt;compose_opt : (’b -&amp;gt; ’c option) -&amp;gt; (’a -&amp;gt; ’b option) -&amp;gt; ’a -&amp;gt; ’c option&amp;lt;/code&amp;gt; that composes two functions with &amp;quot;optional&amp;quot; values. If either function returns NONE, then the result is NONE.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Write a function &amp;lt;code&amp;gt;compose_opt : (’b -&amp;gt; ’c option) -&amp;gt; (’a -&amp;gt; ’b option) -&amp;gt; ’a -&amp;gt; ’c option&amp;lt;/code&amp;gt; that composes two functions with &amp;quot;optional&amp;quot; values. If either function returns &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;NONE&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;, then the result is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;NONE&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==do_until==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;==do_until==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;do_until : (’a -&amp;gt; ’a) -&amp;gt; (’a -&amp;gt; bool) -&amp;gt; ’a -&amp;gt; ’a&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;do_until f p x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f to x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; again to that result and so on until &amp;lt;code&amp;gt;p x&amp;lt;/code&amp;gt; is false. Example: &amp;lt;code&amp;gt;do_until (fn x =&amp;gt; x div 2) (fn x =&amp;gt; x mod 2 &amp;lt;&amp;gt; 1)&amp;lt;/code&amp;gt; will evaluate to a function of type &amp;lt;code&amp;gt;int-&amp;gt;int&amp;lt;/code&amp;gt; that divides its argument by &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; until it reaches an odd number. In effect, it will remove all factors of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; its argument.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Write a function &amp;lt;code&amp;gt;do_until : (’a -&amp;gt; ’a) -&amp;gt; (’a -&amp;gt; bool) -&amp;gt; ’a -&amp;gt; ’a&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;do_until f p x&amp;lt;/code&amp;gt; will apply &amp;lt;code&amp;gt;f to x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt; again to that result and so on until &amp;lt;code&amp;gt;p x&amp;lt;/code&amp;gt; is false. Example: &amp;lt;code&amp;gt;do_until (fn x =&amp;gt; x div 2) (fn x =&amp;gt; x mod 2 &amp;lt;&amp;gt; 1)&amp;lt;/code&amp;gt; will evaluate to a function of type &amp;lt;code&amp;gt;int-&amp;gt;int&amp;lt;/code&amp;gt; that divides its argument by &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; until it reaches an odd number. In effect, it will remove all factors of &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; its argument.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dennis.cosgrove</name></author>
		
	</entry>
</feed>