/infinite-loop.raku Secret
Last active
February 21, 2025 23:59
Revisions
-
wayland revised this gist
Feb 21, 2025 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ #!/usr/bin/raku use XML; sub WalkTreeMatch(@inputs) { -
wayland renamed this gist
Feb 21, 2025 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wayland created this gist
Feb 21, 2025 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ $ ./infinite-loop.raku | head -50 ----- inputs count: 2 inputs: [("A",), ("B", "C", ("E", "F", "G", {:A("E"), :E("A")}))] input count: 1 input: $("A",) input child: "A" nameList Got to A input count: 3 input: $("B", "C", ("E", "F", "G", {:A("E"), :E("A")})) input child: "B" nameList Got to B Got to C ----- inputs count: 4 inputs: ("E", "F", "G", {:A("E"), :E("A")}) ----- inputs count: 3 inputs: (my \XML::Element_3298568580792 = XML::Element.new(name => "rootnode", nodes => [XML::Text.new(text = input count: 3 input: (my \XML::Element_3298568580792 = XML::Element.new(name => "rootnode", nodes => [XML::Text.new(text = input child: (my \XML::Text_3298571614976 = XML::Text.new(text => "\n\t", parent => (my \XML::Element_329856858079 nameXML::Element ----- inputs count: 3 inputs: (my \XML::Element_3298568580792 = XML::Element.new(name => "rootnode", nodes => [XML::Text.new(text = input count: 3 input: (my \XML::Element_3298568580792 = XML::Element.new(name => "rootnode", nodes => [XML::Text.new(text = input child: (my \XML::Text_3298571614976 = XML::Text.new(text => "\n\t", parent => (my \XML::Element_329856858079 nameXML::Element ----- inputs count: 3 .... This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ #!/usr/bin/raku use lib '../XML/improve-Positional/lib/'; use XML; sub WalkTreeMatch(@inputs) { my (@retvals); # Unindented lines were just inserted for debugging, and should be removed later (but see output) say "-----"; say "inputs count: " ~ @inputs.elems; say "inputs: " ~ @inputs.raku().substr(0..100); for @inputs -> $input { # Input nodes in NodeSet $input ~~ Positional or next; say "input count: " ~ ($input[]).elems; say "input: " ~ $input.raku().substr(0..100); say "input child: " ~ $input[0].raku().substr(0..100); say "name" ~ $input.^name(); for @$input -> $child { # Children of node from NodeSet if ($child ~~ Positional) { WalkTreeMatch($child) ==> @retvals; } else { if $child.can('name') { say "Got to " ~ $child.name; } else { say "Got to " ~ $child; } } } } return @retvals; } # Test on regular array my (@inputs) = ( ('A',), ('B','C', ('E','F','G', %( 'A' => 'E', 'E' => 'A')))); WalkTreeMatch(@inputs); # Test with XML my ($xmlstring) = qq:to/EOT/; <rootnode> <item level="1"> <inner>text</inner> </item> </rootnode> EOT my ($doc) = from-xml($xmlstring); WalkTreeMatch($doc.root);