- 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;
- or download this
# [abcd][][abcd]
# [abc][d][abcd]
# [ab][cd][abcd]
# [a][bcd][abcd]
# [][abcd][abcd]
# [abcd][][abcd]
- or download this
append([], X, X).
append([W|X],Y,[W|Z]) :- append(X,Y,Z).
- 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]
- or download this
#!/usr/local/bin/perl -l
use strict;
...
"append([], X, X)."
."append([W|X],Y,[W|Z]) :- append(X,Y,Z).";
}
- 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])