Difference between revisions of "Sum Distances To Origin With Functions Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 14: Line 14:
 
{{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|sum_distances_to_origin_fun}}
 
{{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|sum_distances_to_origin_fun}}
  
[https://smlfamily.github.io/Basis/math.html#SIG:MATH.sqrt:VAL Math.sqrt(v)]
+
<syntaxhighlight lang="sml">
 
+
fun sum_distances_to_origin(xys : (real * real) list)
fun sum_distances_to_origin(xys : (real * real) list)
+
</syntaxhighlight>
  
 
=Test=
 
=Test=
 
{{SMLUnitTesting|run_sum_distances_to_origin_fun_testing|sum_distances_to_origin_fun}}
 
{{SMLUnitTesting|run_sum_distances_to_origin_fun_testing|sum_distances_to_origin_fun}}

Revision as of 22:11, 26 August 2024

Pythagorean.svg

Background

Pythagorean theorem

The distance of a point (x,y) from the origin:

Basis Library

Math.sqrt(x)

Code To Implement

sum_distances_to_origin

file: src/main/sml/sum_distances_to_origin_fun/sum_distances_to_origin.sml Smlnj-logo.png
functions: sum_distances_to_origin
fun sum_distances_to_origin(xys : (real * real) list)

Test

source folder: src/test/sml/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.

SML Error Messages