Just wondering is it possible to run prolog script in a browser? I studied it at university and Id like to add it to my online portfolio?
yes, YieldProlog is a ready-to-use 'transpiler' from a good subset of Prolog to JavaScript.
edit
Now there is a better mantained alternative, ISO compliant: Tau Prolog
edit
A preview of hhprolog, my port to Javascript of Prof.Tarau Hitchhicker Prolog virtual machine.
Hit [ Run code snippet ] to compute 2+2 in Peano notation, i.e. this fragment of pure Prolog
add(0,X,X).
add(s(X),Y,s(Z)):-add(X,Y,Z).
goal(R):-add(s(s(0)),s(s(0)),R).
<script src="https://cdn.jsdelivr.net/gh/CapelliC/hitchhicker-prolog@8424f251246b5f45d5a7ee7046e3e32d29b8282c/hhprolog-es6.js"></script>
<script>
const add = `
add 0 X X .
add _0 Y _1 and
_0 holds s X and
_1 holds s Z
if
add X Y Z .
goal R
if
add _0 _1 R and
_0 holds s _2 and
_2 holds s 0 and
_1 holds s _3 and
_3 holds s 0 .
`
const prog = new Prog(add)
//prog.ppCode()
const t0 = Date.now()
prog.run(true)
console.log('elapsed secs', (Date.now() - t0) / 1000)
</script>
I don't really know what you want to do with Prolog online, but here there are several online "IDEs" and compilers in several languages (Prolog included) so you could execute your prolog script there
If you want to run prolog from scrath in a browser im afraid I don't know how to do it easily
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With