4 module Puppet::Parser::Functions
5 newfunction(:intersection, :type => :rvalue, :doc => <<-DOC
6 This function returns an array of the intersection of two.
10 intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"]
11 intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean)
15 # Two arguments are required
16 raise(Puppet::ParseError, "intersection(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2
21 unless first.is_a?(Array) && second.is_a?(Array)
22 raise(Puppet::ParseError, 'intersection(): Requires 2 arrays')
25 result = first & second
31 # vim: set ts=2 sw=2 et :