有人可以帮我编写一个实现该功能的函数吗?我试过了:
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)