Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 lurking in the Monastery: (4)
As of 2015-03-27 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (597 votes), past polls