Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Bringing Logic Programming to Perl

by Ovid (Cardinal)
on Jan 21, 2005 at 17:36 UTC ( #424075=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Thanks to aristotle for making the regex simpler
    my $string = "abcd";
    my @perms;
    my $regex = qr/(\G[abcd]{0,4}(?{print "# [$&][$'][$string]\n"}))/ x 2;
    $string =~ $regex;
    
  2. or download this
    # [abcd][][abcd]
    # [abc][d][abcd]
    # [ab][cd][abcd]
    # [a][bcd][abcd]
    # [][abcd][abcd]
    # [abcd][][abcd]
    
  3. or download this
    append([], X, X).
    append([W|X],Y,[W|Z]) :- append(X,Y,Z).
    
  4. or download this
    [a,b,c],[d,e,f],[a,b,c,d,e,f] 
      if [b,c],[d,e,f],[b,c,d,e,f]
      if [c],[d,e,f],[c,d,e,f]
      if [],[d,e,f],[d,e,f]
    
  5. or download this
    #!/usr/local/bin/perl -l
    
    use strict;
    ...
        "append([], X, X)."
       ."append([W|X],Y,[W|Z]) :- append(X,Y,Z).";
    }
    
  6. or download this
    Appending two lists 'append([a],[b,c,d],Z).'
    append([a],[b,c,d],[a,b,c,d])
    
    ...
    append([a,b],[c,d],[a,b,c,d])
    append([a,b,c],[d],[a,b,c,d])
    append([a,b,c,d],[],[a,b,c,d])
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://424075]
Approved by rlb3
Front-paged by neniro
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls