Did you know ... Search Documentation:
basics.pl -- XSB basics.P emulation
PublicShow source

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
Source 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.
Source ith(?Index, +List, ?Element)

Re-exported predicates

The following predicates are re-exported from other modules

Source append(?List1, ?List2, ?List1AndList2)
List1AndList2 is the concatenation of List1 and List2
Source reverse(?List1, ?List2)
Is true when the elements of List2 are in reverse order compared to List1.
Source 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
Source 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.
Source 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.
Source 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

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source comma_length(Arg1, Arg2)
Source log_ith(Arg1, Arg2, Arg3)
Source logk_ith(Arg1, Arg2, Arg3, Arg4)
Source comma_member(Arg1, Arg2)
Source comma_memberchk(Arg1, Arg2)
Source log_ith_bound(Arg1, Arg2, Arg3)
 between(Arg1, Arg2, Arg3)
Source comma_append(Arg1, Arg2, Arg3)
Source abscomma_memberchk(Arg1, Arg2)
 memberchk(Arg1, Arg2)
Source log_ith_new(Arg1, Arg2, Arg3)
Source subseq(Arg1, Arg2, Arg3)
Source comma_to_list(Arg1, Arg2)
Source log_ith_to_list(Arg1, Arg2)