Difference between revisions of "Sum Distances To Origin With Pattern Matching Compared To Java Assignment"
Jump to navigation
Jump to search
(Created page with "=Motivation= Compare implementations in Java and SML to highlight what pattern matching provides. =Code To Implement= ==Java== {{JavaToImplement|SumDistancesToOrigin|sumDista...") |
(→SML) |
||
Line 10: | Line 10: | ||
==SML== | ==SML== | ||
{{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|warmup_sum_distances_to_origin}} | {{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|warmup_sum_distances_to_origin}} | ||
+ | |||
+ | [https://smlfamily.github.io/Basis/math.html#SIG:MATH.sqrt:VAL Math.sqrt(v)] | ||
fun sum_distances_to_origin(xys) | fun sum_distances_to_origin(xys) |
Revision as of 16:28, 7 February 2022
Motivation
Compare implementations in Java and SML to highlight what pattern matching provides.
Code To Implement
Java
class: | SumDistancesToOrigin.java | ![]() |
methods: | sumDistancesToOrigin | |
package: | distance.warmup | |
source folder: | src/main/java |
public static double sumDistancesToOrigin(ImList<ImTuple2<Double, Double>> xys)
SML
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)
Test
Java
class: | SumDistancesToOriginTestSuite.java | ![]() |
package: | distance.warmup | |
source folder: | src/test/java |
SML
file: | unit_test_sum_distances_to_origin.sml | |
source folder: | src/test/sml/warmup_sum_distances_to_origin |