- Posted by bensler at mail.com Mar 22, 2002
- 1992 views
I came up with this type definition for arrays. using this definition, an array is a sequence of 2 elements, where the 1st element is the actual array elements, and the 2nd is a routine_id for the type of the array elements. global type array(sequence s) if length(s)=2 and sequence(s[1]) and integer(s[2]) then for i = 1 to length(s[1]) do if not call_func(s[2],{s[1][i]}) then return 0 end if end for return 1 end if return 0 end type type sequence_(integer b) return 1 end type array test test={{},routine_id("sequence_")} -- a string test[1] = "This is a test" puts(1,test[1]) while get_key()=-1 do end while <END DEMO> Just thought I would share it because I could see it being quite useful. Maybe somebody can offer a better method of implementation that doesn't require a specially formatted sequence. Chris