【发布时间】:2013-12-05 06:42:55
【问题描述】:
我知道代码是如何工作的,除了这里的 x 变量:SOME y => SOME (x::y)
fun same_string(s1 : string, s2 : string) =
s1 = s2
fun all_except_option (str, xs) =
case xs of
[] => NONE
| (x::xs') => case (same_string(str,x)) of
true => SOME xs'
| false => case all_except_option(str,xs') of
NONE => NONE
| SOME y=> SOME (x::y)
当您返回 SOME(x::y) 时,"x" 如何保存 ["a","b"] 元素?
val test1 = all_except_option("string", ["a","b","string","c"]) = SOME ["a","b","c"]
【问题讨论】:
标签: functional-programming pattern-matching sml ml