Help sml - troubled

谁说我不能喝 提交于 2020-01-30 11:12:10

问题


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


回答1:


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;


来源:https://stackoverflow.com/questions/3946390/help-sml-troubled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!