Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Bringing Logic Programming to Perl

by Ovid (Cardinal)
on Jan 21, 2005 at 17:36 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found