diff --git a/Logtalk/CUSTOMIZE.txt b/Logtalk/CUSTOMIZE.txt index 64681d805..c6f9c756f 100644 --- a/Logtalk/CUSTOMIZE.txt +++ b/Logtalk/CUSTOMIZE.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This file contains detailed instructions for customizing your Logtalk @@ -31,14 +31,14 @@ operating-system requirements. For details, see the "libpaths/NOTES.txt" file. Logtalk interfaces with a specific Prolog compiler via a configuration file that can be found on the "configs" folder inside your Logtalk user folder. -These configuration files can be customized by changing the values of the -default flags that are used by Logtalk when compiling source files. For a -full description of these default flags, consult the "Running and debugging -Logtalk programs" section of the User Manual. Some of the default flags that -you may want to change include: "smart_compilation", "startup_message", -"portability", "underscore_vars", "altdirs", and the set of documentation- -related flags ("xmldocs", "xslfile", "xmlspec", and "xmlsref"). Be sure to -read the "configs/NOTES.txt" file for Prolog specific notes; some Prolog +These configuration files can be customized by changing the default values +of the flags that are used by Logtalk when compiling source files. For a +full description of these flags, consult the "Running and debugging Logtalk +programs" section of the User Manual. Some of the default flags that you may +want to change include: "smart_compilation", "startup_message", "altdirs", +"tmpdir", "portability", "underscore_vars", and the documentation-related +flags ("xmldocs", "xmldir", "xslfile", "xmlspec", and "xmlsref"). Be sure +to read the "configs/NOTES.txt" file for Prolog specific notes; some Prolog compilers do not support the whole range of compilation flag values. diff --git a/Logtalk/INSTALL.txt b/Logtalk/INSTALL.txt index 82d457fde..0202d6de3 100644 --- a/Logtalk/INSTALL.txt +++ b/Logtalk/INSTALL.txt @@ -1,17 +1,18 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ The recommended way of installing Logtalk is to use, whenever possible, one of the provided installers. This file contains detailed instructions for manual installation and configuration of Logtalk. You should also consult -the "scripts/NOTES.txt" file for a description of a set of shell scripts -that might be used for Logtalk installation on some operating-systems and -for easy Logtalk integration with popular Prolog compilers. +the "scripts/NOTES.txt" and "integration/NOTES.txt" files for a description +of a set of shell scripts that might be used for Logtalk installation on +some operating-systems and for easy Logtalk integration with popular Prolog +compilers. Note that the broad compatibility of Logtalk, both with Prolog compilers and operating-systems, together with all the possible user scenarios, means that @@ -47,21 +48,13 @@ directory can be copied to any location that its accessible by all the users for some reason, not feasible or desired). The "scripts" sub-directory contains shell scripts for easy installation of -Logtalk on MacOS X, Windows, Linux, and Unix-like (POSIX) operating systems -(see the "scripts/NOTES.txt" file for details). - ->> POSIX systems installation (starting from the Logtalk directory): +Logtalk on POSIX operating systems (see the "scripts/NOTES.txt" file for +details). Starting from the Logtalk directory, type: % cd scripts - % sudo ./lgt_install.sh + % sudo ./install.sh ->> Windows installation (starting from the Logtalk directory): - - C:\logtalk> cd scripts - C:\logtalk> cscript lgt_install.js - RESTART - -The "scripts/lgt_install.*" installation scripts make all files read-only in +This installation script makes all files read-only for non-admin users in order to avoid user tempering. This is a convenient setup for computer labs, given that making directories world-writable is a security risk. @@ -69,10 +62,10 @@ given that making directories world-writable is a security risk. 2. SETTING LOGTALK ENVIRONMENT VARIABLES You need to set two environment variables, LOGTALKHOME and LOGTALKUSER. The -environment variable LOGTALKHOME should point to the Logtalk installation +environment variable LOGTALKHOME should be set to the Logtalk installation directory. The environment variable LOGTALKUSER should point to a directory in your home directory where you want to store the user-specific Logtalk files -(for example, ~/logtalk). Both environment variables may be set for all users +(by default, ~/logtalk). Both environment variables may be set for all users by a user with administration privileges. The two environment variables can have the same value if you are the only Logtalk user on your computer and if you have full permissions to the Logtalk installation directory. In addition, @@ -103,13 +96,13 @@ Logtalk. >> Windows systems: In Windows 2000/XP, environment variables are defined using the System -properties control panel. If you are a system administrator, the "scripts/ -lgt_install.js" JScript install script sets the LOGTALKHOME environment -variable for all users and also sets the LOGTALKUSER environment variable -for the administrator user running the script. +properties control panel. If you are a system administrator, the Windows +GUI installer sets the LOGTALKHOME environment variable for all users and +also sets the LOGTALKUSER environment variable for the administrator user +running the installer. -3. COPYING THE LOGTALK USER-MODIFIABLE FILES TO USERS HOME DIRECTORIES +3. END-USER SETUP (COPYING LOGTALK USER-MODIFIABLE FILES TO USERS HOME DIRS) If you installed Logtalk on your home directory, then skip this step if you have set both Logtalk environment variables (LOGTALKHOME and LOGTALKUSER) to @@ -131,36 +124,27 @@ in the "scripts/NOTES.txt" file). The local copies made by the "cplgtdirs" scripts have both read and write permissions for the user running the script. When used with one of the -Prolog compilers for which an integration script is provided on the "scripts" -directory, this setup as the advantage of allowing each end-user to -independently customize default compilation options and library paths. +back-end Prolog compilers for which an integration script is provided on +the "integration" directory, this setup as the advantage of allowing each +end-user to independently customize default compilation options and library +paths. + +Windows (non-admin) users may also use the Logtalk GUI installer to setup +their Logtalk user folder and the LOGTALKUSER environment variable. 4. CREATING NEW PROLOG TOP-LEVELS FOR AUTOMATIC LOADING OF LOGTALK -Most Prolog compilers allows the user to define an initialization file that -is automatically consulted at startup. This initialization file may contain -directives for loading other files, such as the Logtalk configuration file -and the Logtalk compiler. The "$LOGTALKHOME/scripts" sub-directory contains -several scripts (named "make_*lgt.*") for automating the creation of these -initialization files for some Prolog compilers. In addition, be sure to read -the "configs/NOTES.txt" file notes on the Prolog compilers that you intend to -use. There are also "makeall_lgt.*" scripts that try to run all the individual -"make_*lgt.*" scripts: - ->> POSIX systems: - - % cd $LOGTALKHOME/scripts - % sudo ./makeall_lgt.sh - ->> Windows: - - C:\> cd %LOGTALKHOME%\scripts - C:\> cscript makeall_lgt.js - -This assumes that your favorite Prolog compilers are supported by the -"make_*lgt.*" scripts. If that is not the case, don't worry: just follow -the steps described in the "QUICK_START.txt" file. +Most Prolog compilers allows the user to define an initialization file +that is automatically consulted at startup. These initialization files +may contain directives for loading other files, such as the Logtalk +configuration file and the Logtalk compiler. The "$LOGTALKHOME/integration" +sub-directory contains several pre-made scripts (named "*lgt.*") for running +Logtalk with selected back-end Prolog compilers. You can use these scripts +as examples when creating initialization files for other Prolog compilers. +Be sure to read the "configs/NOTES.txt" file notes on the Prolog compilers +that you intend to use. You may also simply follow the steps described in +the "QUICK_START.txt" file. 5. CUSTOMIZING LOGTALK diff --git a/Logtalk/QUICK_START.txt b/Logtalk/QUICK_START.txt index 97162d7b5..c0852a01a 100644 --- a/Logtalk/QUICK_START.txt +++ b/Logtalk/QUICK_START.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ Quick start @@ -22,6 +22,26 @@ favorite Prolog compiler. In this case, skip the instructions below for starting up Logtalk and go straight to the instructions on running the examples. +On POSIX operating-systems, the following shell scripts are installed +by default for running Logtalk with selected back-end Prolog compilers +(which must be properly installed for running the scripts!): + + B-Prolog: bplgt (first run must use sudo) + CIAO: ciaolgt (first run must use sudo) + CxProlog: cxlgt + ECLiPSe: eclipselgt + GNU Prolog: gplgt + K-Prolog: plclgt + SICStus Prolog: sicstuslgt + SWI-Prolog: swilgt + XSB: xsblgt (first run must use sudo) + YAP: yaplgt + +On Windows systems, shortcuts for running Logtalk with selected back-end +Prolog compilers are created on the "Start Menu/Programs/Logtalk" menu. +If you get an unexpected failure when using one of the Prolog integration +scripts, consult the "configs/NOTES.txt" file for compatibility notes. + 2. Open the "manuals/index.html" file with a web browser. 3. Select the "Tutorial" link. This will provide you with a basic @@ -33,7 +53,8 @@ programs" links. This will provide you with a basic understanding of how to start Logtalk as well as how to compile and load Logtalk code. -Assuming that Logtalk supports your Prolog compiler: +In case a manual installation is necessary, and assuming that Logtalk +supports your Prolog compiler, apply the following steps: 1. Read the "NOTES.txt" file in the "configs" sub-directory to check if any patch or workaround is needed for your compiler. diff --git a/Logtalk/README.txt b/Logtalk/README.txt index e5c9a7da0..26f57f881 100644 --- a/Logtalk/README.txt +++ b/Logtalk/README.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ CONTENTS @@ -43,7 +43,8 @@ about Logtalk. 3. REGISTRATION To register as a Logtalk user either use the registration form found at -the Logtalk web site or send an email message to: +the Logtalk web site, http://logtalk.org/regform.html, or send an email +message to: registration@logtalk.org @@ -56,25 +57,7 @@ platforms (mac, pc, unix,...) (optional) 4. SUPPORT -Logtalk support is available for registered users via email to -support@logtalk.org. - -At the URL http://logtalk.org/bugs.html you can find a list of known -problems and download bug fixes. The latest news about Logtalk are -available at the URL http://logtalk.org/news.html. - -There is also a mailing list, "logtalk", used to announce new releases and -bug fixes and for discussion between registered Logtalk users, that you -may subscribe. For instructions on how to subscribe, please visit the web -page: - - http://lserv.ci.uc.pt/mailman/listinfo/logtalk - -or send an email message to: - - logtalk-request@lserv.ci.uc.pt - -with just the word "help" in the subject or in the message body. +For support options, please consult the page http://logtalk.org/support.html. 5. INSTALLATION diff --git a/Logtalk/RELEASE_NOTES.txt b/Logtalk/RELEASE_NOTES.txt index 140ab130e..a301e3987 100644 --- a/Logtalk/RELEASE_NOTES.txt +++ b/Logtalk/RELEASE_NOTES.txt @@ -1,18 +1,185 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ RELEASE NOTES ============= +2.30.1 - June 12, 2007 + + Added a new, experimental control construct, :/1, for calling imported + category predicates without using message sending mechanisms. + + Added preliminary support for static binding when calling imported + category using the new :/1 control construct for categories compiled + and loaded using the compiler option "reload(skip)". + + Added a new control construct, < + ( integer(Length) -> Length >= 0, mod_make_list(Length, List) - ; - mod_length(List, 0, Length). + ; mod_length(List, 0, Length) + ). mod_make_list(0, []):- diff --git a/Logtalk/examples/benchmarks/objects.lgt b/Logtalk/examples/benchmarks/objects.lgt new file mode 100644 index 000000000..e645b27d2 --- /dev/null +++ b/Logtalk/examples/benchmarks/objects.lgt @@ -0,0 +1,60 @@ + +:- object(object, + imports(category)). + + :- info([ + version is 3.0, + author is 'Paulo Moura', + date is 2007/06/11, + comment is 'Example object for benchmarking library predicate calls and imported category predicate calls.']). + + :- public(length/2). + + length(List, Length) :- + length(List, 0, Length). + + length([], Length, Length). + length([_| Tail], Acc, Length) :- + Acc2 is Acc + 1, + length(Tail, Acc2, Length). + + :- public(ctg_self/0). + + % call an imported category predicate by sending a message to self; + % performance will depend on the distance between "self" and "this" + % (always uses dynamic binding) + ctg_self :- + ::ctg_pred. + + :- public(ctg_direct/0). + + % call an imported category predicate directly by using the :/1 control construct; + % (static binding may be used, depending on how the category is compiled) + ctg_direct :- + :ctg_pred. + +:- end_object. + + +:- object(descendant, + extends(object)). + + :- info([ + version is 1.0, + author is 'Paulo Moura', + date is 2007/04/17, + comment is 'Example object used for simulating a small hierarchy.']). + +:- end_object. + + +:- object(leaf, + extends(descendant)). + + :- info([ + version is 1.0, + author is 'Paulo Moura', + date is 2007/04/17, + comment is 'Example object used for simulating a small hierarchy.']). + +:- end_object. diff --git a/Logtalk/examples/benchmarks/plain.lgt b/Logtalk/examples/benchmarks/plain.lgt index 94bf36a5d..a24f8c373 100644 --- a/Logtalk/examples/benchmarks/plain.lgt +++ b/Logtalk/examples/benchmarks/plain.lgt @@ -1,36 +1,42 @@ my_length(List, Length) :- - integer(Length) -> - Length >= 0, - my_make_list(Length, List) - ; - my_length(List, 0, Length). - - -my_make_list(0, []):- - !. - -my_make_list(N, [_| Tail]):- - M is N-1, - my_make_list(M, Tail). - + my_length(List, 0, Length). my_length([], Length, Length). - my_length([_| Tail], Acc, Length) :- Acc2 is Acc + 1, my_length(Tail, Acc2, Length). -:- dynamic(pred_plain/0). +:- dynamic(pred_plain/1). -db_test_plain :- - repeat(100), - assertz(pred_plain), - fail. +plain_dyndb(N) :- + assertz(pred_plain(N)), + retract(pred_plain(N)). -db_test_plain :- - retract(pred_plain), - fail. -db_test_plain. +my_between(Lower, _, Lower). +my_between(Lower, Upper, Integer) :- + Lower < Upper, + Next is Lower + 1, + my_between(Next, Upper, Integer). + + +my_repeat(_). +my_repeat(N) :- + N > 1, + N2 is N - 1, + my_repeat(N2). + + +% generate a list containing the first N non-negative integers + +generate_list(N, List) :- + generate_list(0, N, List). + +generate_list(N, N, []) :- + !. +generate_list(M, N, [M| Ms]) :- + M < N, + M2 is M + 1, + generate_list(M2, N, Ms). diff --git a/Logtalk/examples/birds/NOTES.txt b/Logtalk/examples/birds/NOTES.txt index 46ad6082f..cbe38d4f8 100644 --- a/Logtalk/examples/birds/NOTES.txt +++ b/Logtalk/examples/birds/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/birds/SCRIPT.txt b/Logtalk/examples/birds/SCRIPT.txt index 98b2dc738..9fa91cead 100644 --- a/Logtalk/examples/birds/SCRIPT.txt +++ b/Logtalk/examples/birds/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/bottles/NOTES.txt b/Logtalk/examples/bottles/NOTES.txt index e78e96699..6fba898f6 100644 --- a/Logtalk/examples/bottles/NOTES.txt +++ b/Logtalk/examples/bottles/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/bottles/SCRIPT.txt b/Logtalk/examples/bottles/SCRIPT.txt index 321b849e8..2fb154abd 100644 --- a/Logtalk/examples/bottles/SCRIPT.txt +++ b/Logtalk/examples/bottles/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % just load the example, which contains an initialization/1 directive diff --git a/Logtalk/examples/bricks/NOTES.txt b/Logtalk/examples/bricks/NOTES.txt index ecedf04f7..8dc13497c 100644 --- a/Logtalk/examples/bricks/NOTES.txt +++ b/Logtalk/examples/bricks/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/bricks/SCRIPT.txt b/Logtalk/examples/bricks/SCRIPT.txt index c9dadd8b8..bb9173dcb 100644 --- a/Logtalk/examples/bricks/SCRIPT.txt +++ b/Logtalk/examples/bricks/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/classvars/NOTES.txt b/Logtalk/examples/classvars/NOTES.txt index 750cab058..64c580b8f 100644 --- a/Logtalk/examples/classvars/NOTES.txt +++ b/Logtalk/examples/classvars/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/classvars/SCRIPT.txt b/Logtalk/examples/classvars/SCRIPT.txt index 956379315..d8267583d 100644 --- a/Logtalk/examples/classvars/SCRIPT.txt +++ b/Logtalk/examples/classvars/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/dcgs/NOTES.txt b/Logtalk/examples/dcgs/NOTES.txt index 5f84e9be8..d6892a63e 100644 --- a/Logtalk/examples/dcgs/NOTES.txt +++ b/Logtalk/examples/dcgs/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/dcgs/SCRIPT.txt b/Logtalk/examples/dcgs/SCRIPT.txt index 6bed6e22e..2900268cd 100644 --- a/Logtalk/examples/dcgs/SCRIPT.txt +++ b/Logtalk/examples/dcgs/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/diamonds/NOTES.txt b/Logtalk/examples/diamonds/NOTES.txt index b23d94bcf..0dd26c729 100644 --- a/Logtalk/examples/diamonds/NOTES.txt +++ b/Logtalk/examples/diamonds/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/diamonds/SCRIPT.txt b/Logtalk/examples/diamonds/SCRIPT.txt index d99f9faf6..fd8c9cc20 100644 --- a/Logtalk/examples/diamonds/SCRIPT.txt +++ b/Logtalk/examples/diamonds/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/dynpred/NOTES.txt b/Logtalk/examples/dynpred/NOTES.txt index 22547cf05..7b0bed006 100644 --- a/Logtalk/examples/dynpred/NOTES.txt +++ b/Logtalk/examples/dynpred/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/dynpred/SCRIPT.txt b/Logtalk/examples/dynpred/SCRIPT.txt index 7825a77cd..31bb35167 100644 --- a/Logtalk/examples/dynpred/SCRIPT.txt +++ b/Logtalk/examples/dynpred/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/encodings/NOTES.txt b/Logtalk/examples/encodings/NOTES.txt index 5579e3227..ec9ddffcb 100644 --- a/Logtalk/examples/encodings/NOTES.txt +++ b/Logtalk/examples/encodings/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/encodings/SCRIPT.txt b/Logtalk/examples/encodings/SCRIPT.txt index 0634962e7..09a0362fb 100644 --- a/Logtalk/examples/encodings/SCRIPT.txt +++ b/Logtalk/examples/encodings/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/engines/NOTES.txt b/Logtalk/examples/engines/NOTES.txt index 2e306e815..c7b2a569e 100644 --- a/Logtalk/examples/engines/NOTES.txt +++ b/Logtalk/examples/engines/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/engines/SCRIPT.txt b/Logtalk/examples/engines/SCRIPT.txt index ef747e02d..c5323f74a 100644 --- a/Logtalk/examples/engines/SCRIPT.txt +++ b/Logtalk/examples/engines/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/errors/NOTES.txt b/Logtalk/examples/errors/NOTES.txt index 2e5c8f8f2..aef98284d 100644 --- a/Logtalk/examples/errors/NOTES.txt +++ b/Logtalk/examples/errors/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example, please see the SCRIPT file. diff --git a/Logtalk/examples/errors/SCRIPT.txt b/Logtalk/examples/errors/SCRIPT.txt index a25a82b62..812ece52a 100644 --- a/Logtalk/examples/errors/SCRIPT.txt +++ b/Logtalk/examples/errors/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ The entities on this example are divided in two sets. The first set diff --git a/Logtalk/examples/expansion/NOTES.txt b/Logtalk/examples/expansion/NOTES.txt index 2e306e815..c7b2a569e 100644 --- a/Logtalk/examples/expansion/NOTES.txt +++ b/Logtalk/examples/expansion/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/expansion/SCRIPT.txt b/Logtalk/examples/expansion/SCRIPT.txt index 841bcd269..371fedfe5 100644 --- a/Logtalk/examples/expansion/SCRIPT.txt +++ b/Logtalk/examples/expansion/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/hello_world/NOTES.txt b/Logtalk/examples/hello_world/NOTES.txt index 39fab0d3a..a288a28a1 100644 --- a/Logtalk/examples/hello_world/NOTES.txt +++ b/Logtalk/examples/hello_world/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ No self-respected programming language could do without a "Hello diff --git a/Logtalk/examples/hello_world/SCRIPT.txt b/Logtalk/examples/hello_world/SCRIPT.txt index a57d83e04..901655819 100644 --- a/Logtalk/examples/hello_world/SCRIPT.txt +++ b/Logtalk/examples/hello_world/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % just load the example and check the output message: diff --git a/Logtalk/examples/hooks/NOTES.txt b/Logtalk/examples/hooks/NOTES.txt index 23c840ff4..988a201a0 100644 --- a/Logtalk/examples/hooks/NOTES.txt +++ b/Logtalk/examples/hooks/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/hooks/SCRIPT.txt b/Logtalk/examples/hooks/SCRIPT.txt index 7de1b33a4..b48ee9bf3 100644 --- a/Logtalk/examples/hooks/SCRIPT.txt +++ b/Logtalk/examples/hooks/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/inheritance/NOTES.txt b/Logtalk/examples/inheritance/NOTES.txt index c0888ba5d..755010ae7 100644 --- a/Logtalk/examples/inheritance/NOTES.txt +++ b/Logtalk/examples/inheritance/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/inheritance/SCRIPT.txt b/Logtalk/examples/inheritance/SCRIPT.txt index adf4cb131..8444e48f9 100644 --- a/Logtalk/examples/inheritance/SCRIPT.txt +++ b/Logtalk/examples/inheritance/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/instmethods/NOTES.txt b/Logtalk/examples/instmethods/NOTES.txt index 7d12a2997..301b29895 100644 --- a/Logtalk/examples/instmethods/NOTES.txt +++ b/Logtalk/examples/instmethods/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/instmethods/SCRIPT.txt b/Logtalk/examples/instmethods/SCRIPT.txt index 512fd33e9..92d34337e 100644 --- a/Logtalk/examples/instmethods/SCRIPT.txt +++ b/Logtalk/examples/instmethods/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/lo/NOTES.txt b/Logtalk/examples/lo/NOTES.txt index ae86bd2ff..33511f0cb 100644 --- a/Logtalk/examples/lo/NOTES.txt +++ b/Logtalk/examples/lo/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ The examples in this folder are adopted from the Logic&Objects system diff --git a/Logtalk/examples/lo/planner/NOTES.txt b/Logtalk/examples/lo/planner/NOTES.txt index 0c2022b2c..e35ae6bdc 100644 --- a/Logtalk/examples/lo/planner/NOTES.txt +++ b/Logtalk/examples/lo/planner/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/lo/planner/SCRIPT.txt b/Logtalk/examples/lo/planner/SCRIPT.txt index 746aac493..2c4c34732 100644 --- a/Logtalk/examples/lo/planner/SCRIPT.txt +++ b/Logtalk/examples/lo/planner/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/lo/travellers/NOTES.txt b/Logtalk/examples/lo/travellers/NOTES.txt index 0c2022b2c..e35ae6bdc 100644 --- a/Logtalk/examples/lo/travellers/NOTES.txt +++ b/Logtalk/examples/lo/travellers/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/lo/travellers/SCRIPT.txt b/Logtalk/examples/lo/travellers/SCRIPT.txt index 3a7f4dfb0..73daa1b94 100644 --- a/Logtalk/examples/lo/travellers/SCRIPT.txt +++ b/Logtalk/examples/lo/travellers/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/logic/NOTES.txt b/Logtalk/examples/logic/NOTES.txt index 9ebe5c5a8..88981489d 100644 --- a/Logtalk/examples/logic/NOTES.txt +++ b/Logtalk/examples/logic/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/logic/SCRIPT.txt b/Logtalk/examples/logic/SCRIPT.txt index 812aa65f2..1720fc974 100644 --- a/Logtalk/examples/logic/SCRIPT.txt +++ b/Logtalk/examples/logic/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/lpa/NOTES.txt b/Logtalk/examples/lpa/NOTES.txt index 06469310a..a943643ce 100644 --- a/Logtalk/examples/lpa/NOTES.txt +++ b/Logtalk/examples/lpa/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This directory contains examples adapted from the LPA Prolog++ Reference Manual. This manual can be downloaded from the LPA web diff --git a/Logtalk/examples/lpa/faults/NOTES.txt b/Logtalk/examples/lpa/faults/NOTES.txt index 2b89991d1..dd159359a 100644 --- a/Logtalk/examples/lpa/faults/NOTES.txt +++ b/Logtalk/examples/lpa/faults/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This example is an adaptation of the LPA Prolog++ faults example. diff --git a/Logtalk/examples/lpa/faults/SCRIPT.txt b/Logtalk/examples/lpa/faults/SCRIPT.txt index 0635c6132..1aacf2af4 100644 --- a/Logtalk/examples/lpa/faults/SCRIPT.txt +++ b/Logtalk/examples/lpa/faults/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/lpa/timetables/NOTES.txt b/Logtalk/examples/lpa/timetables/NOTES.txt index 765cdbfee..dff5931e4 100755 --- a/Logtalk/examples/lpa/timetables/NOTES.txt +++ b/Logtalk/examples/lpa/timetables/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This example is an adaptation of the LPA Prolog++ timetables example. diff --git a/Logtalk/examples/lpa/timetables/SCRIPT.txt b/Logtalk/examples/lpa/timetables/SCRIPT.txt index d1489b6bb..5a1b5d8c2 100755 --- a/Logtalk/examples/lpa/timetables/SCRIPT.txt +++ b/Logtalk/examples/lpa/timetables/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/metainterpreters/NOTES.txt b/Logtalk/examples/metainterpreters/NOTES.txt index 96274c850..1f5f70b9a 100644 --- a/Logtalk/examples/metainterpreters/NOTES.txt +++ b/Logtalk/examples/metainterpreters/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/metainterpreters/SCRIPT.txt b/Logtalk/examples/metainterpreters/SCRIPT.txt index 5a27dfbb2..9cd648a51 100644 --- a/Logtalk/examples/metainterpreters/SCRIPT.txt +++ b/Logtalk/examples/metainterpreters/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/metapredicates/NOTES.txt b/Logtalk/examples/metapredicates/NOTES.txt index 836ed1e3c..fec1c4cd1 100644 --- a/Logtalk/examples/metapredicates/NOTES.txt +++ b/Logtalk/examples/metapredicates/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/metapredicates/SCRIPT.txt b/Logtalk/examples/metapredicates/SCRIPT.txt index 09a9c244e..939f857ff 100644 --- a/Logtalk/examples/metapredicates/SCRIPT.txt +++ b/Logtalk/examples/metapredicates/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/mi/NOTES.txt b/Logtalk/examples/mi/NOTES.txt index 026220e4e..53d547c70 100644 --- a/Logtalk/examples/mi/NOTES.txt +++ b/Logtalk/examples/mi/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/mi/SCRIPT.txt b/Logtalk/examples/mi/SCRIPT.txt index 3635a5c34..b926ead63 100644 --- a/Logtalk/examples/mi/SCRIPT.txt +++ b/Logtalk/examples/mi/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/miscellaneous/NOTES.txt b/Logtalk/examples/miscellaneous/NOTES.txt index 37268a69c..ff3b03542 100644 --- a/Logtalk/examples/miscellaneous/NOTES.txt +++ b/Logtalk/examples/miscellaneous/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/miscellaneous/SCRIPT.txt b/Logtalk/examples/miscellaneous/SCRIPT.txt index 9bdffd436..0134803bc 100644 --- a/Logtalk/examples/miscellaneous/SCRIPT.txt +++ b/Logtalk/examples/miscellaneous/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/modules/NOTES.txt b/Logtalk/examples/modules/NOTES.txt index 84e731d8b..985e00e9d 100644 --- a/Logtalk/examples/modules/NOTES.txt +++ b/Logtalk/examples/modules/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/modules/SCRIPT.txt b/Logtalk/examples/modules/SCRIPT.txt index ac0470d39..66289d171 100644 --- a/Logtalk/examples/modules/SCRIPT.txt +++ b/Logtalk/examples/modules/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by compiling and loading the Prolog module files as objects: diff --git a/Logtalk/examples/msglog/NOTES.txt b/Logtalk/examples/msglog/NOTES.txt index 5a898ab88..b37ec55b3 100644 --- a/Logtalk/examples/msglog/NOTES.txt +++ b/Logtalk/examples/msglog/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/msglog/SCRIPT.txt b/Logtalk/examples/msglog/SCRIPT.txt index fe01a10d7..3b2ad9398 100644 --- a/Logtalk/examples/msglog/SCRIPT.txt +++ b/Logtalk/examples/msglog/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/operators/NOTES.txt b/Logtalk/examples/operators/NOTES.txt index 3fd2839cf..c376e5eab 100644 --- a/Logtalk/examples/operators/NOTES.txt +++ b/Logtalk/examples/operators/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/operators/SCRIPT.txt b/Logtalk/examples/operators/SCRIPT.txt index c9d74fc4c..2dad2ffa7 100644 --- a/Logtalk/examples/operators/SCRIPT.txt +++ b/Logtalk/examples/operators/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/parametric/NOTES.txt b/Logtalk/examples/parametric/NOTES.txt index 575a4bd51..71f007fe9 100644 --- a/Logtalk/examples/parametric/NOTES.txt +++ b/Logtalk/examples/parametric/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/parametric/SCRIPT.txt b/Logtalk/examples/parametric/SCRIPT.txt index baec689c3..5e8b2c233 100644 --- a/Logtalk/examples/parametric/SCRIPT.txt +++ b/Logtalk/examples/parametric/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/points/NOTES.txt b/Logtalk/examples/points/NOTES.txt index 6676f1e67..e4e3ca66b 100644 --- a/Logtalk/examples/points/NOTES.txt +++ b/Logtalk/examples/points/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/points/SCRIPT.txt b/Logtalk/examples/points/SCRIPT.txt index 3aab14b7f..0e784a100 100644 --- a/Logtalk/examples/points/SCRIPT.txt +++ b/Logtalk/examples/points/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/polygons/NOTES.txt b/Logtalk/examples/polygons/NOTES.txt index 9e6580484..9c5f18242 100644 --- a/Logtalk/examples/polygons/NOTES.txt +++ b/Logtalk/examples/polygons/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/polygons/SCRIPT.txt b/Logtalk/examples/polygons/SCRIPT.txt index cff6ae0fa..36a72c82f 100644 --- a/Logtalk/examples/polygons/SCRIPT.txt +++ b/Logtalk/examples/polygons/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/profiling/NOTES.txt b/Logtalk/examples/profiling/NOTES.txt index bb6f8dc25..2b1a76f43 100644 --- a/Logtalk/examples/profiling/NOTES.txt +++ b/Logtalk/examples/profiling/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/profiling/SCRIPT.txt b/Logtalk/examples/profiling/SCRIPT.txt index aa6bd84a5..ba7da80f3 100644 --- a/Logtalk/examples/profiling/SCRIPT.txt +++ b/Logtalk/examples/profiling/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/proxies/NOTES.txt b/Logtalk/examples/proxies/NOTES.txt index 7a9d84da2..0c10cf577 100644 --- a/Logtalk/examples/proxies/NOTES.txt +++ b/Logtalk/examples/proxies/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/proxies/SCRIPT.txt b/Logtalk/examples/proxies/SCRIPT.txt index a618cad62..e1a2d8089 100644 --- a/Logtalk/examples/proxies/SCRIPT.txt +++ b/Logtalk/examples/proxies/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/puzzles/NOTES.txt b/Logtalk/examples/puzzles/NOTES.txt index caf13d8c2..11d38c995 100644 --- a/Logtalk/examples/puzzles/NOTES.txt +++ b/Logtalk/examples/puzzles/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/puzzles/SCRIPT.txt b/Logtalk/examples/puzzles/SCRIPT.txt index 45ed1e7bd..84475ae01 100644 --- a/Logtalk/examples/puzzles/SCRIPT.txt +++ b/Logtalk/examples/puzzles/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/reflection/NOTES.txt b/Logtalk/examples/reflection/NOTES.txt index 5b9296556..6af231ce2 100644 --- a/Logtalk/examples/reflection/NOTES.txt +++ b/Logtalk/examples/reflection/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ Run this example with no other examples loaded at the same time. diff --git a/Logtalk/examples/reflection/SCRIPT.txt b/Logtalk/examples/reflection/SCRIPT.txt index 1aa530888..c534e2773 100644 --- a/Logtalk/examples/reflection/SCRIPT.txt +++ b/Logtalk/examples/reflection/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/relations/NOTES.txt b/Logtalk/examples/relations/NOTES.txt index 95f1e36d4..fd30c0dfe 100644 --- a/Logtalk/examples/relations/NOTES.txt +++ b/Logtalk/examples/relations/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/relations/SCRIPT.txt b/Logtalk/examples/relations/SCRIPT.txt index 7f073739c..213acac38 100644 --- a/Logtalk/examples/relations/SCRIPT.txt +++ b/Logtalk/examples/relations/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/roots/NOTES.txt b/Logtalk/examples/roots/NOTES.txt index 99ceaf687..07e3512f4 100644 --- a/Logtalk/examples/roots/NOTES.txt +++ b/Logtalk/examples/roots/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/roots/SCRIPT.txt b/Logtalk/examples/roots/SCRIPT.txt index beba13fc0..930091894 100644 --- a/Logtalk/examples/roots/SCRIPT.txt +++ b/Logtalk/examples/roots/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/searching/NOTES.txt b/Logtalk/examples/searching/NOTES.txt index 610b76dba..585a99181 100644 --- a/Logtalk/examples/searching/NOTES.txt +++ b/Logtalk/examples/searching/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/searching/SCRIPT.txt b/Logtalk/examples/searching/SCRIPT.txt index 1d22420a2..d831e2467 100644 --- a/Logtalk/examples/searching/SCRIPT.txt +++ b/Logtalk/examples/searching/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/searching/salt3.lgt b/Logtalk/examples/searching/salt3.lgt index f8bb2f0b2..b3e41f58b 100755 --- a/Logtalk/examples/searching/salt3.lgt +++ b/Logtalk/examples/searching/salt3.lgt @@ -1,119 +1,119 @@ -/* - Salt state-space search problem - - 2003 Portuguese National Logical Programming Contest problem - http://paginas.fe.up.pt/~eol/LP/0304/documents/Exercicios_CNPL.PDF - -Introduction: - Mr Silva sells salt. He has to measure the quantity requested by his - customers by using two measures and an accumulator. Neither has any - measuring markers. Those measures can easily be broken and he has to - replace them each time it happens. More, a substitution can be made - by a measure with a different capacity than the one being replaced. - -Objective: - To produce a program, given the capacity of two measures and the - intended quantity, which helps Mr. Silva knowing if it is possible - to obtain the amount requested by his customer, and if so, measuring - the intended quantity in the least amount of steps. - -Remarks: - This problem is similar to the Water Jug's' problem. It is more general, - seeing that the Water Jug's problem uses static values for the jugs - capacities and the final goal. -*/ - - -:- object(salt(_Acumulator, _Measure1, _Measure2), - instantiates(state_space)). - - - :- info([ - version is 1.0, - author is 'Paula Marisa Sampaio', - date is 2005/06/08, - comment is 'Salt state-space search problem.']). - - - % each state is represented by a compound term with four arguments: (Acumulator, Measure1, Measure2, Step) - - initial_state(initial, (0, 0, 0, all_empty)). - - - % the intended salt quantity must end up on the acumulator - - goal_state(acumulator, (Acumulator, _, _, _)) :- - parameter(1, Acumulator). - - - % state transitions: - - - % emptying a measure into the accumulator - - next_state((Acc, X, Y, _), (NewAcc, 0, Y, transfer(m1, acc))) :- - X > 0, - NewAcc is Acc + X. - - next_state((Acc, X, Y, _), (NewAcc, X, 0, transfer(m2, acc))) :- - Y > 0, - NewAcc is Acc + Y. - - - % filling up of one of the measures - - next_state((Acc, X, Y, Step), (Acc, MaxX, Y, fill(m1))) :- - parameter(2, MaxX), - X < MaxX, - Step \= empty(m1). - - next_state((Acc, X, Y, Step), (Acc, X, MaxY, fill(m2))) :- - parameter(3, MaxY), - Y < MaxY, - Step \= empty(m2). - - - % either pouring of a measure into the other till it is filled up - % or all content of a measure into the other one - - next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m2, m1))) :- - parameter(2, MaxX), - Y > 0, - X < MaxX, - (X + Y >= MaxX -> - W = MaxX, - Z is Y - (MaxX - X) - ; - W is X + Y, - Z = 0 - ). - - next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m1, m2))) :- - parameter(3, MaxY), - X > 0, - Y < MaxY, - (X + Y >= MaxY -> - W is X - (MaxY - Y), - Z = MaxY - ; - W = 0, - Z is X + Y - ). - - - % throwing out the contents of a measure; does not afect the accumulator - - next_state((Acc, X, Y, Step), (Acc, 0, Y, empty(m1))) :- - X > 0, - Step \= fill(m1). - - next_state((Acc, X, Y, Step), (Acc, X, 0, empty(m2))) :- - Y > 0, - Step \= fill(m2). - - - print_state((Acc, X, Y, Step)) :- - write('('), write((Acc, X, Y)), write(') '), write(Step), nl. - - -:- end_object. +/* + Salt state-space search problem + + 2003 Portuguese National Logical Programming Contest problem + http://paginas.fe.up.pt/~eol/LP/0304/documents/Exercicios_CNPL.PDF + +Introduction: + Mr Silva sells salt. He has to measure the quantity requested by his + customers by using two measures and an accumulator. Neither has any + measuring markers. Those measures can easily be broken and he has to + replace them each time it happens. More, a substitution can be made + by a measure with a different capacity than the one being replaced. + +Objective: + To produce a program, given the capacity of two measures and the + intended quantity, which helps Mr. Silva knowing if it is possible + to obtain the amount requested by his customer, and if so, measuring + the intended quantity in the least amount of steps. + +Remarks: + This problem is similar to the Water Jug's' problem. It is more general, + seeing that the Water Jug's problem uses static values for the jugs + capacities and the final goal. +*/ + + +:- object(salt(_Acumulator, _Measure1, _Measure2), + instantiates(state_space)). + + + :- info([ + version is 1.0, + author is 'Paula Marisa Sampaio', + date is 2005/06/08, + comment is 'Salt state-space search problem.']). + + + % each state is represented by a compound term with four arguments: (Acumulator, Measure1, Measure2, Step) + + initial_state(initial, (0, 0, 0, all_empty)). + + + % the intended salt quantity must end up on the acumulator + + goal_state(acumulator, (Acumulator, _, _, _)) :- + parameter(1, Acumulator). + + + % state transitions: + + + % emptying a measure into the accumulator + + next_state((Acc, X, Y, _), (NewAcc, 0, Y, transfer(m1, acc))) :- + X > 0, + NewAcc is Acc + X. + + next_state((Acc, X, Y, _), (NewAcc, X, 0, transfer(m2, acc))) :- + Y > 0, + NewAcc is Acc + Y. + + + % filling up of one of the measures + + next_state((Acc, X, Y, Step), (Acc, MaxX, Y, fill(m1))) :- + parameter(2, MaxX), + X < MaxX, + Step \= empty(m1). + + next_state((Acc, X, Y, Step), (Acc, X, MaxY, fill(m2))) :- + parameter(3, MaxY), + Y < MaxY, + Step \= empty(m2). + + + % either pouring of a measure into the other till it is filled up + % or all content of a measure into the other one + + next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m2, m1))) :- + parameter(2, MaxX), + Y > 0, + X < MaxX, + (X + Y >= MaxX -> + W = MaxX, + Z is Y - (MaxX - X) + ; + W is X + Y, + Z = 0 + ). + + next_state((Acc, X, Y, _), (Acc, W, Z, transfer(m1, m2))) :- + parameter(3, MaxY), + X > 0, + Y < MaxY, + (X + Y >= MaxY -> + W is X - (MaxY - Y), + Z = MaxY + ; + W = 0, + Z is X + Y + ). + + + % throwing out the contents of a measure; does not afect the accumulator + + next_state((Acc, X, Y, Step), (Acc, 0, Y, empty(m1))) :- + X > 0, + Step \= fill(m1). + + next_state((Acc, X, Y, Step), (Acc, X, 0, empty(m2))) :- + Y > 0, + Step \= fill(m2). + + + print_state((Acc, X, Y, Step)) :- + write('('), write((Acc, X, Y)), write(') '), write(Step), nl. + + +:- end_object. diff --git a/Logtalk/examples/shapes/NOTES.txt b/Logtalk/examples/shapes/NOTES.txt index 2a1da7070..145c575e8 100644 --- a/Logtalk/examples/shapes/NOTES.txt +++ b/Logtalk/examples/shapes/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This directory contains two versions, one prototype-based and the diff --git a/Logtalk/examples/shapes/ch/NOTES.txt b/Logtalk/examples/shapes/ch/NOTES.txt index 0c2022b2c..e35ae6bdc 100644 --- a/Logtalk/examples/shapes/ch/NOTES.txt +++ b/Logtalk/examples/shapes/ch/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/shapes/ch/SCRIPT.txt b/Logtalk/examples/shapes/ch/SCRIPT.txt index 7cec5c410..0297f75a1 100644 --- a/Logtalk/examples/shapes/ch/SCRIPT.txt +++ b/Logtalk/examples/shapes/ch/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/shapes/ph/NOTES.txt b/Logtalk/examples/shapes/ph/NOTES.txt index 0c2022b2c..e35ae6bdc 100644 --- a/Logtalk/examples/shapes/ph/NOTES.txt +++ b/Logtalk/examples/shapes/ph/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT diff --git a/Logtalk/examples/shapes/ph/SCRIPT.txt b/Logtalk/examples/shapes/ph/SCRIPT.txt index 3700cdc1f..3eca499c5 100644 --- a/Logtalk/examples/shapes/ph/SCRIPT.txt +++ b/Logtalk/examples/shapes/ph/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/sicstus/NOTES.txt b/Logtalk/examples/sicstus/NOTES.txt index 4049ce968..4964e2597 100644 --- a/Logtalk/examples/sicstus/NOTES.txt +++ b/Logtalk/examples/sicstus/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ The examples in this folder are adopted from the SICStus Prolog manual. diff --git a/Logtalk/examples/sicstus/SCRIPT.txt b/Logtalk/examples/sicstus/SCRIPT.txt index 5252d38bf..a0831debb 100644 --- a/Logtalk/examples/sicstus/SCRIPT.txt +++ b/Logtalk/examples/sicstus/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and necessary library supporting files: diff --git a/Logtalk/examples/symdiff/NOTES.txt b/Logtalk/examples/symdiff/NOTES.txt index a2c569bc0..ca5ddd270 100644 --- a/Logtalk/examples/symdiff/NOTES.txt +++ b/Logtalk/examples/symdiff/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/symdiff/SCRIPT.txt b/Logtalk/examples/symdiff/SCRIPT.txt index 7c6d0fce6..eb5b5a04e 100644 --- a/Logtalk/examples/symdiff/SCRIPT.txt +++ b/Logtalk/examples/symdiff/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/examples/tabling/NOTES.txt b/Logtalk/examples/tabling/NOTES.txt new file mode 100644 index 000000000..8447eac15 --- /dev/null +++ b/Logtalk/examples/tabling/NOTES.txt @@ -0,0 +1,13 @@ +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 + +Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +================================================================ + + +To load this example and for sample queries, please see the SCRIPT file. + +This folder contains an example of using tabled predicates within objects. +Currently supported compilers include B-Prolog, XSB, and YAP (when compiled +with tabling enabled). diff --git a/Logtalk/examples/tabling/SCRIPT.txt b/Logtalk/examples/tabling/SCRIPT.txt new file mode 100644 index 000000000..e6453e2ca --- /dev/null +++ b/Logtalk/examples/tabling/SCRIPT.txt @@ -0,0 +1,32 @@ +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 + +Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +================================================================ + + +% start by loading the example: + +| ?- logtalk_load(tabling(loader)). +... + + +% use tabling to cope with a left-recursive path finding predicate +% (the order of the solutions may depend on the tabling strategy): + +| ?- paths::path(1, Y). + +Y = 2 ? ; +Y = 4 ? ; +Y = 3 ? ; +Y = 5 ? +yes + + +% use tabling to avoid repeated calculation of Fibonacci numbers: + +| ?- fibonacci::fib(30, F). + +F = 1346269 +yes diff --git a/Logtalk/examples/tabling/loader.lgt b/Logtalk/examples/tabling/loader.lgt new file mode 100644 index 000000000..f4df76457 --- /dev/null +++ b/Logtalk/examples/tabling/loader.lgt @@ -0,0 +1,3 @@ + +:- initialization( + logtalk_load(tabling)). diff --git a/Logtalk/examples/tabling/tabling.lgt b/Logtalk/examples/tabling/tabling.lgt new file mode 100644 index 000000000..0b6fde8ac --- /dev/null +++ b/Logtalk/examples/tabling/tabling.lgt @@ -0,0 +1,48 @@ + +:- object(paths). + + :- info([ + version is 1.0, + author is 'Paulo Moura', + date is 2007/05/14, + comment is 'Simple tabling example using graph paths.', + source is 'Direct conversion to Logtalk of a XSB tabling example.']). + + :- public(path/2). + :- table(path/2). + + path(X,Y) :- path(X,Z), edge(Z,Y). + path(X,Y) :- edge(X,Y). + + edge(1,2). + edge(2,2). + edge(2,4). + edge(2,3). + edge(3,5). + +:- end_object. + + +:- object(fibonacci). + + :- info([ + version is 1.1, + author is 'Paulo Moura', + date is 2007/05/28, + comment is 'Simple tabling example using Fibonacci numbers.', + source is 'Direct conversion to Logtalk of a B-Prolog tabling example.']). + + :- public(fib/2). + :- table(fib/2). + + fib(0, 1). + fib(1, 1). + fib(N,F) :- + N > 1, + N1 is N - 1, + N2 is N - 2, + fib(N1, F1), + fib(N2, F2), + F is F1 + F2. + +:- end_object. diff --git a/Logtalk/examples/threads/NOTES.txt b/Logtalk/examples/threads/NOTES.txt index fe1d4f2a0..3e7fbf468 100644 --- a/Logtalk/examples/threads/NOTES.txt +++ b/Logtalk/examples/threads/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This folder contains some examples of multi-threading programming. diff --git a/Logtalk/examples/threads/birthdays/NOTES.txt b/Logtalk/examples/threads/birthdays/NOTES.txt index a46dbf59a..704e6937d 100644 --- a/Logtalk/examples/threads/birthdays/NOTES.txt +++ b/Logtalk/examples/threads/birthdays/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/birthdays/SCRIPT.txt b/Logtalk/examples/threads/birthdays/SCRIPT.txt index 8d57cd7d0..bd9310374 100644 --- a/Logtalk/examples/threads/birthdays/SCRIPT.txt +++ b/Logtalk/examples/threads/birthdays/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % load the example: diff --git a/Logtalk/examples/threads/blackboard/NOTES.txt b/Logtalk/examples/threads/blackboard/NOTES.txt index 66e066535..5e0121474 100644 --- a/Logtalk/examples/threads/blackboard/NOTES.txt +++ b/Logtalk/examples/threads/blackboard/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/blackboard/SCRIPT.txt b/Logtalk/examples/threads/blackboard/SCRIPT.txt index 74b62e2e3..6e60afbc8 100644 --- a/Logtalk/examples/threads/blackboard/SCRIPT.txt +++ b/Logtalk/examples/threads/blackboard/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/threads/buffer/NOTES.txt b/Logtalk/examples/threads/buffer/NOTES.txt index 6b0287736..be901fdd2 100644 --- a/Logtalk/examples/threads/buffer/NOTES.txt +++ b/Logtalk/examples/threads/buffer/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/buffer/SCRIPT.txt b/Logtalk/examples/threads/buffer/SCRIPT.txt index 21a8e8b66..10647dbea 100644 --- a/Logtalk/examples/threads/buffer/SCRIPT.txt +++ b/Logtalk/examples/threads/buffer/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/threads/functions/NOTES.txt b/Logtalk/examples/threads/functions/NOTES.txt index 9fd24dd19..e608af8f6 100644 --- a/Logtalk/examples/threads/functions/NOTES.txt +++ b/Logtalk/examples/threads/functions/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/functions/SCRIPT.txt b/Logtalk/examples/threads/functions/SCRIPT.txt index 0469ea22a..4ca0b2d34 100644 --- a/Logtalk/examples/threads/functions/SCRIPT.txt +++ b/Logtalk/examples/threads/functions/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the loading the example: diff --git a/Logtalk/examples/threads/nondet/NOTES.txt b/Logtalk/examples/threads/nondet/NOTES.txt index d87b738c8..fdf8b18c5 100644 --- a/Logtalk/examples/threads/nondet/NOTES.txt +++ b/Logtalk/examples/threads/nondet/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/nondet/SCRIPT.txt b/Logtalk/examples/threads/nondet/SCRIPT.txt index 2dce725f8..2595fe36f 100644 --- a/Logtalk/examples/threads/nondet/SCRIPT.txt +++ b/Logtalk/examples/threads/nondet/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the loading the example: diff --git a/Logtalk/examples/threads/philosophers/NOTES.txt b/Logtalk/examples/threads/philosophers/NOTES.txt index 3132b5e55..c11e58625 100644 --- a/Logtalk/examples/threads/philosophers/NOTES.txt +++ b/Logtalk/examples/threads/philosophers/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/philosophers/SCRIPT.txt b/Logtalk/examples/threads/philosophers/SCRIPT.txt index c2c74fb53..8670deb4e 100644 --- a/Logtalk/examples/threads/philosophers/SCRIPT.txt +++ b/Logtalk/examples/threads/philosophers/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example and the required library files: diff --git a/Logtalk/examples/threads/primes/NOTES.txt b/Logtalk/examples/threads/primes/NOTES.txt index 1e9bec087..bea6996f0 100644 --- a/Logtalk/examples/threads/primes/NOTES.txt +++ b/Logtalk/examples/threads/primes/NOTES.txt @@ -1,18 +1,18 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. -This folder contains a simple multi-threading example with calculating -prime numbers in a given interval. Try to run the example in single and -multi-processor (or multi-core) computers and compare the results. Most -Prolog compilers allows you to measure the time taken for proving a goal -using proprietary predicates. +This folder contains a simple example of calculating prime numbers in a +given interval using multiple threads. Try to run the example in single +and multi-processor (or multi-core) computers and compare the results. +Most Prolog compilers allows you to measure the time taken for proving +a goal using proprietary predicates. Note that this example is only meant to illustrate how to use Logtalk multi-threading predicates, not to taken as the efficient solution for diff --git a/Logtalk/examples/threads/primes/SCRIPT.txt b/Logtalk/examples/threads/primes/SCRIPT.txt index 58a32e25e..b664ca706 100644 --- a/Logtalk/examples/threads/primes/SCRIPT.txt +++ b/Logtalk/examples/threads/primes/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the loading the example: diff --git a/Logtalk/examples/threads/sorting/NOTES.txt b/Logtalk/examples/threads/sorting/NOTES.txt new file mode 100644 index 000000000..e57a38a2e --- /dev/null +++ b/Logtalk/examples/threads/sorting/NOTES.txt @@ -0,0 +1,32 @@ +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 + +Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +================================================================ + + +To load this example and for sample queries, please see the SCRIPT file. + +This folder contains a multi-threading implementation of the merge sort +algorithm. Depending on the size of the lists that are ordered, using +only one thread can be faster. The number of threads to use in sorting +is set using the msort/1 object parameter. You may need to adjust the +size of the memory areas used by your Prolog compiler, depending on the +size of the lists you want to sort. + +This example uses a simple implementation of the merge sort algorithm, +intended only to illustrate Logtalk multi-threading features. For any +other purpose, you may find the following paper a worthwhile reading: + +@incollection{ apt93modular, + author = "Krzysztof R. Apt and Dino Pedreschi", + title = "Modular Termination Proofs for Logic and Pure Prolog Programs.", + booktitle = "116", + month = "31", + publisher = "Centrum voor Wiskunde en Informatica (CWI)", + address = "ISSN 0169-118X", + pages = "35", + year = "1993", + url = "citeseer.ist.psu.edu/apt93modular.html" } + diff --git a/Logtalk/examples/threads/sorting/SCRIPT.txt b/Logtalk/examples/threads/sorting/SCRIPT.txt new file mode 100644 index 000000000..288d00510 --- /dev/null +++ b/Logtalk/examples/threads/sorting/SCRIPT.txt @@ -0,0 +1,83 @@ +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 + +Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +================================================================ + + +% start by loading the example and the required library files: + +| ?- logtalk_load(sorting(loader)). +... + + +% NOTE: the example queries below use a SWI-Prolog proprietary predicate +% time/1 in order to get accurate goal times. For other Prolog compilers, +% replace the time/1 call by any appropriate timing calls (e.g. cputime/0). + + +% generate a big list of random floats and then merge sort it using a single thread: + +?- generator::list(20000, List), time(msort(1)::msort(List, Sorted)). +% 1,145,746 inferences, 0.40 CPU in 0.43 seconds (93% CPU, 2864365 Lips) + +List = [0.326219, 0.545052, 0.21687, 0.0500493, 0.772745, 0.805005, 0.574483, 0.301708, 0.670021|...], +Sorted = [1.39358e-06, 0.000206126, 0.00026088, 0.000299165, 0.000362691, 0.000397709, 0.000539889, 0.000574419, 0.000578717|...] + +Yes + + +% generate a big list of random floats and then merge sort it using two threads: + +?- generator::list(20000, List), time(msort(2)::msort(List, Sorted)). +% 80,067 inferences, 0.32 CPU in 0.21 seconds (150% CPU, 250209 Lips) + +List = [0.963245, 0.666814, 0.3841, 0.281952, 0.806571, 0.608224, 0.623344, 0.138888, 0.867367|...], +Sorted = [5.89827e-05, 0.00010463, 0.000105771, 0.000171936, 0.00022632, 0.000378509, 0.000392918, 0.00041885, 0.000482844|...] + +Yes + + +% generate a big list of random floats and then merge sort it using four threads: + +?- generator::list(20000, List), time(msort(4)::msort(List, Sorted)). +% 80,079 inferences, 0.32 CPU in 0.16 seconds (204% CPU, 250247 Lips) + +List = [0.0923009, 0.443585, 0.72304, 0.945816, 0.501491, 0.311327, 0.597448, 0.915656, 0.666957|...], +Sorted = [3.65916e-05, 4.06822e-05, 5.07434e-05, 6.09007e-05, 0.000134275, 0.000190491, 0.00024128, 0.000361441, 0.000412926|...] + +Yes + + +% generate a big list of random floats and then quick sort it using a single thread: + +?- generator::list(20000, List), time(qsort(1)::qsort(List, Sorted)). +% 1,145,746 inferences, 0.40 CPU in 0.43 seconds (93% CPU, 2864365 Lips) + +List = [0.326219, 0.545052, 0.21687, 0.0500493, 0.772745, 0.805005, 0.574483, 0.301708, 0.670021|...], +Sorted = [1.39358e-06, 0.000206126, 0.00026088, 0.000299165, 0.000362691, 0.000397709, 0.000539889, 0.000574419, 0.000578717|...] + +Yes + + +% generate a big list of random floats and then quick sort it using two threads: + +?- generator::list(20000, List), time(qsort(2)::qsort(List, Sorted)). +% 80,067 inferences, 0.32 CPU in 0.21 seconds (150% CPU, 250209 Lips) + +List = [0.963245, 0.666814, 0.3841, 0.281952, 0.806571, 0.608224, 0.623344, 0.138888, 0.867367|...], +Sorted = [5.89827e-05, 0.00010463, 0.000105771, 0.000171936, 0.00022632, 0.000378509, 0.000392918, 0.00041885, 0.000482844|...] + +Yes + + +% generate a big list of random floats and then quick sort it using four threads: + +?- generator::list(20000, List), time(qsort(4)::qsort(List, Sorted)). +% 80,079 inferences, 0.32 CPU in 0.16 seconds (204% CPU, 250247 Lips) + +List = [0.0923009, 0.443585, 0.72304, 0.945816, 0.501491, 0.311327, 0.597448, 0.915656, 0.666957|...], +Sorted = [3.65916e-05, 4.06822e-05, 5.07434e-05, 6.09007e-05, 0.000134275, 0.000190491, 0.00024128, 0.000361441, 0.000412926|...] + +Yes diff --git a/Logtalk/examples/threads/sorting/generator.lgt b/Logtalk/examples/threads/sorting/generator.lgt new file mode 100644 index 000000000..bd7679f69 --- /dev/null +++ b/Logtalk/examples/threads/sorting/generator.lgt @@ -0,0 +1,19 @@ + +:- object(generator). + + :- info([ + version is 1.0, + author is 'Paulo Moura', + date is 2007/03/22, + comment is 'Simple object defining a predicate for generating lists of random values.']). + + :- public(list/2). + + list(0, []). + list(N, [R| Rs]) :- + N > 0, + N2 is N - 1, + random::random(R), + list(N2, Rs). + +:- end_object. diff --git a/Logtalk/examples/threads/sorting/loader.lgt b/Logtalk/examples/threads/sorting/loader.lgt new file mode 100644 index 000000000..d61a685c7 --- /dev/null +++ b/Logtalk/examples/threads/sorting/loader.lgt @@ -0,0 +1,4 @@ + +:- initialization(( + logtalk_load(library(random_loader), [reload(skip)]), + logtalk_load([generator, qsort, msort]))). diff --git a/Logtalk/examples/threads/sorting/msort.lgt b/Logtalk/examples/threads/sorting/msort.lgt new file mode 100644 index 000000000..fff62ba70 --- /dev/null +++ b/Logtalk/examples/threads/sorting/msort.lgt @@ -0,0 +1,57 @@ + +:- object(msort(_Threads)). + + :- info([ + version is 1.1, + author is 'Paulo Moura and Paul Crocker', + date is 2007/03/30, + comment is 'Multi-threaded implementation of the merge sort algorithm.', + parameters is ['Threads'- 'Number of threads to use in sorting. Valid values are 1, 2, 4, 8, etc.']]). + + :- threaded. + + :- public(msort/2). + :- mode(msort(+list, -list), one). + :- info(msort/2, [ + comment is 'Sorts a list of terms into ascending order.', + argnames is ['List', 'Sorted']]). + + msort(List, Sorted) :- + parameter(1, Threads), + mt_msort(Threads, List, Sorted). + + mt_msort(1, List, Sorted) :- + st_msort(List, Sorted). + mt_msort(N, List, Sorted) :- + N > 1, + N2 is N//2, + split(List, List1, List2), + threaded(( + mt_msort(N2, List1, Sorted1), + mt_msort(N2, List2, Sorted2) + )), !, % SWI-Prolog needs help with determinism detection + merge(Sorted1, Sorted2, Sorted). + + st_msort([], []). + st_msort([X], [X]). + st_msort([X, Y| Xs], Ys) :- + split([X, Y| Xs], X1s, X2s), + st_msort(X1s, Y1s), + st_msort(X2s, Y2s), + merge(Y1s, Y2s, Ys). + + split([], [], []). + split([X| Xs], [X| Ys], Zs) :- + split(Xs, Zs, Ys). + + merge([X| Xs], [Y| Ys], [X| Zs]) :- + X =< Y, !, + merge(Xs, [Y| Ys], Zs). + merge([X| Xs], [Y| Ys], [Y| Zs]) :- + X > Y, !, + merge([X | Xs], Ys, Zs). + merge([], Xs, Xs) :- !. + merge(Xs, [], Xs). + +:- end_object. + diff --git a/Logtalk/examples/threads/sorting/qsort.lgt b/Logtalk/examples/threads/sorting/qsort.lgt new file mode 100644 index 000000000..129152456 --- /dev/null +++ b/Logtalk/examples/threads/sorting/qsort.lgt @@ -0,0 +1,50 @@ + +:- object(qsort(_Threads)). + + :- info([ + version is 1.0, + author is 'Paul Croker and Paulo Moura', + date is 2007/03/29, + comment is 'Multi-threaded version of the quick sort algorithm.', + parameters is ['Threads'- 'Number of threads to use in sorting. Valid values are 1, 2, 4, 8, 16, 32, etc.']]). + + :- threaded. + + :- public(qsort/2). + :- mode(qsort(+list, -list), one). + :- info(qsort/2, [ + comment is 'Sorts a list of terms into ascending order.', + argnames is ['List', 'Sorted']]). + + qsort(List, Sorted) :- + parameter(1, Threads), + qsort(List, [], Sorted, Threads). + + qsort([], Sorted, Sorted, _). + qsort([Pivot| Rest], Acc, Sorted, N) :- + ( N =:= 1 -> + quicksort([Pivot| Rest], Acc, Sorted) + ; N2 is N//2, + partition(Rest, Pivot, Smaller0, Bigger0), + threaded(( + qsort(Smaller0, [Pivot| Bigger], Sorted, N2), + qsort(Bigger0, Acc, Bigger, N2) + )), ! % SWI-Prolog needs help with determinism detection + ). + + partition([], _, [], []). + partition([X| Xs], Pivot, Smalls, Bigs) :- + ( X < Pivot -> + Smalls = [X| Rest], + partition(Xs, Pivot, Rest, Bigs) + ; Bigs = [X| Rest], + partition(Xs, Pivot, Smalls, Rest) + ). + + quicksort([], Sorted, Sorted). + quicksort([Pivot| Rest], Acc, Sorted) :- + partition(Rest, Pivot, Smaller0, Bigger0), + quicksort(Smaller0, [Pivot| Bigger], Sorted), + quicksort(Bigger0, Acc, Bigger). + +:- end_object. diff --git a/Logtalk/examples/threads/sync/NOTES.txt b/Logtalk/examples/threads/sync/NOTES.txt index d1dddb377..3217da67b 100644 --- a/Logtalk/examples/threads/sync/NOTES.txt +++ b/Logtalk/examples/threads/sync/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/threads/sync/SCRIPT.txt b/Logtalk/examples/threads/sync/SCRIPT.txt index 64b633be0..2d00f314e 100644 --- a/Logtalk/examples/threads/sync/SCRIPT.txt +++ b/Logtalk/examples/threads/sync/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the loading the example: diff --git a/Logtalk/examples/viewpoints/NOTES.txt b/Logtalk/examples/viewpoints/NOTES.txt index 905180e03..929b3ab05 100644 --- a/Logtalk/examples/viewpoints/NOTES.txt +++ b/Logtalk/examples/viewpoints/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load this example and for sample queries, please see the SCRIPT file. diff --git a/Logtalk/examples/viewpoints/SCRIPT.txt b/Logtalk/examples/viewpoints/SCRIPT.txt index 3bae15fe3..604252edb 100644 --- a/Logtalk/examples/viewpoints/SCRIPT.txt +++ b/Logtalk/examples/viewpoints/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ % start by loading the example: diff --git a/Logtalk/integration/NOTES.txt b/Logtalk/integration/NOTES.txt new file mode 100644 index 000000000..8b4e759aa --- /dev/null +++ b/Logtalk/integration/NOTES.txt @@ -0,0 +1,62 @@ +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 + +Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +================================================================ + + +This directory contains Prolog integration shell scripts and auxiliary +Prolog files. + +On POSIX systems, the Logtalk installers make the following integration +scripts available from the command-line (you may need to adjust your +system path): + + bplgt B-Prolog integration script + ciaolgt Ciao Prolog integration script + cxlgt CxProlog integration script + eclipselgt ECLiPSe integration script + gplgt GNU Prolog integration script + plclgt K-Prolog integration script + sicstuslgt SICStus Prolog integration script + swilgt SWI-Prolog integration script + xsblgt XSB integration script + yaplgt YAP integration script + +On Windows systems, the Logtalk installer makes the Prolog integration +shortcuts available from the "Start Menu/Programs/Logtalk" menu. + +The first run of the B-Prolog, Ciao, and XSB integration scripts must be +made by an user with administrative rights (on POSIX systems, run them +once as root or using sudo; in Windows systems run them once from an +administrative account). + +The GNU Prolog integration script provides adequate performance for +development. For production environments, improved performance can be +achieved by generating a new GNU-Prolog top-level that includes Logtalk. + +Other Prolog compilers require manual steps for integration with Logtalk. +See the "configs/NOTES.txt" file for details. + +The environment variables LOGTALKHOME and LOGTALKUSER should be defined +in order to run the integration scripts (see the "INSTALL.txt" file for +details on setting the variables). + +Note that the integration scripts and shortcuts may fail if you use non- +standard locations for your Prolog compilers. + +Depending on the size and complexity of your Logtalk applications, you +may need to change the integration scripts in order to allocate more +memory to the back-end Prolog compilers. Please consult the documentation +on the Prolog compilers you intend to use for details. + +All the scripts accept command-line options, which are passed straight to +the back-end Prolog compiler. For example (on a POSIX operating-system, +using SWI-Prolog as the back-end compiler): + + % swilgt -g "write('Hello world!'), nl" + +However, keep in mind that the integration scripts already use the back-end +Prolog command-line option that allows a initialization file to be loaded +in order to bootstrap Logtalk. See the scripts/shortcut files for details. diff --git a/Logtalk/integration/bplgt.sh b/Logtalk/integration/bplgt.sh new file mode 100755 index 000000000..468f40d1b --- /dev/null +++ b/Logtalk/integration/bplgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec bp -g "consult('$LOGTALKHOME/integration/logtalk_bp.pl'), \$bp_top_level" "$@" diff --git a/Logtalk/integration/ciaolgt.sh b/Logtalk/integration/ciaolgt.sh new file mode 100755 index 000000000..5bcb442c0 --- /dev/null +++ b/Logtalk/integration/ciaolgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec ciaosh -l "$LOGTALKHOME/integration/logtalk_ciao.pl" "$@" diff --git a/Logtalk/integration/cxlgt.sh b/Logtalk/integration/cxlgt.sh new file mode 100755 index 000000000..dc57dc74e --- /dev/null +++ b/Logtalk/integration/cxlgt.sh @@ -0,0 +1,61 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi + +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec cxprolog --goal "silent_consult('$LOGTALKHOME/integration/logtalk_cx.pl')" "$@" diff --git a/Logtalk/integration/eclipselgt.sh b/Logtalk/integration/eclipselgt.sh new file mode 100755 index 000000000..b420fe263 --- /dev/null +++ b/Logtalk/integration/eclipselgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec eclipse -b "$LOGTALKHOME/integration/logtalk_eclipse.pl" "$@" diff --git a/Logtalk/integration/gplgt.sh b/Logtalk/integration/gplgt.sh new file mode 100755 index 000000000..7a10a2876 --- /dev/null +++ b/Logtalk/integration/gplgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec gprolog --init-goal "['$LOGTALKUSER/configs/gnu.config','$LOGTALKHOME/integration/logtalk_gp.pl','$LOGTALKUSER/libpaths/libpaths.pl']" "$@" diff --git a/Logtalk/integration/logtalk_bp.pl b/Logtalk/integration/logtalk_bp.pl new file mode 100644 index 000000000..4744f1b27 --- /dev/null +++ b/Logtalk/integration/logtalk_bp.pl @@ -0,0 +1,15 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- set_prolog_flag(redefined, off). +:- cl('$LOGTALKUSER/configs/b.config'). +:- cl('$LOGTALKHOME/compiler/logtalk.pl'). +:- cl('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_bp_win.pl b/Logtalk/integration/logtalk_bp_win.pl new file mode 100644 index 000000000..c9ba58516 --- /dev/null +++ b/Logtalk/integration/logtalk_bp_win.pl @@ -0,0 +1,17 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- set_prolog_flag(redefined, off). +:- cl('$LOGTALKUSER/configs/b.config'). +%:- system('del %LOGTALKUSER%\\configs\\b.config.out'). +:- (expand_environment('$LOGTALKHOME/compiler/logtalk.pl.out', Expanded), exists(Expanded) -> load('$LOGTALKHOME/compiler/logtalk.pl'); cl('$LOGTALKHOME/compiler/logtalk.pl')). +:- cl('$LOGTALKUSER/libpaths/libpaths.pl'). +%:- system('del %LOGTALKUSER%\\libpaths\\libpaths.pl.out'). diff --git a/Logtalk/integration/logtalk_ciao.pl b/Logtalk/integration/logtalk_ciao.pl new file mode 100644 index 000000000..357db9473 --- /dev/null +++ b/Logtalk/integration/logtalk_ciao.pl @@ -0,0 +1,22 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- ensure_loaded('$LOGTALKUSER/configs/ciao_aux.config'). +:- set_prolog_flag(multi_arity_warnings, off). +:- ensure_loaded('$LOGTALKHOME/compiler/logtalk.pl'). +:- ensure_loaded('$LOGTALKUSER/libpaths/libpaths.pl'). +:- op(600, xfy, ::). +:- op(600, fy, ::). +:- op(600, fy, ^^). +:- op(200, fy, +). +:- op(200, fy, ?). +:- op(200, fy, @). +:- op(200, fy, -). diff --git a/Logtalk/integration/logtalk_comp_eclipse.pl b/Logtalk/integration/logtalk_comp_eclipse.pl new file mode 100644 index 000000000..9ab1ef570 --- /dev/null +++ b/Logtalk/integration/logtalk_comp_eclipse.pl @@ -0,0 +1,15 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- pragma(system). +:- pragma(nodebug). +:- ensure_loaded(library(toplevel)). +:- include('$LOGTALKHOME/compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_comp_swi.pl b/Logtalk/integration/logtalk_comp_swi.pl new file mode 100644 index 000000000..31938ca4a --- /dev/null +++ b/Logtalk/integration/logtalk_comp_swi.pl @@ -0,0 +1,22 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- set_prolog_flag(iso, true). +:- set_prolog_flag(generate_debug_info, false). +:- system_module. +:- op(600, xfy, ::). +:- op(600, fy, ::). +:- op(600, fy, ^^). +:- op(200, fy, +). +:- op(200, fy, ?). +:- op(200, fy, @). +:- op(200, fy, -). +:- include('../compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_cx.pl b/Logtalk/integration/logtalk_cx.pl new file mode 100644 index 000000000..7efb8a4c2 --- /dev/null +++ b/Logtalk/integration/logtalk_cx.pl @@ -0,0 +1,15 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- set_prolog_flag(file_name_variables, true). +:- silent_consult('$LOGTALKUSER/configs/cx.config'). +:- silent_consult('$LOGTALKHOME/compiler/logtalk.pl'). +:- silent_consult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_eclipse.pl b/Logtalk/integration/logtalk_eclipse.pl new file mode 100644 index 000000000..e4b242fa5 --- /dev/null +++ b/Logtalk/integration/logtalk_eclipse.pl @@ -0,0 +1,14 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- compile('$LOGTALKUSER/configs/eclipseiso.config'). +:- compile('$LOGTALKHOME/integration/logtalk_comp_eclipse.pl'). +:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_gp.pl b/Logtalk/integration/logtalk_gp.pl new file mode 100644 index 000000000..2b9535d0a --- /dev/null +++ b/Logtalk/integration/logtalk_gp.pl @@ -0,0 +1,13 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- built_in. +:- include('$LOGTALKHOME/compiler/logtalk.pl'). diff --git a/Logtalk/integration/logtalk_plc.pl b/Logtalk/integration/logtalk_plc.pl new file mode 100644 index 000000000..1c077e3b6 --- /dev/null +++ b/Logtalk/integration/logtalk_plc.pl @@ -0,0 +1,14 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- consult('$LOGTALKUSER/configs/k.config'). +:- consult('$LOGTALKHOME/compiler/logtalk.pl'). +:- consult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_sicstus3.pl b/Logtalk/integration/logtalk_sicstus3.pl new file mode 100644 index 000000000..246d8e6f2 --- /dev/null +++ b/Logtalk/integration/logtalk_sicstus3.pl @@ -0,0 +1,14 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- compile('$LOGTALKUSER/configs/sicstus.config'). +:- compile('$LOGTALKHOME/compiler/logtalk.pl'). +:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_sicstus4.pl b/Logtalk/integration/logtalk_sicstus4.pl new file mode 100644 index 000000000..86f33d7fb --- /dev/null +++ b/Logtalk/integration/logtalk_sicstus4.pl @@ -0,0 +1,22 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- compile('$LOGTALKUSER/configs/sicstus4.config'). +:- asserta(( + user:goal_expansion(CallWitArgs, Layout, _, Call, Layout) :- + CallWitArgs =.. [call_with_args| Args], + Call =.. [call| Args])). +:- compile('$LOGTALKHOME/compiler/logtalk.pl'). +:- retract(( + user:goal_expansion(CallWitArgs, Layout, _, Call, Layout) :- + CallWitArgs =.. [call_with_args| Args], + Call =.. [call| Args])). +:- compile('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/logtalk_swi.pl b/Logtalk/integration/logtalk_swi.pl new file mode 100644 index 000000000..5072e7fbb --- /dev/null +++ b/Logtalk/integration/logtalk_swi.pl @@ -0,0 +1,16 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- consult('$LOGTALKUSER/configs/swi.config'). +:- consult('$LOGTALKHOME/integration/logtalk_comp_swi.pl'). +:- consult('$LOGTALKUSER/libpaths/libpaths.pl'). +:- consult('$LOGTALKUSER/configs/swihook.pl'). +:- consult('$LOGTALKUSER/configs/xpcehook.pl'). diff --git a/Logtalk/integration/logtalk_xsb.pl b/Logtalk/integration/logtalk_xsb.pl new file mode 100644 index 000000000..f000f217b --- /dev/null +++ b/Logtalk/integration/logtalk_xsb.pl @@ -0,0 +1,15 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- reconsult('$LOGTALKUSER/configs/xsb.pl'). +:- reconsult('$LOGTALKHOME/compiler/logtalk.pl'). +:- reconsult('$LOGTALKUSER/libpaths/libpaths_no_env_var.pl'). +:- path_sysop(chdir, '~'). diff --git a/Logtalk/integration/logtalk_yap.pl b/Logtalk/integration/logtalk_yap.pl new file mode 100644 index 000000000..df90bfe6c --- /dev/null +++ b/Logtalk/integration/logtalk_yap.pl @@ -0,0 +1,14 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 +% +% Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +:- reconsult('$LOGTALKUSER/configs/yap.config'). +:- reconsult('$LOGTALKHOME/compiler/logtalk.pl'). +:- reconsult('$LOGTALKUSER/libpaths/libpaths.pl'). diff --git a/Logtalk/integration/plclgt.sh b/Logtalk/integration/plclgt.sh new file mode 100755 index 000000000..66a76d3b5 --- /dev/null +++ b/Logtalk/integration/plclgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec "$PLC"/plc -h 2048k -l 1024k -g 2048k -e "(consult('$LOGTALKHOME/integration/logtalk_plc.pl'), '\$root')." "$@" diff --git a/Logtalk/integration/sicstuslgt.sh b/Logtalk/integration/sicstuslgt.sh new file mode 100755 index 000000000..eff768b69 --- /dev/null +++ b/Logtalk/integration/sicstuslgt.sh @@ -0,0 +1,64 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +if sicstus -f --goal "halt." 2>&1 | grep "SICStus 4" 2>&1 >/dev/null; then + exec sicstus -l "$LOGTALKHOME/integration/logtalk_sicstus4.pl" "$@" +else + exec sicstus -l "$LOGTALKHOME/integration/logtalk_sicstus3.pl" "$@" +fi diff --git a/Logtalk/integration/swilgt.sh b/Logtalk/integration/swilgt.sh new file mode 100755 index 000000000..7fbaa00ef --- /dev/null +++ b/Logtalk/integration/swilgt.sh @@ -0,0 +1,68 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +if pl -t halt 2>&1 | grep "SWI-Prolog"; then + exec pl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@" +elif swipl -t halt 2>&1 | grep "SWI-Prolog"; then + exec swipl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@" +else case $( uname -s ) in + Darwin ) exec swipl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@";; + * ) exec pl -f "$LOGTALKHOME/integration/logtalk_swi.pl" "$@";; +esac +fi diff --git a/Logtalk/integration/xsblgt.sh b/Logtalk/integration/xsblgt.sh new file mode 100755 index 000000000..665a6c98c --- /dev/null +++ b/Logtalk/integration/xsblgt.sh @@ -0,0 +1,64 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +if xsb -v 2>&1 | grep "CVS" 2>&1 >/dev/null; then + exec xsb -l -e "['$LOGTALKUSER/configs/xsbcvs.pl', '$LOGTALKHOME/compiler/logtalk.pl', '$LOGTALKUSER/libpaths/libpaths.pl']." "$@" +else + exec xsb -l -e "['$LOGTALKUSER/configs/xsb.pl', '$LOGTALKHOME/compiler/logtalk.pl', '$LOGTALKUSER/libpaths/libpaths_no_env_var.pl']." "$@" +fi diff --git a/Logtalk/integration/yaplgt.sh b/Logtalk/integration/yaplgt.sh new file mode 100755 index 000000000..f9f790273 --- /dev/null +++ b/Logtalk/integration/yaplgt.sh @@ -0,0 +1,60 @@ +#/bin/sh + +## ================================================================ +## Logtalk - Open source object-oriented logic programming language +## Release 2.30.1 +## +## Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. +## ================================================================ + +if ! [ "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME should be defined first, pointing" + echo "to your Logtalk installation directory!" + echo "Trying the default locations for the Logtalk installation..." + if [ -d "/usr/local/share/logtalk" ]; then + LOGTALKHOME=/usr/local/share/logtalk + echo "... using Logtalk installation found at /usr/local/share/logtalk" + elif [ -d "/usr/share/logtalk" ]; then + LOGTALKHOME=/usr/share/logtalk + echo "... using Logtalk installation found at /usr/share/logtalk" + elif [ -d "/opt/local/share/logtalk" ]; then + LOGTALKHOME=/opt/local/share/logtalk + echo "... using Logtalk installation found at /opt/local/share/logtalk" + elif [ -d "/opt/share/logtalk" ]; then + LOGTALKHOME=/opt/share/logtalk + echo "... using Logtalk installation found at /opt/share/logtalk" + else + echo "... unable to locate Logtalk installation directory!" + echo + exit 1 + fi + echo +elif ! [ -d "$LOGTALKHOME" ]; then + echo "The environment variable LOGTALKHOME points to a non-existing directory!" + echo "Its current value is: $LOGTALKHOME" + echo "The variable must be set to your Logtalk installation directory!" + echo + exit 1 +fi +export LOGTALKHOME + +if ! [ "$LOGTALKUSER" ]; then + echo "The environment variable LOGTALKUSER should be defined first, pointing" + echo "to your Logtalk user directory!" + echo "Trying the default location for the Logtalk user directory..." + export LOGTALKUSER=$HOME/logtalk + if [ -d "$LOGTALKUSER" ]; then + echo "... using Logtalk user directory found at $LOGTALKUSER" + else + echo "... Logtalk user directory not found at default location. Creating a" + echo "new Logtalk user directory by running the \"cplgtdirs\" shell script:" + cplgtdirs + fi +elif ! [ -d "$LOGTALKUSER" ]; then + echo "Cannot find \$LOGTALKUSER directory! Creating a new Logtalk user directory" + echo "by running the \"cplgtdirs\" shell script:" + cplgtdirs +fi +echo + +exec yap -s 49152 -h 16384 -t 1024 -l "$LOGTALKHOME/integration/logtalk_yap.pl" "$@" diff --git a/Logtalk/libpaths/NOTES.txt b/Logtalk/libpaths/NOTES.txt index bfaf497b7..f4776751f 100644 --- a/Logtalk/libpaths/NOTES.txt +++ b/Logtalk/libpaths/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This folder contains a Prolog file, "libpaths.pl", which, when loaded, defines the library paths for the Logtalk standard library and for all @@ -23,15 +23,15 @@ As defined, the provided "libpaths.pl" file is already compatible with some of the most popular Prolog compilers, running on both MacOS X, Linux, Windows, Unix, and Unix-like operating-systems. -The Prolog integration scripts found on the "scripts" directory generate -scripts and shortcuts that automatically load the copy of the "libpaths.pl" -file from the Logtalk end-user directory created by the "scripts/cplgtdirs.*" -scripts. See the "INSTALL.txt" and "scripts/NOTES.txt" files for more details. -Note that some Prolog compilers do not support the () -notation. See the "configs/NOTES.txt" file for details. +The Prolog integration scripts, found on the "integration" directory, +automatically load the copy of the "libpaths.pl" file from the Logtalk +end-user directory created by the "scripts/cplgtdirs.*" scripts. See the +"INSTALL.txt" and "scripts/NOTES.txt" files for more details. Note that +some Prolog compilers do not support the () notation. +See the "configs/NOTES.txt" file for details. -The somehow contrived code found on the "libpaths.pl" file is needed -to ensure compatibility with both the ISO Prolog standard and with most +The somehow contrived code found on the "libpaths.pl" file is needed to +ensure compatibility with both the ISO Prolog standard and with most Prolog compilers. The code could be greatly simplified by using a multifile predicate directive for the library path dynamic predicate. Unfortunately, not all Prolog compilers support multifile predicates. @@ -41,6 +41,7 @@ Prolog compilers that are expected to be compatible with the provided * B-Prolog * CIAO + * CxProlog * ECLiPSe * GNU-Prolog * K-Prolog diff --git a/Logtalk/libpaths/libpaths.pl b/Logtalk/libpaths/libpaths.pl index 0475ee8a5..9c2bc7536 100644 --- a/Logtalk/libpaths/libpaths.pl +++ b/Logtalk/libpaths/libpaths.pl @@ -1,8 +1,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% Logtalk - Object oriented extension to Prolog -% Release 2.29.5 +% Logtalk - Open source object-oriented logic programming language +% Release 2.30.1 % % Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. % @@ -46,7 +46,6 @@ assertz(logtalk_library_path(miscellaneous, examples('miscellaneous/'))), assertz(logtalk_library_path(modules, examples('modules/'))), assertz(logtalk_library_path(msglog, examples('msglog/'))), - assertz(logtalk_library_path(msort, threads('msort/'))), assertz(logtalk_library_path(nondet, threads('nondet/'))), assertz(logtalk_library_path(operators, examples('operators/'))), assertz(logtalk_library_path(parametric, examples('parametric/'))), @@ -65,7 +64,9 @@ assertz(logtalk_library_path(shapes_ch, examples('shapes/ch/'))), assertz(logtalk_library_path(shapes_ph, examples('shapes/ph/'))), assertz(logtalk_library_path(sicstus, examples('sicstus/'))), + assertz(logtalk_library_path(sorting, threads('sorting/'))), assertz(logtalk_library_path(sync, threads('sync/'))), assertz(logtalk_library_path(symdiff, examples('symdiff/'))), + assertz(logtalk_library_path(tabling, examples('tabling/'))), assertz(logtalk_library_path(threads, examples('threads/'))), assertz(logtalk_library_path(viewpoints, examples('viewpoints/'))))). diff --git a/Logtalk/library/NOTES.txt b/Logtalk/library/NOTES.txt index 1558f633b..ebb62c71b 100644 --- a/Logtalk/library/NOTES.txt +++ b/Logtalk/library/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This folder contains some useful objects, categories, and protocols. diff --git a/Logtalk/library/SCRIPT.txt b/Logtalk/library/SCRIPT.txt index 8bdf08ade..389fb2c72 100644 --- a/Logtalk/library/SCRIPT.txt +++ b/Logtalk/library/SCRIPT.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ | ?- meta::succeeds(integer, [1, 2, 3]). diff --git a/Logtalk/library/after_event_registry.lgt b/Logtalk/library/after_event_registry.lgt index a0e456ddb..09bc6cada 100644 --- a/Logtalk/library/after_event_registry.lgt +++ b/Logtalk/library/after_event_registry.lgt @@ -2,38 +2,30 @@ :- object(after_event_registry, implements(event_registryp)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'After events registry predicates.']). - monitors(Monitors) :- findall(Monitor, current_event(after, _, _, _, Monitor), List), {sort(List, Monitors)}. - monitored(Objects) :- findall(Object, current_event(after, Object, _, _, _), List), {sort(List, Objects)}. - monitor(Object, Message, Sender, Monitor) :- current_event(after, Object, Message, Sender, Monitor). - set_monitor(Object, Message, Sender, Monitor) :- define_events(after, Object, Message, Sender, Monitor). - del_monitors(Object, Message, Sender, Monitor) :- abolish_events(after, Object, Message, Sender, Monitor). - del_monitors :- abolish_events(after, _, _, _, _). - :- end_object. diff --git a/Logtalk/library/all.notes b/Logtalk/library/all.notes index 173577c84..543f780b4 100644 --- a/Logtalk/library/all.notes +++ b/Logtalk/library/all.notes @@ -1,10 +1,10 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ The all_loader.lgt file will load all the entities loaded by the other diff --git a/Logtalk/library/assignvars.lgt b/Logtalk/library/assignvars.lgt index 3f2dc0e74..d6f661d21 100644 --- a/Logtalk/library/assignvars.lgt +++ b/Logtalk/library/assignvars.lgt @@ -15,14 +15,12 @@ version 2.1 (http://opensource.org/licenses/osl-2.1.php). :- category(assignvars). - :- info([ version is 1.0, author is 'Nobukuni Kino and Paulo Moura', date is 2005/1/7, comment is 'Assignable variables (supporting logical, backtracable assignement of non-variable terms).']). - :- public(assignable/1). :- mode(assignable(-assignvar), one). :- info(assignable/1, [ @@ -56,35 +54,28 @@ version 2.1 (http://opensource.org/licenses/osl-2.1.php). exceptions is [ 'Variable is not instantiated' - instantiation_error]]). - :-op(100, xfx, <=). :-op(100, xfx, =>). - assignable(Assig) :- nonvar(Assig), self(Self), sender(Sender), throw(error(type_error(variable, Assig), Self::assignable(Assig), Sender)). - assignable([_| _]). - assignable(Assig, Init) :- nonvar(Assig), self(Self), sender(Sender), throw(error(type_error(variable, Assig), Self::assignable(Assig, Init), Sender)). - assignable(Assig, Init) :- var(Init), self(Self), sender(Sender), throw(error(instantiation_error, Self::assignable(Assig, Init), Sender)). - assignable([_, Init| _], Init). - Assig <= Value :- var(Value), self(Self), @@ -97,7 +88,6 @@ version 2.1 (http://opensource.org/licenses/osl-2.1.php). ; Tail = [Value| _]. - Assig => Value :- var(Assig), self(Self), @@ -110,5 +100,4 @@ version 2.1 (http://opensource.org/licenses/osl-2.1.php). ; Current = Value. - :- end_category. diff --git a/Logtalk/library/atom.lgt b/Logtalk/library/atom.lgt index c6a10b076..6526fb4f7 100644 --- a/Logtalk/library/atom.lgt +++ b/Logtalk/library/atom.lgt @@ -2,16 +2,13 @@ :- object(atom, extends(atomic)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Atom data type predicates.']). - valid(Atom) :- atom(Atom). - :- end_object. diff --git a/Logtalk/library/atomic.lgt b/Logtalk/library/atomic.lgt index 64db015a6..25a77811f 100644 --- a/Logtalk/library/atomic.lgt +++ b/Logtalk/library/atomic.lgt @@ -2,16 +2,13 @@ :- object(atomic, extends(term)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Atomic data type predicates.']). - valid(Atomic) :- atomic(Atomic). - :- end_object. diff --git a/Logtalk/library/attributes.lgt b/Logtalk/library/attributes.lgt index f65f83af7..d935feb5b 100644 --- a/Logtalk/library/attributes.lgt +++ b/Logtalk/library/attributes.lgt @@ -1,105 +1,75 @@ :- category(attributes). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Dynamic attributes dictionary.']). - :- public(attribute/2). - :- mode(attribute(?nonvar, ?nonvar), zero_or_more). - :- info(attribute/2, [comment is 'Returns, by backtracking, all pairs of atribute-values.', argnames is ['Attribute', 'Value']]). - :- public(attributes/1). - :- mode(attributes(-list), one). - :- info(attributes/1, [comment is 'List of all pairs of atribute-values.', argnames is ['Attributes']]). - :- private(attribute_/2). :- dynamic(attribute_/2). - :- mode(attribute_(?nonvar, ?nonvar), zero_or_more). - :- info(attribute_/2, [comment is 'Stores attributes values.', argnames is ['Attribute', 'Value']]). - :- public(del_attribute/2). - :- mode(del_attribute(?nonvar, ?nonvar), zero_or_more). - :- info(del_attribute/2, [comment is 'Deletes a matching attribute-value pair.', argnames is ['Attribute', 'Value']]). - :- public(del_attributes/2). - :- mode(del_attributes(@term, @term), one). - :- info(del_attributes/2, [comment is 'Deletes all matching attribute-value pairs.', argnames is ['Attribute', 'Value']]). - :- public(set_attribute/2). - :- mode(set_attribute(+nonvar, +nonvar), one). - :- info(set_attribute/2, [comment is 'Sets an attribute value.', argnames is ['Attribute', 'Value']]). - :- public(set_attributes/1). - :- mode(set_attributes(+list), one). - :- info(set_attributes/1, [comment is 'Sets a list of attribute-value pairs.', argnames is ['Attributes']]). - attribute(Attribute, Value) :- ::attribute_(Attribute, Value). - attributes(Attributes) :- findall(Attribute, ::attribute_(Attribute, _), Attributes). - del_attribute(Attribute, Value) :- ::retract(attribute_(Attribute, Value)). - del_attributes(Attribute, Value) :- ::retractall(attribute_(Attribute, Value)). - set_attribute(Attribute, Value) :- ::retractall(attribute_(Attribute, _)), ::assertz(attribute_(Attribute, Value)). - set_attributes([]). - set_attributes([Attribute-Value| Attributes]) :- ::retractall(attribute_(Attribute, _)), ::assertz(attribute_(Attribute, Value)), set_attributes(Attributes). - :- end_category. diff --git a/Logtalk/library/before_event_registry.lgt b/Logtalk/library/before_event_registry.lgt index 396642cf1..51b210e45 100644 --- a/Logtalk/library/before_event_registry.lgt +++ b/Logtalk/library/before_event_registry.lgt @@ -2,38 +2,30 @@ :- object(before_event_registry, implements(event_registryp)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Before events registry predicates.']). - monitors(Monitors) :- findall(Monitor, current_event(before, _, _, _, Monitor), List), {sort(List, Monitors)}. - monitored(Objects) :- findall(Object, current_event(before, Object, _, _, _), List), {sort(List, Objects)}. - monitor(Object, Message, Sender, Monitor) :- current_event(before, Object, Message, Sender, Monitor). - set_monitor(Object, Message, Sender, Monitor) :- define_events(before, Object, Message, Sender, Monitor). - del_monitors(Object, Message, Sender, Monitor) :- abolish_events(before, Object, Message, Sender, Monitor). - del_monitors :- abolish_events(before, _, _, _, _). - :- end_object. diff --git a/Logtalk/library/bintree.lgt b/Logtalk/library/bintree.lgt index d10279f30..b0d18314f 100644 --- a/Logtalk/library/bintree.lgt +++ b/Logtalk/library/bintree.lgt @@ -3,153 +3,112 @@ implements(dictionaryp), extends(compound)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/9/17, comment is 'Dictionary protocol implemented using binary trees.']). - :- private(map/4). :- meta_predicate(map(*, *, *, ::)). - :- mode(map(+atom, +tree, -tree, -callable), zero_or_one). - as_list(Tree, List) :- as_list(Tree, [], List). - as_list(t, List, List). - as_list(t(Key, Value, Left, Right), Acc, List) :- as_list(Right, Acc, Acc2), as_list(Left, [Key-Value| Acc2], List). - empty(Tree) :- Tree == t. - insert(Key, Value, t, t(Key, Value, t, t)) :- nonvar(Key). - insert(Key, Value, t(Key1, Value1, Left1, Right1), t(Key1, Value2, Left2, Right2)) :- compare(Order, Key, Key1), insert(Order, Key, Value, Key1, Value1, Left1, Right1, Value2, Left2, Right2). - insert(=, _, Value, _, _, Left, Right, Value, Left, Right). - insert(<, Key, Value, _, Value1, Left1, Right, Value1, Left2, Right) :- insert(Key, Value, Left1, Left2). - insert(>, Key, Value, _, Value1, Left, Right1, Value1, Left, Right2) :- insert(Key, Value, Right1, Right2). - insert_all([], Tree, Tree). - insert_all([Key-Value| Rest], Old, New) :- insert(Key, Value, Old, Aux), insert_all(Rest, Aux, New). - lookup(Key, Value, Tree) :- - var(Key) -> + ( var(Key) -> lookup_var(Key, Value, Tree) - ; - lookup_nonvar(Key, Value, Tree). - + ; lookup_nonvar(Key, Value, Tree) + ). lookup_nonvar(Key, Value, t(Key1, Value1, Left1, Right1)) :- compare(Order, Key, Key1), lookup_nonvar(Order, Key, Value, Value1, Left1, Right1). - lookup_nonvar(=, _, Value, Value, _, _). - lookup_nonvar(<, Key, Value, _, Left, _) :- lookup_nonvar(Key, Value, Left). - lookup_nonvar(<, Key, Value, _, _, Right) :- lookup_nonvar(Key, Value, Right). - lookup_var(Key, Value, t(_, _, Left, _)) :- lookup_var(Key, Value, Left). - lookup_var(Key, Value, t(Key, Value,_,_)). - lookup_var(Key, Value, t(_, _, _, Right)) :- lookup_var(Key, Value, Right). - keys(Tree, Keys) :- keys(Tree, [], Keys). - keys(t, Keys, Keys). - keys(t(Key, _, Left, Right), Acc, Keys) :- keys(Right, Acc, Acc2), keys(Left, [Key| Acc2], Keys). - delete(t, _, _, t). - delete(t(Key1, Value1, Left1, Right1), Key, Value, Out) :- compare(Order, Key, Key1), delete(Order, Key1, Value1, Left1, Right1, Key, Value, Out). - delete(=, Key1, Value1, Left1, Right1, Key1, Value1, Out) :- join(Left1, Right1, Out). - delete(<, Key1, Value1, Left1, Right1, Key, Value, t(Key1, Value1, Left2, Right1)) :- delete(Left1, Key, Value, Left2). - delete(>, Key1, Value1, Left1, Right1, Key, Value, t(Key1, Value1, Left1, Right2)) :- delete(Right1, Key, Value, Right2). - join(t, Right, Right) :- !. - join(Left, t, Left) :- !. - join(t(Key, Value, Left, Right), Tree, t(Key, Value, Left, Right2)) :- join(Right, Tree, Right2). - map(Pred, Old, New) :- map(Pred, Old, New, _). - map(Pred, t(Key1, Value1, Left1, Right1), t(Key2, Value2, Left2, Right2), Goal) :- Goal =.. [Pred, Key1-Value1, Key2-Value2], once(Goal), map(Pred, Left1, Left2, _), map(Pred, Right1, Right2, _). - map(_, t, t, _). - new(t). - size(Dictionary, Size) :- size(Dictionary, 0, Size). - size(t, Size, Size). - size(t(_, _, Left, Right), Acc, Size) :- size(Left, Acc, Acc2), Acc3 is Acc2 + 1, size(Right, Acc3, Size). - :- end_object. diff --git a/Logtalk/library/callable.lgt b/Logtalk/library/callable.lgt index 636b399bf..402cf17b8 100644 --- a/Logtalk/library/callable.lgt +++ b/Logtalk/library/callable.lgt @@ -2,16 +2,16 @@ :- object(callable, extends(term)). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, + date is 2007/4/29, comment is 'Callable term type predicates.']). - valid(Callable) :- - once((atom(Callable); compound(Callable))). - + ( atom(Callable) -> + true + ; compound(Callable) + ). :- end_object. diff --git a/Logtalk/library/character.lgt b/Logtalk/library/character.lgt index c76619a3c..750ebef02 100644 --- a/Logtalk/library/character.lgt +++ b/Logtalk/library/character.lgt @@ -3,87 +3,68 @@ implements(characterp), extends(atom)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Character predicates.']). - is_alpha('_'). - is_alpha(Char) :- is_letter(Char). - is_letter(Char) :- is_lower_case(Char). - is_letter(Char) :- is_upper_case(Char). - is_alphanumeric(Char) :- is_alpha(Char). - is_alphanumeric(Char) :- is_dec_digit(Char). - is_bin_digit(0). is_bin_digit(1). - is_octal_digit(Digit) :- Digit @>= 0, Digit @=< 7. - is_dec_digit(Digit) :- Digit @>= 0, Digit @=< 9. - is_hex_digit(Digit) :- Digit @>= 0, Digit @=< 9. - is_hex_digit(Digit) :- Digit @>= 'A', Digit @=< 'F'. - is_hex_digit(Digit) :- Digit @>= a, Digit @=< f. - is_lower_case(Char) :- Char @>= a, Char @=< z. - is_upper_case(Char) :- Char @>= 'A', Char @=< 'Z'. - is_vowel(a). is_vowel(e). is_vowel(i). is_vowel(o). is_vowel(u). - is_vowel('A'). is_vowel('E'). is_vowel('I'). is_vowel('O'). is_vowel('U'). - is_layout(' '). - lower_upper(a, 'A'). lower_upper(b, 'B'). lower_upper(c, 'C'). @@ -110,15 +91,12 @@ lower_upper(x, 'X'). lower_upper(y, 'Y'). lower_upper(z, 'Z'). - lower_upper(Char, Char) :- \+ (Char @>= a, Char @=< z), \+ (Char @>= 'A', Char @=< 'Z'). - valid(Character) :- atom(Character), atom_length(Character, 1). - :- end_object. diff --git a/Logtalk/library/characterp.lgt b/Logtalk/library/characterp.lgt index 5699dae81..1049fd655 100644 --- a/Logtalk/library/characterp.lgt +++ b/Logtalk/library/characterp.lgt @@ -1,122 +1,84 @@ :- protocol(characterp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Character protocol.']). - :- public(is_alphanumeric/1). - :- mode(is_alphanumeric(+char), zero_or_one). - :- info(is_alphanumeric/1, [ comment is 'True if the argument is an alphanumeric character.', argnames is ['Term']]). - :- public(is_alpha/1). - :- mode(is_alpha(+char), zero_or_one). - :- info(is_alpha/1, [ comment is 'True if the argument is a letter or an underscore.', argnames is ['Term']]). - :- public(is_letter/1). - :- mode(is_letter(+char), zero_or_one). - :- info(is_letter/1, [ comment is 'True if the argument is a letter.', argnames is ['Term']]). - :- public(is_bin_digit/1). - :- mode(is_bin_digit(+char), zero_or_one). - :- info(is_bin_digit/1, [ comment is 'True if the argument is a binary digit.', argnames is ['Term']]). - :- public(is_octal_digit/1). - :- mode(is_octal_digit(+char), zero_or_one). - :- info(is_octal_digit/1, [ comment is 'True if the argument is an octal digit.', argnames is ['Term']]). - :- public(is_dec_digit/1). - :- mode(is_dec_digit(+char), zero_or_one). - :- info(is_dec_digit/1, [ comment is 'True if the argument is a decimal digit.', argnames is ['Term']]). - :- public(is_hex_digit/1). - :- mode(is_hex_digit(+char), zero_or_one). - :- info(is_hex_digit/1, [ comment is 'True if the argument is an hexadecimal digit.', argnames is ['Term']]). - :- public(is_lower_case/1). - :- mode(is_lower_case(+char), zero_or_one). - :- info(is_lower_case/1, [ comment is 'True if the argument is a lower case letter.', argnames is ['Term']]). - :- public(is_upper_case/1). - :- mode(is_upper_case(+char), zero_or_one). - :- info(is_upper_case/1, [ comment is 'True if the argument is a upper case letter.', argnames is ['Term']]). - :- public(is_vowel/1). - :- mode(is_vowel(+char), zero_or_one). - :- info(is_vowel/1, [ comment is 'True if the argument is a vowel.', argnames is ['Term']]). - :- public(is_layout/1). - :- mode(is_layout(+char), zero_or_one). - :- info(is_layout/1, [ comment is 'True if the argument is a layout character.', argnames is ['Term']]). - :- public(lower_upper/2). - :- mode(lower_upper(?char, ?char), zero_or_more). :- mode(lower_upper(+char, ?char), zero_or_one). :- mode(lower_upper(?char, +char), zero_or_one). - :- info(lower_upper/2, [ comment is 'Converts between lower and upper case letters.', argnames is ['Term1', 'Term2']]). - :- end_protocol. diff --git a/Logtalk/library/class_hierarchy.lgt b/Logtalk/library/class_hierarchy.lgt index af6757ee6..30b5960f5 100644 --- a/Logtalk/library/class_hierarchy.lgt +++ b/Logtalk/library/class_hierarchy.lgt @@ -2,69 +2,56 @@ :- category(class_hierarchy, implements(class_hierarchyp)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/2/20, comment is 'Class hierarchy predicates.']). - class(Class) :- self(Self), instantiates_class(Self, Class). - classes(Classes) :- self(Self), findall(Class, instantiates_class(Self, Class), Classes). - ancestor(Ancestor) :- self(Self), ancestor(Self, Ancestor). - ancestor(Self, Ancestor) :- instantiates_class(Self, Ancestor). - ancestor(Self, Ancestor) :- instantiates_class(Self, Class), superclass(Class, Ancestor). - ancestors(Ancestors) :- self(Self), findall(Ancestor, ancestor(Self, Ancestor), Ancestors). - instance(Instance) :- self(Self), instantiates_class(Instance, Self). - instances(Instances) :- self(Self), findall(Instance, instantiates_class(Instance, Self), Instances). - subclass(Subclass) :- self(Self), specializes_class(Subclass, Self). - subclasses(Subclasses) :- self(Self), findall(Subclass, specializes_class(Subclass, Self), Subclasses). - superclass(Superclass) :- self(Self), superclass(Self, Superclass). superclass(Self, Superclass) :- specializes_class(Self, Superclass). - superclass(Self, Superclass) :- specializes_class(Self, Class), superclass(Class, Superclass). @@ -73,27 +60,22 @@ self(Self), findall(Superclass, specializes_class(Self, Superclass), Superclasses). - leaf(Leaf) :- self(Self), leaf(Self, Leaf). - leaf(Self, Leaf) :- instantiates_class(Leaf, Self), \+ instantiates_class(_, Leaf), \+ specializes_class(_, Leaf). - leaf(Self, Leaf) :- specializes_class(Leaf, Self), \+ instantiates_class(_, Leaf), \+ specializes_class(_, Leaf). - leaf(Self, Leaf) :- specializes_class(Subclass, Self), leaf(Subclass, Leaf). - leaves(Leaves) :- self(Self), ( setof(Leaf, leaf(Self, Leaf), Leaves) -> @@ -101,21 +83,17 @@ ; Leaves = [] ). - leaf_instance(Leaf) :- self(Self), leaf_instance(Self, Leaf). - leaf_instance(Self, Leaf) :- instantiates_class(Leaf, Self), \+ instantiates_class(_, Leaf). - leaf_instance(Self, Leaf) :- specializes_class(Subclass, Self), leaf_instance(Subclass, Leaf). - leaf_instances(Leaves) :- self(Self), ( setof(Leaf, leaf_instance(Self, Leaf), Leaves) -> @@ -123,7 +101,6 @@ ; Leaves = [] ). - leaf_class(Leaf) :- self(Self), leaf_class(Self, Leaf). @@ -131,7 +108,6 @@ leaf_class(Self, Leaf) :- specializes_class(Leaf, Self), \+ specializes_class(_, Leaf). - leaf_class(Self, Leaf) :- specializes_class(Subclass, Self), leaf_class(Subclass, Leaf). @@ -143,24 +119,19 @@ ; Leaves = [] ). - descendant(Descendant) :- self(Self), descendant(Self, Descendant). - descendant(Self, Descendant) :- instantiates_class(Descendant, Self). - descendant(Self, Descendant) :- specializes_class(Descendant, Self), \+ instantiates_class(Descendant, Self). - descendant(Self, Descendant) :- specializes_class(Subclass, Self), descendant(Subclass, Descendant). - descendants(Descendants) :- self(Self), ( setof(Descendant, descendant(Self, Descendant), Descendants) -> @@ -168,20 +139,16 @@ ; Descendants = [] ). - descendant_class(Descendant) :- self(Self), descendant_class(Self, Descendant). - descendant_class(Self, Descendant) :- specializes_class(Descendant, Self). - descendant_class(Self, Descendant) :- specializes_class(Subclass, Self), descendant_class(Subclass, Descendant). - descendant_classes(Descendants) :- self(Self), ( setof(Descendant, descendant_class(Self, Descendant), Descendants) -> @@ -189,20 +156,16 @@ ; Descendants = [] ). - descendant_instance(Descendant) :- self(Self), descendant_instance(Self, Descendant). - descendant_instance(Self, Descendant) :- instantiates_class(Descendant, Self). - descendant_instance(Self, Descendant) :- specializes_class(Subclass, Self), descendant_instance(Subclass, Descendant). - descendant_instances(Descendants) :- self(Self), ( setof(Descendant, descendant_instance(Self, Descendant), Descendants) -> @@ -210,5 +173,4 @@ ; Descendants = [] ). - :- end_category. diff --git a/Logtalk/library/class_hierarchyp.lgt b/Logtalk/library/class_hierarchyp.lgt index f3dbc14b4..350f6d222 100644 --- a/Logtalk/library/class_hierarchyp.lgt +++ b/Logtalk/library/class_hierarchyp.lgt @@ -2,156 +2,106 @@ :- protocol(class_hierarchyp, extends(hierarchyp)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Class hierarchy protocol.']). - :- public(class/1). - :- mode(class(?object), zero_or_more). - :- info(class/1, [ comment is 'Returns, by backtracking, all object classes.', argnames is ['Class']]). - :- public(classes/1). - :- mode(classes(-list), one). - :- info(classes/1, [ comment is 'List of all object classes.', argnames is ['Classes']]). - :- public(instance/1). - :- mode(instance(?object), zero_or_more). - :- info(instance/1, [ comment is 'Returns, by backtracking, all class instances.', argnames is ['Instance']]). - :- public(instances/1). - :- mode(instances(-list), one). - :- info(instances/1, [ comment is 'List of all class instances.', argnames is ['Instances']]). - :- public(subclass/1). - :- mode(subclass(?object), zero_or_more). - :- info(subclass/1, [ comment is 'Returns, by backtracking, all class subclasses.', argnames is ['Subclass']]). - :- public(subclasses/1). - :- mode(subclasses(-list), one). - :- info(subclasses/1, [ comment is 'List of all class subclasses.', argnames is ['Subclasses']]). - :- public(superclass/1). - :- mode(superclass(?object), zero_or_more). - :- info(superclass/1, [ comment is 'Returns, by backtracking, all class superclasses.', argnames is ['Superclass']]). - :- public(superclasses/1). - :- mode(superclasses(-list), one). - :- info(superclasses/1, [ comment is 'List of all class superclasses.', argnames is ['Superclasses']]). - :- public(leaf_instance/1). - :- mode(leaf_instance(?object), zero_or_more). - :- info(leaf_instance/1, [ comment is 'Returns, by backtracking, all class leaf instances.', argnames is ['Leaf']]). - :- public(leaf_instances/1). - :- mode(leaf_instances(-list), one). - :- info(leaf_instances/1, [ comment is 'List of all class leaf instances.', argnames is ['Leaves']]). - :- public(leaf_class/1). - :- mode(leaf_class(?object), zero_or_more). - :- info(leaf_class/1, [ comment is 'Returns, by backtracking, all class leaf subclasses.', argnames is ['Leaf']]). - :- public(leaf_classes/1). - :- mode(leaf_classes(-list), one). - :- info(leaf_classes/1, [ comment is 'List of all class leaf leaf subclasses.', argnames is ['Leaves']]). - :- public(descendant_instance/1). - :- mode(descendant_instance(?object), zero_or_more). - :- info(descendant_instance/1, [ comment is 'Returns, by backtracking, all class descendant instances.', argnames is ['Descendant']]). - :- public(descendant_instances/1). - :- mode(descendant_instances(-list), one). - :- info(descendant_instances/1, [ comment is 'List of all class descendant instances.', argnames is ['Descendants']]). - :- public(descendant_class/1). - :- mode(descendant_class(?object), zero_or_more). - :- info(descendant_class/1, [ comment is 'Returns, by backtracking, all class descendant subclasses.', argnames is ['Descendant']]). - :- public(descendant_classes/1). - :- mode(descendant_classes(-list), one). - :- info(descendant_classes/1, [ comment is 'List of all class descendant subclasses.', argnames is ['Descendants']]). - :- end_protocol. diff --git a/Logtalk/library/comparingp.lgt b/Logtalk/library/comparingp.lgt index 166487405..5de6a21ca 100644 --- a/Logtalk/library/comparingp.lgt +++ b/Logtalk/library/comparingp.lgt @@ -1,66 +1,46 @@ :- protocol(comparingp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Comparing protocol using overloading of standard operators.']). - :- public((<)/2). - :- mode(<(+term, +term), zero_or_one). - :- info((<)/2, [ comment is 'True if Term1 is less than Term2.', argnames is ['Term1', 'Term2']]). - :- public((=<)/2). - :- mode(=<(+term, +term), zero_or_one). - :- info((=<)/2, [ comment is 'True if Term1 is less or equal than Term2.', argnames is ['Term1', 'Term2']]). - :- public((>)/2). - :- mode(>(+term, +term), zero_or_one). - :- info((>)/2, [ comment is 'True if Term1 is greater than Term2.', argnames is ['Term1', 'Term2']]). - :- public((>=)/2). - :- mode(>=(+term, +term), zero_or_one). - :- info((>=)/2, [ comment is 'True if Term1 is equal or grater than Term2.', argnames is ['Term1', 'Term2']]). - :- public((=:=)/2). - :- mode(=:=(+term, +term), zero_or_one). - :- info((=:=)/2, [ comment is 'True if Term1 is equal to Term2.', argnames is ['Term1', 'Term2']]). - :- public((=\=)/2). - :- mode(=\=(+term, +term), zero_or_one). - :- info((=\=)/2, [ comment is 'True if Term1 is not equal to Term2.', argnames is ['Term1', 'Term2']]). - :- end_protocol. diff --git a/Logtalk/library/compound.lgt b/Logtalk/library/compound.lgt index 190a53cab..d1ebbf503 100644 --- a/Logtalk/library/compound.lgt +++ b/Logtalk/library/compound.lgt @@ -2,16 +2,13 @@ :- object(compound, extends(term)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Compound data type.']). - valid(Compound) :- compound(Compound). - :- end_object. diff --git a/Logtalk/library/date.lgt b/Logtalk/library/date.lgt index a762b2af9..5d15cfa87 100644 --- a/Logtalk/library/date.lgt +++ b/Logtalk/library/date.lgt @@ -2,25 +2,21 @@ :- object(date, implements(datep)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/3/7, comment is 'Date predicates.']). - today(Year, Month, Day) :- {'$lgt_current_date'(Year, Month, Day)}. - leap_year(Year) :- ( 0 =:= mod(Year, 4), 0 =\= mod(Year, 100) -> true ; 0 =:= mod(Year, 400) ). - name_of_day(1, 'Sunday', 'Sun'). name_of_day(2, 'Monday', 'Mon'). name_of_day(3, 'Tuesday', 'Tue'). @@ -29,7 +25,6 @@ name_of_day(6, 'Friday', 'Fri'). name_of_day(7, 'Saturday', 'Sat'). - name_of_month( 1, 'January', 'Jan'). name_of_month( 2, 'February', 'Feb'). name_of_month( 3, 'March', 'Mar'). @@ -43,7 +38,6 @@ name_of_month(11, 'November', 'Nov'). name_of_month(12, 'December', 'Dec'). - days_in_month( 1, _, 31). days_in_month( 2, Year, Days) :- leap_year(Year) -> Days = 29; Days = 28. @@ -58,7 +52,6 @@ days_in_month(11, _, 30). days_in_month(12, _, 31). - valid(Year, Month, Day) :- integer(Year), integer(Month), Month >= 1, Month =< 12, @@ -66,5 +59,4 @@ days_in_month(Month, Year, Days), Day >= 1, Day =< Days. - :- end_object. diff --git a/Logtalk/library/datep.lgt b/Logtalk/library/datep.lgt index 4cd6984fc..102f4f9fb 100644 --- a/Logtalk/library/datep.lgt +++ b/Logtalk/library/datep.lgt @@ -1,66 +1,46 @@ :- protocol(datep). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2005/3/17, comment is 'Date protocol.']). - :- public(today/3). - :- mode(today(-integer, -integer, -integer), one). - :- info(today/3, [ comment is 'Returns current date.', argnames is ['Year', 'Month', 'Day']]). - :- public(leap_year/1). - :- mode(leap_year(+integer), zero_or_one). - :- info(leap_year/1, [comment is 'True if the argument is a leap year.', argnames is ['Year']]). - :- public(name_of_day/3). - :- mode(name_of_day(?integer, ?atom, ?atom), zero_or_more). - :- info(name_of_day/3, [ comment is 'Name and short name of day.', argnames is ['Index', 'Name', 'Short']]). - :- public(name_of_month/3). - :- mode(name_of_month(?integer, ?atom, ?atom), zero_or_more). - :- info(name_of_month/3, [ comment is 'Name and short name of month.', argnames is ['Index', 'Name', 'Short']]). - :- public(days_in_month/3). - :- mode(days_in_month(?integer, +integer, ?integer), zero_or_more). - :- info(days_in_month/3, [ comment is 'Number of days in a month.', argnames is ['Month', 'Year', 'Days']]). - :- public(valid/3). - :- mode(valid(@integer, @integer, @integer), zero_or_one). - :- info(valid/3, [ comment is 'True if the arguments represent a valid date.', argnames is ['Year', 'Month', 'Day']]). - :- end_protocol. diff --git a/Logtalk/library/dates.notes b/Logtalk/library/dates.notes index 4fc9d55a8..5cd14dca7 100644 --- a/Logtalk/library/dates.notes +++ b/Logtalk/library/dates.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the dates_loader.lgt utility diff --git a/Logtalk/library/dates_loader.lgt b/Logtalk/library/dates_loader.lgt index ea510475c..eb3840cdf 100644 --- a/Logtalk/library/dates_loader.lgt +++ b/Logtalk/library/dates_loader.lgt @@ -1,5 +1,3 @@ :- initialization( - logtalk_load([ - datep, date, - timep, time])). + logtalk_load([datep, date, timep, time], [reload(skip)])). diff --git a/Logtalk/library/debugging.notes b/Logtalk/library/debugging.notes index 7d7c2de33..e8ee0347e 100644 --- a/Logtalk/library/debugging.notes +++ b/Logtalk/library/debugging.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the debugging_loader.lgt utility diff --git a/Logtalk/library/debugging_loader.lgt b/Logtalk/library/debugging_loader.lgt index 84e2e1729..da145feb4 100644 --- a/Logtalk/library/debugging_loader.lgt +++ b/Logtalk/library/debugging_loader.lgt @@ -1,3 +1,3 @@ :- initialization( - logtalk_load([event_dbgp, event_dbg], [events(on)])). + logtalk_load([event_dbgp, event_dbg], [events(on), reload(skip)])). diff --git a/Logtalk/library/dependents.notes b/Logtalk/library/dependents.notes index 7585f4f65..a4d22be5b 100644 --- a/Logtalk/library/dependents.notes +++ b/Logtalk/library/dependents.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the dependents_loader.lgt diff --git a/Logtalk/library/dependents_loader.lgt b/Logtalk/library/dependents_loader.lgt index 03f1e494c..9c8c85e98 100644 --- a/Logtalk/library/dependents_loader.lgt +++ b/Logtalk/library/dependents_loader.lgt @@ -1,3 +1,3 @@ :- initialization( - logtalk_load([observer, subject])). + logtalk_load([observer, subject], [reload(skip)])). diff --git a/Logtalk/library/dictionaryp.lgt b/Logtalk/library/dictionaryp.lgt index 9615dc098..0fa7d5a94 100644 --- a/Logtalk/library/dictionaryp.lgt +++ b/Logtalk/library/dictionaryp.lgt @@ -1,103 +1,71 @@ :- protocol(dictionaryp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Dictionary protocol.']). - :- public(as_dictionary/2). - :- mode(as_dictionary(@list, -dictionary), one). - :- info(as_dictionary/2, [ comment is 'Converts a list of key-value pairs to a dictionary.', argnames is ['List', 'Dictionary']]). - :- public(as_list/2). - :- mode(as_list(@dictionary, -list), one). - :- info(as_list/2, [ comment is 'Converts a dictionary to a list of key-value pairs.', argnames is ['Dictionary', 'List']]). - :- public(delete/4). - :- mode(delete(+dictionary, @ground, ?term, -dictionary), zero_or_one). - :- info(delete/4, [ comment is 'Deletes a matching Key-Value pair from a dictionary, returning the updated dictionary.', argnames is ['Dictionary_in', 'Key', 'Value', 'Dictionary_out']]). - :- public(empty/1). - :- mode(empty(@dictionary), zero_or_one). - :- info(empty/1, [ comment is 'True if the dictionary is empty.', argnames is ['Dictionary']]). - :- public(insert/4). - :- mode(insert(+ground, @term, +dictionary, -dictionary), one). - :- info(insert/4, [ comment is 'Inserts a Key-Value pair into a dictionary, returning the updated dictionary.', argnames is ['Key', 'Value', 'Dictionary_in', 'Dictionary_out']]). - :- public(insert_all/3). - :- mode(insert_all(@list, +dictionary, -dictionary), one). - :- info(insert_all/3, [ comment is 'Inserts a list of Key-Value pairs into a dictionary, returning the updated dictionary.', argnames is ['List', 'Dictionary_in', 'Dictionary_out']]). - :- public(lookup/3). - :- mode(lookup(+ground, ?term, @dictionary), zero_or_one). :- mode(lookup(-ground, ?term, @dictionary), zero_or_more). - :- info(lookup/3, [ comment is 'Get a matching Key-Value pair from a dictionary.', argnames is ['Key', 'Value', 'Dictionary']]). - :- public(keys/2). - :- mode(keys(@dictionary, -list), one). - :- info(keys/2, [ comment is 'Returns a list with all dictionary keys.', argnames is ['Dictionary', 'List']]). - :- public(map/3). - :- mode(map(+functor, +dictionary, -dictionary), zero_or_one). - :- info(map/3, [ comment is 'Maps a binary predicate over each dictionary key-value pair returning a new pair.', argnames is ['Functor', 'In', 'Out']]). - :- public(size/2). - :- mode(size(@dictionary, ?integer), zero_or_one). - :- info(size/2, [ comment is 'Number of dictionary entries.', argnames is ['Dictionary', 'Size']]). - :- end_protocol. diff --git a/Logtalk/library/difflist.lgt b/Logtalk/library/difflist.lgt index c18c8790f..a23725e83 100644 --- a/Logtalk/library/difflist.lgt +++ b/Logtalk/library/difflist.lgt @@ -3,28 +3,22 @@ implements(listp), extends(compound)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2004/5/9, comment is 'Difference list predicates.']). - :- public(as_list/2). - :- mode(as_list(+list, -list), one). - :- info(as_list/2, [comment is 'Converts a difference list to a normal list.', argnames is ['Diffist', 'List']]). - append(List1-Back1, Back1-Back2, List1-Back2) :- nonvar(List1), nonvar(Back1), !. - append(Prefix, Suffix, List) :- length(List, Length), prefix(Prefix, List), @@ -33,187 +27,153 @@ length(Suffix, SLength), suffix(Suffix, List). - as_list(List-Back, Out) :- - List == Back -> + ( List == Back -> Out = [] - ; - Out = [Head| Tail], + ; Out = [Head| Tail], List = [Head| Rest], - as_list(Rest-Back, Tail). - + as_list(Rest-Back, Tail) + ). delete(List-Back, Element, Remaining) :- - List == Back -> + ( List == Back -> unify_with_occurs_check(Remaining, Back-Back) - ; - List \== Back, + ; List \== Back, List = [Head| Tail], - (Head == Element -> + ( Head == Element -> delete(Tail-Back, Element, Remaining) - ; - Remaining = [Head| Tail2], - delete(Tail-Back, Element, Tail2-Back)). - - + ; Remaining = [Head| Tail2], + delete(Tail-Back, Element, Tail2-Back) + ) + ). delete_matches(List-Back, Element, Remaining) :- - List == Back -> + ( List == Back -> unify_with_occurs_check(Remaining, Back-Back) - ; - List \== Back, + ; List \== Back, List = [Head| Tail], - (\+ \+ Head = Element -> + ( \+ \+ Head = Element -> delete_matches(Tail-Back, Element, Remaining) - ; - Remaining = [Head| Tail2], - delete_matches(Tail-Back, Element, Tail2-Back)). - + ; Remaining = [Head| Tail2], + delete_matches(Tail-Back, Element, Tail2-Back) + ) + ). empty(List-Back) :- List == Back. - flatten(List-Back, Flatted-Back) :- flatten(List-Back, Back-Back, Flatted-Back). - flatten(Var, Tail-Back, [Var| Tail]-Back) :- var(Var), !. - flatten(List-Back, Flatted, Flatted) :- List == Back, !. - flatten(List-Back, Acc, Flatted) :- !, List \== Back, List = [Head| Tail], flatten(Tail-Back, Acc, Acc2), flatten(Head, Acc2, Flatted). - flatten(Head, Tail-Back, [Head| Tail]-Back). - keysort(Difflist, Sorted) :- as_list(Difflist, List), {keysort(List, List2)}, list::as_difflist(List2, Sorted). - last(List-Back, Last) :- List \== Back, List = [Head| Tail], last(Tail-Back, Head, Last). - last(List, Last, Last) :- unify_with_occurs_check(List, Back-Back). - last(List-Back, _, Last) :- List \== Back, List = [Head| Tail], last(Tail-Back, Head, Last). - length(List, Length) :- - integer(Length) -> + ( integer(Length) -> Length >= 0, make_list(Length, List) - ; - length(List, 0, Length). - + ; length(List, 0, Length) + ). length(List, Length, Length) :- unify_with_occurs_check(List, Back-Back). - length(List-Back, Acc, Length) :- List \== Back, List = [_| Tail], Acc2 is Acc + 1, length(Tail-Back, Acc2, Length). - make_list(0, List):- !, unify_with_occurs_check(List, Back-Back). - make_list(N, List-Back):- List \== Back, List = [_| Tail], M is N-1, make_list(M, Tail-Back). - max(List-Back, Max) :- List \== Back, List = [Head| Tail], max(Tail-Back, Head, Max). - max(List-Back, Max, Max) :- List == Back, !. - max(List-Back, Aux, Max) :- List \== Back, List = [Head| Tail], - (Aux @< Head -> + ( Aux @< Head -> max(Tail-Back, Head, Max) - ; - max(Tail-Back, Aux, Max)). - + ; max(Tail-Back, Aux, Max) + ). member(Element, List-Back) :- List \== Back, List = [Element|_]. - member(Element, List-Back) :- List \== Back, List = [_| Tail], member(Element, Tail-Back). - memberchk(Element, List) :- once(member(Element, List)). - nth0(Position, List, Element) :- nth(Element, List, 0, Position, _). - nth0(Nth, List, Element, Tail) :- nth(Element, List, 0, Nth, Tail). - nth1(Position, List, Element) :- nth(Element, List, 1, Position, _). - nth1(Nth, List, Element, Tail) :- nth(Element, List, 1, Nth, Tail). - nth(Element, List-Back, Position, Position, Tail-Back) :- List \== Back, List = [Element| Tail]. - nth(Element, List-Back, Count, Position, Tail-Back) :- List \== Back, List = [_| List2], Count2 is Count + 1, nth(Element, List2-Back, Count2, Position, Tail-Back). - min(List-Back, Min) :- List \== Back, List = [Head| Tail], min(Tail-Back, Head, Min). - min(List-Back, Min, Min) :- List == Back, !. - min(List-Back, Aux, Min) :- List \== Back, List = [Head| Tail], @@ -222,30 +182,24 @@ ; min(Tail-Back, Aux, Min)). - new(List) :- unify_with_occurs_check(List, Back-Back). - permutation(List, Permutation) :- same_length(List, Permutation), permutation2(List, Permutation). - permutation2(List1-Back1, List2-Back2) :- List1 == Back1, List2 == Back2. - permutation2(List1-Back1, List2-Back2) :- List2 \== Back2, List2 = [Head2| Tail2], select(Head2, List1-Back1, Tail1-Back1), permutation2(Tail1-Back1, Tail2-Back2). - prefix(List, _) :- unify_with_occurs_check(List, Back-Back). - prefix(List-Back, List2-Back2) :- List \== Back, List = [Head| Tail], @@ -253,25 +207,20 @@ List2 = [Head| Tail2], prefix(Tail-Back, Tail2-Back2). - reverse(List-Back, Reversed-Back) :- same_length(List-Back, Reversed-Back), reverse(List-Back, Back-Back, Reversed-Back). - reverse(List-Back, Reversed, Reversed) :- List == Back. - reverse(List-Back, Acc-Back, Reversed) :- List \== Back, List = [Head| Tail], reverse(Tail-Back, [Head| Acc]-Back, Reversed). - same_length(List1, List2) :- unify_with_occurs_check(List1, Back1-Back1), unify_with_occurs_check(List2, Back2-Back2). - same_length(List1-Back1, List2-Back2) :- List1 \== Back1, List1 = [_| Tail1], @@ -279,11 +228,9 @@ List2 = [_| Tail2], same_length(Tail1-Back1, Tail2-Back2). - select(Head, List-Back, Tail-Back) :- List \== Back, List = [Head| Tail]. - select(Head, List-Back, List2-Back) :- List \== Back, List = [Other| Tail], @@ -291,40 +238,32 @@ List2 = [Other| Tail2], select(Head, Tail-Back, Tail2-Back). - sort(Difflist, Sorted) :- as_list(Difflist, List), {sort(List, List2)}, list::as_difflist(List2, Sorted). - sublist(Sublist, List) :- unify_with_occurs_check(Sublist, List). - sublist(Sublist-Back, List-Back):- List \== Back, List = [Head| Tail], sublist(Tail-Back, Head, Sublist-Back). - sublist(List, _, Sublist) :- unify_with_occurs_check(List, Sublist). - sublist(List-Back, _, Sublist-Back):- List \== Back, List = [Head| Tail], sublist(Tail-Back, Head, Sublist-Back). - sublist(List-Back, Element, [Element| Sublist]-Back):- List \== Back, List = [Head| Tail], sublist(Tail-Back, Head, Sublist-Back). - subtract(List-Back, _, Result) :- unify_with_occurs_check(Result, Back-Back), List == Back, !. - subtract(List-Back, Ys, List2-Back) :- List \== Back, List = [Head| Tail], @@ -334,29 +273,23 @@ List2 = [Head| Tail2], subtract(Tail-Back, Ys, Tail2-Back)). - suffix(Suffix, List) :- unify_with_occurs_check(Suffix, List). - suffix(Suffix-Back, List-Back) :- List \== Back, List = [_| Tail], suffix(Suffix-Back, Tail-Back). - valid(List) :- nonvar(List), valid2(List). - valid2(List-Back) :- List == Back, !. - valid2(List-Back) :- nonvar(List), List = [_| Tail], valid2(Tail-Back). - :- end_object. diff --git a/Logtalk/library/event_dbg.lgt b/Logtalk/library/event_dbg.lgt index b9202487c..49f7c777e 100644 --- a/Logtalk/library/event_dbg.lgt +++ b/Logtalk/library/event_dbg.lgt @@ -3,63 +3,46 @@ implements(event_dbgp, monitoring), imports(monitor)). - :- info([ version is 1.1, date is 2006/12/15, author is 'Paulo Moura', comment is 'Debugging facilities similar to those found in most Prolog compilers.']). - :- initialization(::init). - :- protected(port_output/4). - :- mode(port_output(+atom, +object, @callable, +object), one). - :- info(port_output/4, [ comment is 'Outputs current port information.', argnames is ['Port', 'Object', 'Message', 'Sender']]). - :- protected(execute_option/1). - :- mode(execute_option(+atom), one). - :- info(execute_option/1, [ comment is 'Executes a user option at a debugger port.', argnames is ['Option']]). - :- protected(query_user/1). - :- mode(query_user(-atom), one). - :- info(query_user/1, [ comment is 'Query a user about an option at a debugger port.', argnames is ['Option']]). - :- private(stream_/2). :- dynamic(stream_/2). - :- mode(stream_(?atom, ?stream), zero_or_more). - :- info(stream/2, [ comment is 'Stores the current debugger input and ouput streams.', argnames is ['Kind', 'Stream']]). - stream(Name, Stream) :- ::stream_(Name, Stream). - set_stream(Name, Stream) :- ::retractall(stream_(Name, _)), ::assertz(stream_(Name, Stream)). - trace :- self(Self), abolish_events(before, _, _, _, Self), @@ -67,25 +50,20 @@ define_events(before, _, _, _, Self), define_events(after, _, _, _, Self). - notrace :- self(Self), abolish_events(before, _, _, _, Self), abolish_events(after, _, _, _, Self). - debugging :- ::monitor_activated. - debug :- ::activate_monitor. - nodebug :- ::suspend_monitor. - port_output(Port, Object, Message, Sender) :- ::stream(output, Output), write(Output, Port), @@ -97,7 +75,6 @@ writeq(Output, Sender), nl(Output). - query_user(Option) :- ::stream(output, Output), ::stream(input, Input), @@ -105,21 +82,18 @@ write(Output, ' >> '), read(Input, Option), nl(Output), - (valid_option(Option) -> + ( valid_option(Option) -> true - ; - ::execute_option(h), fail), + ; ::execute_option(h), + fail + ), !. - execute_option(c). - execute_option(f) :- !, fail. - execute_option(n) :- ::nodebug. - execute_option(b) :- ::stream(output,Output), ::stream(input, Input), @@ -128,17 +102,15 @@ read(Input, Goal), writeq(Output, Goal), nl(Output), - (once(Goal) -> + ( once(Goal) -> write(Output, ' answer: '), writeq(Output, Goal), nl(Output) - ; - write(Output, ' no'), nl(Output)), + ; write(Output, ' no'), nl(Output) + ), Goal = true, !. - execute_option(a) :- throw(error(logtalk_execution_aborted)). - execute_option(h) :- ::stream(output, Output), write(Output, ' Available options are:'), nl(Output), @@ -150,26 +122,22 @@ write(Output, ' h - help (prints this list of options)'), nl(Output), nl(Output). - valid_option(c). valid_option(f). valid_option(n). valid_option(b). valid_option(a). - before(Object, Message, Sender) :- ::port_output(call, Object, Message, Sender), ::query_user(Option), ::execute_option(Option). - after(Object, Message, Sender) :- ::port_output(exit, Object, Message, Sender), ::query_user(Option), ::execute_option(Option). - init :- ::reset_monitor, current_input(Input), @@ -177,5 +145,4 @@ current_output(Output), ::set_stream(output, Output). - :- end_object. diff --git a/Logtalk/library/event_dbgp.lgt b/Logtalk/library/event_dbgp.lgt index 6e5d2099c..ddba4d123 100644 --- a/Logtalk/library/event_dbgp.lgt +++ b/Logtalk/library/event_dbgp.lgt @@ -1,78 +1,52 @@ :- protocol(event_dbgp). - :- info([ version is 1.0, date is 2000/7/24, author is 'Paulo Moura', comment is 'Debugging protocol similar to those found in most Prolog compilers.']). - :- public(trace/0). - :- mode(trace, one). - :- info(trace/0, [ comment is 'Starts tracing all message sending events.']). - :- public(notrace/0). - :- mode(notrace, one). - :- info(notrace/0, [ comment is 'Stops tracing.']). - :- public(debug/0). - :- mode(debug, one). - :- info(debug/0, [ comment is 'Activates spy points and starts debugging.']). - :- public(nodebug/0). - :- mode(nodebug, one). - :- info(nodebug/0, [ comment is 'Suspends spy points and stops debugging.']). - :- public(debugging/0). - :- mode(debugging, zero_or_one). - :- info(debugging/0, [ comment is 'True if the debugger is active.']). - :- public(init/0). - :- mode(init, one). - :- info(init/0, [ comment is 'Initializes debugger, turns debugging off and resets all spy points and streams.']). - :- public(stream/2). - :- mode(stream(?atom, ?stream), zero_or_more). - :- info(stream/2, [ comment is 'Current debugger input or ouput streams.', argnames is ['Kind', 'Stream']]). - :- public(set_stream/2). - :- mode(set_stream(+atom, +stream), one). - :- info(set_stream/2, [ comment is 'Sets the debugger input or output stream.', argnames is ['Kind', 'Stream']]). - :- end_protocol. diff --git a/Logtalk/library/event_handlersp.lgt b/Logtalk/library/event_handlersp.lgt index db456fb43..263786a1f 100644 --- a/Logtalk/library/event_handlersp.lgt +++ b/Logtalk/library/event_handlersp.lgt @@ -1,30 +1,22 @@ :- protocol(event_handlersp). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2003/2/12, comment is 'Event handlers protocol.']). - :- public(before/3). - :- mode(before(@object, @nonvar, @object), zero_or_one). - :- info(before/3, [ comment is 'Before event handler.', argnames is ['Object', 'Message', 'Sender']]). - :- public(after/3). - :- mode(after(@object, @nonvar, @object), zero_or_one). - :- info(after/3, [ comment is 'After event handler.', argnames is ['Object', 'Message', 'Sender']]). - :- end_protocol. diff --git a/Logtalk/library/event_registry.lgt b/Logtalk/library/event_registry.lgt index 9bcd44ae4..c93dc026e 100644 --- a/Logtalk/library/event_registry.lgt +++ b/Logtalk/library/event_registry.lgt @@ -2,14 +2,12 @@ :- object(event_registry, implements(event_registryp)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Before and after events registry predicates.']). - monitors(Monitors) :- findall( Monitor, @@ -18,7 +16,6 @@ List), {sort(List, Monitors)}. - monitored(Objects) :- findall( Object, @@ -27,25 +24,20 @@ List), {sort(List, Objects)}. - monitor(Object, Message, Sender, Monitor) :- current_event(before, Object, Message, Sender, Monitor), current_event(after, Object, Message, Sender, Monitor). - set_monitor(Object, Message, Sender, Monitor) :- define_events(before, Object, Message, Sender, Monitor), define_events(after, Object, Message, Sender, Monitor). - del_monitors(Object, Message, Sender, Monitor) :- abolish_events(before, Object, Message, Sender, Monitor), abolish_events(after, Object, Message, Sender, Monitor). - del_monitors :- abolish_events(before, _, _, _, _), abolish_events(after, _, _, _, _). - :- end_object. diff --git a/Logtalk/library/event_registryp.lgt b/Logtalk/library/event_registryp.lgt index 4ff9555be..fe65fe336 100644 --- a/Logtalk/library/event_registryp.lgt +++ b/Logtalk/library/event_registryp.lgt @@ -1,65 +1,45 @@ :- protocol(event_registryp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Event registry protocol.']). - :- public(monitors/1). - :- mode(monitors(-list), one). - :- info(monitors/1, [ comment is 'Returns a list of all current monitors.', argnames is ['Monitors']]). - :- public(monitored/1). - :- mode(monitored(-list), one). - :- info(monitored/1, [ comment is 'Returns a list of all currently monitored objects.', argnames is ['Objects']]). - :- public(monitor/4). - :- mode(monitor(?object, ?nonvar, ?object, ?object), zero_or_more). - :- info(monitor/4, [ comment is 'True if the arguments describe a currently defined monitored event.', argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - :- public(set_monitor/4). - :- mode(set_monitor(?object, ?nonvar, ?object, +object), zero_or_one). - :- info(set_monitor/4, [ comment is 'Sets a monitor for the set of matching events.', argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - :- public(del_monitors/4). - :- mode(del_monitors(?object, ?nonvar, ?object, ?object), one). - :- info(del_monitors/4, [ comment is 'Deletes all matching monitored events.', argnames is ['Object', 'Message', 'Sender', 'Monitor']]). - :- public(del_monitors/0). - :- mode(del_monitors, one). - :- info(del_monitors/0, [ comment is 'Deletes all monitored events.']). - :- end_protocol. diff --git a/Logtalk/library/events.notes b/Logtalk/library/events.notes index 90c24e6f9..446dc5a13 100644 --- a/Logtalk/library/events.notes +++ b/Logtalk/library/events.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this library load the events_loader.lgt utility diff --git a/Logtalk/library/events_loader.lgt b/Logtalk/library/events_loader.lgt index 13397f2c0..1c382b9a7 100644 --- a/Logtalk/library/events_loader.lgt +++ b/Logtalk/library/events_loader.lgt @@ -4,4 +4,4 @@ event_handlersp, event_registryp, event_registry, before_event_registry, after_event_registry, - monitorp, monitor])). + monitorp, monitor], [events(on), reload(skip)])). diff --git a/Logtalk/library/experimental/NOTES.txt b/Logtalk/library/experimental/NOTES.txt index 7ef29ba00..3a28a602e 100644 --- a/Logtalk/library/experimental/NOTES.txt +++ b/Logtalk/library/experimental/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ This folder contains objects, categories, and protocols whose implementation is Prolog-compiler dependent. Each sub-folder diff --git a/Logtalk/library/float.lgt b/Logtalk/library/float.lgt index 6a18c214d..318fdaa5b 100644 --- a/Logtalk/library/float.lgt +++ b/Logtalk/library/float.lgt @@ -2,16 +2,13 @@ :- object(float, extends(number)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Floating point numbers data type predicates.']). - valid(Float) :- float(Float). - :- end_object. diff --git a/Logtalk/library/hierarchies.notes b/Logtalk/library/hierarchies.notes index bff0c8abb..a0fbf7da1 100644 --- a/Logtalk/library/hierarchies.notes +++ b/Logtalk/library/hierarchies.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the hierarchies_loader.lgt diff --git a/Logtalk/library/hierarchies_loader.lgt b/Logtalk/library/hierarchies_loader.lgt index 7a05c6f90..90e8c895f 100644 --- a/Logtalk/library/hierarchies_loader.lgt +++ b/Logtalk/library/hierarchies_loader.lgt @@ -3,4 +3,4 @@ logtalk_load([ hierarchyp, proto_hierarchyp, proto_hierarchy, - class_hierarchyp, class_hierarchy])). + class_hierarchyp, class_hierarchy], [reload(skip)])). diff --git a/Logtalk/library/hierarchyp.lgt b/Logtalk/library/hierarchyp.lgt index f1f1aacaa..009663f47 100644 --- a/Logtalk/library/hierarchyp.lgt +++ b/Logtalk/library/hierarchyp.lgt @@ -1,66 +1,46 @@ :- protocol(hierarchyp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Common hierarchy protocol for prototype and class hierarchies.']). - :- public(ancestor/1). - :- mode(ancestor(?object), zero_or_more). - :- info(ancestor/1, [ comment is 'Returns, by backtracking, all object ancestors.', argnames is ['Ancestor']]). - :- public(ancestors/1). - :- mode(ancestors(-list), one). - :- info(ancestors/1, [ comment is 'List of all object ancestors.', argnames is ['Ancestors']]). - :- public(leaf/1). - :- mode(leaf(?object), zero_or_more). - :- info(leaf/1, [ comment is 'Returns, by backtracking, all object leaves.', argnames is ['Leaf']]). - :- public(leaves/1). - :- mode(leaves(-list), one). - :- info(leaves/1, [ comment is 'List of all object leaves.', argnames is ['Leaves']]). - :- public(descendant/1). - :- mode(descendant(?object), zero_or_more). - :- info(descendant/1, [ comment is 'Returns, by backtracking, all object descendants.', argnames is ['Descendant']]). - :- public(descendants/1). - :- mode(descendants(-list), one). - :- info(descendants/1, [ comment is 'List of all object descendants.', argnames is ['Descendants']]). - :- end_protocol. diff --git a/Logtalk/library/integer.lgt b/Logtalk/library/integer.lgt index 18f876341..5431caf66 100644 --- a/Logtalk/library/integer.lgt +++ b/Logtalk/library/integer.lgt @@ -2,45 +2,37 @@ :- object(integer, extends(number)). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, + date is 2007/4/20, comment is 'Integer data type predicates.']). - :- public(between/3). - - :- mode(between(+integer, +integer, ?integer), zero_or_more). - + :- mode(between(+integer, +integer, +integer), zero_or_one). + :- mode(between(+integer, +integer, -integer), zero_or_more). :- info(between/3, [ comment is 'Returns integers in the interval defined by the two first arguments.', argnames is ['Lower', 'Upper', 'Integer']]). - between(Lower, Upper, Integer) :- integer(Lower), integer(Upper), - (var(Integer) -> + ( var(Integer) -> Lower =< Upper, generate(Lower, Upper, Integer) - ; - integer(Integer), + ; integer(Integer), Lower =< Integer, - Integer =< Upper). - + Integer =< Upper + ). generate(Lower, _, Lower). - generate(Lower, Upper, Integer) :- Lower < Upper, Next is Lower + 1, generate(Next, Upper, Integer). - valid(Integer) :- integer(Integer). - :- end_object. diff --git a/Logtalk/library/list.lgt b/Logtalk/library/list.lgt index c98a15cc9..e93b0c1d8 100644 --- a/Logtalk/library/list.lgt +++ b/Logtalk/library/list.lgt @@ -3,37 +3,30 @@ implements(listp), extends(compound)). - :- info([ version is 1.3, author is 'Paulo Moura', date is 2006/12/21, comment is 'List predicates.']). - :- public(as_difflist/2). - :- mode(as_difflist(+list, -list), one). - :- info(as_difflist/2, [comment is 'Converts a list to a difference list.', argnames is ['List', 'Diffist']]). append([], List, List). - append([Head| Tail], List, [Head| Tail2]) :- append(Tail, List, Tail2). as_difflist([], Back-Back). - as_difflist([Head| Tail], [Head| Tail2]-Back) :- as_difflist(Tail, Tail2-Back). delete([], _, []). - delete([Head| Tail], Element, Remaining) :- ( Head == Element -> delete(Tail, Element, Remaining) @@ -41,9 +34,7 @@ delete(Tail, Element, Tail2) ). - delete_matches([], _, []). - delete_matches([Head| Tail], Element, Remaining) :- ( \+ \+ Head = Element -> delete_matches(Tail, Element, Remaining) @@ -51,44 +42,33 @@ delete_matches(Tail, Element, Tail2) ). - empty(List) :- List == []. - flatten(List, Flatted) :- flatten(List, [], Flatted). - flatten(Var, Tail, [Var| Tail]) :- var(Var), !. - flatten([], Flatted, Flatted) :- !. - flatten([Head| Tail], List, Flatted) :- !, flatten(Tail, List, Aux), flatten(Head, Aux, Flatted). - flatten(Head, Tail, [Head| Tail]). - keysort(List, Sorted) :- {keysort(List, Sorted)}. - last([Head| Tail], Last) :- last(Tail, Head, Last). - last([], Last, Last). - last([Head| Tail], _, Last) :- last(Tail, Head, Last). - length(List, Length) :- ( integer(Length) -> Length >= 0, @@ -96,84 +76,65 @@ ; length(List, 0, Length) ). - make_list(0, []):- !. - make_list(N, [_| Tail]):- M is N-1, make_list(M, Tail). - length([], Length, Length). - length([_| Tail], Acc, Length) :- Acc2 is Acc + 1, length(Tail, Acc2, Length). - max([N| Ns], Max) :- max(Ns, N, Max). max([], Max, Max). - max([N| Ns], Aux, Max) :- ( N @> Aux -> max(Ns, N, Max) ; max(Ns, Aux, Max) ). - member(Element, [Element| _]). - member(Element, [_| List]) :- member(Element, List). memberchk(Element, [Element| _]) :- !. - memberchk(Element, [_| List]) :- memberchk(Element, List). - min([N| Ns], Min) :- min(Ns, N, Min). min([], Min, Min). - min([N| Ns], Aux, Min) :- ( N @< Aux -> min(Ns, N, Min) ; min(Ns, Aux, Min) ). - new([]). - nextto(X, Y, [X, Y| _]). - nextto(X, Y, [_| Tail]) :- nextto(X, Y, Tail). - nth0(Nth, List, Element) :- nth(Element, List, 0, Nth, _). - nth0(Nth, List, Element, Tail) :- nth(Element, List, 0, Nth, Tail). - nth1(Nth, List, Element) :- nth(Element, List, 1, Nth, _). - nth1(Nth, List, Element, Tail) :- nth(Element, List, 1, Nth, Tail). - nth(Element, List, Acc, Nth, Tail) :- ( integer(Nth), Nth >= Acc, @@ -183,75 +144,53 @@ nth_aux(Element, List, Acc, Nth, Tail) ). - nth_aux(Head, [Head| Tail], Position, Position, Tail). - nth_aux(Head, [_| List], Count, Position, Tail) :- Count2 is Count + 1, nth_aux(Head, List, Count2, Position, Tail). - permutation(List, Permutation) :- same_length(List, Permutation), permutation2(List, Permutation). - permutation2([], []). - permutation2(List, [Head| Tail]) :- select(Head, List, Remaining), permutation2(Remaining, Tail). - prefix([], _). - prefix([Element| Tail], [Element| Tail2]) :- prefix(Tail, Tail2). - reverse(List, Reversed) :- reverse(List, [], Reversed, Reversed). - reverse([], Reversed, Reversed, []). - reverse([Head| Tail], List, Reversed, [_| Bound]) :- reverse(Tail, [Head| List], Reversed, Bound). - same_length([], []). - same_length([_| Tail1], [_| Tail2]) :- same_length(Tail1, Tail2). - select(Head, [Head| Tail], Tail). - select(Head, [Head2| Tail], [Head2| Tail2]) :- select(Head, Tail, Tail2). - sort(List, Sorted) :- {sort(List, Sorted)}. - sublist(List, List). - sublist(Sublist, [Head| Tail]):- sublist(Tail, Head, Sublist). - sublist(Sublist, _, Sublist). - sublist([Head| Tail], _, Sublist):- sublist(Tail, Head, Sublist). - sublist([Head| Tail], Element, [Element| Sublist]):- sublist(Tail, Head, Sublist). - subtract([], _, []). - subtract([Head| Tail], List, Rest) :- ( ::memberchk(Head, List) -> subtract(Tail, List, Rest) @@ -259,22 +198,16 @@ subtract(Tail, List, Tail2) ). - suffix(List, List). - suffix(List, [_| Tail]) :- suffix(List, Tail). - valid(List) :- nonvar(List), \+ \+ valid2(List). - valid2([]). - valid2([_| List]) :- valid2(List). - :- end_object. diff --git a/Logtalk/library/listp.lgt b/Logtalk/library/listp.lgt index 66462dcc3..32ad4ecc7 100644 --- a/Logtalk/library/listp.lgt +++ b/Logtalk/library/listp.lgt @@ -1,251 +1,171 @@ :- protocol(listp). - :- info([ version is 1.2, author is 'Paulo Moura', date is 2004/5/9, comment is 'List protocol.']). - :- public(append/3). - :- mode(append(?list, ?list, ?list), zero_or_more). - :- info(append/3, [ comment is 'Appends two lists.', argnames is ['List1', 'List2', 'List']]). - :- public(delete/3). - :- mode(delete(@list, @term, ?list), one). - :- info(delete/3, [comment is 'Deletes from a list all ocurrences of an element returning the list of remaining elements.', argnames is ['List', 'Element', 'Remaining']]). - :- public(delete_matches/3). - :- mode(delete_matches(@list, @term, ?list), one). - :- info(delete_matches/3, [comment is 'Deletes all matching elements from a list, returning the list of remaining elements.', argnames is ['List', 'Element', 'Remaining']]). - :- public(empty/1). - :- mode(empty(@list), zero_or_one). - :- info(empty/1, [comment is 'True if the argument is an empty list.', argnames is ['List']]). - :- public(flatten/2). - :- mode(flatten(+list, -list), one). - :- info(flatten/2, [comment is 'Flattens a list of lists into a list.', argnames is ['List', 'Flatted']]). - :- public(keysort/2). - :- mode(keysort(+list, -list), one). - :- info(keysort/2, [comment is 'Sorts a list of key-value pairs in ascending order.', argnames is ['List', 'Sorted']]). - :- public(last/2). - :- mode(last(?list, ?term), zero_or_more). - :- info(last/2, [comment is 'List last element (if it exists).', argnames is ['List', 'Last']]). - :- public(length/2). - :- mode(length(?list, ?integer), zero_or_more). - :- info(length/2, [comment is 'List length.', argnames is ['List', 'Length']]). - :- public(max/2). - :- mode(max(+list, -term), zero_or_one). - :- info(max/2, [comment is 'Determines the list maximum value using standard order. Fails if the list is empty.', argnames is ['List', 'Maximum']]). - :- public(member/2). - :- mode(member(?term, ?list), zero_or_more). - :- info(member/2, [comment is 'Element is a list member.', argnames is ['Element', 'List']]). - :- public(memberchk/2). - :- mode(memberchk(?term, ?list), zero_or_one). - :- info(memberchk/2, [comment is 'Checks if a term is a member of a list.', argnames is ['Element', 'List']]). - :- public(min/2). - :- mode(min(+list, -term), zero_or_one). - :- info(min/2, [comment is 'Determines the minimum value in a list using standard order. Fails if the list is empty.', argnames is ['List', 'Minimum']]). - :- public(nextto/3). - :- mode(nextto(?term, ?term, ?list), zero_or_more). - :- info(nextto/3, [ comment is 'X and Y are consecutive elements in List.', argnames is ['X', 'Y', 'List']]). - :- public(nth0/3). - :- mode(nth0(?integer, ?list, ?term), zero_or_more). - :- info(nth0/3, [ comment is 'Nth element of a list (counting from zero).', argnames is ['Nth', 'List', 'Element']]). - :- public(nth0/4). - :- mode(nth0(?integer, ?list, ?term, ?list), zero_or_more). - :- info(nth0/4, [ comment is 'Nth element of a list (counting from zero).', argnames is ['Nth', 'List', 'Element', 'Residue']]). - :- public(nth1/3). - :- mode(nth1(?integer, ?list, ?term), zero_or_more). - :- info(nth1/3, [ comment is 'Nth element of a list (counting from one).', argnames is ['Nth', 'List', 'Element']]). - :- public(nth1/4). - :- mode(nth1(?integer, ?list, ?term, ?list), zero_or_more). - :- info(nth1/4, [ comment is 'Nth element of a list (counting from zero).', argnames is ['Nth', 'List', 'Element', 'Residue']]). - :- public(permutation/2). - :- mode(permutation(?list, ?list), zero_or_more). - :- info(permutation/2, [comment is 'The two lists are a permutation of the same list.', argnames is ['List', 'Permutation']]). - :- public(prefix/2). - :- mode(prefix(?list, +list), zero_or_more). - :- info(prefix/2, [comment is 'Prefix is a prefix of List.', argnames is ['Prefix', 'List']]). - :- public(reverse/2). - :- mode(reverse(+list, ?list), zero_or_one). :- mode(reverse(?list, +list), zero_or_one). :- mode(reverse(-list, -list), one_or_more). - :- info(reverse/2, [comment is 'Reverses a list.', argnames is ['List', 'Reversed']]). - :- public(same_length/2). - :- mode(same_length(+list, ?list), zero_or_one). :- mode(same_length(?list, +list), zero_or_one). :- mode(same_length(-list, -list), one_or_more). - :- info(same_length/2, [comment is 'The two lists have the same length.', argnames is ['List1', 'List2']]). - :- public(select/3). - :- mode(select(?term, +list, ?list), zero_or_more). :- mode(select(?term, ?list, +list), zero_or_more). - :- info(select/3, [comment is 'Selects an element from a list, returning the list of remaining elements.', argnames is ['Element', 'List', 'Remaining']]). - :- public(sort/2). - :- mode(sort(+list, -list), one). - :- info(sort/2, [comment is 'Sorts a list in ascending order.', argnames is ['List', 'Sorted']]). - :- public(sublist/2). - :- mode(sublist(?list, +list), zero_or_more). - :- info(sublist/2, [comment is 'The first list is a sublist of the second.', argnames is ['Sublist', 'List']]). - :- public(subtract/3). - :- mode(subtract(+list, +list, -list), one). - :- info(subtract/3, [comment is 'Removes all elements in the second list from the first list, returning the list of remaining elements.', argnames is ['List', 'Elements', 'Remaining']]). - :- public(suffix/2). - :- mode(suffix(?list, +list), zero_or_more). - :- info(suffix/2, [comment is 'Suffix is a suffix of List.', argnames is ['Suffix', 'List']]). - :- end_protocol. diff --git a/Logtalk/library/loop.lgt b/Logtalk/library/loop.lgt index cf4cd9222..978d81de9 100644 --- a/Logtalk/library/loop.lgt +++ b/Logtalk/library/loop.lgt @@ -2,74 +2,59 @@ :- object(loop, implements(loopp)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/9/17, comment is 'Loop control structures predicates.']). + :- meta_predicate(whiledo(::, ::)). + whiledo(Condition, Action) :- + ( call(Condition) -> + \+ \+ call(Action), + whiledo(Condition, Action) + ; true + ). :- meta_predicate(dowhile(::, ::)). - - :- meta_predicate(forto(*, *, ::)). - - :- meta_predicate(forto(*, *, *, ::)). - - :- meta_predicate(fordownto(*, *, ::)). - - :- meta_predicate(fordownto(*, *, *, ::)). - - :- meta_predicate(whiledo(::, ::)). - - dowhile(Action, Condition) :- \+ \+ call(Action), whiledo(Condition, Action). - - whiledo(Condition, Action) :- - call(Condition) -> - \+ \+ call(Action), - whiledo(Condition, Action) - ; - true. - - + :- meta_predicate(forto(*, *, ::)). forto(First, Last, Call) :- - First =< Last -> + ( First =< Last -> \+ \+ call(Call), Next is First + 1, forto(Next, Last, Call) - ; - true. - + ; true + ). + :- meta_predicate(forto(*, *, *, ::)). forto(Count, First, Last, Call) :- - First =< Last -> + ( First =< Last -> \+ \+ (Count = First, call(Call)), Next is First + 1, forto(Count, Next, Last, Call) - ; - true. - + ; true + ). + :- meta_predicate(fordownto(*, *, ::)). fordownto(First, Last, Call) :- - First >= Last -> + ( First >= Last -> \+ \+ call(Call), Next is First - 1, fordownto(Next, Last, Call) - ; - true. - + ; true + ). + :- meta_predicate(fordownto(*, *, *, ::)). fordownto(Count, First, Last, Call) :- - First >= Last -> + ( First >= Last -> \+ \+ (Count = First, call(Call)), Next is First - 1, fordownto(Count, Next, Last, Call) - ; - true. - + ; true + ). :- end_object. diff --git a/Logtalk/library/loopp.lgt b/Logtalk/library/loopp.lgt index ead548343..1f629a4ee 100644 --- a/Logtalk/library/loopp.lgt +++ b/Logtalk/library/loopp.lgt @@ -1,72 +1,52 @@ :- protocol(loopp). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/9/17, comment is 'Loop control structures protocol.']). - :- public(dowhile/2). :- meta_predicate(dowhile(::, ::)). - :- mode(dowhile(+callable, @callable), zero_or_one). - :- info(dowhile/2, [ comment is 'Do Action while Condition is true.', argnames is ['Action', 'Condition']]). - :- public(forto/3). :- meta_predicate(forto(*, *, ::)). - :- mode(forto(+integer, +integer, @callable), zero_or_one). - :- info(forto/3, [ comment is 'Counting from First to Last do Call.', argnames is ['First', 'Last', 'Call']]). - :- public(forto/4). :- meta_predicate(forto(*, *, *, ::)). - :- mode(forto(-integer, +integer, +integer, @callable), zero_or_one). - :- info(forto/4, [ comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', argnames is ['Count', 'First', 'Last', 'Call']]). - :- public(fordownto/3). :- meta_predicate(fordownto(*, *, ::)). - :- mode(fordownto(+integer, +integer, @callable), zero_or_one). - :- info(fordownto/3, [ comment is 'Counting from First to Last do Call.', argnames is ['First', 'Last', 'Call']]). - :- public(fordownto/4). :- meta_predicate(fordownto(*, *, *, ::)). - :- mode(fordownto(-integer, +integer, +integer, @callable), zero_or_one). - :- info(fordownto/4, [ comment is 'Do Call counting from First to Last and instantiating Count to each sucessive value.', argnames is ['Count', 'First', 'Last', 'Call']]). - :- public(whiledo/2). :- meta_predicate(whiledo(::, ::)). - :- mode(whiledo(+callable, @callable), zero_or_one). - :- info(whiledo/2, [ comment is 'While Condition is true do Action.', argnames is ['Condition', 'Action']]). - :- end_protocol. diff --git a/Logtalk/library/metapredicates.notes b/Logtalk/library/metapredicates.notes index 82e8aa692..38c948e9e 100644 --- a/Logtalk/library/metapredicates.notes +++ b/Logtalk/library/metapredicates.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the metapredicates_loader.lgt diff --git a/Logtalk/library/metapredicates_loader.lgt b/Logtalk/library/metapredicates_loader.lgt index e5dfcfedb..823cbfcb1 100644 --- a/Logtalk/library/metapredicates_loader.lgt +++ b/Logtalk/library/metapredicates_loader.lgt @@ -1,5 +1,3 @@ :- initialization( - logtalk_load([ - metap, meta, - loopp, loop])). + logtalk_load([metap, meta, loopp, loop], [reload(skip)])). diff --git a/Logtalk/library/monitor.lgt b/Logtalk/library/monitor.lgt index 16d08bff0..dceabb086 100644 --- a/Logtalk/library/monitor.lgt +++ b/Logtalk/library/monitor.lgt @@ -2,29 +2,23 @@ :- category(monitor, implements(monitorp)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2004/3/31, comment is 'Monitor predicates.']). - :- private(spy_point_/4). :- dynamic(spy_point_/4). - :- mode(spy_point_(?event, ?object, ?callable, ?object), zero_or_more). - :- info(spy_point_/4, [ comment is 'Stores current spy points.', argnames is ['Event', 'Object', 'Message', 'Sender']]). - monitor_activated :- self(Self), once(current_event(_, _, _, _, Self)). - activate_monitor :- self(Self), abolish_events(before, _, _, _, Self), @@ -33,32 +27,26 @@ ::spy_point_(Event, Object, Message, Sender), define_events(Event, Object, Message, Sender, Self)). - suspend_monitor :- self(Self), abolish_events(before, _, _, _, Self), abolish_events(after, _, _, _, Self). - reset_monitor :- self(Self), abolish_events(before, _, _, _, Self), abolish_events(after, _, _, _, Self), ::retractall(spy_point_(_, _, _, _)). - spy_point(Event, Object, Message, Sender) :- ::spy_point_(Event, Object, Message, Sender). - set_spy_point(Event, Object, Message, Sender) :- ::retractall(spy_point_(Event, Object, Message, Sender)), once((var(Event); Event = before; Event = after)), ::assertz(spy_point_(Event, Object, Message, Sender)). - del_spy_points(Event, Object, Message, Sender) :- ::retractall(spy_point_(Event, Object, Message, Sender)). - :- end_category. diff --git a/Logtalk/library/monitorp.lgt b/Logtalk/library/monitorp.lgt index a20a393f4..34b895315 100644 --- a/Logtalk/library/monitorp.lgt +++ b/Logtalk/library/monitorp.lgt @@ -1,71 +1,48 @@ :- protocol(monitorp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Monitor protocol.']). - :- public(monitor_activated/0). - :- mode(monitor_activated, zero_or_one). - :- info(monitor_activated/0, [ comment is 'True if monitor is currently active.']). - :- public(activate_monitor/0). - :- mode(activate_monitor, one). - :- info(activate_monitor/0, [ comment is 'Activates all spy points and start monitoring.']). - :- public(suspend_monitor/0). - :- mode(suspend_monitor, one). - :- info(suspend_monitor/0, [ comment is 'Suspends monitoring, deactivating all spy points.']). - :- public(reset_monitor/0). - :- mode(reset_monitor, one). - :- info(reset_monitor/0, [ comment is 'Resets monitor, deactivating and deleting all spy points.']). - :- public(spy_point/4). - :- mode(spy_point(?event, ?object, ?callable, ?object), zero_or_more). - :- info(spy_point/4, [ comment is 'Current spy point.', argnames is ['Event', 'Object', 'Message', 'Sender']]). - :- public(set_spy_point/4). - :- mode(set_spy_point(?event, ?object, ?callable, ?object), one). - :- info(set_spy_point/4, [ comment is 'Sets a spy point.', argnames is ['Event', 'Object', 'Message', 'Sender']]). - :- public(del_spy_points/4). - :- mode(del_spy_points(@event, @object, @callable, @object), one). - :- info(del_spy_points/4, [ comment is 'Deletes all matching spy points.', argnames is ['Event', 'Object', 'Message', 'Sender']]). - :- end_protocol. diff --git a/Logtalk/library/natural.lgt b/Logtalk/library/natural.lgt index 6f46cda15..d87ef1148 100644 --- a/Logtalk/library/natural.lgt +++ b/Logtalk/library/natural.lgt @@ -2,23 +2,19 @@ :- object(natural, extends(integer)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Natural numbers data type predicates.']). - between(Lower, Upper, Integer) :- integer(Lower), Lower > 0, ^^between(Lower, Upper, Integer). - valid(Natural) :- integer(Natural), Natural > 0. - :- end_object. diff --git a/Logtalk/library/number.lgt b/Logtalk/library/number.lgt index eb4bbdb6e..267d4011d 100644 --- a/Logtalk/library/number.lgt +++ b/Logtalk/library/number.lgt @@ -2,16 +2,13 @@ :- object(number, extends(atomic)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Number data type predicates.']). - valid(Number) :- number(Number). - :- end_object. diff --git a/Logtalk/library/numberlist.lgt b/Logtalk/library/numberlist.lgt index 55e03e980..3ed4a9788 100644 --- a/Logtalk/library/numberlist.lgt +++ b/Logtalk/library/numberlist.lgt @@ -3,74 +3,66 @@ implements(numberlistp), extends(list)). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, + date is 2007/4/20, comment is 'List of numbers predicates.']). - - average([], 0). - + average([], 0.0). average([N| Ns], Average) :- - average([N| Ns], 0, 0, Average). - + average(Ns, 1, N, Average). average([], Length, Sum, Average) :- Average is Sum / Length. - average([N| Ns], Lacc, Sacc, Average) :- Lacc2 is Lacc + 1, Sacc2 is Sacc + N, average(Ns, Lacc2, Sacc2, Average). - min([N| Ns], Min) :- min(Ns, N, Min). min([], Min, Min). - min([N| Ns], Aux, Min) :- - N < Aux -> + ( N < Aux -> min(Ns, N, Min) - ; - min(Ns, Aux, Min). - + ; min(Ns, Aux, Min) + ). max([N| Ns], Max) :- max(Ns, N, Max). max([], Max, Max). - max([N| Ns], Aux, Max) :- - N > Aux -> + ( N > Aux -> max(Ns, N, Max) - ; - max(Ns, Aux, Max). + ; max(Ns, Aux, Max) + ). + product(List, Product) :- + product(List, 1, Product). + + product([], Product, Product). + product([N| Ns], Acc, Product) :- + Acc2 is Acc * N, + product(Ns, Acc2, Product). sum(List, Sum) :- sum(List, 0, Sum). - sum([], Sum, Sum). - sum([N| Ns], Acc, Sum) :- Acc2 is Acc + N, sum(Ns, Acc2, Sum). - valid(List) :- nonvar(List), \+ \+ valid2(List). - valid2([]). - valid2([Head| Tail]) :- number(Head), valid2(Tail). - :- end_object. diff --git a/Logtalk/library/numberlistp.lgt b/Logtalk/library/numberlistp.lgt index f6ad24480..b5216975c 100644 --- a/Logtalk/library/numberlistp.lgt +++ b/Logtalk/library/numberlistp.lgt @@ -1,30 +1,28 @@ :- protocol(numberlistp). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, + date is 2007/4/20, comment is 'List of numbers protocol.']). + :- public(product/2). + :- mode(product(+list(number), ?number), zero_or_one). + :- info(product/2, + [comment is 'Calculates the product of all list values.', + argnames is ['List', 'Product']]). :- public(sum/2). - - :- mode(sum(+list, ?number), zero_or_one). - + :- mode(sum(+list(number), ?number), zero_or_one). :- info(sum/2, [comment is 'Calculates the sum of all list values.', argnames is ['List', 'Sum']]). - :- public(average/2). - - :- mode(average(+list, ?number), zero_or_one). - + :- mode(average(+list(number), ?float), zero_or_one). :- info(average/2, [comment is 'Calculates the average of a list of values.', argnames is ['List', 'Average']]). - :- end_protocol. diff --git a/Logtalk/library/proto_hierarchy.lgt b/Logtalk/library/proto_hierarchy.lgt index 016417048..d5da9c7b2 100644 --- a/Logtalk/library/proto_hierarchy.lgt +++ b/Logtalk/library/proto_hierarchy.lgt @@ -2,66 +2,53 @@ :- category(proto_hierarchy, implements(proto_hierarchyp)). - :- info([ version is 1.1, author is 'Paulo Moura', date is 2006/2/20, comment is 'Prototype hierarchy predicates.']). - parent(Parent) :- self(Self), extends_object(Self, Parent). - parents(Parents) :- self(Self), findall(Parent, extends_object(Self, Parent), Parents). - ancestor(Ancestor) :- self(Self), ancestor(Self, Ancestor). - ancestor(Self, Ancestor) :- extends_object(Self, Ancestor). - ancestor(Self, Ancestor) :- extends_object(Self, Parent), ancestor(Parent, Ancestor). - ancestors(Ancestors) :- self(Self), findall(Ancestor, ancestor(Self, Ancestor), Ancestors). - extension(Prototype) :- self(Self), extends_object(Prototype, Self). - extensions(Prototypes) :- self(Self), findall(Prototype, extends_object(Prototype, Self), Prototypes). - leaf(Leaf) :- self(Self), leaf(Self, Leaf). - leaf(Self, Leaf) :- extends_object(Leaf, Self), \+ extends_object(_, Leaf). - leaf(Self, Leaf) :- extends_object(Object, Self), leaf(Object, Leaf). - leaves(Leaves) :- self(Self), ( setof(Leaf, leaf(Self, Leaf), Leaves) -> @@ -69,24 +56,19 @@ ; Leaves = [] ). - descendant(Descendant) :- self(Self), descendant(Self, Descendant). - descendant(Self, Descendant) :- extends_object(Descendant, Self). - descendant(Self, Descendant) :- extends_object(Descendant, Self), \+ extends_object(Descendant, Self). - descendant(Self, Descendant) :- extends_object(Subclass, Self), descendant(Subclass, Descendant). - descendants(Descendants) :- self(Self), ( setof(Descendant, descendant(Self, Descendant), Descendants) -> @@ -94,5 +76,4 @@ ; Descendants = [] ). - :- end_category. diff --git a/Logtalk/library/queue.lgt b/Logtalk/library/queue.lgt index efcf7bb99..4e4d8805a 100644 --- a/Logtalk/library/queue.lgt +++ b/Logtalk/library/queue.lgt @@ -3,14 +3,12 @@ implements(queuep), extends(compound)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Queue predicates implemented using difference lists.']). - as_list(Queue-Back, List) :- Queue == Back -> List = [] @@ -19,70 +17,53 @@ Queue = [Head| Rest], as_list(Rest-Back, Tail). - empty(Front-Back) :- Front == Back. - head(Front-Back, Head) :- Front \== Back, Front = [Head| _]. - join(Element, Front-[Element| Back], Front-Back). - join_all([], Queue, Queue). - join_all([Head| Tail], Queue1, Queue3) :- join(Head, Queue1, Queue2), join_all(Tail, Queue2, Queue3). - jump(Element, Front-Back, [Element| Front]-Back). - jump_all([], Queue, Queue). - jump_all([Head| Tail], Queue1, Queue3) :- jump(Head, Queue1, Queue2), jump_all(Tail, Queue2, Queue3). - length(Front-Back, Length) :- length(Front, Back, 0, N), Length = N. - length(Front, Back, N, N) :- Front == Back, !. - length([_|Front], Back, K, N) :- L is K+1, length(Front, Back, L, N). - new(Back-Back). - serve(OldFront-Back, Head, NewFront-Back) :- OldFront \== Back, OldFront = [Head| NewFront]. - valid(Queue) :- nonvar(Queue), valid2(Queue). - valid2(Queue-Back) :- Queue == Back, !. - valid2(Queue-Back) :- nonvar(Queue), Queue = [_| Tail], valid2(Tail-Back). - :- end_object. diff --git a/Logtalk/library/queuep.lgt b/Logtalk/library/queuep.lgt index 9876cea62..10f33c4df 100644 --- a/Logtalk/library/queuep.lgt +++ b/Logtalk/library/queuep.lgt @@ -1,93 +1,64 @@ :- protocol(queuep). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Queue protocol.']). - :- public(empty/1). - :- mode(empty(@queue), zero_or_one). - :- info(empty/1, [ comment is 'True if the queue is empty.', argnames is ['Queue']]). - :- public(head/2). - :- mode(head(+queue, ?term), zero_or_one). - :- info(head/2, [ comment is 'Unifies Head with the first element of the queue.', argnames is ['Queue', 'Head']]). - :- public(join/3). - :- mode(join(@term, +queue, -queue), zero_or_one). - :- info(join/3, [ comment is 'Adds the new element at the end of the queue.', argnames is ['Element', 'Queue_in', 'Queue_out']]). - :- public(join_all/3). - :- mode(join_all(+list, +queue, -queue), zero_or_one). - :- info(join_all/3, [ comment is 'Adds the new elements at the end of the queue. The elements are added in the same order that they appear in the list.', argnames is ['List', 'Queue_in', 'Queue_out']]). - :- public(jump/3). - :- mode(jump(@term, +queue, -queue), zero_or_one). - :- info(jump/3, [ comment is 'Adds the new element at the front of the queue.', argnames is ['Element', 'Queue_in', 'Queue_out']]). - :- public(jump_all/3). - :- mode(jump_all(+list, +queue, -queue), zero_or_one). - :- info(jump_all/3, [ comment is 'Adds the new elements at the front of the queue. The elements are added in the same order that they appear in the list.', argnames is ['Element', 'Queue_in', 'Queue_out']]). - :- public(length/2). - :- mode(length(+queue, ?integer), zero_or_one). - :- info(length/2, [comment is 'Queue length.', argnames is ['Queue', 'Length']]). - :- public(serve/3). - :- mode(serve(+queue, ?term, -queue), zero_or_one). - :- info(serve/3, [ comment is 'Removes the first element of the queue for service.', argnames is ['Queue_in', 'Head', 'Queue_out']]). - :- public(as_list/2). - :- mode(as_list(+queue, -list), one). - :- info(as_list/2, [comment is 'Converts a queue to a list.', argnames is ['Queue', 'List']]). - :- end_protocol. diff --git a/Logtalk/library/random.notes b/Logtalk/library/random.notes index 86c63efdc..3b34121f9 100644 --- a/Logtalk/library/random.notes +++ b/Logtalk/library/random.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this library load the random_loader.lgt utility diff --git a/Logtalk/library/random_loader.lgt b/Logtalk/library/random_loader.lgt index 1753fbac1..1b69ea634 100644 --- a/Logtalk/library/random_loader.lgt +++ b/Logtalk/library/random_loader.lgt @@ -1,3 +1,3 @@ :- initialization( - logtalk_load([randomp, random])). + logtalk_load([randomp, random], [reload(skip)])). diff --git a/Logtalk/library/randomp.lgt b/Logtalk/library/randomp.lgt index e071c6291..34443739c 100644 --- a/Logtalk/library/randomp.lgt +++ b/Logtalk/library/randomp.lgt @@ -1,68 +1,48 @@ :- protocol(randomp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Random number generator protocol.']). - :- public(random/1). - :- mode(random(-float), one). - :- info(random/1, [ comment is 'Returns a new random float value in the interval [0.0, 1.0[.', argnames is ['Random']]). - :- public(random/3). - :- mode(random(+integer, +integer, -integer), zero_or_one). :- mode(random(+float, +float, -float), zero_or_one). - :- info(random/3, [ comment is 'Returns a new random value in the interval [Lower, Upper[.', argnames is ['Lower', 'Upper', 'Random']]). - :- public(randseq/4). - :- mode(randseq(+integer, +integer, +integer, -list), zero_or_one). :- mode(randseq(+integer, +float, +float, -list), zero_or_one). - :- info(randseq/4, [ comment is 'Returns a list of Length random values in the interval [Lower, Upper[.', argnames is ['Length', 'Lower', 'Upper', 'List']]). - :- public(randset/4). - :- mode(randset(+integer, +integer, +integer, -list), zero_or_one). :- mode(randset(+integer, +float, +float, -list), zero_or_one). - :- info(randset/4, [ comment is 'Returns an ordered set of Length random values in the interval [Lower, Upper[.', argnames is ['Length', 'Lower', 'Upper', 'Set']]). - :- public(reset_seed/0). - :- mode(reset_seed, one). - :- info(reset_seed/0, [ comment is 'Resets the random seed to its default value.']). - :- public(set_seed/1). - :- mode(set_seed(+integer), zero_or_one). - :- info(set_seed/1, [ comment is 'Sets the random seed to the given value.', argnames is ['Seed']]). - :- end_protocol. diff --git a/Logtalk/library/set.lgt b/Logtalk/library/set.lgt index 459f7d8d8..0b1a4002f 100644 --- a/Logtalk/library/set.lgt +++ b/Logtalk/library/set.lgt @@ -3,89 +3,65 @@ implements(setp), extends(compound)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Set predicates implemented using ordered lists. Uses ==/2 for element comparison and standard term ordering.']). - delete([], _, []). - delete([Head| Tail], Element, Remaining) :- compare(Order, Head, Element), delete(Order, Head, Tail, Element, Remaining). delete(=, _, Tail, _, Tail). - delete(<, Head, Tail, Element, [Head| Tail2]) :- delete(Tail, Element, Tail2). - delete(>, _, Tail, _, Tail). - disjoint([], _) :- !. - disjoint(_, []) :- !. - disjoint([Head1| Tail1], [Head2| Tail2]) :- compare(Order, Head1, Head2), disjoint(Order, Head1, Tail1, Head2, Tail2). - disjoint(<, _, Tail1, Head2, Tail2) :- disjoint(Tail1, [Head2| Tail2]). - disjoint(>, Head1, Tail1, _, Tail2) :- disjoint([Head1| Tail1], Tail2). - equal(Set1, Set2) :- Set1 == Set2. - empty(Set) :- Set == []. - insert([], Element, [Element]). - insert([Head| Tail], Element, Set) :- compare(Order, Head, Element), insert(Order, Head, Tail, Element, Set). - insert(<, Head, Tail, Element, [Head| Set]) :- insert(Tail, Element, Set). - insert(=, Head, Tail, _, [Head| Tail]). - insert(>, Head, Tail, Element, [Element, Head| Tail]). - insert_all([], Set, Set). - insert_all([Head| Tail], Set1, Set3) :- insert(Set1, Head, Set2), insert_all(Tail, Set2, Set3). - intersect([Head1| Tail1], [Head2| Tail2]) :- compare(Order, Head1, Head2), intersect(Order, Head1, Tail1, Head2, Tail2). intersect(=, _, _, _, _). - intersect(<, _, Tail1, Head2, Tail2) :- intersect(Tail1, [Head2| Tail2]). - intersect(>, Head1, Tail1, _, Tail2) :- intersect([Head1| Tail1], Tail2). - intersection(_, [], []) :- !. - intersection([], _, []) :- !. intersection([Head1| Tail1], [Head2| Tail2], Intersection) :- @@ -94,170 +70,124 @@ intersection(=, Head, Tail1, _, Tail2, [Head| Intersection]) :- intersection(Tail1, Tail2, Intersection). - intersection(<, _, Tail1, Head2, Tail2, Intersection) :- intersection(Tail1, [Head2| Tail2], Intersection). - intersection(>, Head1, Tail1, _, Tail2, Intersection) :- intersection([Head1|Tail1], Tail2, Intersection). - length(Set, Length) :- length(Set, 0, Length). - length([], Length, Length). - length([_| Set], Acc, Length) :- Acc2 is Acc + 1, length(Set, Acc2, Length). - member(Element, Set) :- - var(Element) -> + ( var(Element) -> member_var(Element, Set) - ; - member_nonvar(Element, Set). - + ; member_nonvar(Element, Set) + ). member_var(Element, [Element| _]). - member_var(Element, [_| Set]) :- member_var(Element, Set). - member_nonvar(Element, [Head| Tail]):- compare(Order, Element, Head), member_nonvar(Order, Element, Tail). member_nonvar(=, _, _). - member_nonvar(>, Element, [Head| Tail]) :- compare(Order, Element, Head), member_nonvar(Order, Element, Tail). - new([]). - powerset(Set, PowerSet):- reverse(Set, RSet), powerset_1(RSet, [[]], PowerSet). - powerset_1([], PowerSet, PowerSet). - powerset_1([X| Xs], Yss0, Yss):- powerset_2(Yss0, X, Yss1), powerset_1(Xs, Yss1, Yss). - powerset_2([], _, []). - powerset_2([Zs| Zss], X, [Zs, [X| Zs]| Yss]):- powerset_2(Zss, X, Yss). - reverse(List, Reversed) :- reverse(List, [], Reversed). - reverse([], Reversed, Reversed). - reverse([Head| Tail], List, Reversed) :- reverse(Tail, [Head| List], Reversed). - select(Head, [Head| Tail], Tail). - select(Head, [Head2| Tail], [Head2| Tail2]) :- select(Head, Tail, Tail2). - subset([], _) :- !. - subset([Head1| Tail1], [Head2| Tail2]) :- compare(Order, Head1, Head2), subset(Order, Head1, Tail1, Head2, Tail2). - subset(=, _, Tail1, _, Tail2) :- subset(Tail1, Tail2). - subset(>, Head1, Tail1, _, Tail2) :- subset([Head1| Tail1], Tail2). - subtract(Set, [], Set) :- !. - subtract([], _, []) :- !. subtract([Head1| Tail1], [Head2| Tail2], Difference) :- compare(Order, Head1, Head2), subtract(Order, Head1, Tail1, Head2, Tail2, Difference). - subtract(=, _, Tail1, _, Tail2, Difference) :- subtract(Tail1, Tail2, Difference). - subtract(<, Head1, Tail1, Head2, Tail2, [Head1| Difference]) :- subtract(Tail1, [Head2| Tail2], Difference). - subtract(>, Head1, Tail1, _, Tail2, Difference) :- subtract([Head1| Tail1], Tail2, Difference). - symdiff(Set, [], Set) :- !. - symdiff([], Set, Set) :- !. - symdiff([Head1| Tail1], [Head2| Tail2], Difference) :- compare(Order, Head1, Head2), symdiff(Order, Head1, Tail1, Head2, Tail2, Difference). - symdiff(=, _, Tail1, _, Tail2, Difference) :- symdiff(Tail1, Tail2, Difference). - symdiff(<, Head1, Tail1, Head2, Tail2, [Head1| Difference]) :- symdiff(Tail1, [Head2| Tail2], Difference). - symdiff(>, Head1, Tail1, Head2, Tail2, [Head2| Difference]) :- symdiff([Head1| Tail1], Tail2, Difference). - union(Set, [], Set) :- !. - union([], Set, Set) :- !. - union([Head1| Tail1], [Head2| Tail2], Union) :- compare(Order, Head1, Head2), union(Order, Head1, Tail1, Head2, Tail2, Union). - union(=, Head, Tail1, _, Tail2, [Head| Union]) :- union(Tail1, Tail2, Union). - union(<, Head1, Tail1, Head2, Tail2, [Head1| Union]) :- union(Tail1, [Head2| Tail2], Union). - union(>, Head1, Tail1, Head2, Tail2, [Head2| Union]) :- union([Head1| Tail1], Tail2, Union). - valid(Set) :- nonvar(Set), valid2(Set). valid2([]) :- !. - valid2([_]) :- !. - valid2([Element1, Element2| Set]) :- Element1 @< Element2, valid2([Element2| Set]). - :- end_object. diff --git a/Logtalk/library/setp.lgt b/Logtalk/library/setp.lgt index 5859dd99d..76fe30caa 100644 --- a/Logtalk/library/setp.lgt +++ b/Logtalk/library/setp.lgt @@ -1,157 +1,107 @@ :- protocol(setp). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Set protocol.']). - :- public(delete/3). - :- mode(delete(+set, @term, ?set), one). - :- info(delete/3, [comment is 'Deletes an element from a set returning the set of remaining elements.', argnames is ['Set', 'Element', 'Remaining']]). - :- public(disjoint/2). - :- mode(disjoint(+set, +set), zero_or_one). - :- info(disjoint/2, [ comment is 'True if the two sets have no element in common.', argnames is ['Set1', 'Set2']]). - :- public(equal/2). - :- mode(equal(+set, +set), zero_or_one). - :- info(equal/2, [ comment is 'True if the two sets are equal.', argnames is ['Set1', 'Set2']]). - :- public(empty/1). - :- mode(empty(+set), zero_or_one). - :- info(empty/1, [ comment is 'True if the set is empty.', argnames is ['Set']]). - :- public(insert/3). - :- mode(insert(+set, +term, ?set), one). - :- info(insert/3, [ comment is 'Inserts an element in a set, returning the resulting set.', argnames is ['In', 'Element', 'Out']]). - :- public(insert_all/3). - :- mode(insert_all(+list, +set, ?set), one). - :- info(insert_all/3, [ comment is 'Inserts a list of elemnts in a set, returning the resulting set.', argnames is ['List', 'In', 'Out']]). - :- public(intersect/2). - :- mode(intersect(+set, +set), zero_or_one). - :- info(intersect/2, [ comment is 'True if the two sets have at least one element in common.', argnames is ['Set1', 'Set2']]). - :- public(intersection/3). - :- mode(intersection(+set, +set, ?set), zero_or_one). - :- info(intersection/3, [ comment is 'Returns the intersection of Set1 and Set2.', argnames is ['Set1', 'Set2', 'Intersection']]). - :- public(length/2). - :- mode(length(+set, ?integer), zero_or_one). - :- info(length/2, [comment is 'Number of set elements.', argnames is ['Set', 'Length']]). - :- public(member/2). - :- mode(member(+term, +set), zero_or_one). :- mode(member(-term, +set), zero_or_more). - :- info(member/2, [comment is 'Element is a member of set Set.', argnames is ['Element', 'Set']]). - :- public(powerset/2). - :- mode(powerset(+set, -list), one). - :- info(powerset/2, [comment is 'Returns the power set of a set, represented as a list of sets.', argnames is ['Set', 'Powerset']]). - :- public(select/3). - :- mode(select(?term, +set, ?set), zero_or_more). - :- info(select/3, [comment is 'Selects an element from a set, returning the set of remaining elements.', argnames is ['Element', 'Set', 'Remaining']]). - :- public(subset/2). - :- mode(subset(+set, +set), zero_or_one). - :- info(subset/2, [ comment is 'True if Subset is a subset of Set.', argnames is ['Subset', 'Set']]). - :- public(subtract/3). - :- mode(subtract(+set, +set, ?set), zero_or_one). - :- info(subtract/3, [ comment is 'True when Difference contains all and only the elements of Set1 which are not also in Set2.', argnames is ['Set1', 'Set2', 'Difference']]). - :- public(symdiff/3). - :- mode(symdiff(+set, +set, ?set), zero_or_one). - :- info(symdiff/3, [ comment is 'True if Difference is the symmetric difference of Set1 and Set2.', argnames is ['Set1', 'Set2', 'Difference']]). - :- public(union/3). - :- mode(union(+set, +set, ?set), zero_or_one). - :- info(union/3, [ comment is 'True if Union is the union of Set1 and Set2.', argnames is ['Set1', 'Set2', 'Union']]). - :- end_protocol. diff --git a/Logtalk/library/term.lgt b/Logtalk/library/term.lgt index c865b290f..a75a3accf 100644 --- a/Logtalk/library/term.lgt +++ b/Logtalk/library/term.lgt @@ -2,23 +2,45 @@ :- object(term, implements(termp)). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Prolog term predicates.']). + date is 2007/4/3, + comment is 'Prolog term utility predicates.']). + depth(Term, Depth) :- + depth(Term, 0, 0, Depth). + + depth(Var, Acc, MaxSoFar, Depth) :- + var(Var), + !, + ( Acc > MaxSoFar -> + Depth = Acc + ; Depth = MaxSoFar + ). + depth(Atomic, Acc, MaxSoFar, Depth) :- + atomic(Atomic), + !, + ( Acc > MaxSoFar -> + Depth = Acc + ; Depth = MaxSoFar + ). + depth([Arg| Args], Acc, MaxSoFar, Depth) :- + !, + depth(Arg, Acc, MaxSoFar, ArgDepth), + depth(Args, Acc, ArgDepth, Depth). + depth(Term, Acc, MaxSoFar, Depth) :- + Acc2 is Acc + 1, + Term =.. [_| Args], + depth(Args, Acc2, MaxSoFar, Depth). ground(Term) :- nonvar(Term), functor(Term, _, Arity), ground(Arity, Term). - ground(0, _) :- !. - ground(N, Term) :- N > 0, arg(N, Term, Arg), @@ -26,39 +48,34 @@ N2 is N - 1, ground(N2, Term). - occurs(Var, Term) :- - var(Term) -> + ( var(Term) -> Var == Term - ; - functor(Term, _, Arity), - occurs(Arity, Var, Term). - + ; functor(Term, _, Arity), + occurs(Arity, Var, Term) + ). occurs(N, Var, Term) :- compound(Term), arg(N, Term, Arg), occurs(Var, Arg), !. - occurs(N, Var, Term) :- N > 1, N2 is N - 1, occurs(N2, Var, Term). - subsumes(General, Specific) :- vars(Specific, Vars), subsumes(General, Specific, Vars). - subsumes(General, Specific, Vars) :- var(General), !, - (var_member_chk(General, Vars) -> + ( var_member_chk(General, Vars) -> General == Specific - ; - General = Specific). + ; General = Specific + ). subsumes(General, Specific, Vars) :- nonvar(Specific), @@ -66,9 +83,8 @@ functor(Specific, Functor, Arity), subsumes(Arity, General, Specific, Vars). - - subsumes(0, _, _, _) :- !. - + subsumes(0, _, _, _) :- + !. subsumes(N, General, Specific, Vars) :- arg(N, General, GenArg), arg(N, Specific, SpeArg), @@ -76,56 +92,49 @@ M is N-1, !, subsumes(M, General, Specific, Vars). - var_member_chk(Var, [Head| Tail]) :- - Var == Head -> + ( Var == Head -> true - ; - var_member_chk(Var, Tail). - + ; var_member_chk(Var, Tail) + ). subterm(Term, Term). - subterm(Sub, Term) :- nonvar(Term), functor(Term, _, N), subterm(N, Sub, Term). - subterm(N, Sub, Term) :- compound(Term), arg(N, Term, Arg), subterm(Sub, Arg). - subterm(N, Sub, Term) :- N > 1, M is N-1, subterm(M, Sub, Term). - valid(_). + variant(Term1, Term2) :- + \+ \+ subsumes(Term1, Term2), + \+ \+ subsumes(Term2, Term1). vars(Term, Vars) :- vars(Term, [], Vars). - vars(Term, Acc, Vars) :- - var(Term) -> - (var_member_chk(Term, Acc) -> + ( var(Term) -> + ( var_member_chk(Term, Acc) -> Vars = Acc - ; - Vars = [Term| Acc]) - ; - Term =.. [_| Args], - var_list(Args, Acc, Vars). - + ; Vars = [Term| Acc] + ) + ; Term =.. [_| Args], + var_list(Args, Acc, Vars) + ). var_list([], Vars, Vars). - var_list([Term| Terms], Acc, Vars) :- vars(Term, Acc, Acc2), var_list(Terms, Acc2, Vars). - :- end_object. diff --git a/Logtalk/library/termp.lgt b/Logtalk/library/termp.lgt index e377c60c3..191297963 100644 --- a/Logtalk/library/termp.lgt +++ b/Logtalk/library/termp.lgt @@ -1,75 +1,64 @@ :- protocol(termp). - :- info([ - version is 1.0, + version is 1.1, author is 'Paulo Moura', - date is 2000/7/24, - comment is 'Prolog terms protocol.']). + date is 2007/4/3, + comment is 'Prolog term utility predicates protocol.']). + :- public(depth/2). + :- mode(depth(@term, ?integer), zero_or_one). + :- info(depth/2, [ + comment is 'True if the depth of Term is Depth. The depth of atomic terms is zero; the depth of a compound term is one plus the maximium depth of its sub-terms.', + argnames is ['Term', 'Depth']]). :- public(ground/1). - :- mode(ground(@term), zero_or_one). - :- info(ground/1, [ comment is 'True if the argument is ground.', argnames is ['Term']]). - :- public(new/1). - :- mode(new(-nonvar), zero_or_one). - :- info(new/1, [ comment is 'Creates a new term instance (if meaningful).', argnames is ['Term']]). - :- public(occurs/2). - :- mode(occurs(@var, @term), zero_or_one). - :- info(occurs/2, [ comment is 'True if the variable occurs in the term.', argnames is ['Variable', 'Term']]). - :- public(subsumes/2). - :- mode(subsumes(@term, @term), zero_or_one). - :- info(subsumes/2, [ comment is 'The first term subsumes the second term.', argnames is ['General', 'Specific']]). - :- public(subterm/2). - :- mode(subterm(?term, +term), zero_or_more). - :- info(subterm/2, [ comment is 'The first term is a subterm of the second term.', argnames is ['Subterm', 'Term']]). - :- public(valid/1). - :- mode(valid(@nonvar), zero_or_one). - :- info(valid/1, [ comment is 'Term is valid.', argnames is ['Term']]). + :- public(variant/2). + :- mode(variant(@term, @term), zero_or_one). + :- info(variant/2, [ + comment is 'Each term is a variant of the other (i.e. they are structurally equivalent).', + argnames is ['Term1', 'Term2']]). :- public(vars/2). - :- mode(vars(@term, -list), one). - :- info(vars/2, [ comment is 'Returns a list of all term variables.', argnames is ['Term', 'List']]). - :- end_protocol. diff --git a/Logtalk/library/time.lgt b/Logtalk/library/time.lgt index 69a1b241a..265de01fc 100644 --- a/Logtalk/library/time.lgt +++ b/Logtalk/library/time.lgt @@ -2,26 +2,21 @@ :- object(time, implements(timep)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Time predicates.']). - now(Hours, Mins, Secs) :- {'$lgt_current_time'(Hours, Mins, Secs)}. - cpu_time(Seconds) :- {'$lgt_cpu_time'(Seconds)}. - valid(Hours, Mins, Secs) :- integer(Hours), Hours >= 0, integer(Mins), Mins >= 0, Mins =< 59, integer(Secs), Secs >= 0, Secs =< 59. - :- end_object. diff --git a/Logtalk/library/timep.lgt b/Logtalk/library/timep.lgt index bcdd4a681..ea345e498 100644 --- a/Logtalk/library/timep.lgt +++ b/Logtalk/library/timep.lgt @@ -1,39 +1,28 @@ :- protocol(timep). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'Time protocol.']). - :- public(now/3). - :- mode(now(-integer, -integer, -integer), one). - :- info(now/3, [ comment is 'Returns current time.', argnames is ['Hours', 'Mins', 'Secs']]). - :- public(cpu_time/1). - :- mode(cpu_time(-number), one). - :- info(cpu_time/1, [comment is 'Returns the current cpu time.', argnames is ['Time']]). - :- public(valid/3). - :- mode(valid(+integer, +integer, +integer), zero_or_one). - :- info(valid/3, [ comment is 'True if the arguments represent a valid time value.', argnames is ['Hours', 'Mins', 'Secs']]). - :- end_protocol. diff --git a/Logtalk/library/types.notes b/Logtalk/library/types.notes index 44dfb24c2..04c0c6565 100644 --- a/Logtalk/library/types.notes +++ b/Logtalk/library/types.notes @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To load all entities in this group load the types_loader.lgt utility diff --git a/Logtalk/library/types_loader.lgt b/Logtalk/library/types_loader.lgt index 4bf878fe3..cc6000c70 100644 --- a/Logtalk/library/types_loader.lgt +++ b/Logtalk/library/types_loader.lgt @@ -13,4 +13,4 @@ queuep, queue, dictionaryp, bintree, setp, set, set1, - comparingp])). + comparingp], [reload(skip)])). diff --git a/Logtalk/library/varlist.lgt b/Logtalk/library/varlist.lgt index 802427da0..6c9b0bc11 100644 --- a/Logtalk/library/varlist.lgt +++ b/Logtalk/library/varlist.lgt @@ -2,45 +2,36 @@ :- object(varlist, extends(list)). - :- info([ version is 1.0, author is 'Paulo Moura', date is 2000/7/24, comment is 'List of variables predicates.']). - member(Element, [Head| _]) :- Element == Head. - member(Element, [_| Tail]) :- member(Element, Tail). memberchk(Element, [Head| Tail]) :- - Element == Head -> + ( Element == Head -> true - ; - memberchk(Element, Tail). - + ; memberchk(Element, Tail) + ). prefix([], _). - prefix([Head1| Tail1], [Head2| Tail2]) :- Head1 == Head2, prefix(Tail1, Tail2). - valid(List) :- nonvar(List), \+ \+ valid2(List). - valid2([]). - valid2([Head| Tail]) :- var(Head), valid2(Tail). - :- end_object. diff --git a/Logtalk/manuals/NOTES.txt b/Logtalk/manuals/NOTES.txt index 392d45f42..6c27bbed8 100644 --- a/Logtalk/manuals/NOTES.txt +++ b/Logtalk/manuals/NOTES.txt @@ -1,9 +1,9 @@ -================================================================= -Logtalk - Object oriented extension to Prolog -Release 2.29.5 +================================================================ +Logtalk - Open source object-oriented logic programming language +Release 2.30.1 Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved. -================================================================= +================================================================ To consult the Logtalk documentation open the file "index.html" with a web browser. diff --git a/Logtalk/manuals/glossary.html b/Logtalk/manuals/glossary.html index c09e18e2d..5ba2798c3 100644 --- a/Logtalk/manuals/glossary.html +++ b/Logtalk/manuals/glossary.html @@ -23,170 +23,170 @@
-
ancestor
+
ancestor
A class or parent that contributes (via inheritance) to the definition of an object. For class-based hierarchies, the ancestors of an object are its class(es) and all the superclasses of its class(es). For prototype-based hierarchies, the ancestors of an object are its parent(s) and the ancestors of its parent(s).
-
category
+
category
A set of predicates directives and clauses that can be imported by any object.
-
class
+
class
An object that defines the common predicates of a set of objects (its instances).
-
abstract class
+
abstract class
A class that cannot be instantiated. Usually used to store common predicates that are inherited by other classes.
-
metaclass
+
metaclass
The class of a class, when we see it as an object. Metaclass instances are themselves classes. In a reflexive system any metaclass is also an object.
-
subclass
+
subclass
A class that is a specialization, direct or indirectly, of another class.
-
superclass
+
superclass
A class from which another class is a specialization (directly or indirectly via another class).
-
directive
-
A Prolog term that affects the interpretation of Prolog code. Directives are represented using the :-/1 prefix operator.
+
directive
+
A Prolog/Logtalk term that affects the interpretation of Prolog/Logtalk code. Directives are represented using the :-/1 prefix operator.
-
entity directive
+
entity directive
A directive that affects how Logtalk entities (objects, protocols, or categories) are used or compiled.
-
predicate directive
+
predicate directive
A directive that affects how predicates are called or compiled.
-
source file directive
+
source file directive
A directive that affects how a source file is compiled.
-
encapsulation
+
encapsulation
The hiding of an object implementation. This promotes software reuse by isolating users from implementation details.
-
entity
+
entity
Generic name for Logtalk compilation units: objects, categories, and protocols.
-
event
+
event
The sending of a message to an object. An event can be expressed as an ordered tuple: (Event, Object, Message, Sender). Logtalk distinguish between the sending of a message - before event - and the return of control to the sender - after event.
-
grammar rule
+
grammar rule
An alternative notation for predicates used to parse or generate sentences on some language. This notation hides the arguments used to pass the lists of tokens being processed, thus simplifying the representation of grammars. Grammar rules are represented using the infix operator -->/2 instead of the operator used on predicate clauses (:-/2).
-
grammar rule non-terminal
+
grammar rule non-terminal
A syntactic category of words of phrases. A non-terminal is identified by its name and number of arguments using the notation <name>//<nargs>.
-
grammar rule terminal
+
grammar rule terminal
A word or a basic symbol of a language.
-
identity
-
Property of an entity that distinguish it from every other entity. In Logtalk an entity identity can be an atom or a compound term. All Logtalk entities (objects, protocols, and categories) share the same name space.
+
identity
+
Property of an entity that distinguishes it from every other entity. In Logtalk, an object identity can be an atom or a compound term. Category and protocol identities must be atoms. All Logtalk entities (objects, protocols, and categories) share the same name space.
-
inheritance
+
inheritance
An object inherits predicate directives and clauses from other objects that it extends or specializes. If an object extends other object then we have a prototype-based inheritance. If an object specializes or instantiates another object we have a class-based inheritance.
-
private inheritance
+
private inheritance
All public and protected predicates are inherited as private predicates.
-
protected inheritance
+
protected inheritance
All public predicates are inherited as protected. No change for protected or private predicates.
-
public inheritance
+
public inheritance
All inherited predicates maintain the declared scope.
-
instance
+
instance
The same as object. This term is used when we want to emphasize that an object characteristics are defined by another object (its class).
-
instantiation
-
The process of creating a new class instance. In Logtalk does not necessarily implies dynamic creation of an object at runtime; an instance may also be defined as a static object in a source file.
+
instantiation
+
The process of creating a new class instance. In Logtalk, this does not necessarily implies dynamic creation of an object at runtime; an instance may also be defined as a static object in a source file.
-
library
+
library
A directory containing source files. The directory name is used as the library name.
-
message
+
message
A request for a service, sent to an object. In more logical terms, a message can be seen as a request for proof construction using an object's predicates.
-
metainterpreter
+
metainterpreter
A program capable of running other programs written in the same language.
-
method
+
method
Set of predicate clauses used to answer a message sent to an object. Logtalk uses dynamic binding to find which method to run to answer a message.
-
monitor
+
monitor
Any object that is notified when a spied event occurs. The spied events can be set by the monitor itself or by any other object.
-
object
-
An entity characterized by an identity and a set of predicate directives and clauses. In Logtalk objects can be either static or dynamic, like any other Prolog code.
+
object
+
An entity characterized by an identity and a set of predicate directives and clauses. Logtalk objects can be either static or dynamic. Logtalk objects can play the role of classes, instances, or prototypes.
-
parametric object
+
parametric object
An object whose name is a compound term containing free variables that can be used to parameterize the object predicates.
-
parametric object proxy
-
A compond term with the same functor and usually the same number of arguments as the identifier of a parametric object.
+
parametric object proxy
+
A compound term with the same functor and usually with the same number of arguments as the identifier of a parametric object.
-
parent
-
An object that is extended by another object.
+
parent
+
A prototype that is extended by another prototype.
-
predicate
+
predicate
Predicates describe what is true about the application domain. A predicate is identified by its name and number of arguments using the notation <name>/<nargs>.
-
local predicate
-
A predicate that is defined in an object (or in a category) but that is not listed in a scope directive. These predicates behave like private predicates but are invisible to the reflection methods.
+
local predicate
+
A predicate that is defined in an object (or in a category) but that is not listed in a scope directive. These predicates behave like private predicates but are invisible to the reflection built-in methods. Local predicates are usually auxiliary predicates, only relevant to the entity where they are defined.
-
meta-predicate
+
meta-predicate
A predicate where one of its arguments will be called as a goal. For instance, findall/3 and call/1 are Prolog built-ins meta-predicates.
-
private predicate
+
private predicate
A predicate that can only be called from the object that contains the scope directive.
-
protected predicate
+
protected predicate
A predicate that can only be called from the object containing the scope directive or from an object that inherits the predicate.
-
public predicate
+
public predicate
A predicate that can be called from any object.
-
visible predicate
-
A predicate that is declared for an object, a built-in method, or a Prolog or Logtalk built-in predicate.
+
visible predicate
+
A predicate that is declared for an object, a built-in method, or a Prolog/Logtalk built-in predicate.
-
profiler
+
profiler
A program that collects data about other program performance.
-
protocol
+
protocol
A set of predicates directives that can be implemented by an object or a category (or extended by another protocol).
-
prototype
+
prototype
A self-describing object that may extend or be extended by other objects.
-
self
+
self
The original object that received the message under processing.
-
sender
+
sender
An object that sends a message to other object.
-
specialization
+
specialization
A class is specialized by constructing a new class that inherit its predicates and possibly add new ones.
-
this
+
this
The object that contains the predicate clause under execution.
@@ -194,7 +194,7 @@