帮助sml - 困扰

时间:2010-10-15 21:45:53

标签: sml

如何声明一个函数,使Listn:''列表 - > ''列表 - > bool,listn xs和ys返回true。

示例:lisen [#“1”#“2”],[#“1”“#3”]返回false和[#“1”,#“2”] [#“2”,#“1 “]返回true

1 个答案:

答案 0 :(得分:0)

试试这个:

infix member
fun x member []         = false
  | x member (y::ys)    = x = y orelse x member ys;

fun listn (x::xs) ys = x member ys andalso listn xs ys
  | listn [] _       = true;