Re: Prolog OOP (prologonlinereference.org)
- From: "Paulo Moura" <pjlmoura@xxxxxxxxx>
- Date: 19 Jun 2006 00:54:44 -0700
Mauro DiNuzzo wrote:
...
For example, system can be configured in order to allow things like the
following:
| ?- [1,2,3]:length(L).
L = 3
yes
In other Prolog object-oriented extensions (e.g. OL(P), L&O, SICStus
Objects, or Logtalk) similar functionality is achieved using parametric
objects, which allows you to associate predicates with compound terms
(such as ./2 above). For example, in Logtalk you would write:
:- object(.(_, _)). % note that the [X, Y, ...] notation
% is just syntactic sugar for ./2
:- public(member/1).
member(Element) :-
this(List),
member(Element, List).
member(Element, [Element| _]).
member(Element, [_| Tail]) :-
member(Element, Tail).
:- end_object.
Compiling and loading this object allows similar queries to your
example above:
?- [1,2,3]::member(X).
X = 1 ;
X = 2 ;
X = 3 ;
No
Cheers,
Paulo
.
- Follow-Ups:
- Re: Prolog OOP (prologonlinereference.org)
- From: Mauro DiNuzzo
- Re: Prolog OOP (prologonlinereference.org)
- References:
- Prolog OOP (prologonlinereference.org)
- From: Mauro DiNuzzo
- Prolog OOP (prologonlinereference.org)
- Prev by Date: Prolog OOP (prologonlinereference.org)
- Next by Date: Commercial Prolog Position Available
- Previous by thread: Prolog OOP (prologonlinereference.org)
- Next by thread: Re: Prolog OOP (prologonlinereference.org)
- Index(es):