检查字符串在SML中是否包含Pascal整数

检查字符串在SML中是否包含Pascal整数,sml,ml,Sml,Ml,有人能帮我写一个函数吗 我试过这个: fun isPascalInteger (s:string) = if (size(s)=0) then return true else if (!(isDigit(sub(s,0)))) then return false else (isPascalInteger(extract(s,1))); 使用字符串最方便的方法通常是先转换为列表,然后使用列表函数: fun isPascalInteger (s:string) = List.a

有人能帮我写一个函数吗

我试过这个:

fun isPascalInteger (s:string) = if (size(s)=0) then return true
    else if (!(isDigit(sub(s,0)))) then return false
    else (isPascalInteger(extract(s,1)));

使用字符串最方便的方法通常是先转换为列表,然后使用列表函数:

fun isPascalInteger (s:string) = List.all Char.isDigit (explode s)