Re: Standard Lib Func for string type?
- Posted by unkmar Apr 20, 2009
- 873 views
euphoric said...
Is there a function or type definition in the standard library for a string type? Basically, I just want to distinguish between "this is a string" and { "this is a string" }, one of which is a string and the other is a sequence of strings.
If there is not yet one, I would suggest at least an all_atoms() function, which returns True if all elements of the sequence are atoms.
I don't know if there is one in the standard libs. Might be. But I know I wrote one many years ago. In fact, something very close is in my math lib. bigfixed - http://malcom.unkmar.com/hol/FilesEu/bigfixed-0.6704.zip
global type string(object x) -- check for flatness. -- Any embedded sequences? if atom(x) then return 0 end if for index = 1 to length(x) do if sequence(x[index]) or not integer(x[index]) or (0 > x[index])or (x[index] > 255) then return 0 end if end for return 1 end type
The code above was modified from the bigfixed lib to add the restriction of integer values between 0 and 255.
Unkmar