Re: Sequence index with sequences... Why not?!

new topic     » goto parent     » topic index » view thread      » older message » newer message

Anders Eurenius recently suggested that Euphoria should =

allow subscripting of a sequence with a sequence. This is a =

reasonable idea. I can understand his arguments in favor of this
feature. =


I'd like to point out that in addition to using recursion to =

subscript a tree of unknown depth, you can also write a =

loop that subscripts one level with each iteration.

This topic was discussed a few months ago on this mailing list, =

and the rest of this message is a copy of what I said back then...

---------

I've received many suggestions for defining what it would
mean to subscript a sequence with a sequence:

1. Jeff Zeitlin's idea (it's done like this in APL):

    s[{a,b,c}] is {s[a],s[b],s[c]}

2. Other people suggested:   *Anders idea too*
   (useful for tree structures of unknown depth):

    s[{a,b,c}] is s[a][b][c]

3. Someone else suggested (the database people would like it):

    s["Fred"] is the Euphoria object associated with "Fred" e.g.
               s["Fred"] =3D 99
               s["Dave"] =3D 27
               s["George"] =3D {1,2,3}

    Euphoria would try to look up "Fred" in s
    in some efficient way (linear search, hashing, whatever).
    If "Fred" couldn't be found it might fail, or perhaps =

    return some special value (what value?).

So far I haven't been convinced that any of the above are really worth it=
,
since you can achieve the same effect fairly easily using the
existing language. Plus the fact there are at least three choices  =

makes it difficult to confidently commit to one of them.
The main reason is I don't want to make the language more complicated
without good reason.

Regards,
  Rob Craig
  Rapid Deployment Software
 =

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu