Difference between revisions of "Sum Distances To Origin With Functions Assignment"
Jump to navigation
Jump to search
(Created page with "thumb =Background= [https://en.wikipedia.org/wiki/Pythagorean_theorem Pythagorean theorem] The distance of a point (x,y) from the origin: <math>dist...") |
|||
Line 8: | Line 8: | ||
==Basis Library== | ==Basis Library== | ||
− | |||
[https://smlfamily.github.io/Basis/math.html#SIG:MATH.sqrt:VAL Math.sqrt(x)] | [https://smlfamily.github.io/Basis/math.html#SIG:MATH.sqrt:VAL Math.sqrt(x)] | ||
Revision as of 02:20, 9 September 2022
Background
The distance of a point (x,y) from the origin:
Basis Library
Code To Implement
sum_distances_to_origin
Fall 2022 Note: if attempted without pattern matching, you may receive an unresolved flex record error:
../../../main/sml/warmup_sum_distances_to_origin/sum_distances_to_origin.sml:4.2-21.56 Error: unresolved flex record (need to know the names of ALL the fields in this context) type: {1:real, 2:real; 'Z}
this can be solved by using pattern matching or specifying the type of the parameter xys:
fun sum_distances_to_origin(xys : (real * real) list)
file: | src/main/sml/warmup_sum_distances_to_origin/sum_distances_to_origin.sml | |
functions: | sum_distances_to_origin |
fun sum_distances_to_origin(xys : (real * real) list)
Test
source folder: | src/test/sml/warmup_sum_distances_to_origin_fun |
how to run with CM.make verbosity off: | sml -Ccm.verbose=false run_sum_distances_to_origin_fun_testing.sml |
how to run with CM.make verbosity on: | sml run_sum_distances_to_origin_fun_testing.sml |
note: ensure that you have removed all printing to receive credit for any assignment.