This module provides the XSB basics
module. The implementation either
simply uses SWI-Prolog built-ins and libraries or is copied from the XSB
file.
- license
- - LGPLv2
- for(?I, +B1, +B2)
- Nondeterministically binds I to all integer values from B1 to B2
inclusive. B1 and B2 must be integers, but either may be larger.
- ith(?Index, +List, ?Element)
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
- flatten(+NestedList, -FlatList) is det
- Is true if FlatList is a non-nested version of NestedList. Note
that empty lists are removed. In standard Prolog, this implies
that the atom '[]' is removed too. In SWI7,
[]
is distinct
from '[]'.
Ending up needing flatten/2 often indicates, like append/3 for
appending two lists, a bad design. Efficient code that generates
lists from generated small lists must use difference lists,
often possible through grammar rules for optimal readability.
- See also
- - append/2
- reverse(?List1, ?List2)
- Is true when the elements of List2 are in reverse order compared to
List1. This predicate is deterministic if either list is a proper
list. If both lists are partial lists backtracking generates
increasingly long lists.
- subset(+SubSet, +Set) is semidet
- True if all elements of SubSet belong to Set as well. Membership
test is based on memberchk/2. The complexity is |SubSet|*|Set|. A
set is defined to be an unordered list without duplicates.
Elements are considered duplicates if they can be unified.
- See also
- - ord_subset/2.
- member(?Elem, ?List)
- True if Elem is a member of List. The SWI-Prolog definition
differs from the classical one. Our definition avoids unpacking
each list element twice and provides determinism on the last
element. E.g. this is deterministic:
member(X, [One]).
- author
- - Gertjan van Noord
- append(?List1, ?List2, ?List1AndList2)
- List1AndList2 is the concatenation of List1 and List2
- select(?Elem, ?List1, ?List2)
- Is true when List1, with Elem removed, results in List2. This
implementation is determinsitic if the last element of List1 has
been selected.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- comma_append(Arg1, Arg2, Arg3)
- logk_ith(Arg1, Arg2, Arg3, Arg4)
- comma_length(Arg1, Arg2)
- comma_to_list(Arg1, Arg2)
- abscomma_memberchk(Arg1, Arg2)
- comma_memberchk(Arg1, Arg2)
- comma_member(Arg1, Arg2)
- log_ith_new(Arg1, Arg2, Arg3)
- log_ith_to_list(Arg1, Arg2)
- between(Arg1, Arg2, Arg3)
- log_ith(Arg1, Arg2, Arg3)
- log_ith_bound(Arg1, Arg2, Arg3)
- memberchk(Arg1, Arg2)