Difference between revisions of "Remove First Assignment"
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
raise NotYetImplemented</nowiki> | raise NotYetImplemented</nowiki> | ||
− | Remove the first item which matches <code>target</code> if it exists. For example, <code>remove_first([1,2,3,4,5], 3)</code> should return the list [1,2,4,5]. | + | Remove the first item which matches <code>target</code> if it exists. For example, <code>remove_first([1,2,3,4,5], 3)</code> should return the list <code>[1,2,4,5]</code>. |
− | If the target does not exist, return the complete list. For example, <code>remove_first([1,2,3,4,5], 6)</code> should return the list [1,2,3,4,5]. | + | If the target does not exist, return the complete list. For example, <code>remove_first([1,2,3,4,5], 6)</code> should return the list <code>[1,2,3,4,5]</code>. |
=Test= | =Test= | ||
{{SMLUnitTest|remove_first|warmup_remove_first}} | {{SMLUnitTest|remove_first|warmup_remove_first}} |
Revision as of 05:14, 15 October 2020
Code to Implement
file: | src/main/sml/warm_up_remove_first/remove_first.sml | |
functions: | remove_first |
remove_first
fun remove_first(xs : ''a list, target : ''a) : ''a list = raise NotYetImplemented
Remove the first item which matches target
if it exists. For example, remove_first([1,2,3,4,5], 3)
should return the list [1,2,4,5]
.
If the target does not exist, return the complete list. For example, remove_first([1,2,3,4,5], 6)
should return the list [1,2,3,4,5]
.
Test
file: | unit_test_remove_first.sml | |
source folder: | src/test/sml/warmup_remove_first |