Re: Possible feature for new Euphoria-version
- Posted by "Kat" <gertie at visionsix.com> Jan 08, 2004
- 391 views
On 8 Jan 2004, at 14:38, Euman wrote: > > > Ouch, to much confusion...Im an old timer in euphoria > > Euman > > ----- Original Message ----- > From: "Tommy Carlier" <tommy.carlier at pandora.be> > To: "Euphoria Mailing List" <EUforum at topica.com> > Subject: Possible feature for new Euphoria-version > > > > Sequences are really easy to use, but there is no way you can create an > > index to a sub-, sub-, sub-sequence of a given sequence. Wouldn't it be > > nice if such a thing existed? > > > > In the current version of Euphoria, you can do: > > sequence seq > > seq = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} > > integer a > > a = seq[2][2] > > > > My suggestion for a new feature: allow the index to be a sequence. That > > way you could do something like this: > > sequence seq > > seq = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} > > integer a > > a = seq[ {2, 2} ] > > > > And now for the exciting part: > > sequence seq > > seq = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} > > sequence b > > b = {2, 2} > > integer a > > a = seq[b] > > > > This way you can also pass and return multiple indices to and from > > procedures and functions. You can do this in strtok: param = {2} db = {"this is a test1","this is test2 a"} result = gettok(db,param,"") And this: string = {"Red,Skelton,45,London,England", "Lucy,Ball,56,Barre,North Dakota", "Fred,Astaire,45,Alberta,Canada", "Pierre,du Pont,56,Paris,France"} string = sorttok(string,{3,-2},',') string = {"Red,Skelton,45,London,England", "Fred,Astaire,45,Alberta,Canada", "Pierre,du Pont,56,Paris,France", "Lucy,Ball,56,Barre,North Dakota"} You see, it did a ascending sort on (fictitious) age field, then sorted the two last name fields in decending order. And this gets you a seq in reply: string = {"Red,Skelton,45,London,England", "Lucy,Ball,56,Barre,North Dakota", "Fred,Astaire,45,Alberta,Canada", "Pierre,du Pont,56,Paris,France"} string = sortntok(string,{3,-2},',') string = {1,3,4,2} Eu should be as versatile as possible, no? Kat