2007-06-12 11:39:47 +01:00
|
|
|
================================================================
|
|
|
|
Logtalk - Open source object-oriented logic programming language
|
2007-11-06 01:50:09 +00:00
|
|
|
Release 2.30.7
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2007-01-10 12:46:10 +00:00
|
|
|
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
|
2007-06-12 11:39:47 +01:00
|
|
|
================================================================
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2007-03-28 23:44:31 +01:00
|
|
|
% start by loading the example and the required library files:
|
2004-11-29 20:36:31 +00:00
|
|
|
|
|
|
|
| ?- logtalk_load(metapredicates(loader)).
|
2004-06-13 19:04:28 +01:00
|
|
|
...
|
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
% note that "user" is a pseudo-object representing the Prolog database
|
|
|
|
% this implies that the integer comparisons are done using the standard
|
|
|
|
% Prolog built-in predicates
|
|
|
|
|
|
|
|
| ?- sort(user)::sort([3, 1, 4, 2, 9], Sorted).
|
|
|
|
|
|
|
|
call: partition([1,4,2,9],3,_358,_359)
|
|
|
|
exit: partition([1,4,2,9],3,[1,2],[4,9])
|
|
|
|
call: sort([1,2],_740)
|
|
|
|
call: partition([2],1,_967,_968)
|
|
|
|
exit: partition([2],1,[],[2])
|
|
|
|
call: sort([],_1300)
|
|
|
|
exit: sort([],[])
|
|
|
|
call: sort([2],_1539)
|
|
|
|
call: partition([],2,_1765,_1766)
|
|
|
|
exit: partition([],2,[],[])
|
|
|
|
call: sort([],_2093)
|
|
|
|
exit: sort([],[])
|
|
|
|
call: sort([],_2332)
|
|
|
|
exit: sort([],[])
|
|
|
|
exit: sort([2],[2])
|
|
|
|
exit: sort([1,2],[1,2])
|
|
|
|
call: sort([4,9],_2831)
|
|
|
|
call: partition([9],4,_3058,_3059)
|
|
|
|
exit: partition([9],4,[],[9])
|
|
|
|
call: sort([],_3391)
|
|
|
|
exit: sort([],[])
|
|
|
|
call: sort([9],_3630)
|
|
|
|
call: partition([],9,_3856,_3857)
|
|
|
|
exit: partition([],9,[],[])
|
|
|
|
call: sort([],_4184)
|
|
|
|
exit: sort([],[])
|
|
|
|
call: sort([],_4423)
|
|
|
|
exit: sort([],[])
|
|
|
|
exit: sort([9],[9])
|
|
|
|
exit: sort([4,9],[4,9])
|
|
|
|
|
|
|
|
Sorted = [1,2,3,4,9] ?
|
|
|
|
|
|
|
|
yes
|
2006-12-28 13:03:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
% call the meta-predicate apply/2 directly:
|
|
|
|
|
|
|
|
| ?- meta::test_this.
|
|
|
|
|
|
|
|
1, meta
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% send an apply/2 message to self:
|
|
|
|
|
|
|
|
| ?- desc::test_self.
|
|
|
|
|
|
|
|
2, desc
|
|
|
|
|
|
|
|
yes
|
|
|
|
|
|
|
|
|
|
|
|
% send an apply/2 message from another object:
|
|
|
|
|
|
|
|
| ?- test::test_obj.
|
|
|
|
|
|
|
|
3, test
|
|
|
|
|
|
|
|
yes
|