sequence OF what? - structores
Only thing I can figure you can get out of that is.
Very fixed, non-dynamic typing.
I know, you say, What?
Using OF how would you type handle this?
sequence pb
pb = {"Johnny", "Robert", "Princeton", "Jr.", 12, 31, 1977, 150, "blue",
"blonde", 6, 2, 'M'}
----
I stand by my proposal... or should I say Chris Bensler's proposal of
structures.
Maybe, someone mentioned before him. I wouldn't doubt it. Either way.
Something like this can handle it.
----}}}
<eucode>
type month(object x)
if (integer(x) and (12 >= x and x >=1)) then
return 1
else
return 0
end if
end type
type mday(object x)
if (integer(x) and (31 >= x and x >=1)) then
return 1
else
return 0
end if
end type
type year(object x)
if (integer(x) and (1890 >= x and x >=3000)) then
return 1
else
return 0
end if
end type
type weight(obect x)
if (atom(x) and (2000 >= x and x >=0)) then
return 1
else
return 0
end if
end type
type byte(object x)
if (integer(x) and (255 >= x and x >=0)) then
return 1
else
return 0
end if
end type
type feet(object x)
if (integer(x) and (10 >= x and x >=0)) then
return 1
else
return 0
end if
end type
type inches(object x)
if (integer(x) and (12 >= x and x >=0)) then
return 1
else
return 0
end if
end type
type gender(object x)
if (integer(x) and find(x, "MFUmfu")) then
return 1
else
return 0
end if
end type
-- Hmm, I haven't thought of a way for handling a dynamic length item using
struct
type string(object x)
if (sequence(x)) then
for A = 1 to length(x) do
if (not byte(x[A]) then
return 0
end if
end for
return 1
else
return 0
end if
end type
struct PhoneBookItem
{string, string, string, string, month, mday, year, string, string, feet,
inches, gender}
end struct
</eucode>
{{{
unkmar
-----------------
Complete message by Patrick Barnes is at
http://www.listfilter.com/cgi-bin/esearch.exu?postedBy=Barnes&keywords=myDat
aStructure
----- Original Message -----
From: "Patrick Barnes" <mistertrik at hotmail.com>
To: <EUforum at topica.com>
Sent: Monday, May 31, 2004 7:08 PM
Subject: Re: Stupid Newbie-sounding question.
> We need a new keyword; "of".
> Usage:
>
> type char ( integer c )
> -- return 1 valid character, 0 otherwise
> end type
>
> --myStr is a string
> sequence of char myStr
>
<snip>
>
> If you have a complex data structure list, you could have:
>
> type myDataStructure( sequence s)
> --return 1 if valid myDataStructure, 0 otherwise
> end type
>
> sequence of myDataStructure master_list
>
<snip>
> Multi-dimensional arrays are also possible:
>
> --2d array of integers
> sequence of sequence of integer 2d_array
>
> type textpict_line( sequence s)
> if length(s) = 80 then return 1
> else return 0
> end if
> end type
>
> --2d array where the length of each line is fixed, and consists of
> characters
> sequence of textpict_line of char text_picture
>
>
<snip>>
> type rgb (sequence of integer c)
> return length(c) = 3
> end type
>
> type rgb_map ( sequence of sequence of rgb x)
> return 1
> end type
>
> If no extra checking has to be done, then the type just returns 1.
>
<snip>
> Cheers.
> MrTrick
|
Not Categorized, Please Help
|
|