Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.7
    • Component/s: Runtime (Boo.Lang)
    • Labels:
      None
    • Number of attachments :
      3

      Description

      Python style reversed iteration (http://www.python.org/dev/doc/devel/whatsnew/node7.html).

      1. boo-113.patch
        0.8 kB
        Arron Washington
      2. boo-113-suckless-v2
        3 kB
        Arron Washington
      3. reversed-builtin-suckless.patch
        0.7 kB
        Arron Washington

        Activity

        Hide
        Rafael Teixeira added a comment -

        Perhaps a more compact syntax

        instead of

        for i in reversed(xrange(1,4)):
        ... print i

        something like

        rfor i in xrange(1,4):
        print i

        Show
        Rafael Teixeira added a comment - Perhaps a more compact syntax instead of for i in reversed(xrange(1,4)): ... print i something like rfor i in xrange(1,4): print i
        Hide
        Carlos Villela added a comment -

        I don't think adding a new keyword would be necessary - at least for now, while we don't have macros. Something like reverse(<list>) would be a lot simpler - or even, why not just xrange(4,1)?

        Show
        Carlos Villela added a comment - I don't think adding a new keyword would be necessary - at least for now, while we don't have macros. Something like reverse(<list>) would be a lot simpler - or even, why not just xrange(4,1)?
        Hide
        Rodrigo B. de Oliveira added a comment -

        a function is applicable to a wider range of situations than a explicit reversed loop operation:

        lastLine, lineBeforeLast = reversed(File.OpenText("foo.txt"))

        Show
        Rodrigo B. de Oliveira added a comment - a function is applicable to a wider range of situations than a explicit reversed loop operation: lastLine, lineBeforeLast = reversed(File.OpenText("foo.txt"))
        Hide
        Rodrigo B. de Oliveira added a comment -

        let's make the 0.5 release sooner.

        Show
        Rodrigo B. de Oliveira added a comment - let's make the 0.5 release sooner.
        Hide
        Arron Washington added a comment -

        The only way I can think to implement reverse iteration is to first iterate through the array, then pass back a new enumerator (ReversedEnumerator) that pops out the values last to first. However, the inital iteration to gather all the values might actually affect or trigger something.

        Can anyone think of a way of reverse iteration in C# that does not require going through the the enumeration one way, first?

        Show
        Arron Washington added a comment - The only way I can think to implement reverse iteration is to first iterate through the array, then pass back a new enumerator (ReversedEnumerator) that pops out the values last to first. However, the inital iteration to gather all the values might actually affect or trigger something. Can anyone think of a way of reverse iteration in C# that does not require going through the the enumeration one way, first?
        Hide
        Arron Washington added a comment -

        This is a tentative patch that implements a basic builtin function called "reversed." It takes one parameter, an object that implements IEnumerable, then reverses the contants (iterating through the IEnumerable object once), and returns an IEnumerable (of the reversed loot).

        Its probably suboptimal, but it is the only way I could really think of implementing it.

        Show
        Arron Washington added a comment - This is a tentative patch that implements a basic builtin function called "reversed." It takes one parameter, an object that implements IEnumerable, then reverses the contants (iterating through the IEnumerable object once), and returns an IEnumerable (of the reversed loot). Its probably suboptimal, but it is the only way I could really think of implementing it.
        Hide
        Arron Washington added a comment -

        This patch sucks significantly less--it only takes about 0.5 seconds to reverse an enumerable object of 1,000 items, which is likely the most anyone will ever use it for.

        I wipe my hands of it!

        Show
        Arron Washington added a comment - This patch sucks significantly less--it only takes about 0.5 seconds to reverse an enumerable object of 1,000 items, which is likely the most anyone will ever use it for. I wipe my hands of it!
        Hide
        Arron Washington added a comment -

        (I am a machochist)

        Show
        Arron Washington added a comment - (I am a machochist)
        Hide
        Rodrigo B. de Oliveira added a comment -

        patch applied. thanks!

        Show
        Rodrigo B. de Oliveira added a comment - patch applied. thanks!

          People

          • Assignee:
            Unassigned
            Reporter:
            Rodrigo B. de Oliveira
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: