0

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?)

Derek Mahar
  • 27,608
  • 43
  • 124
  • 174

2 Answers2

2

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'?

List.is.

(Like Haskell, does Oz treat a string as a list of characters?)

That's explained on the page you linked:

Further notational variant is allowed for lists whose elements correspond to character codes. Lists written in this notation are called strings

See also

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 '#'.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
2

Here is a possible implementation of the List.isfunction mentioned by Alexey in his answer.

fun {IsList Xs}
   case Xs of nil then true
   [] _|Xr then {IsList Xr}
   else false
   end
end
francoisr
  • 4,407
  • 1
  • 28
  • 48