开发者

Help sml - troubled

How to declare a function so Listn : ' ' a list -> ' ' a list -> bool, listn xs and ys return true.  

Example: lisen [#"1" #"2"]开发者_如何学编程 , [#"1" "#3"] return false and  [#"1" , #"2"] [#"2" , #"1"] return true


Try this:

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜