Skip to content
Snippets Groups Projects
Commit 637d4cde authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Handle nested lists in cartesian().

Allow nested lists as parameters to cartesian(), and flatten them
before use.  This can make it easier to combine lists to "supersets"
(although no attempt is made to uniquify the elements of the lists).

This was originally commit a29c5ba921cd in nsc-puppet-utils.
parent 1292ecfe
Branches
No related tags found
No related merge requests found
......@@ -19,7 +19,8 @@ module Puppet::Parser::Functions
'iptables -i eth3 -o eth7 -j REJECT' ]
A simple string as an argument is equivalent to a one element
long list of that string.
long list of that string. Lists within lists are also allowed,
and will be flattened before use.
If any of the arguments is an empty list, the return value will
be an empty list.
......@@ -27,9 +28,7 @@ module Puppet::Parser::Functions
do |args|
result = [ "" ]
args.each do |a|
if not a.is_a?(Array)
a = [a]
end
a = [a].flatten
newres = []
result.each do |p1|
a.each do |p2|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment