2015-10-19 43 views

回答

2

的奧茲程序如何才能知道一個值的類型是List和其中一個是一個非列表,如簡單的標量的區別值1或字符串'你好'?

List.is

(比如Haskell,並奧茲將一個字符串作爲字符列表?)

這就是你的鏈接頁面上解釋說:

而且記譜變體允許列出其元素對應於字符代碼。寫在這個符號列表被稱爲串

參見

This chapter describes modules for handling data encoding textual information. Characters are encoded as integers. Strings are lists of characters. Virtual Strings are atoms, strings, byte strings, integers, and floats closed under virtual concatenation encoded by tuples with label '#'.

2

這裏是一個可能實現由阿列克謝在他的回答中提到的List.is功能。

fun {IsList Xs} 
    case Xs of nil then true 
    [] _|Xr then {IsList Xr} 
    else false 
    end 
end