Help for this page

Select Code to Download


  1. 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$/);
    
  2. 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$/);
    
  3. or download this
    #Word boundries are zero-width so the regex engine will never progress
    
    my $inf; $inf=qr/\b(??{$inf})/;
    
  4. or download this
    #simple computations with pattern matching operating on unary numbers
    $"="";
    ...
    @sqr = m/(l)(?=(l*))(?=(l*))/g;
    print "$_ squared = @sqr\n";
    
  5. or download this
    #implement rule 110 cellular automata
    $init = "  X  ";  #initial value (pad with two spaces on either side)
    ...
                         (\s)$                   #End of line
                       /gx)]} ";
    }