Package-level declarations
Types
An Indexed value whose index is an Int, comparable to other IntIndexed values by index. This is the type produced by Sequence.indexed, the "counted" counterpart of kotlin.collections.withIndex used throughout the codebase whenever a position needs to travel along with a value through further transformations (e.g. .map { it.map(...) }), which a plain IndexedValue/destructured pair would not allow as conveniently.
An Indexed value whose index is a Long, comparable to other LongIndexed values by index. This is the type produced by Sequence.longIndexed, the 64-bit counterpart of IntIndexed, useful whenever the position of a value may exceed Int.MAX_VALUE (e.g. it.unibo.tuprolog.collections.rete.custom.clause.IndexedClause in the :theory module indexes clauses by insertion order using a Long, since a knowledge base may grow without a practical Int-sized bound).
Classifies platform Numbers (e.g. Int, Double, Float, or any other JVM/JS numeric boxed type encountered while converting external, non-Prolog values into Prolog terms) as integral or decimal, and converts them into the arbitrary-precision BigInteger/BigDecimal types used internally to represent Prolog numbers, based on their String representation rather than on their runtime class.
A container that either holds exactly one value of type T (Some), or holds none (None), used across the codebase as an explicit, null-safe substitute for a nullable T? wherever null itself could be a meaningful value to store (so that "no value" and "the value happens to be null" cannot be confused), e.g. as the return type of Cache.get/Cache.set (the evicted pair, if any) or Cached.ifValid.
A BinaryOperator over Taggable.tags maps, used to combine the tags of two Taggable instances into a single tags map, e.g. when two tagged objects are merged into one and their tags need to be reconciled (see, for instance, Substitution.plus(Substitution, TagsOperator) in the :core module).
Functions
Inserts item at the head of this list, shifting all other elements one position towards the tail. Named after (and, on platforms with one, backed by) the "add first" operation of a proper deque.
Inserts all the elements of items, in iteration order, at the head of this list.
Inserts item at the head of this list, shifting all other elements one position towards the tail. Named after (and, on platforms with one, backed by) the "add first" operation of a proper deque.
Inserts all the elements of items, in iteration order, at the head of this list.
Returns a new instance, otherwise equivalent to this one, with tags merged into its existing Taggable.tags (overwriting any existing tags with the same names as one of tags' keys).
Returns a new instance, otherwise equivalent to this one, with tag (and any otherTags) merged into its existing Taggable.tags (overwriting any existing tags with the same names).
Asserts that none of the elements of this array is null, returning it as an Array of the non-nullable element type T (which, for a reference-typed array, is the very same array instance, unsafely cast).
Same as Sequence.assertItemsAreNotNull, starting from an Iterable rather than a Sequence.
Eagerly materializes this sequence into a List and returns it as a (now safely re-iterable) Sequence. Use this to consume a one-shot/expensive-to-recompute sequence more than once without recomputing it every time, at the cost of holding all of its elements in memory at once; see also cached for a lazier alternative that memoizes elements only as they are first traversed.
Returns a Sequence view that lazily memoizes the elements of this sequence as they are first traversed (via Cursor.asSequence), so that traversing the result more than once does not recompute already-seen elements. Unlike buffered, this does not eagerly consume the whole sequence upfront.
Returns a lazy Cursor traversing the elements of this Collection, in iteration order.
Force-casts this (possibly null) receiver to T, with no runtime type check performed by this function itself (on the JVM, this is a plain as T unchecked cast; on JS, it goes through a dynamic value, bypassing type checking altogether). Use this only where the caller has independent, external knowledge that the cast is safe (e.g. the Cursor plus operator in CursorExtensions.kt uses it to narrow an Iterable-backed Cursor<out T> back down to a Cursor<T>), since, unlike a checked as T, an invalid cast may not fail immediately at the call site, but only later, wherever the miscast value is first used as a T.
Force-casts this (possibly null) receiver to T, with no runtime type check performed by this function itself (on the JVM, this is a plain as T unchecked cast; on JS, it goes through a dynamic value, bypassing type checking altogether). Use this only where the caller has independent, external knowledge that the cast is safe (e.g. the Cursor plus operator in CursorExtensions.kt uses it to narrow an Iterable-backed Cursor<out T> back down to a Cursor<T>), since, unlike a checked as T, an invalid cast may not fail immediately at the call site, but only later, wherever the miscast value is first used as a T.
Force-casts this (possibly null) receiver to T, with no runtime type check performed by this function itself (on the JVM, this is a plain as T unchecked cast; on JS, it goes through a dynamic value, bypassing type checking altogether). Use this only where the caller has independent, external knowledge that the cast is safe (e.g. the Cursor plus operator in CursorExtensions.kt uses it to narrow an Iterable-backed Cursor<out T> back down to a Cursor<T>), since, unlike a checked as T, an invalid cast may not fail immediately at the call site, but only later, wherever the miscast value is first used as a T.
Pairs each element of this sequence with its 0-based position, as an IntIndexed value, lazily.
Lazily interleaves the elements of the given iterables, round-robin style: the first element of every iterable, then the second element of every (still non-exhausted) iterable, and so on, until all of them are exhausted. Unlike merge, this does not require the inputs to be sorted, and does not reorder elements based on their value, only on their position within their originating iterable.
Same as interleave, taking the outer collection of iterables as a Sequence.
Same as interleave, taking the iterables to interleave as varargs.
Same as interleave, where each of the interleaved elements is a Sequence rather than an Iterable.
Same as interleave, where both the outer collection and each of the interleaved elements are Sequences.
Same as interleave, taking the Sequences to interleave as varargs.
Same as itemWiseEquals, using Any.equals (==) as the element comparator.
Same as itemWiseEquals, for two Sequences rather than Iterables, using Any.equals (==) as the element comparator.
Compares iterable1 and iterable2 element-by-element, in iteration order, via comparator, returning true if and only if both have the same number of elements and every corresponding pair of elements satisfies comparator. Useful to compare two iterables for equality without materializing them into Lists first, or using a notion of "equality" other than Any.equals (e.g. structural equality of terms that ignores variable naming).
Same as itemWiseEquals, for two Sequences rather than Iterables.
Same as itemWiseHashCode, taking the items as an Iterable.
Same as itemWiseHashCode, taking the items as a Sequence.
Computes a hash code out of the given items, consistent with itemWiseEquals: two iterables that are itemWiseEquals (under ==) always produce the same itemWiseHashCode, much like List.hashCode does for lists, but usable on any Iterable/Sequence. Handy when implementing Any.hashCode for a custom collection-like type that should be compared item-wise (e.g. structurally-shared term lists) rather than by reference.
Wraps iterable as a MutableIterable, usable from JVM code expecting one; each call to MutableIterable.iterator wraps a fresh iterable.iterator() via iterator.
Wraps sequence as a MutableIterable, usable from JVM code expecting one; each call to MutableIterable.iterator wraps a fresh sequence.iterator().
Wraps iterator as a MutableIterator, usable from JVM code expecting one.
Pairs each element of this sequence with its 0-based position, as a LongIndexed value, lazily. Use this rather than indexed when the sequence may contain more than Int.MAX_VALUE elements.
Performs a k-way merge of the given iterables, each of which is assumed to already be sorted according to comparator, producing a single Sequence that yields all their elements in the order induced by comparator (like the "merge" step of a merge-sort, generalized to more than two inputs).
Same as merge, with comparator expressed as a plain comparison lambda instead of a Comparator.
Same as List.permutations, starting from an Iterable rather than a List.
Lazily generates every permutation of the elements of this list, as Lists, in an unspecified order, via the standard recursive "pick each element as head, permute the rest" algorithm. The number of permutations generated is size factorial (e.g. 720 for a 6-element list), so this quickly becomes expensive for anything but small inputs.
Same as List.permutations, starting from a Sequence rather than a List.
Operator alias for addTags, allowing tags to be merged in via the + operator, e.g. term + ("k" to v).
Operator alias for addTags, allowing a whole tags map to be merged in via the + operator.
Concatenates this cursor with other, yielding a Cursor that traverses first the elements of this cursor, then, once it Cursor.isOver, the elements of other.
Returns the lazy Cartesian product of this sequence and other, combining each pair of elements via combinator. Equivalent to a nested for (x in this) for (y in other) yield(combinator(x, y)), except lazy: the result has this.count() * other.count() elements, but other must be safely re-iterable (e.g. backed by a List, not a one-shot generator), since it is traversed once per element of this sequence.
Returns a new instance, otherwise equivalent to this one, whose Taggable.tags are entirely replaced by tags (i.e. this is not a merge: any previously attached tag not present in tags is dropped). Thin, type-preserving wrapper around Taggable.replaceTags.
Returns the lazy Cartesian product of this sequence with itself (see product), combining each pair of elements (including a value with itself) via combinator.
Same as Sequence.subsequences, taking the items to generate prefixes of as varargs.
Same as Sequence.subsequences, but starting from an Iterable.
Lazily generates every prefix (i.e. leading subsequence) of this sequence, from the singleton sequence containing only the first element up to the full sequence, one element longer than the previous at each step; stops as soon as a prefix turns out shorter than requested (i.e. once this sequence is exhausted). Note that, despite the name, this yields growing prefixes, not every possible (non-contiguous) subsequence.
Runs action while holding the monitor/lock associated with obj, returning its result; a platform-agnostic, expression-based counterpart of the JVM's synchronized(obj) { ... } block, usable from common code. On platforms without real concurrency (e.g. JS), this may simply invoke action directly, since no synchronization is needed there.
Runs action while holding the monitor/lock associated with obj, returning its result; a platform-agnostic, expression-based counterpart of the JVM's synchronized(obj) { ... } block, usable from common code. On platforms without real concurrency (e.g. JS), this may simply invoke action directly, since no synchronization is needed there.
Runs action while holding the monitor/lock associated with obj, returning its result; a platform-agnostic, expression-based counterpart of the JVM's synchronized(obj) { ... } block, usable from common code. On platforms without real concurrency (e.g. JS), this may simply invoke action directly, since no synchronization is needed there.
Removes and returns the first element of this list, or null if the list is empty.
Removes and returns the first element of this list, or null if the list is empty.
Removes and returns the first element of this list, or null if the list is empty.