Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个将列表和项目作为参数的 SML 函数。如果该项目存在,则该函数应返回一个包含列表的元组,而不会第一次出现该项目和刚刚删除的项目。如果列表中没有出现该项目,则该函数应返回 NONE 或类似的内容以指示此不存在。
尝试这个:
fun same_string(str, lst) = case lst of [] => NONE |x::xs => case same_string(str, xs) of NONE => if str = x then SOME(xs) else NONE |SOME xs' => SOME (x :: xs')