Difference between revisions of "Sum Distances To Origin Using Higher Order Functions Assignment"
Jump to navigation
Jump to search
(Created page with "=Motivation= Gain experience using higher-order functions. =Previous Warmup= This warmup is a variation of the Sum_Distances_To_Origin_With_Functions_Assignment|Sum Distanc...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
=Previous Warmup= | =Previous Warmup= | ||
This warmup is a variation of the [[Sum_Distances_To_Origin_With_Functions_Assignment|Sum Distances To Origin with Functions]] warmup. | This warmup is a variation of the [[Sum_Distances_To_Origin_With_Functions_Assignment|Sum Distances To Origin with Functions]] warmup. | ||
+ | |||
+ | =Library Functions to Use= | ||
+ | ==[https://smlfamily.github.io/Basis/math.html Math]== | ||
+ | [https://smlfamily.github.io/Basis/math.html#SIG:MATH.sqrt:VAL Math.sqrt(v)] | ||
+ | |||
+ | ==[https://smlfamily.github.io/Basis/list.html List]== | ||
+ | Note: you should only require one of the higher-order functions listed below: | ||
+ | * [https://smlfamily.github.io/Basis/list.html#SIG:LIST.map:VAL map] NOTE: curried | ||
+ | * [https://smlfamily.github.io/Basis/list.html#SIG:LIST.map:VAL filter] NOTE: curried | ||
+ | * [https://smlfamily.github.io/Basis/list.html#SIG:LIST.foldl:VAL foldl] or [https://smlfamily.github.io/Basis/list.html#SIG:LIST.foldr:VAL foldr] NOTE: both curried | ||
+ | * [https://smlfamily.github.io/Basis/list.html#SIG:LIST.map:VAL find] NOTE: curried | ||
=Code To Implement= | =Code To Implement= | ||
{{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|warmup_sum_distances_to_origin_using_hof}} | {{SMLToImplement|sum_distances_to_origin|sum_distances_to_origin|warmup_sum_distances_to_origin_using_hof}} | ||
− | |||
− | |||
fun sum_distances_to_origin(xys : (real * real) list) | fun sum_distances_to_origin(xys : (real * real) list) |
Latest revision as of 20:43, 26 September 2022
Contents
Motivation
Gain experience using higher-order functions.
Previous Warmup
This warmup is a variation of the Sum Distances To Origin with Functions warmup.
Library Functions to Use
Math
List
Note: you should only require one of the higher-order functions listed below:
Code To Implement
file: | src/main/sml/warmup_sum_distances_to_origin_using_hof/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_using_hof |
how to run with CM.make verbosity off: | sml -Ccm.verbose=false run_sum_distances_to_origin_using_hof_testing.sml |
how to run with CM.make verbosity on: | sml run_sum_distances_to_origin_using_hof_testing.sml |
note: ensure that you have removed all printing to receive credit for any assignment.