Prolog code:
append([], X, X). append([X|R], L, [X|S]) :- append(R, L, S).
In long form:
sub append { my ($a, $b, $ab) = @_; my ($x, $r, $l, $s); $_ = Logic::Variable->new for $x, $r, $l, $s; Logic::Basic::Alternation->new( Logic::Data::Unify->new( [$a, $b, $ab], [[], $x, $x], ), Logic::Basic::Sequence->new( Logic::Data::Unify->new( [ $a, $b, $ab ], [ Logic::Data::Cons->new($x, $r), $l, Logic::Data::Cons->new($x, $s) ], ), Logic::Basic::Rule->new(sub { append($r, $l, $s), }), ), ); }
To install Logic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Logic
CPAN shell
perl -MCPAN -e shell install Logic
For more information on module installation, please visit the detailed CPAN module installation guide.