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

Add a `unique` function that works with all kinds of iterables

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 5.0.0
    • Functions, Language
    • None
    • New Feature
    • Hide
      The function {{unique}} is now available directly in Puppet and does no longer require {{stdlib}} to be included. The new version of the function also handles {{Hash}} and {{Iterable}} data types. It is now also possible to give a code block that determines of the uniqueness is computed.
      Show
      The function {{unique}} is now available directly in Puppet and does no longer require {{stdlib}} to be included. The new version of the function also handles {{Hash}} and {{Iterable}} data types. It is now also possible to give a code block that determines of the uniqueness is computed.
    • Manual
    • covered by unit tests

    Description

      The stdlib unique function can only process String and Array values and it is not possible to influence the comparison (it is always a Ruby == operation).

      The unique function is really intrinsic to collections and iterators and it makes sense for it to be in Puppet instead of stdlib.

      • For String and Array the function must be compatible with the stdlib version
      • The function should handle all Iterables
      • It should be possible to give the function a lambda that computes the value to do the equality/uniqueness check on.
      • For Hash the result should be a hash with associations between the sets of keys that all have values that are computed to be equal (by the built in == or by a given lambda) and the set of those values.

      Attachments

        Activity

          People

            Unassigned Unassigned
            henrik.lindberg Henrik Lindberg
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support