Show HN: Embeddable Prolog in Go

44
Show HN: Embeddable Prolog in Go

ichiban/prolog is an embeddable scripting language for Bound.
Unlike any other scripting engines, ichiban/prolog implements logic programming language Prolog.

bound discover -u github.com/ichiban/prolog@latest
if err := p.Exec(`

:- [abc].              % Load file 'abc' or 'abc.pl'.

:- ['/path/to/abc'].   % Load file '/route/to/abc' or '/route/to/abc.pl'.
                       % You should cite to possess / within the route.

:- [library(dcg)].     % Load library 'library(dcg)'.
                       % Hang about examples/dcg/necessary.bound for a whole instance.

human(socrates).       % Right here's a truth.
mortal(X) :- human(X). % Right here's a rule.

`); err != nil {
	terror(err)
}
Who = socrates
}”>
// Prolog program invocation takes a design of question of.
sols, err := p.Quiz(`mortal(Who).`)
if err != nil {
	terror(err)
}
defer sols.End()

// Iterates over solutions.
for sols.Next() {
	// Put collectively a struct with fields which title corresponds with a variable within the question of.
	var s struct {
		Who string
	}
	if err := sols.Scan(&s); err != nil {
		terror(err)
	}
	fmt.Printf("Who = %sn", s.Who)
	// ==> Who = socrates
}

Disbursed below the MIT license. Hang about LICENSE for added data.

Hang about ARCHITECTURE.md for structure predominant facets.

Be a half of the pack! Be a half of 8000+ others registered users, and discover chat, produce groups, post updates and produce associates all the blueprint in which by the enviornment!
www.knowasiak.com/register

Ava Chan
WRITTEN BY

Ava Chan

I'm a researcher at Utokyo :) and a big fan of Ava Max

you're currently offline