Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ The pre-defined procedures ~min~ and ~max~ each take two arguments and return th

Implement ~deepSum~, where given an instance of ~Nested~, defined below, an arbitrarily nested list of numbers, ~deepSum~ the sum of all the numbers. That is, your input list may have sublists, which may themselves have sublists and so on.
#+BEGIN_SRC haskell
data Nested a = Value a | List [NestedList a]
data NestedList a = Value a | List [NestedList a]
#+END_SRC

Which can be instantiated as follows:
#+BEGIN_SRC haskell
-- while x is of the type NestedList, we never directly instantiate a NestedList
-- Instead, instantiate the types Value or List
x = (List [Value 3, List [Value 2, Value 3], Value 4])
#+END_SRC

Implement deepsum on an instance of Nested instead of arbitrarily nested lists.
Implement ~deepsum~ on an instance of ~NestedList~ instead of arbitrarily nested lists.
a. Haskell has stricter type requirements than Scheme did. What would be true of nested arrays in Haskell?
b. Implement the function
* Question 2 - Prime numbers
Expand Down