Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Raku

Visibility

unlisted

Author

legacy-anonymous

Created

2025-03-25T11:14:30.609218Z

Updated

2025-03-25T11:14:30.609218Z

class Node {
    has $.parent;
    has $.child;
    has @.tests;
    method AT-KEY(&code) {
        @!tests.push: &code;
        self
    }
    method add($child) {
        without $!parent {
            $!parent = $!child;
            return self
        }
        self.new: :parent(self), :$child
    }
}

sub term:<html> {
    Node.new: :child<html>
}

multi infix:<< <- >>(Node $parent, $child) {
    Node.new: :$parent, :$child
}

say (html <- "body" <- "h1"){ *.id eq "red" }
INFO