Did you know ... Search Documentation:
Profile for user LogicalCaptain

Tags by LogicalCaptain

backquotesatom_codes/2
coroutinesSec. 4.9
datatypesSec. 4.5
deprecatedlibrary_directory/1, reconsult/1
doc-needs-helpis_of_type/2, assertion/1, , memberchk/2, cyclic_term/1, [wiki] Wiki page at "FAQ/reconsult.txt", ?=/2, dif/2, ==/2, Sec. A.51, [wiki] XPCE: the SWI-Prolog native GUI library, [wiki] Fix incomplete installation due to missing dependencies, [wiki] SWI-Prolog future directions, [wiki] Program Development Tools, call/1, format/2, Sec. 2.12, Sec. 2.16.1, maplist/2, writef/2, Sec. 2.16.1.3, Sec. 1.1, pengine_event_loop/2, Sec. 4.14, Sec. A.30, float/1, Sec. A.21, end_tests/1, Sec. 6.1, setup_call_cleanup/3, Sec. A.38, open/3, \=/2, \==/2, meta_predicate/1, Sec. 12.3, PL_register_foreign_in_module(), PL_get_atom_chars(), number/1, keysort/2, predicate_property/2, clause/2, Sec. G, atomic/1, Sec. 5.3.3, compound_name_arity/3, compound_name_arguments/3, get_dict_ex/3, Sec. 7.6, atom_string/2, acyclic_term/1, is_list/1, Sec. 5, Sec. 2.2.5, string_chars/2, Sec. 8.1, ord_intersection/2, expand_file_name/2, Sec. 12.4.11, Sec. 12.4.10, Sec. 12.4.16, Sec. 12, Sec. 12.3.1, Sec. 12.8.1, Sec. 12.4.17, Sec. 12.8.2
docs-needs-helpSec. 4.1, Sec. 5.4.1, read_stream_to_codes/3
exceptionsSec. A.16, throw/1, catch/3, Sec. 4.10.3, assertion/1
hashesSec. 5.4
joinatomic_list_concat/3
limit-solutionsonce/1
listlengthlength/2
mapsSec. 5.4
mode-indicatorsSec. 4.1
modesSec. 4.1
naf\+/1
negation\+/1
plunit
predicate-modesSec. 4.1
single_quoted_characterinteger/1
trimsplit_string/4
type_assertionmust_be/2
typesSec. 4.5
typetreeSec. 4.5
unit-tests

Comments by LogicalCaptain

PL_set_engine()In jpl.c there is a call == PL_set_engine(NULL, NULL); == What does that do?
Sec. 12.8.2"Portable" in the sense of "if it works here, it works there" as opposed to "eve ...
Sec. 12.4.17The correct format from `SWI-Prolog.h` is ``` int PL_warning(const char *fmt, .. ...
Sec. 12.8.1For `PL_check_data` and `PL_check_stacks` the formulation is incomplete: I suppo ...
Sec. 12.3.1"Creates a new term reference to the same term as the argument.
Sec. 12I guess referencing Kernighan & Ritchie, 1978, in 2020 (already?) is a bit quain ...
Sec. 12.4.16Why can one call `PL_set_prolog_flag` for `PL_BOOL`, `PL_ATOM`, `PL_INTEGER`, bu ...
Sec. 12.4.15The relevant man page for POSIX OS-level signals is - man 7 signal - man 2 sigac ...
Sec. 12.4.10In predicate_t PL_predicate(const char *name, int arity, const char* module) how is the encoding of "name" and "module" specified (is it always UTF-8?) (nit pick: note the inconsistent sidedness of *) In int PL_call(term_t t, module_t m) the link to "figure 8" is dead.
Sec. 12.4.11We read: "See figure 8 for an example." But the link for "figure 8" (i.e.
getenv/2Background reading: https://en.wikipedia.org/wiki/Environment_variable On Linux, the environment variables, as attributes of the process, can be manually inspected by reading file `/proc/$PID/environ` like a normal text file.
read_stream_to_codes/3"creates a difference-list" should be "creates an open list ending in Tail if Ta ...
expand_file_name/2## References Note that this is based on "csh" filename expansion.
open/4Note that the "~" notation (used on Unix to indicate the user's home directory) ...
random/1## Sample application: Generate random atoms - [`random_atom.pl`](https://github ...
Sec. 11There is also a pack for UUIDs: https://eu.swi-prolog.org/pack/list?p=pluuid Exp ...
random_float/0An example that uses random_float/1 to generate a random atom: - [`random_atom.p ...
ord_intersection/2The first argument is not the/a [PowerSet](https://en.wikipedia.org/wiki/Power_s ...
Sec. 8.1## Diagram showing how to think about the structure involved The diagram explain ...
list_to_ord_set/2This predicate should probably be named list_to_ordset/2 instead of list_to_ord_ ...
Sec. 8.1.1Note that you can "put" to an unbound variable: == ?- put_attr(X,module,Y),get_a ...
attr_unify_hook/2"Triska 2016" is right here: https://www.metalevel.at/swiclpb.pdf "The Boolean C ...
put_attr/3On the toplevel, the predicate prints itself.
More on Communicating FSMs here: https://en.wikipedia.org/wiki/Communicating_fin ...
Sec. 4.10## My notes See [this page](https://github.com/dtonhofer/prolog_notes/blob/maste ...
split_string/4The example as test case: == :- begin_tests(split_string). test("A simple split" ...
Reference manual## Sometimes the documentation website is confusing. Main elements: - [*The SWI- ...
[wiki] XPCE: the SWI-Prolog native GUI libraryFor some reason this page shows up in no "list of contents", one finds it throug ...
statistics/0There is a full-fat statistics/1 from `library(statistics)` (file `swipl/lib/swi ...
time/1This prints something like == % 4,623,232 inferences, 1.223 CPU in 1.229 seconds (99% CPU, 3780625 Lips) == But why aren't those values returned in variables?!? They can't even be caught using `with_output_to/2`: == ?- with_output_to(string(S),time(sleep(1))). % 1 inferences, 0.000 CPU in 1.000 seconds (0% CPU, 24841 Lips) S = "". == Time to go take a look at that code... (Also, what exactly is a "logical inference" ... is it a clause call?
integer/1This doesn't _really_ belong here but: A special way to generate integers is by ...
string_chars/2See also atom_chars/2
atom_concat/3For concatenating more than one atom in one operation, see atomic_list_concat/2 ...
shell/2This is actually not that good an approach. The command is passed as a string an ...
jpl_class_to_classname/2== :- begin_tests(jpl_class_to_classname). instance_ref_to_entity_name(InstanceR ...
Sec. 10See also: - https://en.wikipedia.org/wiki/POSIX_Threads - https://computing.llnl ...
threads/0Example: == ?- threads. % Thread Status Time Stack use allocated % ------------- ...
Sec. 2.2.5The latest output for the test given is: == ?- run_tests. % PL-Unit: test ERROR: /home/user/tests.pl:3: test a: assertion failed Assertion: float(8) ERROR: /home/user/tests.pl:3: test a: assertion failed Assertion: 8==9 A done % 2 assertions failed % 1 test failed % 0 tests passed false. ==
Sec. 7The Twiki idea of == =code= Typeset text fixed font for identifiers (see running text).
acyclic_term/1How expensive is this test?
get_dict/5This predicate is misnamed.
discontiguous/1Note that making one predicate (for example, a lookup predicate) discontiguous a ...
Sec. 4.10.3## More info I'm trying to keep [**this page**](https://github.com/dtonhofer/pro ...
type_error/2A little diagram to discuss the "instantiation & type & domain verification pipe ...
atom_length/2## Something for the toolbox == character(A) :- atom(A),atom_length(A,1). == ## ...
is_list/1## Doc error "a term with functor `[|]` and arity 2" is slightly incorrect. The ...
reverse/2Instead of reverse/2 after a successful recursion, consider using the correct [l ...
Sec. 4.21[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
setarg/3Position is 1-based and the predicate fails if _Value_ is out-of-bounds: == ?- X ...
Sec. 2.2The example init.pl file is in lib/swipl/customize/init.pl in the installation d ...
load_files/2## Load from where? "The specification for a source file is handed to absolute_f ...
Sec. 6.5Noet that this works for complex goals too. For example, in one module: == :- mo ...
use_module/1use_module/1 is of course the wrong name for this functionality - it should be u ...
load_test_files/1For some reason this does not work for "raw code" files, i.e.
string_length/2It actually accepts Numbers on "String" position: == ?- string_length(1r2,Len). ...
with_output_to/2## If the goal emitting output fails... Evidently, if the goal fails, and you ou ...
run_tests/0This predicate succeeds if all the tests succeeed and fails otherwise (i.e.
Sec. 4.39## "The Byrd Box Model" aka.
atomic_list_concat/3Shouldn't there be a "stringy_list_concat" which generates a string?
ground/1Notice that the anonymous variable stays unground as every new occurrence is rea ...
Sec. 7.6Here is an excellent explanatory paper for Well-Founded Models by Teodor Przymus ...
Sec. 9"In the current system, test units are compiled into sub-modules of the module i ...
get_dict_ex/3This predicate no longer exists (and this page will be removed in a future updat ...
debug/1Please read important note on **debug topics** in the comment section of **[debu ...
Sec. A.14## An important note on topics (I will add this to the manual text later): Jan w ...
Sec. 5.4.1.2The parameter for .put/1 should be called "NewKeyValuePairs".
Sec. 5.4.1## Doc needs help The `New` in `put(+New)`should really be called `NewKeyValuePa ...
dict_create/3The difference between dict_create/3 and dict_pairs/3 is: - dict_create/3 takes ...
-- Special case: When you create a module to host dict method calls, you don't list those in the "public list" section: Here, just the predicate is listed: == :- module(point, [point_length/2]). M.multiply(F) % Method ".multiply/1" on dict M := point{x:X, y:Y} % Returns a "point" dict :- X is M.x*F, Y is M.y*F.
list_debug_topics/0This is a user-oriented predicate: == ?- list_debug_topics. -------------------- ...
:</2## Naming IMHO, "select" is not the appropriate name here, the more so because " ...
sub_string/5Time for test cases! == :- begin_tests(sub_string). test(find_single_bravo,[true ...
min/2This should really be extended to take vectors: == Small is min(ListOfExpression ...
forall/2Related reading: "Logical Loops" by Joachim Schimpf (2002) PDF downloadable here ...
is_dict/2A random atom is not a dict == ?- is_dict(atom,X). false. == A dict tagged "foo" is tagged "foo" indeed == ?- is_dict(foo{},foo). true. == Extracting the tag of a dict == ?- is_dict(foo{},X). X = foo. == An "anonymous dict" is a dict tagged as "foo" (this actually sets the tag of the anonymous dict to "foo" but we will never be able to ascertain this because there is no intruction to the right of the is_dict/2 call). == ?- is_dict(_{},foo). true. == Making another variable to denote the "hole" of an "anonymous dict" == ?- is_dict(Y{},X), X == Y. Y = X. == Setting/Binding/Refining the still fresh tag of the dict?
put_dict/3## Improvement The argument "New" should really be called "Updates" or "NewKeyVa ...
dict_pairs/3## Need doc fix "ordered list of pairs" means (probably) "ordered by natural ord ...
random_between/3## Example of selecting an id between 0 and 6 that is not in a (small) dict yet. This is an example of a "failure-driven loop". == clashfree_id_selection(Dict,Id) :- repeat, random_between(0,6,Id), (true;(format("CLASH for ~q\n",[Id]),fail)), % print CLASH on backtracking \+ get_dict(Id,Dict,_), format("FOUND ~q\n",[Id]), !. == Then == ?- clashfree_id_selection(_{3:x,4:x,5:x,6:x,7:x},Id). CLASH for 3 CLASH for 3 CLASH for 3 FOUND 1 Id = 1. == Philosophically, it is weird that that random_between/3 is "semidet" (i.e.
Sec. 4.32## For those looking for the correct predicate to use: - [Relevant predicates fo ...
Sec. 4.20For those looking for the predicate to use: - [Relevant predicates for generatin ...
debug_message_context/1The flag =message_context= is explained on the page for current_prolog_flag/2
is/2is/2 is **arithmetic function evaluation** from the original Prolog But in SWI-P ...
atomic/1The complement of atomic/1 is compound/1.
compound/1[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
aggregate/3Suppose you have an SWI-Prolog dict with integer values and you want to sum over those values: == dict_sum(_{} ,0) :- !. % Spcial case of empty dict, red-cutted. dict_sum(Dict,Total) :- aggregate(sum(Val), Key^get_dict(Key,Dict,Val), Total). :- begin_tests(sum). test(sum1, [ true(T) ]) :- Dict = quux{}, dict_sum(Dict,Total), T = ( Total == 0 ). test(sum2, [ true(T) ]) :- Dict = quux{x:1,y:2}, dict_sum(Dict,Total), T = ( Total == 3 ). :- end_tests(sum). rt(_) :- run_tests(sum). ==
findall/4Useful when you want to append to a list using several calls to findall/4. For e ...
put_dict/4Simply inserting or incrementing a dict of counters == % === % Increment the cou ...
number_codes/2## Getting the number from the list of character codes == ?- number_codes(N,[49, 50, 51]).
- [Cheatsheet for Perl Regular Expressions](https://perlmaven.com/regex-cheat-s ...
number_chars/2This tests whether the "serialized representation" doesn't lose digits: == ?- X ...
atom_chars/2See also string_chars/2 ## Tests are good Unit test code for atom_chars/2, also ...
debug/3## Topics Please read important note on **debug topics** in the comment section ...
Sec. 4.13Introduction and tutorials: - [DCG Primer](https://www.metalevel.at/prolog/dcg) ...
char_code/2Remember that a Prolog "character" is an atom of length 1. However, this predica ...
phrase/3## Example == :- use_module(library(dcg/basics)). :- begin_tests(dcg). % Parsing the (unicode) codepoints in "Codes" with the callable % integer(X) which actually resolves to predicate integer/3, taking % itself "Codes" and "Rest" in addition to "X".
Sec. 4.9## Reading The link to "Schrijvers et al., 2013." just goes to the bibliography ...
Sec. GSome of the above can be live linked directly to (legit) Internet-available PDFs In particular, there's one right here on this server Delimited continuations for Prolog: https://www.swi-prolog.org/download/publications/iclp2013.pdf
initialization/1Example for when you want to call =main= of your source file **immediately after the source file has been loaded** (from swipl-devel/man/select.pl): == :- initialization ( catch(main, E, ( print_message(error, E), fail )) -> halt ; halt(1) ). ==
Sec. 9.1Note the following outcomes of calling a CHR constraint from Prolog: - The call ...
Sec. 9.1"Committed Choice" very concretely means there is no backtracking over the CHR r ...
Sec. 9.1The links to "further information" should probably not be as in an academic pape ...
term_expansion/2A simple example to print out whatever is read during consultation. In this case ...
Sec. 9Working on unconfusing myself on CHR/Prolog interaction. Here is some reading of interest: [Abductive reasoning in Prolog and CHR A short introduction for the KIIS course, autumn 2005](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.602.3397)
unify_with_occurs_check/2"That is, a variable only unifies to a term if this term does not contain the va ...
dif/2## Needs text improvement We read: _Finally, if A and B can unify, goals are del ...
throw/1I put together some comments on exceptions (especially on ISO standard exception ...
Sec. 2.10 ## "The Byrd Box Model" aka.
Sec. 4.14## From "The Craft of Prolog" Relative to **4.13.5 Update view**, Richard A.
instantiation_error/1The ISO exception term has no information (see also throw/1) and is completely u ...
module/1This predicate should probably also be able to retrieve the name of the current ...
freeze/2## Some notes 1.
succ/2In fact, succ/2 is made to order for natural numbers. - What is the predecessor ...
setof/3See bagof/3 for some commentary.
false/0## Zero-effect clauses Note that writing clauses like == p(1,2) :- false. == has absolutely no effect on the meaning of Prolog program - you might as well leave them out (because everything that is left out is considered false - Closed World Assumption) For example: == p(2,4) :- false. p(A,B) :- between(1,4,A),B is 2*A. == Result: == ?- p(2,4). true. ?- bagof([X,Y],p(X,Y),Bag). Bag = [[1, 2], [2, 4], [3, 6], [4, 8]]. == and it is exactly the same for == p(A,B) :- between(1,4,A),B is 2*A. p(2,4) :- false. == or == p(A,B) :- between(1,4,A),B is 2*A. == ## And now for some inconsistency Using `false` and the cut means you can write Bad and Inconsistent Programs: == f(X,X) :- !, false. f(0,1). == Now you are in trouble: == ?- f(0,1).
Sec. 5.3.2## Compound terms of arity 0 vs.
## Works "out of the box"! As an example, try a few test cases.
retractall/1This predicate never fails. "If Head refers to a predicate that is not defined, ...
clause/2Jan Burse writes: "According to ISO core standard clause/2 is also only allowed ...
retract/1"logical update view" would be more correctly called "transactional update view" ...
dynamic/1See also: [Database Section](https://www.swi-prolog.org/pldoc/man?section=db) wh ...
flag/3From the [Database](https://eu.swi-prolog.org/pldoc/man?section=db) page: "flag/ ...
[wiki] SWI-Prolog downloadsTL;DR for "Install development version on Linux" With `bash`. Building is done u ...
must_be/2## When to use must_be? This predicate should be used exclusively to perform con ...
include/3Example: We want the _Keys_ of _Key-Value_ pairs which match a certain _Value_. ...
## Test cases are your track bed through the swampland Write your test cases.
domain_error/2An example for a "domain error": == ?- catch(length(L,-1),C,true). C = error(dom ...
between/3## Unit test code for "between" [**Here is unit test code for between/3**](https ...
compound_name_arguments/3[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
=../2[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
Sec. A.51## Don't forget the bracy part A question that often comes up is due to differen ...
\+/1## Interpretation Read \+ p(X) as "there is no evidence for p(X)" or "there is n ...
[wiki] SWI-Prolog datatypesThe SWI-Prolog documentation has more on SWI-Prolog datatypes test predicates he ...
Sec. 4.5## The Type Tree in ASCII == any T | +-------------------------+---------------- ...
repeat/0## See also forall/2 as a better alternative to the failure-driven loop ## Alter ...
once/1Definitely prefer once/1 over ->/2.
-- I put together some comments on exceptions here: [On Exceptions](https://github. ...
var/1This predicate is named according to tradition but in a very unfortunate fashion (leading to much confusion for newcomers trying to understand Prolog). The correct name should be: == fresh/1 == Because var(X) does not test whether whatever is in between the parentheses (in this case =X=), is a _variable_ (we **know that** just by looking at the source code and the compiler should flag an always-true call "var(foo)", and actually it does), but whether =X= is a _fresh variable_ (alias "names a 'hole'", "names an uninstantiated term", "names a fresh term", "is uninstantiated", "is unrefined", "is the name denoting an empty box in the term store" and also "unifies with anything" and variations thereof) at the current state of computation. It is also the **exact complement** of "nonvar(X)".
get_assoc/5Jan, why not add your comment to the documentation directly. This approach has t ...
length/2## Unit test code [Unit testing length/2](https://github.com/dtonhofer/prolog_no ...
atomic_list_concat/2The second argument is always from the set of atoms: == ?- atomic_list_concat([a ...
list_to_assoc/2Missed opportunity: The predicate **fails** if =Assoc= is set but =Pairs= is fre ...
max_list/2Unexpectedly, it is `max_list(List,Max)` on one hand but `max_member(Max,List)` ...
append/3## Don't use append excessively From the description of flatten/2 : "Ending up n ...
sort/2I have gone through the available sorting predicates and assembled some unit tes ...
keysort/2There should be a link to library(pairs): https://www.swi-prolog.org/pldoc/man?s ...
Sec. A.3I had some fun writing =foldl/4= and =foldr/4=, including an implementation of = ...
mod/2A little exercise to compare the pairs == div,mod == and == //,rem == can be [** ...
foldl/4## Example (aka "don't fear the `foldl`") The _Goal_ in `foll` call is a predica ...
maplist/4All three lists must be the same length otherwise the predicate fails. It makes ...
current_prolog_flag/2I'm always looking for the way make the: ### toplevel printer print lists in ful ...
same_length/2Behaves like a bidirectional length/2, same as: == ?- length(L,3). L = [_22942, ...
nth0/3A "vector nth0" vector_nth0/3, based on nth0/3 and which retrieves several entri ...
nth0/3This can also be used for *searching in a list* (and thus for checking whether a ...
-- Powerful append/2 is powerful.
list_to_set/2See also library(ordset) https://www.swi-prolog.org/pldoc/man?section=ordsets an ...
select/3== ?- select(10,[1,2,3],R). false. ?- select(2,[1,2,3],R). R = [1, 3] ; % maybe ...
write_canonical/1Quite an interesting predicate to see what syntax tree the parser has created fr ...
functor/3[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
compound_name_arity/3[**This page**](https://github.com/dtonhofer/prolog_notes/tree/master/swipl_note ...
number/1Rational Numbers are "numbers" and "atomic" (latest in SWI-Prolog 8.1.24, ration ...
append/2How to remove an element from a list (which must contain it) using append/2 once ...
member/2## Some text vagueness "provides determinism on the last element" should be "pro ...
Sec. 5.1Do not be confused by '[|]'.
Sec. 5.4## Helper library There is an additional [library(dicts)](https://eu.swi-prolog. ...
\==/2Application: membership check in a difference list, to check whether we have rea ...
atom_codes/2## Testing atom_codes(_,_) Unit test code is here [`test_atom_codes.pl`](https:/ ...
sleep/1Oh important: You can sleep a float time! == % 5 seconds sleep ?- Sleep=5,get_ti ...
random/1Watch out for confusion: Obtaining a pseudo-random float using the *built-in ran ...
get_dict/3## Simple test code == :- begin_tests(dict). xyz_dict(_{x:alpha, y:beta, z:gamma ...
-- I have been looking for a predicate to split a list L into three pieces: - Front (a list) - Element at Index N (0-based) - Back (a list) such that: == append([Front,[Element],Back],L). == Here is one.
nth0/4Replacing an element in a list (with 0-based indexing) from https://stackoverflo ...
foreach/2The "foreach" example is confusing because "dif/2" freezes until a decision can ...
Sec. 2## Errors on reloading source code Note that all the predicates (including helpe ...
Sec. 4.27.2.1Links to the GMP library: https://gmplib.org/ https://en.wikipedia.org/wiki/GNU_ ...
predsort/3This absolutely needs to be extended to `predsort(+Pred, +List, -Sorted, +Flags) ...
current_prolog_flag/2For the next iteration of the website, the flags listed really need their indivi ...
predsort/3Here is another example of predsort in a rather disconcerting duplicate-killing ...
Sec. 12.2.3Once you have compiled an .so file, make it discoverable by swipl using == asser ...
Sec. 12.2.3Try == swipl-ld -help == for help information (for some reason, not -h or --help ...
Sec. 4.1See also: - https://www.swi-prolog.org/pldoc/man?section=glossary - https://stac ...
PL_get_atom_chars()Returns 1 on success, 0 on failure (e.g.
PL_register_foreign_in_module()"After this call returns successfully" means... it returns 0?
Sec. 12.3`atom_t` may point to static memory or garbage-collectable memory if I understan ...
sleep/1"On most non-realtime operating systems we can only ensure execution is suspende ...
meta_predicate/1Confused by "The argument is a term that is used to reference a predicate with N more arguments than the given argument term.
Sec. 6.5Confused by "The argument is a term that is used to reference a predicate with N more arguments than the given argument term.
Sec. 6.1As noted by Paulo Moura "Prolog Modules" (SWI-Prolog Modules?) can be seen as "o ...
current_prolog_flag/2This is not the user's home directory: == ?- current_prolog_flag(home, X). X = ' ...
nan/0== ?- NAN is nan, write_canonical(NAN). 1.5NaN NAN = 1.5NaN. == Weird! I suppose one can test against NaN using =:= ?
max/2This should really be extended to take vectors: == Big is max(ListOfExpressions) ...
=:=/2Some examples: Everything must be known at the time of evaluation: == ?- 2*2 =:= X. ERROR: Arguments are not sufficiently instantiated ?- X=4.0, 2*2 =:= X. X = 4.0. ?- cos(X) =\= sin(X). ERROR: Arguments are not sufficiently instantiated % Ok, then! ?- X=pi, cos(X) =\= sin(X). X = pi. == Sadly =:= is a bit fussy.
\==/2For clarity, this should be written with complimentary parentheses: == \+(Term1 ...
copy_term/2It is intuitively clear what "renamed (fresh) variables" means but it's not real ...
\=/2We read: _"In other cases, such as `?- X \= Y.`, the predicate fails although th ...
\=/2It would be clearer to write == \+(Term1 = Term2) == rather than than == \+Term1 = Term2 == Although of course: == ?- write_canonical(\+Term1 = Term2). \+(=(_,_)) ==
->/2## Naming Do not call this construct an "implication".
initialization/2Regarding "main", note that an exit status of 0 indicating "success" is a conven ...
Sec. 2.11.2.1Contra Carlo Capelli's note, the "shebang" is not at all overengineered. As a co ...
option/2I'm not sure why, but this predicate is indeed semi-deterministic. This means yo ...
Sec. 4.36Also consider library "filesex" ("extended operations on files", damned PhDs doi ...
Sec. A.22For the shebang trick where swipl is started indirectly through =env= == #!/usr/ ...
Sec. A.22For the "initialization" directive, see: https://www.swi-prolog.org/pldoc/doc_fo ...
open/3What does an empty option list assume about the encoding of the file? See: https ...
setup_call_cleanup/3The example given in the text is incomprehensible, here is another one: == alty ...
setup_call_cleanup/3Demo of determinism in the cleanup procedure: == ?- setup_call_cleanup(true,memb ...
setup_call_cleanup/3== intro :- format("intro\n").
deterministic/1Example: == ory :- format("1st clause:\n"), deterministic(D1), format(" Det at ( ...
setup_call_cleanup/3This is a bit like try-with-resources in Java: https://docs.oracle.com/javase/tu ...
atom/1See also: https://www.swi-prolog.org/pldoc/man?section=text-representation Atoms ...
option/3Example: Give me the option for =foramt=, but use =html= if it is missing == ?- ...
[wiki] SWI-Prolog -- Installation on Linux, *BSD (Unix)You may want to ensure that environment variable SWI_HOME_DIR is unset before co ...
Sec. 6.2## Do not export predicates if you just want to access them from test code It se ...
Sec. 6.1The page of "library(prolog_xref)" seems to be here: https://www.swi-prolog.org/ ...
Sec. GThis above just the list of references that appear in the Documentation. I have ...
get_time/1I wonder why this isn't == T is get_time() == possibly == T is get_time(now) == ...
begin_tests/1Note that if you add tests from the command line using [user]., you can do so on ...
end_tests/1What is the rationale behind having to repeat the test name in the block termina ...
consult/1You can actually also pass a series of files: == ?- consult([foo,roo]). == If yo ...
Sec. A.21I would also point the user to https://www.swi-prolog.org/pldoc/man?section=ords ...
predicate_property/2This may not be directly clear from the description: Perhaps surprisingly, the t ...
[wiki] Eat Your Own Dog FoodThis should really be linked from the "Documentation" intro page.
Sec. 3ISO Prolog only defines the "% ..." comments and the "/* ... */" comment block i ...
maplist/2Major explainer including examples for the use of maplist/2 here: [Examples for ...
string_concat/3An application of string_concat/3: Creating strings consisting only of spaces. F ...
float/1"When used around the 2nd argument of is/2, the result will be returned as a flo ...
Sec. A.30This needs more explanation on the attached "database file". Is it a text file w ...
Sec. 4.14Please provide the link to library(persistency) in the second paragraph of "Usin ...
pengine_event_loop/2I think the use of "Closure" here is a bit misleading.
Sec. 1.1The link = http://www.swi-prolog.org/pldoc/doc/home/vnc/prolog/lib/swipl/library ...
catch/3## Example 1 Example, catching format/2 complaining about a lack of arguments: = ...
float/1What is a "float"?
Sec. 2.16.1.3This section applies to Strings, too == ?- format(">\c | hello<"). >hello< true. == Jan Wielemaker writes: "Although incomplete in the implementation, the overall idea is that predicates that require text input accept all text representations and produce the documented type as output." ---- The \uXXXX encoding (really, NAMING of a glyph in the Unicode BMP) is called "UCS-2" https://en.wikipedia.org/wiki/Universal_Coded_Character_Set More on Unicode here: https://en.wikipedia.org/wiki/Unicode#Architecture_and_terminology ---- Note that the unicode escapes are meant to be used in the context of strings, atoms or chars (atoms of length 1).
writef/2As noted on the page of format/2, the escape sequences one uses in practice are ...
format/2## More tricks Generates a string of 2 spaces in `Spaces`: ``` format(string(Spa ...
atom_string/2## Text needs fixing - This predicate takes general numbers, including non-ratio ...
read/1This corresponds to "serialization/deserialization" in Java and other languages. You CAN but shouldn't use this for reading input typed in by the user. Example: ?- with_output_to(string(Buf),write_term(a(b,c,[1,2,3],var(ZZ)),[])), read_term_from_atom(Buf, T, []). Buf = "a(b,c,[1,2,3],var(_7256))", T = a(b, c, [1, 2, 3], var(_7848)). Use readutil for user querying: https://www.swi-prolog.org/pldoc/man?section=readutil Example: format("Answer me!\n"), read_line_to_string(user_input,S1), string_lower(S1,S2), (member(S2,["yes","1","ok","y","ja","oui"]) -> format("OK!") ; (format("NOK"), fail)). Answer me! |: YES OK!
maplist/3Some examples for the use of maplist/3 here: [Examples for the Prolog predicate ...
Sec. 4.6Note that "==" and "\==" are really tests about the current state of the computa ...
Sec. 2.1"Getting started quickly" should point the user to a description/tutorial/howto ...
Sec. 2.16.1.9See also: https://eu.swi-prolog.org/pldoc/man?section=widechars
Sec. 2.16.1The title of this section is "ISO Syntax Support" but should probably be "Extens ...
Sec. 2.16.1.5This is not ISO Prolog, but quite useful. Compare with Java where this trick is ...
findall/3## Success if no solution As the description says, unlike bagof/3 and setof/3, f ...
Sec. 2.12I'm always looking for the way make the ### Prolog Toplevel printer print lists ...
Sec. 5.2.1Regarding the traditional "string": Wikipedia says at https://en.wikipedia.org/w ...
call/1## Backtracking works as expected == ?- call(member(X,[1,2,3])). X = 1 ; X = 2 ; X = 3. == ## Doc changes The text should probably be changed from > Note that clauses may have variables as subclauses, which is identical to call/1. to > Note that clauses may have variables as goals.
[wiki] Program Development ToolsThere is nothing for IntelliJ JetBrains plugin repository: https://plugins.jetbr ...
[wiki] Program Development ToolsCurrently trying "ProDT"... Trying with Eclipse Oxygen (Eclipse 4.7, 2017-12) on Linux Fedora with JDK 1.8.0 The original site is http://prodevtools.sourceforge.net/ - the instructions on that site are a bit stale.
[wiki] Program Development ToolsThe link to "Prolog Development Tool - PDT" and the link to "Prolog Development ...
[wiki] SWI-Prolog future directionsIt might be helpful to indicate when this entry was written.
[wiki] Fix incomplete installation due to missing dependenciesDead link in the line "Redo the build.
[wiki] Wiki page at "build/issues/xpce.txt"Compiling on Fedora: At first sight, the error log seems to indicate that there ...
[wiki] XPCE: the SWI-Prolog native GUI librarySadly, the link "The design of the XPCE/Prolog interface (Publication in Worksho ...
bagof/3## No solutions for Goal lead to failure, instead of an empty bag. == ?- bagof(X ...
^/2Outside of arithmetic contexts, the ^/2 operator is used to mark variables as "n ...
==/2Confusingly, the explanations uses two adjectives: "equivalent" and "identical".
?=/2I think the text "Succeeds if the syntactic equality of Term1 and Term2..." shou ...
[wiki] Wiki page at "FAQ/reconsult.txt"The link to "Initialising and Managing.." has to be changed to http://www.swi-pr ...
cyclic_term/1Example: == obtain_cyclic(L) :- L=[1,2,3,4,5|T],L=[1,2|T]. :- begin_tests(cyclic ...
memberchk/2This predicate does not backtrack, which is the idea.
Sec. 5See also http://eu.swi-prolog.org/pldoc/man?section=preddesc from the reference ...
Sec. 4.1See also the description in the package of the Prolog documentation generator: h ...
Sec. A.4.3Actually missing a way to get the number of elements in the association list...
Reference manual#### SWI-Prolog Wiki entry There is a wiki entry at the SWI-Prolog Discourse Gro ...
assertion/1## When to use this? Jan Wielemaker writes: > Public APIs should not use asserti ...
call/2In this context, the following, though rather old, is highly readable: "Higher-o ...
file_search_path/2Thanks @Jan.
[wiki] Representation and printing of floating point numbersAnd here is the [reference for floating-point notation](http://www.dcc.fc.up.pt/ ...
[wiki] Representation and printing of floating point numbersHere is a another link of interest that predigests the "What Every Computer Scie ...
file_search_path/2The definition should be "file_search_path(?Alias, ?Path)" as the following work ...