Difference between revisions of "Sum Scan No Identity Element Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
(Created page with "[https://photos.app.goo.gl/Dv7sEBtmMkGndXUu8 entrance] [https://photos.app.goo.gl/HK5NRhbnxCR3B47f9 view from seats]")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://photos.app.goo.gl/Dv7sEBtmMkGndXUu8 entrance]
+
Reimplement [[Sum_Scan_Assignment|Sum Scan]] with no identity element.
[https://photos.app.goo.gl/HK5NRhbnxCR3B47f9 view from seats]
+
=Background=
 +
A clean solution to sum_scan can be achieved by leveraging sum's [https://en.wikipedia.org/wiki/Identity_element Identity element] of 0.  The coming [[Scan_Higher_Order_Function_Assignment|scan higher order function exercise]] must make do without this information. Since we often only use the identity element (if we use it at all) to apply with the value of first item in a list to get that value of the first item in the list back again, this should not be the greatest inconvenience.
 +
 
 +
=Code to Implement=
 +
{{SMLToImplement|sum_scan_pattern|sum_scan|warmup_sum_scan_no_identity_element}}
 +
 
 +
=Test=
 +
{{SMLUnitTesting|run_sum_scan_no_identity_element|warmup_sum_scan_no_identity_element}}

Latest revision as of 05:15, 21 January 2023

Reimplement Sum Scan with no identity element.

Background

A clean solution to sum_scan can be achieved by leveraging sum's Identity element of 0. The coming scan higher order function exercise must make do without this information. Since we often only use the identity element (if we use it at all) to apply with the value of first item in a list to get that value of the first item in the list back again, this should not be the greatest inconvenience.

Code to Implement

file: src/main/sml/warmup_sum_scan_no_identity_element/sum_scan_pattern.sml Smlnj-logo.png
functions: sum_scan

Test

source folder: src/test/sml/warmup_sum_scan_no_identity_element
how to run with CM.make verbosity off: sml -Ccm.verbose=false run_sum_scan_no_identity_element.sml
how to run with CM.make verbosity on: sml run_sum_scan_no_identity_element.sml

note: ensure that you have removed all printing to receive credit for any assignment.

SML Error Messages