<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse425s/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Peyton.gozon</id>
	<title>CSE425S Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse425s/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Peyton.gozon"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=Special:Contributions/Peyton.gozon"/>
	<updated>2026-11-27T20:31:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=Hearts_Card_Game_Assignment&amp;diff=1762</id>
		<title>Hearts Card Game Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=Hearts_Card_Game_Assignment&amp;diff=1762"/>
		<updated>2022-09-17T18:07:16Z</updated>

		<summary type="html">&lt;p&gt;Peyton.gozon: /* total_score_of_player_list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Code To Implement=&lt;br /&gt;
{{SMLToImplement|hearts|is_card_valid&amp;lt;br/&amp;gt;are_all_cards_valid&amp;lt;br/&amp;gt;card_score&amp;lt;br/&amp;gt;total_score_of_card_list&amp;lt;br/&amp;gt;total_card_count_for_all_players&amp;lt;br/&amp;gt;is_correct_total_of_cards&amp;lt;br/&amp;gt;is_shenanigans_detected|hearts}}&lt;br /&gt;
&lt;br /&gt;
Given these type definitions:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;datatype suit = Clubs | Diamonds | Hearts | Spades&lt;br /&gt;
datatype rank = Jack | Queen | King | Ace | Num of int &lt;br /&gt;
type card = suit * rank&lt;br /&gt;
type player = card list&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==cards==&lt;br /&gt;
===is_card_valid===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;is_card_valid&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;card&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;is_card_valid&amp;lt;/code&amp;gt; should evaluate to false if the int value of the &amp;lt;code&amp;gt;Num&amp;lt;/code&amp;gt; constructor is&lt;br /&gt;
less than 2 or greater than 10. Otherwise, it should evaluate to true&lt;br /&gt;
&lt;br /&gt;
===are_all_cards_valid===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;are_all_cards_valid&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;card list&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;are_all_cards_valid&amp;lt;/code&amp;gt; should evaluate to false if any of the cards in the list are&lt;br /&gt;
invalid, and true otherwise. Note: the empty list is valid.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;are_all_cards_valid&amp;lt;/code&amp;gt; may be tail-recursive or not at your preference.&lt;br /&gt;
&lt;br /&gt;
==hearts==&lt;br /&gt;
'''NOTE: From here on you will no longer need to concern yourself with invalid cards.  We will not test your functions from here on with invalid cards.'''&lt;br /&gt;
&lt;br /&gt;
Hearts is an trick-taking card game. Further, [https://en.wikipedia.org/wiki/Hearts_(card_game) Hearts is an &amp;quot;evasion-type&amp;quot; card game]&lt;br /&gt;
where the objective is to avoid taking positive penalty point cards. The Queen of&lt;br /&gt;
Spades as well as each and every Heart are positive penalty point cards. Therefore,&lt;br /&gt;
players attempt to avoid taking those cards. The Jack of Diamonds is the one favorable card players strive to take (it is worth negative penalty points). For simplicity,&lt;br /&gt;
we will ignore a common variation which involves a player &amp;quot;shooting the moon&amp;quot; by&lt;br /&gt;
taking all of the positive penalty point cards.&lt;br /&gt;
&lt;br /&gt;
For the remainder of this assignment you will write code to calculate scores, count&lt;br /&gt;
the number of cards, as well as detect possible shenanigans of a player/players not&lt;br /&gt;
turning in all of their penalty point cards.&lt;br /&gt;
&lt;br /&gt;
Note: &amp;quot;[https://www.merriam-webster.com/dictionary/shenanigan shenanigans]&amp;quot; are devious tricks used especially for an underhand purpose.&lt;br /&gt;
&lt;br /&gt;
===card_score===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;card_score&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;card&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;card_score&amp;lt;/code&amp;gt; should evaluate to the integer point value of the card as specified below:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|The Queen of Spades&lt;br /&gt;
|13 points&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|Each Heart&lt;br /&gt;
|1 point&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|The Jack of Diamonds&lt;br /&gt;
|minus 10 points &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|All other cards&lt;br /&gt;
|0 points &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Recall: ~ is the unary minus operator in SML.&lt;br /&gt;
&lt;br /&gt;
===total_score_of_card_list===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;total_score_of_card_list&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;card list&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;total_score_of_card_list&amp;lt;/code&amp;gt; should evaluate to the sum of the scores of the cards in&lt;br /&gt;
the list. &lt;br /&gt;
&lt;br /&gt;
Note: the empty list should evaluate to 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;total_score_of_card_list&amp;lt;/code&amp;gt; may be tail-recursive or not at your preference&lt;br /&gt;
&lt;br /&gt;
===total_score_of_player_list===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;total_score_of_player_list&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;player list&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;total_score_of_player_list&amp;lt;/code&amp;gt; should evaluate to the sum of the scores of the players&lt;br /&gt;
in the list. &lt;br /&gt;
&lt;br /&gt;
Note: the empty list should evaluate to 0.&lt;br /&gt;
&lt;br /&gt;
Recall: &amp;lt;code&amp;gt;type player = card list&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===total_card_count_for_all_players===&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;total_card_count_for_all_players&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;player&lt;br /&gt;
list&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;total_card_count_for_all_players&amp;lt;/code&amp;gt; should evaluate to the total number of cards&lt;br /&gt;
of all the players in the list. &lt;br /&gt;
&lt;br /&gt;
Note: the empty list should evaluate to 0.&lt;br /&gt;
&lt;br /&gt;
This function may use the [https://smlfamily.github.io/Basis/list.html#SIG:LIST.length:VAL length] function in the [https://smlfamily.github.io/Basis/list.html List] structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Recall: many of the higher ordered functions in List are curried.&lt;br /&gt;
&lt;br /&gt;
This function must appropriately use a higher order function from the [https://smlfamily.github.io/Basis/list.html List] structure&lt;br /&gt;
&lt;br /&gt;
Tip: if you are struggling with type checking errors resulting from curried function calls, try wrapping the arguments in parentheses.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===is_correct_total_of_cards===&lt;br /&gt;
Perhaps a player neglected to turn in all of his or her cards.&lt;br /&gt;
&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;is_correct_total_of_cards&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;player list&amp;lt;/code&amp;gt; parameter. &amp;lt;code&amp;gt;is_correct_total_of_cards&amp;lt;/code&amp;gt; should return true if the total number of&lt;br /&gt;
cards of all the players in the list is 52. Otherwise, it should evaluate to false.&lt;br /&gt;
&lt;br /&gt;
Recall the equality operator in SML is a single =.&lt;br /&gt;
&lt;br /&gt;
===is_shenanigans_detected===&lt;br /&gt;
Not turning in all of one’s cards could be an honest mistake. Neglecting to turn in point cards, however??? We will declare that &amp;quot;shenanigans!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Define a function &amp;lt;code&amp;gt;is_shenanigans_detected&amp;lt;/code&amp;gt; which accepts a &amp;lt;code&amp;gt;player list&amp;lt;/code&amp;gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;is_shenanigans_detected&amp;lt;/code&amp;gt; should evaluate to true if the total points of all the&lt;br /&gt;
players in the list is not 16. Otherwise, it should evaluate to false.&lt;br /&gt;
&lt;br /&gt;
Recall the not equality operator in SML is &amp;lt;&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note: there are far more sophisticated checks we could do. We will simply check for not 16.&lt;br /&gt;
&lt;br /&gt;
=Type Summary=&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;val is_card_valid = fn : card -&amp;gt; bool&lt;br /&gt;
val are_all_cards_valid = fn : card list -&amp;gt; bool&lt;br /&gt;
val card_score = fn : card -&amp;gt; int&lt;br /&gt;
val total_score_of_card_list = fn : card list -&amp;gt; int&lt;br /&gt;
val total_score_of_player_list = fn : player list -&amp;gt; int&lt;br /&gt;
val total_card_count_for_all_players = fn : player list -&amp;gt; int&lt;br /&gt;
val is_correct_total_of_cards = fn : player list -&amp;gt; bool&lt;br /&gt;
val is_shenanigans_detected = fn : player list -&amp;gt; bool&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Test=&lt;br /&gt;
{{SMLUnitTest|hearts|hearts}}&lt;/div&gt;</summary>
		<author><name>Peyton.gozon</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=Optional_Assignment&amp;diff=1741</id>
		<title>Optional Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=Optional_Assignment&amp;diff=1741"/>
		<updated>2022-09-08T05:12:33Z</updated>

		<summary type="html">&lt;p&gt;Peyton.gozon: /* Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note this studio is '''required'''.  It helps us gain experience using [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html java.util.Optional&amp;lt;T&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
=Code To Implement=&lt;br /&gt;
==Max==&lt;br /&gt;
{{JavaToImplement|Max|max|optional.exercise}}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static Optional&amp;lt;Integer&amp;gt; maximum(ImmutableList&amp;lt;Integer&amp;gt; xs)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given a list of Integers, return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#of-T- Optional.of] the maximum value in that list if it exists, otherwise return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#empty-- Optional.empty].&lt;br /&gt;
&lt;br /&gt;
=Test=&lt;br /&gt;
&lt;br /&gt;
NOTE: in order to test this studio you must first complete the main (non-app) part of the [[ImmutableList_Assignment|ImmutableList&amp;lt;E&amp;gt; studio]].&lt;br /&gt;
&lt;br /&gt;
{{TestSuite|MaxTestSuite|optional.exercise}}&lt;/div&gt;</summary>
		<author><name>Peyton.gozon</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse425s/index.php?title=Optional_Assignment&amp;diff=1740</id>
		<title>Optional Assignment</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse425s/index.php?title=Optional_Assignment&amp;diff=1740"/>
		<updated>2022-09-08T05:11:32Z</updated>

		<summary type="html">&lt;p&gt;Peyton.gozon: /* Max */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note this studio is '''required'''.  It helps us gain experience using [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html java.util.Optional&amp;lt;T&amp;gt;].&lt;br /&gt;
&lt;br /&gt;
=Code To Implement=&lt;br /&gt;
==Max==&lt;br /&gt;
{{JavaToImplement|Max|max|optional.exercise}}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;public static Optional&amp;lt;Integer&amp;gt; maximum(ImmutableList&amp;lt;Integer&amp;gt; xs)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given a list of Integers, return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#of-T- Optional.of] the maximum value in that list if it exists, otherwise return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#empty-- Optional.empty].&lt;br /&gt;
&lt;br /&gt;
=Test=&lt;br /&gt;
&lt;br /&gt;
NOTE: in order to test this studio you must first complete the main (non-app) part of the [[ImmutableList_Assignment|ImmutableList&amp;lt;E&amp;gt; studio]].&lt;br /&gt;
&lt;br /&gt;
{{TestSuite|MaxTestSuite|optional.assignment}}&lt;/div&gt;</summary>
		<author><name>Peyton.gozon</name></author>
		
	</entry>
</feed>