Starting from:

$34.99

CS2030S Lab 8: Infinite List Solution


Prerequisite
• Caught up to Unit 34 of Lecture Notes
• Completed Lab 7
Important Concepts Tested
• Memo: Compute only when needed & do not repeat yourself
• Actually: Possibly error handled by container
• PECS: Make your method signature as flexible as possible
• JavaDoc: Documenting your code and generating the documentation
Files
A skeleton for InfiniteList<T> is provided for you. Copy the following implementations over before you start with Lab 7:
fp .Action fp .Immutator fp .Constant
fp . Combiner
fp . Actionable
fp . Immutatorable fp . Actually
fp . Memo
The files Test 1 . java , Test2.java , etc., as well as CS2Ø3ØSTest . java , are provided for testing. You can edit them to add your test cases, but they will not be submitted.
Infinite List
You have seen in class a poorly implemented version of InfiniteList . Recall that there are two issues:
1. It uses null to represent a missing value.
• This design prevents us from having null as elements in the list.
2. Produced values are not memoized.
• This desigÄ1 results in repeated computation of the same value.
You are already given a (badly written but still correct) implementation of which will solve problem (1), and Memo<T> which will solve problem (2). We will use them to build a better version of InfiniteList here.
public class InfiniteList<T> {
2 private Memo<Actua11Y<T>> head; 3 private Memo<InfiniteList<T>> tail ;
4
IMPORTANTU
Take note of the following constraints. Not following these constraints will result in immediate 0 for your lab.
• You are NOT allowed to add other instance fields.
• You are NOT allowed to use any raw types.
• You are NOT allowed to use java . util . stream . Stream to solve this lab.
• You are NOT allowed to use unwrap from Actually .
Additionally, you must follow the following constraints or heavy penalty will be given.
• @SuppressWarnings must be used responsibly.
• Where possible, use the methods provided by ActuallY<T> to handle the conditions where the value is there or not there, instead of using if-else or try-catch .
The Basics
Write the static generate and iterate methods that create an InfiniteList . This is different from generate in MemoList in Lab 7 but this is similar to generate introduced in the lecture on Infinite List.
To access the elements of the list, provide the head and tail method that produces the head and tail of the infinite list. Recap the problem in the lecture about head() and tail() in relation to filter method. You should follow the idea presented in the lecture to avoid modifying head() and tail( ) later on.
To help with debugging, a toString method has been provided for you.
jshell> import cs2Ø3es .fp. InfiniteList ;
2 jshell> import cs2û3ûs .fp. Immutator;
3
4 jshell> import cs2Ø3Øs .fp.Constant ;
5 jshell> Infinitel-ist<lnteger> one InfiniteList .
6 one
7 jshell> one. head( )
8
9 jshell> one
19 one
1 1 jshell> one. tail( ) . head( )
12
13 jshell> one
14 one
15
16 jshell> Infinitel-ist<lnteger> nul = Infinitel-ist .generate( ( ) null)

1 8 jshell> nul. head( )
19 null
29 jshell> nul

21 nul [<null> ? ]
22 jshell> nul . tail ( ) . head( )
23 null
24 jshell> nul
25
26 nul [<null> [<null> ? ] ]
27 jshell> InfiniteList<String> str InfiniteList . iterate( "A
28 str
29 jshell> str .tail( ) . head( )
39 " AR

31 jshell> str
32 str
33 jshell> str .tail( ) . tail( ) . tail( ) . head( )
" ARRR
35 jshell> str
36 str
37
38 jshell> Immutator<lnteger, Integer> incr
39 System . out . println( l return x + 1
41
42 jshell> Infinitel-ist<lnteger> nat Infinitel-ist . iterate(l , incr)
43 nat
44
45 jshell> nat . head( )
46
47 jshell> nat

49
59 jshell> nat . tail ( ) . head( )
51 - 2
52 $21 2
53 jshell> nat
54 nat
55
56 jshell> nat . tail ( ) . head( )
2
58 jshell> nat
59 nat = = > [ < ? ] ]
69
61 jshell> nat . tail ( ) . tail( ) . head( )
62- 3
633
64 jshell> nat
65 nat
66
67 jshell> nat . tail ( ) . head( )
68 2
69 jshell> nat
79 nat
71
72 jshell> Constant<lnteger> zero
73 System . out . print
74 return e ;
75
76 jshell> Infinitel-ist<lnteger> zeroes - InfiniteList .generate(zero)
77 zeroes
78
79 jshell> zeroes . head( )
89
81
82 jshell> zeroes 83 zeroes
84
85 jshell> zeroes . tail( ) . head( )
86
88 jshell> zeroes 89 zeroes
91 jshell> zeroes . head( )
92
93 jshell> zeroes
94 zeroes
95
96 jshell> zeroes . tail( ) . head( )

98 jshell> zeroes 99 zeroes lee 181 jshell> zeroes . tail( ) . tail( ) . head( )
192
183
184 jshell> zeroes
195 zeroes
196
197 jshell> zeroes . tail( ) . head( )
198
189 jshell> zeroes
119 zeroes
You can test your code by running the Test 1 . java provided. The following should compile without errors or warnings. Make sure your code follows the CS2030S Java style and can generate the documentation without error.
$ javac -Xlint : rawtypes cs2û3ûs/fp/*java
2 $ javac -Xlint : rawtypes Test 1 . java
3 $ java Test 1
4 $ java -jar -a cs2Ø3es/bin/checksty1e. jar -c cs2939s/fp
5 / InfiniteList . java
$ javadoc -quiet -private -d docs cs2û3gs/fp/InfiniteList . java
map
Now let's add the map method. The map method (lazily) applies the given Immutator to each element in the list and returns the resulting InfiniteList .
tail

list
map(tail)
j shell> import cs293es.fp .InfiniteList
2 j shell> import cs2939s.fp . Immutator
3
4 j shell> import cs2939s.fp . Constant
5 j shell> InfiniteList<Integer> nat - InfiniteList . iterate(l ,
6 nat
7 l ) .map(x
8
9
19
11 l ) .map(x -> x * 2) . tail( ) . head( )
12
13
14
15
16
171 ) . head( )
18
19 j shell> nat .map (x 2) . map(x 1 ) . tail( ) . head( )
29 3
21 j shell> nat .map (x X 0/0 2 e ? null
22 null
23
24 j shell> Constant<lnteger> one
25 System . out . print
26
27 return 1 ;
28 j shell> Immutator<lnteger, Integer> dbl 29 System . out . print
38 return x + x;
31
32
33 j shell> InfiniteList . generate(one) .map(dbl) . tail( ) . head( )
34
35
36
37
38
39
49 jshell> InfiniteList<Integer> ones InfiniteList . generate (one)
41 ones
42 jshell> InfiniteList<Integer> twos - ones.map(dbl)
43 twos
44
45 jshell> twos. tail( ) . head( )
46
47
48
49
59
51 jshell> ones
52 ones
53 j shell> twos
54 twos
55
56 jshell> twos. head( )
57
58 jshell> twos. tail( ) . head( )
59
You can test your code by running the Test2. java provided. The following should compile without errors or warnings. Make sure your code follows the CS2030S Java style and can generate the documentation without error.
$ javac -Xlint : rawtypes cs2939s/fp/*java
2 $ javac -X lint : rawtypes Test2 . java
3 $ java Test2
4 $ java -jar N cs2Ø3es/bin/checksty1e. jar -c •vcs293es/bin/cs293e_checks.xm1 cs2939s/fp 5 / InfiniteList . java
$ javadoc -quiet -private -d docs cs293es/fp/InfiniteList . java
filter
Add the filter method to filter out elements in the list that fail a given Immutator<B001ean, T> (note: make the type flexible following PECS). filter should mark any filtered (i.e., removed or missing) element as Actually. err() instead of null . The resulting (lazily) filtered InfiniteList is returned.
tail

list
ao filter(tail)
Lastly, for this lab, modify such that Failure class simply returns <> on toString . This has been done in our implementation of Actually (there is no Failure class but we print <> on our equivalent concept offailure) but if you are using your own implementation, you need to modify this.
jshell> import cs2Ø3Øs.fp. Immutator
2 jshell> import cs2û3ûs .fp. InfiniteList
3
4 jshell> Infinitel-ist<lnteger> nat InfiniteList . iterate(l
5 nat
6 jshell> InfiniteList . generate( ( ) 1 ) . filte r (x -> x % 2 -
7
8 jshell> nat .filter(x 9)
9
19 jshell> nat .filter(x 9) . head( )
1 1 2
12 jshell> nat . filte r ( x 9) . filter (x -> x > 4) . head( )
1 3 6
14
1 5 jshell> Immutator<lnteger, Integer> incr
16 System . out . print In( return x + 1
1 8
19 jshell> Immutator<B001ean, Integer> isEven
System . out . print
21 return x % 2
22
23
24 jshell> InfiniteList . iterate(l incr) . filter(isEven) . tail( ) . head( )
25 1 0/0 2 - 1
26 1 - 2
27
28 2 - 3
29 1
39
31
32
33 jshell> Infinitel-ist<lnteger> nums Infinitel-ist . iterate(l , x
35 nums
36 jshell> Infinitel-ist<lnteger> evens nums .filter(x -> x % 2 - e)
37
38
39 jshell> evens. tail( ) . head( )

41 jshell> nums
42 nums
43 jshell> evens // modify Failure : :toString for this
44
45
46 jshell> nums .tail( ) . head( )
47 2
jshell> evens. tail( ) . head( )
49
59 4
51 jshell> Immutator<B001ean, Integer> moreThan5 52 System . out . println( l
53
54 >
return x > 5 ;
55 jshell> Immutator<lnteger, Integer> dbl
56 System . out . print
> ret U r n x + x ;
58
59
69 jshell> InfiniteList . iterate(l incr) . filter(moreThan5) . filter(isEven) . head( )
61 1 false
62 1 1 - 2
63 2 false
64 2 1 - 3
65
66 3 3
false
67 4 false
68 4
69 5 false
79
6 true
72 6 0/0 2 -
73
74
75 jshell> Infinitel-ist . iterate(l , incr)
76 . map(dbl) . filter(moreThan5)
. filter(isEven) . tail( ) . head( )
78
79false
81
82false
83
84
85 - true
86
88
89true
92
93 jshell> Infinitel-ist . iterate(l , incr) 94 . filter(isEven) .map(dbl)
95 . filter(moreThan5) . head( )
96
97 1 0/0 2 -
98
99 2 2
0/0 2 -

lee
181 2 4
false
182
193 3 3
0/0 2 -

194
185 4 4
0/0 2 -

186 8 true
197
You can test your code by running the Test3 . java provided. The following should compile without errors or warnings. Make sure your code follows the CS2030S Java style and can generate the documentation without error.
$ javac -Xlint : rawtypes cs2939s/fp/*java
$ javac -X lint : rawtypes Test3 . java
$ java Test3
$ java -jar -a cs2Ø3Øs/bin/checksty1e.jar -c -vcs293es/bin/cs293e_checks.xm1 cs2939s/fp / InfiniteList . java
$ javadoc -quiet -private -d docs cs293es/fp/InfiniteList . java
end and isEnd
Provide a boolean isEnd method that returns true if the list is an instance of End and returns false otherwise. Note that isEnd is a lazy operation and should not trigger the evaluation of the infinite list.
Provide an end method that returns an end.
Provide a head and tail method that simply throws java . util.NoSuchE1ementException( )
1 j shell> import cs293es.fp .Immutator
2 j shell> import cs293es.fp .InfiniteList
3
4 j shell> import cs2939s.fp . Constant
5
6 j shell>
InfiniteList . iterate(1 , x false
7
8 j shell>
InfiniteList . false 2) . isEnd( )
9
19 j shell>
InfiniteList . false filter (x -> x 0/0 3 = 9) . isEnd( )
11
12 j shell>
InfiniteList . iterate(l , false + 1 ) . map(x 2) . isEnd( )
13
14
15 j shell>
InfiniteList . iterate(l , false + 1 ) . filte r ( x — > X 0/0 2 — e ) . isEnd( )
16
17 j shell>
InfiniteList . end( )
18
19 j shell>
InfiniteList . end( ) . isEnd( ) true
29
21 j shell>
InfiniteList .end( ) . map(x -> 2) . isEnd( ) true
22
23 j shell>
InfiniteList . end( ) . filter (x true) . isEnd( ) true
24 j shell> InfiniteList . end( ) . filter (x false) . isEnd( )
25 true
limit , toList
Now that we have a way to terminate an infinite list into a finite list, write a limit method that takes in a value n and truncate the InfiniteList<T> to a finite list with at most n elements. Your limit method must not count elements that are filtered out by filter , if any. Here, the type of n should be long instead of int .
jshell> import cs2Ø3Øs.fp. Immutator
2 jshell> import cs2û3es .fp. InfiniteList
3
4 jshell> import cs2Ø3Øs .fp.Constant
5 jshell> InfiniteList . end( ) . limit (4) . isEnd( )
6 true
7 jshell> Infinitel-ist<lnteger> nat - Infinitel-ist . iterate(l
8 nat
9 jshell> nat . limit(û) . isEnd( )
19 true
1 1 jshell> nat . limit(l ) . isEnd( )
12 false
1 3 jshell> nat . 1imit(19) . isEnd( )
14 false
1 5 jshell> nat . limit ( - l ) . isEnd( )
16 true
jshell> nat . 1imit(Ø) . isEnd( )
1 8 true
19 jshell>
nat . limit(l ) . isEnd( ) false
21 jshell> nat . 1imit(19) . isEnd( )
22
23 false
24 jshell> InfiniteList . generate( ( ) 1 ) . limit(4)
25
26 jshell> nat . 1imit(4)
27
28
29 jshell>
nat . limit(l ) . head( )
39
31
32 jshell>
nat . 1imit(4) . head( )
33 jshell>
T run(Constant<T> c) try {
35 return c . init( ) ;
36 } catch (Exception e) {
37 System . out . println(e) ;
38
39
49 return nu ll ;
41 jshell> Immutator<B001ean, Integer> isEven
42 jshell> Immutator<String, String> zzz
43
44 jshell> run( ( ) -> nat . limit(l ) . tail( ) . head( ) )
45 j ava . util . NoSuchE1ementException
46 $ null
47 jshell> run( ( ) -> nat . limit(e) . head( ) )
48 j ava . util . NoSuchE1ementException
49 $ null
59 jshell> run( ( ) -> nat . 1imit(4) . tail( ) . tail( ) . head( ) ) 51 52 jshell> run( ( ) -> nat . 1imit(4) . limit (1 ) . tail( ) . head( ) )
53 j ava . util . NoSuchE1ementException
54 $ null
55 jshell> run( ( ) -> nat . limit(l ) . limit (4) . tail( ) . head( ) )
56 j ava . util . NoSuchE1ementException
$ null
58
59 jshell> run( ( ) -> nat .fi1ter(isEven) . limit (9) . head( ) )
69 j ava . util . NoSuchE1ementException
61 $ null
62 jshell> run( ( ) -> nat .fi1ter(isEven) . limit (1 ) . head( ) )
63 jshell> run( ( ) -> nat . limit(l ) . filter(isEven) . head( ) )
65 java . util . NoSuchE1ementException
66 null
67 jshell> run( ( ) -> nat . 1imit(2) . filter(isEven) . head( ) )
68 2
69
79 jshell> run( ( ) -> Infinitel-ist . iterate( "A" , zzz) . limit (2) . map(s -> s . length( ) )
71 . head( ) )
72
73 jshell> run( ( ) -> Infinitel-ist . iterate( "A zzz) . limit (2) . map(s -> s . length( ) ) 74. tail( ) . head( ) )
752
76 jshell> run( ( ) -> InfiniteList . iterate( "A I
. . head( ) ) zzz) . limit (2) . map(s s . length( ) )
78 j ava . util . NoSuchE1ementException
79
89 null
81 jshell> run( ( ) InfiniteList . iterate( "A zzz) . map(s -> s . length( ) )
82
83 . limit (2) . head( ) )

84 jshell> run( ( ) InfiniteList . iterate( "A' zzz) . map(s -> s . length( ) )
85 . limit (2) . tail( ) . head( ) )
86 2
jshell> run( ( ) Infinitel-ist . iterate( "A" , zzz) . map(s -> s . length( ) )
88 . limit (2) . tail( ) . tail( ) . head( ) )
89 j ava . util . NoSuchE1ementException null
91
92 jshell> InfiniteList . .toList( )
93
94 jshell> Infinitel-ist . iterate( "A" , zzz) . map(s -> s . length( ) ) . limit (2) .toList( )

96 jshell> Infinitel-ist . iterate( "A" , zzz) . limit (2) . map(s -> s . length( ) ) .toList( )

98 jshell> nat . limit (2) . filter(isEven) .toList( )
99 [2] lee jshell> nat .fi1ter(isEven) . limit (2) .toList( ) 191
182 jshell> Infinitel-ist . iterate(û, x -> x + 1 ) . filter (x -> x > 19)
193 . map(x -> x. hashCode( ) % 39) . filte r (x -> x < 29) . limit (5) .toList( )
184 s. . [11 , 12, 13, 14, 15]
195 jshell> Random rng - new Random(l ) rng ==> java . util.Random@2b9627bc
196 jshell> InfiniteList . generate( ( ) -> rng . nextlnt( ) % 1 0 )
187 . filte r (x -> x > 19) . limit (4) .toList( )
198 [76, 95, 26, 69]
189 jshell> InfiniteList . generate( ( ) -> null) . limit (4) . limit ( 1 ) .toList( )
119 [null]
11 1 jshell> InfiniteList . generate( ( ) -> null) . limit ( 1 ) . limit (4) .toList( )
112 [null]
You can test your code by running the Test4. java provided. The following should compile without errors or warnings. Make sure your code follows the CS2030S Java style and can generate the documentation without error.
$ javac -Xlint : rawtypes cs2û3ûs/fp/*java
2 $ javac -X lint : rawtypes Test4. java
3 $ java Test4
4 $ java -jar -,cs2Ø3es/bin/checksty1e. jar -c cs2939s/fp
5 / InfiniteList . java
$ javadoc -quiet -private -d docs cs293es/fp/InfiniteList . java
takeWhi1e
Now, implement the takeWhi1e method. The method takes in an Immutator<B001ean, T> (note: make the type flexible following PECS), and truncates the list as soon as it finds an element that evaluates the condition to false.
Just like limit , the takeWhi1e method should ignore elements that have been filtered out by filte r .
jshell> import cs2Ø3Øs.fp. Immutator
2 jshell> import cs2û3Øs .fp. InfiniteList
3
4 jshell> import cs2Ø3Øs .fp.Constant
5 jshell> Immutator<lnteger, Integer> incr
6 System . out . println( l 1
7
8 >
return x + 1
9 jshell> Immutator<B001ean, Integer> less Thane 19 System . out . println( l
1 1
12 return x < e ;
13 jshell> Immutator<B001ean, Integer> lessThan2
14 System . out . println( l
15
16 return x < 2 ;
jshell> Immutator<B001ean, Integer> lessThan5 1 8 System . out . println( l
19
26 return x < 5 ;
21 jshell> Immutator<B001ean, Integer> less Than 1 e
22 System . out . println( l
23
24 return x < 19;
25 jshell> Immutator<B001ean, Integer > isEven
26 System . out . println(
27 return x % 2 28
29 jshell> < T > T run(Constant<T> c) {
39 try {
31 return c . in it ( ) •
32 } catch (Exception e) {
33 System.out .println(e) ; return nu ll ;
35
36
37
38 jshell> jshell> InfiniteList . < . takeWhi1e(1essThanØ) . isEnd( )
39 true jshell> InfiniteList . iterate(l incr) . takeWhi1e(1essThanû) . isEnd( ) 41 false 42 jshell> InfiniteList . iterate(l incr) . takeWhi1e(1essThan2) . isEnd( ) 43 false 44 jshell> InfiniteList . iterate(l incr) . takeWhi1e(1essThan5)
45 . takeWhi1e(1essThan2) . toList( )
46true
47true
1
49 2 < 5 — true
59false
51
52 jshell> Infinitel-ist . iterate(l incr) . filter(isEven)
53 . takeWhi1e(1essThan1û) .toList( )
54 0/0 2 -
55 1 - 2
56 2 0/0 2 -
2 true
58 2 - 3
59 3 0/0 2 -
69 3
61 4 0/0 2 -
62 4 true
63 4 - 5
64
65 5 5
0/0 2 -

66
68 6 6
6
0/0 2 -


true
69 7 0/0 2
79 7 - 8
71 8 0/0 2 -
72 8 true
73 8 1
74 9 0/0 2 -
75 9 1
76
77 = false
78
79
89
81 jshell> run( ( ) -> Infinitel-ist .generate( ( )
-> 2) .takeWhi1e(1essThane)) ;
82
83 jshell> run( ( ) -> Infinitel-ist . iterate(l
incr) . takeWhi1e(1essThanØ) ) ;
84 jshell> run( ( ) -> Infinitel-ist . iterate(l incr) . takeWhi1e(1essThane) . head( ) ) ;
85 false
86
j ava . util . NoSuchE1ementException $ null
88 jshell> run( ( ) -> Infinitel-ist . iterate(l incr) . takeWhi1e(1essThan2) . head( ) ) ;
89 true
91 jshell> run( ( ) -> Infinitel-ist . iterate(l incr) . takeWhi1e(1essThan2)
92. tail( ) . head( ) ) ;
93true
94
95false
96
j ava . util . NoSuchE1ementException $ null
98 jshell> run( ( ) -> Infinitel-ist . iterate(l incr) . takeWhi1e(1essThan2)
99. takeWhi1e(1essThan9) . head( ) ) ; leetrue
181 1 < = false
192 j ava . util . NoSuchE1ementException
193 $ null
194 jshell> run( ( ) -> Infinitel-ist . iterate(l , incr) .takeWhi1e(1essThanû)
195. takeWhi1e(1essThan2) . head( ) ) ;
196= false
187 j ava . util . NoSuchE1ementException
198 $ null
199 jshell> run( ( ) -> Infinitel-ist . iterate(l , incr) .takeWhi1e(1essThan5)
119. takeWhi1e(1essThan2) . tail( ) . head( ) ) ;
11 1 - true
112true
113
2 < 5 — true
11 5 false
11 6 java . util . NoSuchE1ementException
117 $ null
11 8 jshell> run( ( ) -> Infinitel-ist . iterate(l , incr) . filter(isEven)
11 9 . takeWhi1e(1essThan1Ø) . head( ) ) ;
129 1 0/0 2 - 1
121 - 2
122 2 0/0 2 -
123 2 19 - true
124
125 jshell> run( ( ) -> Infinitel-ist . iterate(l , incr) . filter(isEven)
126 . takeWhi1e(1essThan1Ø) . tail( ) . head( ) ) ;
127 0/0 2 -
128 1 - 2
129 2 0/0 2 -
13Û 2 true
131 2 1 - 3
132 3
133 3 4
134 4 0/0 2 = 9
135 4 true
136
137
138 jshell> Infinitel-ist<lnteger> list Infinitel-ist . iterate(l , incr)
139 . takeWhi1e( less Than 1 e )
149 list
141 jshell> list . tail( ) . tail( ) . head( )
142 1 < 18 - true
143
144true
145 2 + 1 - 3
146true
147
148 jshell> list . head( )
149
159 jshell> list
151 list
152 jshell> list . tail( ) . head( )
153
154 jshell> list . tail( ) . tail( ) . tail( ) . head( )
155 3 + 1
156 4 < 19 - true
157
158 jshell> list 159 list
reduce and count
Finally, we are going to implement the terminal operations: count and reduce . To imitate java . util . stream. Stream , the count method should return a long .
Note: In Java, any integral value with suffix L is treated as a long value. For instance, 123 has the type int , but 1231- has the type long .
1 j shell> import cs293es.fp .InfiniteList ;
2
3 j shell> . reduce(e, (x, y) x + Y)
4
5 j shell> Infinitel-ist . iterate(e, x -> x + 1 ) . limit (5) . reduce(e, (x, y)
6 19
7 j shell> Infinitel-ist . iterate(e, x -> x + 1 ) . limit (e) . reduce(e, (x, y)
8
9 j shell> Infinitel-ist . iterate(l , x -> x + 1 ) . map(x -> x * x)
19 . limit (5) . reduce(l ,
11 14499
12
13 j shell> InfiniteList . <lnteger>end( ) . count( )
14
15 j shell> InfiniteList . iterate(e, x -> x + 1 ) . limit (e) . count( )
16
17 j shell> InfiniteList . iterate(e, x -> x + 1 ) . limit(l ) .count( )
18
19
29 j shell> InfiniteList . iterate(Ø, x -> x + 1 ) . filte r (x -> x % 2 - 1)
21 . limit (19) . count( )
22 19
23 j shell> InfiniteList . iterate(e, x x + 1 ) . limit ( 1 9)
24 . filter (x 1 ) . count( )
25 5
26 j shell> InfiniteList . iterate(Ø, x -> x + 1 ) .takeWhi1e(x x < 19)
27 . count( )
28 19
29 j shell> InfiniteList . iterate(û, x x + 1 ) .takeWhi1e(x
39 . filter (x 9) . count( )
31 5

You can test your code by running the Test6 . java provided. The following should compile without errors or warnings. Make sure your code follows the CS2030S Java style and can generate the documentation without error.
$ javac -X lint : rawtypes cs2939s/fp/*java
2 $ javac -Xlint : rawtypes Test6 . java
3 $ java Test6
4 $ java -jar cs2939s/fp
5 / InfiniteList . java
$ javadoc -quiet -private -d docs InfiniteList . java
Following CS2030S Style Guide
You should make sure that your code follows the given Java style guide.
Grading
This lab is worth 24 marks and contributes 6% to your final grade. The marking scheme is as follows:
• Documentation: 2 marks
• Everything Else: 22 marks
We will deduct 1 mark for each unnecessary use of @SuppressWarnings and each raw type.
@SuppressWarnings should be used appropriately and not abused to remove compilation warnings.
Note that general style marks are no longer awarded will only be awarded for documentation. You should know how to follow the prescribed Java style by now. We will still deduct up to 2 marks if there are serious violations of styles. In other words, if you have no documentation and serious violation of styles, you will get deducted 4 marks.
Submission
Similar to Lab 7, submit the files inside the directory cs2030s/fp along with the other file without the need for folder. Your cs2030s/fp should only contain the following files:
Action . java
Actionable . java
Actually . java
Combiner . java
Constant . java
Immutator . java
Immutatorable . java
Memo . java
InfiniteList . java
Additionally, you must submit the file Lab8.h and Lab8 . java . Otherwise, you CodeCrunch submission will not run.

More products