- or download this
#match context free grammar --[0{N}1{N}] (e.g. 01, 0011, 000111, etc.)
$cf = qr/01|0(??{$cf})1/;
$init = "00001111";
print "match\n" if ($init=~m/^$cf$/);
- or download this
#match context sensitive grammar --[0{N}1{N}2{N}] (012, 001122, 000111
+222, ...)
$h=qr/01|0(??{$h})1/;
...
$init = "001122";
print "match\n" if ($init=~m/^$cs$/);
- or download this
#Word boundries are zero-width so the regex engine will never progress
my $inf; $inf=qr/\b(??{$inf})/;
- or download this
#simple computations with pattern matching operating on unary numbers
$"="";
...
@sqr = m/(l)(?=(l*))(?=(l*))/g;
print "$_ squared = @sqr\n";
- or download this
#implement rule 110 cellular automata
$init = " X "; #initial value (pad with two spaces on either side)
...
(\s)$ #End of line
/gx)]} ";
}