Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] FWD: Index? Re:

From: galtbarber:mailandnews at: 25-Aug-2000 17:54

I have often wished I could do what you want. Sometimes you want to have your cake and eat it, too! It is a drag to have to insert first everywhere in examples like this: forall somelist [print first somelist] and when you do this: foreach element somelist [print element] this is great as long as you don't also need to know it's position. many times you may need that position. You can also do this: repeat i length? somelist [print somelist/:i] which is sort of ok as you can see, in your example below, item is the actual character from the string, not the string, therefore you can't ask for it's position, as it won't have access to that info. I suppose Rebol could create a local keyword that stored that index, because obviously, internally it does know what the index really is. But Rebol avoids creating new keywords, and when you get multiple nested structures, exposing that index as a keyword might be a real drag. And how come there isn't a short hand for: list: next list wouldn't it be helpful to everybody to have something like this: advance list which would do the same thing, and even better as a native. I guess one could make up your own function, but then everybody would be re-inventing this wheel independently. It seems like it ought to come with the system.