Skip to content

Instantly share code, notes, and snippets.

View pmoura's full-sized avatar

Paulo Moura pmoura

View GitHub Profile
@pmoura
pmoura / particles.lgt
Last active March 17, 2020 00:48
Logtalk version of particles.pl
:- object(particle).
% common properties to all particles
:- public([
boson/0, fermion/0,
mass/1, spin/1, lifetime/1, charge/1
]).
:- end_object.
@pmoura
pmoura / ale.swi.pl lint warnings
Last active January 21, 2020 09:48
Lint warnings for ale.swi.pl
?- logtalk_compile('ale.swi.pl').
* Suspicious call: \+A=(B intro C) instead of A\=(B intro C)
* while compiling object ale
* in file /Users/pmoura/Desktop/ale.swi.pl between lines 1435-1438
*
* Suspicious call: sub_type(A,B),\+A=a_ C,sub_type(D,B),\+D=a_ E in setof/3 goal contains singleton variables [C,E]
* while compiling object ale
* in file /Users/pmoura/Desktop/ale.swi.pl between lines 1481-1488
*
* Suspicious call: \+A=a_ B instead of A\=a_ B
@pmoura
pmoura / ale.swi.pl
Last active January 21, 2020 12:31
Patched ale.swi.pl file with fixes for current_predicate/2 and assert/1 predicates plus missing dynamic/1 and use_module/2 directives
:- module(ale, []).
:- dynamic to_rebuild/1.
:- dynamic edge/8.
:- dynamic parsing/1.
:- dynamic ext_sub_structs/6.
:- dynamic alec_closed_rules/1.
:- dynamic fspal_ref/1.
:- dynamic (empty)/1.
digraph "assertions" {
rankdir="BT"
ranksep="1.0"
compound="true"
splines="true"
pack="true"
clusterrank="local"
labeljust="l"
margin="1.0"
fontname="Courier"
digraph "sicstus" {
rankdir="BT"
ranksep="1.0"
compound="true"
splines="true"
pack="true"
clusterrank="local"
labeljust="l"
margin="1.0"
fontname="Courier"
@pmoura
pmoura / LogtalkLoader.java
Created November 24, 2018 00:50 — forked from sergio-castro/LogtalkLoader.java
This class shows an easy way to configure Logtalk in SWI or YAP using the Jpl library, together with examples of simple invocations of Logtalk methods from Java. You need to have the jpl jar in your classpath to compile and execute this file.
import jpl.Atom;
import jpl.Compound;
import jpl.JPL;
import jpl.Query;
import jpl.Term;
/**
* This class shows how to configure Logtalk in SWI or YAP using the Jpl library.
* You need to have the jpl jar in your classpath to compile and execute this file.
@pmoura
pmoura / interpolation.lgt
Last active September 14, 2018 17:26
Interpolation polymorphic example
% use the apply module instead of the Logtalk meta
% library object to illustrate interoperability
:- use_module(library(apply)).
:- use_module(library(apply_macros)).
:- category(math).
:- public(interpolate/4).
interpolate(K1, X1, X2, Y) :-
@pmoura
pmoura / points.lgt
Last active June 21, 2018 09:26
Sane parametric object implementation of points and color points
% Logtalk parametric entity parameters are _logical variables_
% that are implicitly shared by all entity predicates.
%
% Parameters can be accessed using either the parameter/2 built-in
% predicate or by using _parameter variables_. Here we use the
% latter to decouple parameter access from parameter position.
%
% As ancestors should not force a specific parameter order on the
% descendants (which would be a code smell), each prototype provides
% a protected predicate (that can be overriden) for constructing a