Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5730

Add a step(<n>) function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: Docs
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      1
    • Sprint:
      Language 2016-02-10
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      The iterative function an_iterable.step(n) has been added. It yields every nth succesor from its input iterable when chained into another function.
      Earlier it was difficult to iterate in steps other than one. This function makes use of the new types Iterable and Iterator which enable efficient chaining of iterative functions. See those types for more details.
      Show
      The iterative function an_iterable.step(n) has been added. It yields every nth succesor from its input iterable when chained into another function. Earlier it was difficult to iterate in steps other than one. This function makes use of the new types Iterable and Iterator which enable efficient chaining of iterative functions. See those types for more details.

      Description

      Add a step(iterable, n) function that takes two arguments and an optional block. The declared parameter types must be `Iterable` and `Integer[1]` (a positive integer).

      If the function is called without a block, it must return a new iterable that will yield each nth element of the given argument
      When a block is given, it must be called with each nth element of the given argument. The argument is then returned.

      Example:

      [1,2,3,4,5,6,7,8].step(3) |$x| { notice($x) }
      

      will result in the notices '1', '4', '7'

      $c =.[1,2,3,4,5,6,7,8].step(3).map |$x| { $x * 10 }
      

      Will result in:

      $c == [10, 40, 70]
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              thomas.hallgren Thomas Hallgren
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support