Difference between revisions of "My Length Assignment"
Jump to navigation
Jump to search
(→Test) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | =Code to Use= | ||
+ | =={{ListStructure}}== | ||
+ | {{ListNull}} | ||
+ | {{ListTl}} | ||
+ | |||
=Code to Implement= | =Code to Implement= | ||
Line 5: | Line 10: | ||
==my_length== | ==my_length== | ||
Write a function <code>my_length</code> which evaluates to the length of the given <code>values</code> list. | Write a function <code>my_length</code> which evaluates to the length of the given <code>values</code> list. | ||
+ | |||
+ | * what is the base case? | ||
+ | * what is the general (recursive) case? | ||
+ | |||
+ | <syntaxhighlight lang="sml"> | ||
+ | fun my_length(values) = | ||
+ | raise Fail "NotYetImplemented" | ||
+ | </syntaxhighlight> | ||
=Test= | =Test= | ||
{{SMLUnitTesting|run_my_length_testing|warmup_my_length}} | {{SMLUnitTesting|run_my_length_testing|warmup_my_length}} |
Latest revision as of 16:03, 30 August 2024
Code to Use
List
Code to Implement
file: | src/main/sml/warmup_my_length/my_length.sml | |
functions: | my_length |
my_length
Write a function my_length
which evaluates to the length of the given values
list.
- what is the base case?
- what is the general (recursive) case?
fun my_length(values) =
raise Fail "NotYetImplemented"
Test
source folder: | src/test/sml/warmup_my_length |
how to run with CM.make verbosity off: | sml -Ccm.verbose=false run_my_length_testing.sml |
how to run with CM.make verbosity on: | sml run_my_length_testing.sml |
note: ensure that you have removed all printing to receive credit for any assignment.