Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title John Duarte updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: John Duarte QA Risk Assessment Reason: Covered by spec tests Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title John Duarte updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: John Duarte QA Risk Assessment: No Action Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title John Duarte updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: John Duarte Sprint: Language Triage Agent 2017-06-28 Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title John Duarte assigned an issue to qa Puppet / PUP-5893 Add the tree iterative function tree_each Change By: John Duarte Status: Ready for CI Test Assignee: qa Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Thomas Hallgren assigned an issue to Unassigned Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Thomas Hallgren Assignee: Thomas Hallgren Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Thomas Hallgren commented on PUP-5893 Re: Add the tree iterative function tree_each Merged to master at d72a163. Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg assigned an issue to Thomas Hallgren Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg Assignee: Henrik Lindberg Thomas Hallgren Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Thomas Hallgren assigned an issue to Henrik Lindberg Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Thomas Hallgren Assignee: Thomas Hallgren Henrik Lindberg Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg UPDATE-A simpler solution was implemented. The function {{tree_each}} which is configurable to iterate over Array, Hash and Object data types (the type of container can be selected), yielding elements that represents a "flattened tree". This enables other existing iterable functions to be used to map, filter, reduce (etc.) the result.At the end, a tree can again be constructed by creating a new Hash using {{Hash(, 'tree')}}. For details see the documentation in the {{new}} function, and in the documentation for {{tree_each}}.The Original ticket text is retained below (mostly for its motivation why the function is wanted).ORIGINAL-BackgroundAt the moment it is difficult to flatten out a complex structure. There is a flatten in standard lib that creates a flat copy of a tree of {{Array}} objects, and it errors if given a Hash. If the restriction was lifted to also support Hash, Ruby flatten method flattens a hash by making an array of keys and values. That makes the result hard to use if it is a mix of arrays and hashes.It is very useful to be able to iterate over such a tree instead of creating a copy, and it is of value to iterate over it in different ways. This is what the flat_each does.To describe what is wanted; imagine the two functions {{each_element}}, and {{each_container}} (these are not the functions we want at the end; they are too special, but they serve as illustration).{{each_element(Iterable $x)}}This function visits each container and leaf in the tree $x and calls a given block with 1.3 parameters. The block gets container, index, and value if defining three parameters, if using 2 arguments the container and index is delivered as a tuple, and if using 1 arg the three args are delivered as a Triple. The first yielded value is the given argument value. Each element in the tree is yielded with parent before children, depth first.When not given a block, each_element produces an Iterator that yields a triplet.{{each_container(Iterable $x)}}This function is he same as to each_element but skips children that are not containers. This enables doing inner loops conditionally.What we should do instead is to first implement {{next()}} since that makes it possible to do general skipping and pruning; {{next(true)}} means skip this element and its children and {{next()}}, or {{next(false)}} to mean "do not prune", take next element I am done with the one you just gave me. ProposalImplement flat_each such that:* It accepts an Iterable and a required block* It produces an Iterator if not given a block* When given a block, it produces the given first argument* It yields 1-3 arguments as described for each_element* The value produced by the block is ignored (as for a regular each)* If next is called, the value given to next determines if iteration continues with the next in order {{next(false)}}/{{next()}}, or if it prunes {{next(true)}}.Implement flat_reduce such that:* It accepts an Any and a required block* if value is not Iterable, the given value is yielded and nothing more, else every value in the iterable is yielded to the block* It produces an Iterator if not given a block* When given a
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg assigned an issue to Thomas Hallgren Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg Assignee: Thomas Hallgren Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg Release Notes Summary: The functions function {{ tree_each , and tree_reduce have }} has been added to allow convenient iteration , filtering, mapping, and reduction over complex structures. The function iterates recursively in a way that flattens a structure into a sequence, but that retains information about the structure thus making it possible to put it back together with possibly altered values. This was a difficult operation to do in Puppet Language earlier and required a user to write a custom recursive function to achieve the same result. Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg Fix Version/s: PUP 5.1.0 Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg UPDATE-A simpler solution was implemented. The function {{tree_each}} which is configurable to iterate over Array, Hash and Object data types (the type of container can be selected), yielding elements that represents a "flattened tree". This enables other existing iterable functions to be used to map, filter, reduce (etc.) the result.At the end, a tree can again be constructed by creating a new Hash using {{Hash(, 'tree')}}. For details see the documentation in the {{new}} function, and in the documentation for {{tree_each}}.The Original ticket text is retained below (mostly for its motivation why the function is wanted).ORIGINAL- BackgroundAt the moment it is difficult to flatten out a complex structure. There is a flatten in standard lib that creates a flat copy of a tree of {{Array}} objects, and it errors if given a Hash. If the restriction was lifted to also support Hash, Ruby flatten method flattens a hash by making an array of keys and values. That makes the result hard to use if it is a mix of arrays and hashes.It is very useful to be able to iterate over such a tree instead of creating a copy, and it is of value to iterate over it in different ways. This is what the flat_each does.To describe what is wanted; imagine the two functions {{each_element}}, and {{each_container}} (these are not the functions we want at the end; they are too special, but they serve as illustration).{{each_element(Iterable $x)}}This function visits each container and leaf in the tree $x and calls a given block with 1.3 parameters. The block gets container, index, and value if defining three parameters, if using 2 arguments the container and index is delivered as a tuple, and if using 1 arg the three args are delivered as a Triple. The first yielded value is the given argument value. Each element in the tree is yielded with parent before children, depth first.When not given a block, each_element produces an Iterator that yields a triplet.{{each_container(Iterable $x)}}This function is he same as to each_element but skips children that are not containers. This enables doing inner loops conditionally.What we should do instead is to first implement {{next()}} since that makes it possible to do general skipping and pruning; {{next(true)}} means skip this element and its children and {{next()}}, or {{next(false)}} to mean "do not prune", take next element I am done with the one you just gave me.ProposalImplement flat_each such that:* It accepts an Iterable and a required block* It produces an Iterator if not given a block* When given a block, it produces the given first argument* It yields 1-3 arguments as described for each_element* The value produced by the block is ignored (as for a regular each)* If next is called, the value given to next determines if iteration continues with the next in order {{next(false)}}/{{next()}}, or if it prunes {{next(true)}}.Implement flat_reduce such that:* It accepts an Any and a required block* if value is not Iterable, the given value is yielded and nothing more, else every value in the iterable is yielded to the block* It produces an Iterator if not given a block* When given a
Jira (PUP-5893) Add the tree iterative function tree_each
Title: Message Title Henrik Lindberg updated an issue Puppet / PUP-5893 Add the tree iterative function tree_each Change By: Henrik Lindberg Summary: Add the tree iterative functions - function tree_each , and tree_reduce Add Comment This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To post to this group, send email to puppet-bugs@googlegroups.com. Visit this group at https://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/d/optout.