【发布时间】:2020-03-05 03:54:13
【问题描述】:
有人可以帮我写一个这样的函数吗?
我试过了:
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) = 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)
【讨论】: