For this assignment, you will be writing a Seq based on a doubly-linked list with a sentental. The methods are the same as the array-based Seq. I've included samples here for your convenience.
map
(5, 8, 2, 5).map(i -> i*2) ====> (10, 16, 4, 10)
("hi", "there", "student").map(s -> s.length()) ====> (2, 5, 7)
filter
(2, 9, 3, 8, 1, 4, 3).filter(i -> i % 2 == 0) ====> (2, 8, 4)
("hi", "there", "my", "student").filter(s -> s.length() < 3) ====> ("hi", "my")
takeWhile
(3, 4, 2, 7, 5, 9, 1).takeWhile(i -> i < 6) ====> (3, 4, 2)
dropWhile
(3, 4, 2, 7, 5, 9, 1).dropWhile(i -> i < 6) ====> (7, 5, 9, 1)
find
(3, 4, 2, 7, 5, 9, 1).find(i -> i * 2 > 10) ====> Optional.of(7)
(3, 4, 2, 7, 5, 9, 1).find(i -> i * 2 > 100) ====> Optional.empty
foldLeft
(3, 4, 2, 7, 5, 9, 1).foldLeft(0, (sum, i) -> sum + i) ====> 31
(3, 4, 2, 7, 5, 9, 1).foldLeft("", (str, i) -> str + i) ====> "3427591"
(3, 4, 2, 7, 5, 9, 1).foldLeft(0, (diff, i) -> diff - i) ====> -31
foldRight
(3, 4, 2, 7, 5, 9, 1).foldRight((sum, i) -> sum + i, 0) ====> 31
(3, 4, 2, 7, 5, 9, 1).foldRight((str, i) -> str + i, "") ====> "3427591"
(3, 4, 2, 7, 5, 9, 1).foldRight((diff, i) -> diff - i, 0) ====> -9
mapped
Same as map for the any function that doesn't change the type, but in the same sequence and not a few on.
filtered
Same as filtered for the any function that doesn't change the type, but in the same sequence and not a few on.
keepWhile
Same as takeWhile for the any function that doesn't change the type, but in the same sequence and not a few on.
removeWhile
Same as dropWhile for the any function that doesn't change the type, but in the same sequence and not a few on.
Test Rubric:
Basic tests of all methods (13 points)
Large tests (1000+ items) (5 points)
Tests with multiple types (2 points)