Difference between revisions of "ImmutableList Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
=Code To Implement=
 
=Code To Implement=
 +
==Utilities==
 
{{JavaToImplement|DefaultImmutableList|constructors<br/>head<br/>tail<br/>isEmpty<br/>|immutable.list.assignment}}
 
{{JavaToImplement|DefaultImmutableList|constructors<br/>head<br/>tail<br/>isEmpty<br/>|immutable.list.assignment}}
 
class DefaultImmutableList implements [https://www.cse.wustl.edu/~cosgroved/courses/cse425s/spring20/apidocs/immutable/list/core/ImmutableList.html ImmutableList<E>]
 
class DefaultImmutableList implements [https://www.cse.wustl.edu/~cosgroved/courses/cse425s/spring20/apidocs/immutable/list/core/ImmutableList.html ImmutableList<E>]
Line 9: Line 10:
 
{{JavaToImplement|Lists|nil<br/>cons<br/>brackets<br/>|immutable.list.assignment}}
 
{{JavaToImplement|Lists|nil<br/>cons<br/>brackets<br/>|immutable.list.assignment}}
  
==Length==
+
==Apps==
 +
===Length===
 
{{JavaToImplement|Length|length|immutable.list.apps.assignment}}
 
{{JavaToImplement|Length|length|immutable.list.apps.assignment}}
  
 
<nowiki>public static <E> int length(ImmutableList<E> list)</nowiki>
 
<nowiki>public static <E> int length(ImmutableList<E> list)</nowiki>
  
==SumProductCountdownFactorial==
+
===SumProductCountdownFactorial===
 
{{JavaToImplement|SumProductCountdownFactorial|sum<br/>product<br/>countdown<br/>factorial|immutable.list.apps.assignment}}
 
{{JavaToImplement|SumProductCountdownFactorial|sum<br/>product<br/>countdown<br/>factorial|immutable.list.apps.assignment}}
  
===sum===
+
====sum====
 
<nowiki>public static int sum(ImmutableList<Integer> xs)</nowiki>
 
<nowiki>public static int sum(ImmutableList<Integer> xs)</nowiki>
  
===product===
+
====product====
 
<nowiki>public static int product(ImmutableList<Integer> xs)</nowiki>
 
<nowiki>public static int product(ImmutableList<Integer> xs)</nowiki>
  
===countdown===
+
====countdown====
 
<nowiki>public static ImmutableList<Integer> countdown(int n)</nowiki>
 
<nowiki>public static ImmutableList<Integer> countdown(int n)</nowiki>
  
===factorial===
+
====factorial====
 
<nowiki>public static int factorial(int n)</nowiki>
 
<nowiki>public static int factorial(int n)</nowiki>
  
==Concat==
+
===Concat===
 
{{JavaToImplement|Concat|concat|immutable.list.apps.assignment}}
 
{{JavaToImplement|Concat|concat|immutable.list.apps.assignment}}
  

Revision as of 16:51, 17 January 2020

Code To Implement

Utilities

class: DefaultImmutableList.java Java.png
methods: constructors
head
tail
isEmpty
package: immutable.list.assignment
source folder: src/main/java

class DefaultImmutableList implements ImmutableList<E>

Note: consider using java.util.Optional

Note: you need not implement iterator() now. That will be the subject of a future studio.

class: Lists.java Java.png
methods: nil
cons
brackets
package: immutable.list.assignment
source folder: src/main/java

Apps

Length

class: Length.java Java.png
methods: length
package: immutable.list.apps.assignment
source folder: src/main/java

public static <E> int length(ImmutableList<E> list)

SumProductCountdownFactorial

class: SumProductCountdownFactorial.java Java.png
methods: sum
product
countdown
factorial
package: immutable.list.apps.assignment
source folder: src/main/java

sum

public static int sum(ImmutableList<Integer> xs)

product

public static int product(ImmutableList<Integer> xs)

countdown

public static ImmutableList<Integer> countdown(int n)

factorial

public static int factorial(int n)

Concat

class: Concat.java Java.png
methods: concat
package: immutable.list.apps.assignment
source folder: src/main/java

public static <E> ImmutableList<E> concat(ImmutableList<E> xs, ImmutableList<E> ys)

Test

class: ImmutableListTestSuite.java Junit.png
package: immutable.list.assignment
source folder: src/test/java