Converts Prolog algorithms to List Prolog algorithms
Converts Prolog algorithms to List Prolog algorithms
/bin/bash
~/.bashrc
using the text editor Nano:
nano ~/.bashrc
~/.bashrc
:
export PATH="$PATH:/opt/homebrew/bin/"
sudo ln -s /opt/homebrew/bin/swipl /usr/local/bin/swipl
Download this repository and the List Prolog interpreter.
mkdir GitHub
cd GitHub/
git clone https://github.com/luciangreen/List-Prolog-Package-Manager.git
cd List-Prolog-Package-Manager
swipl
['lppm'].
lppm_install("luciangreen","Prolog-to-List-Prolog").
../
halt.
cd Prolog-to-List-Prolog
swipl
['p2lpconverter.pl'].
Run:
Convert Prolog code to List Prolog code by copying Prolog algorithm into test1.pl
and running: p2lpconverter(S1),pp0(S1,S2),writeln(S2).
p2lp_test(A,B)
or p2lp_test1(N,B)
where N is the test number from Prolog to List Prolog/p2lpverify.pl.Install:
Load each file into SWI-Prolog using ['la_strings.pl'].
and ['p2slpconverter.pl'].
Run:
Convert Prolog code to List Prolog code by copying Prolog algorithm into test1.pl and running: p2slpconverter.
Input:
a.
b(C,D).
ef(G):-(h(I)->true;true),!.
Note: [a,*,*]
not a
, which is Simple List Prolog. [a,*,*]
is for inputting into CAWPS predicate dictionary.
Output:
[[[a,*,*]],[[b,*,*],[c,d]],[[ef,*,*],[g],:-,[[[[h,*,*],[i]],->,true,or,true],!]]]
Pretty-print List Prolog algorithm by typing e.g.:
pp0([[[a,*,*]],[[b,*,*],[c,d]],[[ef,*,*],[g],(:-),[[[[h,*,*],[i]],->,true,or,true],!]]]).`
Output:
[
[[a,*,*]],
[[b,*,*],[c,d]],
[[ef,*,*],[g],(:-),
[
[[[h,*,*],[i]],->,true,or,true],
!
]]
]