Scan Higher Order Function Assignment

From CSE425S Wiki
Revision as of 09:00, 16 February 2022 by Dennis.cosgrove (talk | contribs) (Created page with "=Background= Previously, we have built Sum_Scan_Assignment sum_scan. This is a specific version of scan where the operation is +. We will build a higher-order function s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Background

Previously, we have built Sum_Scan_Assignment sum_scan. This is a specific version of scan where the operation is +. We will build a higher-order function scan which takes an operation to apply, as well as a list.

Code To Implement

scan

scan op+

Example [131,231,425]

For example:

scan op+ [131,231,425]

would produce:

[131, 362, 787]
xs 131 231 425
sum_scan(xs) 131 362 787

scan op*

Example [131,231,425]

For example:

scan op* [131,231,425]

would produce:

[131, 30261, 12860925]
xs 131 231 425
sum_scan(xs) 131 30261 12860925

Testing