Oz 程序如何区分列表和非列表?
How can an Oz program tell the difference between a list and a non-list?
Oz program tell the difference between a value which is of type List and one which is a non-list such as simple scalar value 1
or string 'Hello'
? (Like HaskellOz 如何将字符串视为字符列表?)
How can an Oz program tell the difference between a value which is of type List and one which is a non-list such as simple scalar value 1 or string 'Hello'?
(Like Haskell, does Oz treat a string as a list of characters?)
这在您链接的页面上有解释:
Further notational variant is allowed for lists whose elements correspond to character codes. Lists written in this notation are called strings
另见
这是 Alexey 在他的回答中提到的 List.is
函数的可能实现。
fun {IsList Xs}
case Xs of nil then true
[] _|Xr then {IsList Xr}
else false
end
end
Oz program tell the difference between a value which is of type List and one which is a non-list such as simple scalar value 1
or string 'Hello'
? (Like HaskellOz 如何将字符串视为字符列表?)
How can an Oz program tell the difference between a value which is of type List and one which is a non-list such as simple scalar value 1 or string 'Hello'?
(Like Haskell, does Oz treat a string as a list of characters?)
这在您链接的页面上有解释:
Further notational variant is allowed for lists whose elements correspond to character codes. Lists written in this notation are called strings
另见
这是 Alexey 在他的回答中提到的 List.is
函数的可能实现。
fun {IsList Xs}
case Xs of nil then true
[] _|Xr then {IsList Xr}
else false
end
end