@tuprolog/arg2p-core 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kotlin/arg2p-core.js +6 -6
- package/kotlin/arg2p-core.js.map +1 -1
- package/package.json +1 -1
- package/package.json.hash +1 -1
- package/pre-package.json +1 -1
package/kotlin/arg2p-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arg2p-core.js","sources":["generated/_Collections.kt","kotlin/collections.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/Arg2p.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/dsl/Arg2pScope.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/ArgLibrary.kt","util/Lazy.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/Cache.kt","util/Standard.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/Context.kt","collections/Maps.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/DynamicLoader.kt","generated/_Sequences.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/EngineInterface.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/FlagManager.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/extra/MetaInterpreter.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/extra/ModuleCalls.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/AbstractMode.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/builder/ArgumentationGraphBuilder.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/AttackRestrictionHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/BpMetaGraphHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/DefeasiblePreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/GenericDefeasiblePreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/StrictPreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BinaryStatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpCompleteLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpPartialLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/CompleteLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/GroundedLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/PassThroughStatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/StatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/language/RuleParser.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/structured/StructuredMode.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Debug.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/SuperiorityRelation.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Utils.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/meta/MetaInterpreterLib.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/mining/SolverMining.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Argument.kt","collections/Collections.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Attack.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Graph.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/LabelledArgument.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Rule.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Support.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/EngineInterface.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/AbstractMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/builder/ArgumentationGraphBuilder.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/AttackRestrictionHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/BpMetaGraphHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/DefeasiblePreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/GenericDefeasiblePreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/StrictPreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpCompleteLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpPartialLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/CompleteLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/GroundedLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/StatementLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/language/RuleParser.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/AbstractMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/ArgumentationEngineInterface.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/ArgumentationGraph.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/AttackRestriction.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Bp.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGrounded.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGroundedComplete.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGroundedPartial.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Complete.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Debug.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/DefPreferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/GenericDefPreferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Grounded.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Preferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/QueryMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/RuleTranslator.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/StatementLabelling.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/SuperiorityRelation.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Utils.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/structured/StructuredMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Debug.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/SuperiorityRelation.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Utils.kt"],"sourcesContent":["/*\n * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n\npackage kotlin.collections\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\nimport kotlin.ranges.contains\nimport kotlin.ranges.reversed\n\n/**\n * Returns 1st *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 1.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component1(): T {\n return get(0)\n}\n\n/**\n * Returns 2nd *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 2.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component2(): T {\n return get(1)\n}\n\n/**\n * Returns 3rd *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 3.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component3(): T {\n return get(2)\n}\n\n/**\n * Returns 4th *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 4.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component4(): T {\n return get(3)\n}\n\n/**\n * Returns 5th *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 5.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component5(): T {\n return get(4)\n}\n\n/**\n * Returns `true` if [element] is found in the collection.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains(element: T): Boolean {\n if (this is Collection)\n return contains(element)\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\npublic fun <T> Iterable<T>.elementAt(index: Int): T {\n if (this is List)\n return get(index)\n return elementAtOrElse(index) { throw IndexOutOfBoundsException(\"Collection doesn't contain element at index $index.\") }\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAt(index: Int): T {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\npublic fun <T> Iterable<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n if (this is List)\n return this.getOrElse(index, defaultValue)\n if (index < 0)\n return defaultValue(index)\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\npublic fun <T> Iterable<T>.elementAtOrNull(index: Int): T? {\n if (this is List)\n return this.getOrNull(index)\n if (index < 0)\n return null\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAtOrNull(index: Int): T? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the collection is empty.\n */\npublic fun <T> Iterable<T>.first(): T {\n when (this) {\n is List -> return this.first()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the list is empty.\n */\npublic fun <T> List<T>.first(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,\n * or throws [NoSuchElementException] if no non-null value was produced.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Iterable<T>.firstNotNullOf(transform: (T) -> R?): R {\n return firstNotNullOfOrNull(transform) ?: throw NoSuchElementException(\"No element of the collection was transformed to a non-null value.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,\n * or `null` if no non-null value was produced.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? {\n for (element in this) {\n val result = transform(element)\n if (result != null) {\n return result\n }\n }\n return null\n}\n\n/**\n * Returns the first element, or `null` if the collection is empty.\n */\npublic fun <T> Iterable<T>.firstOrNull(): T? {\n when (this) {\n is List -> {\n if (isEmpty())\n return null\n else\n return this[0]\n }\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns the first element, or `null` if the list is empty.\n */\npublic fun <T> List<T>.firstOrNull(): T? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.getOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.getOrNull\n */\npublic fun <T> List<T>.getOrNull(index: Int): T? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns first index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T): Int {\n if (this is List) return this.indexOf(element)\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {\n return indexOf(element)\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n if (predicate(iterator.previous())) {\n return iterator.nextIndex()\n }\n }\n return -1\n}\n\n/**\n * Returns the last element.\n * \n * @throws NoSuchElementException if the collection is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Iterable<T>.last(): T {\n when (this) {\n is List -> return this.last()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element.\n * \n * @throws NoSuchElementException if the list is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> List<T>.last(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T {\n var last: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n last = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return last as T\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> List<T>.last(predicate: (T) -> Boolean): T {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"List contains no element matching the predicate.\")\n}\n\n/**\n * Returns last index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element: T): Int {\n if (this is List) return this.lastIndexOf(element)\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns last index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {\n return lastIndexOf(element)\n}\n\n/**\n * Returns the last element, or `null` if the collection is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Iterable<T>.lastOrNull(): T? {\n when (this) {\n is List -> return if (isEmpty()) null else this[size - 1]\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element, or `null` if the list is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> List<T>.lastOrNull(): T? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n var last: T? = null\n for (element in this) {\n if (predicate(element)) {\n last = element\n }\n }\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns a random element from this collection.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.random(): T {\n return random(Random)\n}\n\n/**\n * Returns a random element from this collection using the specified source of randomness.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Collection<T>.random(random: Random): T {\n if (isEmpty())\n throw NoSuchElementException(\"Collection is empty.\")\n return elementAt(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this collection, or `null` if this collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.randomOrNull(): T? {\n return randomOrNull(Random)\n}\n\n/**\n * Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T> Collection<T>.randomOrNull(random: Random): T? {\n if (isEmpty())\n return null\n return elementAt(random.nextInt(size))\n}\n\n/**\n * Returns the single element, or throws an exception if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.single(): T {\n when (this) {\n is List -> return this.single()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n val single = iterator.next()\n if (iterator.hasNext())\n throw IllegalArgumentException(\"Collection has more than one element.\")\n return single\n }\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.single(): T {\n return when (size) {\n 0 -> throw NoSuchElementException(\"List is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"List has more than one element.\")\n }\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Collection contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns single element, or `null` if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.singleOrNull(): T? {\n when (this) {\n is List -> return if (size == 1) this[0] else null\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n val single = iterator.next()\n if (iterator.hasNext())\n return null\n return single\n }\n }\n}\n\n/**\n * Returns single element, or `null` if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.singleOrNull(): T? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun <T> Iterable<T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Iterable<T>.drop(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return toList()\n val list: ArrayList<T>\n if (this is Collection<*>) {\n val resultSize = size - n\n if (resultSize <= 0)\n return emptyList()\n if (resultSize == 1)\n return listOf(last())\n list = ArrayList<T>(resultSize)\n if (this is List<T>) {\n if (this is RandomAccess) {\n for (index in n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(n))\n list.add(item)\n }\n return list\n }\n }\n else {\n list = ArrayList<T>()\n }\n var count = 0\n for (item in this) {\n if (count >= n) list.add(item) else ++count\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> List<T>.dropLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n return take(iterator.nextIndex() + 1)\n }\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> Iterable<T>.dropWhile(predicate: (T) -> Boolean): List<T> {\n var yielding = false\n val list = ArrayList<T>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> {\n return filterTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexed\n */\npublic inline fun <T> Iterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T> {\n return filterIndexedTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexedTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a list containing all elements that are instances of specified type parameter R.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstance\n */\npublic inline fun <reified R> Iterable<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {\n return filterIsInstanceTo(ArrayList<R>())\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstanceTo\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic inline fun <T> Iterable<T>.filterNot(predicate: (T) -> Boolean): List<T> {\n return filterNotTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing all elements that are not `null`.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNull\n */\npublic fun <T : Any> Iterable<T?>.filterNotNull(): List<T> {\n return filterNotNullTo(ArrayList<T>())\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterNotNullTo\n */\npublic fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun <T> List<T>.slice(indices: IntRange): List<T> {\n if (indices.isEmpty()) return listOf()\n return this.subList(indices.start, indices.endInclusive + 1).toList()\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun <T> List<T>.slice(indices: Iterable<Int>): List<T> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<T>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Iterable<T>.take(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (this is Collection<T>) {\n if (n >= size) return toList()\n if (n == 1) return listOf(first())\n }\n var count = 0\n val list = ArrayList<T>(n)\n for (item in this) {\n list.add(item)\n if (++count == n)\n break\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> List<T>.takeLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(last())\n val list = ArrayList<T>(n)\n if (this is RandomAccess) {\n for (index in size - n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(size - n))\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> List<T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {\n if (isEmpty())\n return emptyList()\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n iterator.next()\n val expectedSize = size - iterator.nextIndex()\n if (expectedSize == 0) return emptyList()\n return ArrayList<T>(expectedSize).apply {\n while (iterator.hasNext())\n add(iterator.next())\n }\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T> {\n val list = ArrayList<T>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Reverses elements in the list in-place.\n */\npublic expect fun <T> MutableList<T>.reverse(): Unit\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun <T> Iterable<T>.reversed(): List<T> {\n if (this is Collection && size <= 1) return toList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Randomly shuffles elements in this list in-place using the specified [random] instance as the source of randomness.\n * \n * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> MutableList<T>.shuffle(random: Random): Unit {\n for (i in lastIndex downTo 1) {\n val j = random.nextInt(i + 1)\n this[j] = this.set(i, this[j])\n }\n}\n\n/**\n * Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortBy(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareBy(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareByDescending(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> MutableList<T>.sortDescending(): Unit {\n sortWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()\n }\n return toMutableList().apply { sort() }\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n * \n * @sample samples.collections.Collections.Sorting.sortedBy\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedBy(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()\n }\n return toMutableList().apply { sortWith(comparator) }\n}\n\n/**\n * Returns an array of Boolean containing all of the elements of this collection.\n */\npublic fun Collection<Boolean>.toBooleanArray(): BooleanArray {\n val result = BooleanArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Byte containing all of the elements of this collection.\n */\npublic fun Collection<Byte>.toByteArray(): ByteArray {\n val result = ByteArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Char containing all of the elements of this collection.\n */\npublic fun Collection<Char>.toCharArray(): CharArray {\n val result = CharArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Double containing all of the elements of this collection.\n */\npublic fun Collection<Double>.toDoubleArray(): DoubleArray {\n val result = DoubleArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Float containing all of the elements of this collection.\n */\npublic fun Collection<Float>.toFloatArray(): FloatArray {\n val result = FloatArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Int containing all of the elements of this collection.\n */\npublic fun Collection<Int>.toIntArray(): IntArray {\n val result = IntArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Long containing all of the elements of this collection.\n */\npublic fun Collection<Long>.toLongArray(): LongArray {\n val result = LongArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Short containing all of the elements of this collection.\n */\npublic fun Collection<Short>.toShortArray(): ShortArray {\n val result = ShortArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associate\n */\npublic inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given collection indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateBy\n */\npublic inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateByWithValueTransform\n */\npublic inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given collection\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateByTo\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateTo\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Returns a [Map] where keys are elements from the given collection and values are\n * produced by the [valueSelector] function applied to each element.\n * \n * If any two elements are equal, the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateWith\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V> Iterable<K>.associateWith(valueSelector: (K) -> V): Map<K, V> {\n val result = LinkedHashMap<K, V>(mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16))\n return associateWithTo(result, valueSelector)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs for each element of the given collection,\n * where key is the element itself and value is provided by the [valueSelector] function applied to that key.\n * \n * If any two elements are equal, the last one overwrites the former value in the map.\n * \n * @sample samples.collections.Collections.Transformations.associateWithTo\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M {\n for (element in this) {\n destination.put(element, valueSelector(element))\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a new [HashSet] of all elements.\n */\npublic fun <T> Iterable<T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun <T> Iterable<T>.toList(): List<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(if (this is List) get(0) else iterator().next())\n else -> this.toMutableList()\n }\n }\n return this.toMutableList().optimizeReadOnlyList()\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Iterable<T>.toMutableList(): MutableList<T> {\n if (this is Collection<T>)\n return this.toMutableList()\n return toCollection(ArrayList<T>())\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Collection<T>.toMutableList(): MutableList<T> {\n return ArrayList(this)\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toSet(): Set<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(if (this is List) this[0] else iterator().next())\n else -> toCollection(LinkedHashSet<T>(mapCapacity(size)))\n }\n }\n return toCollection(LinkedHashSet<T>()).optimizeReadOnlySet()\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\npublic inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapSequence\")\npublic inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Sequence<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterable\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.flatMapIndexed(transform: (index: Int, T) -> Iterable<R>): List<R> {\n return flatMapIndexedTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequence\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.flatMapIndexed(transform: (index: Int, T) -> Sequence<R>): List<R> {\n return flatMapIndexedTo(ArrayList<R>(), transform)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterableTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Iterable<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequenceTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Sequence<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapSequenceTo\")\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Sequence<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Iterable<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Iterable<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from a collection to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Iterable<T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = this@groupingBy.iterator()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.map\n */\npublic inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {\n return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R> Iterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R> {\n return mapIndexedNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(checkIndexOverflow(index++), item))\n return destination\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.mapNotNull\n */\npublic inline fun <T, R : Any> Iterable<T>.mapNotNull(transform: (T) -> R?): List<R> {\n return mapNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element in the original collection\n * and appends only the non-null results to the given [destination].\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original collection\n * and appends the results to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a lazy [Iterable] that wraps each element of the original collection\n * into an [IndexedValue] containing the index of that element and the element itself.\n */\npublic fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a list containing only distinct elements from the given collection.\n * \n * Among equal elements of the given collection, only the first one will be present in the resulting list.\n * The elements in the resulting list are in the same order as they were in the source collection.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T> Iterable<T>.distinct(): List<T> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only elements from the given collection\n * having distinct keys returned by the given [selector] function.\n * \n * Among elements of the given collection with equal keys, only the first one will be present in the resulting list.\n * The elements in the resulting list are in the same order as they were in the source collection.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic inline fun <T, K> Iterable<T>.distinctBy(selector: (T) -> K): List<T> {\n val set = HashSet<K>()\n val list = ArrayList<T>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a set containing all elements that are contained by both this collection and the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n * \n * To get a set containing all elements that are contained at least in one of these collections use [union].\n */\npublic infix fun <T> Iterable<T>.intersect(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.retainAll(other)\n return set\n}\n\n/**\n * Returns a set containing all elements that are contained by this collection and not contained by the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic infix fun <T> Iterable<T>.subtract(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.removeAll(other)\n return set\n}\n\n/**\n * Returns a new [MutableSet] containing all distinct elements from the given collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toMutableSet(): MutableSet<T> {\n return when (this) {\n is Collection<T> -> LinkedHashSet(this)\n else -> toCollection(LinkedHashSet<T>())\n }\n}\n\n/**\n * Returns a set containing all distinct elements from both collections.\n * \n * The returned set preserves the element iteration order of the original collection.\n * Those elements of the [other] collection that are unique are iterated in the end\n * in the order of the [other] collection.\n * \n * To get a set containing all elements that are contained in both collections use [intersect].\n */\npublic infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.addAll(other)\n return set\n}\n\n/**\n * Returns `true` if all elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.all\n */\npublic inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (!predicate(element)) return false\n return true\n}\n\n/**\n * Returns `true` if collection has at least one element.\n * \n * @sample samples.collections.Collections.Aggregates.any\n */\npublic fun <T> Iterable<T>.any(): Boolean {\n if (this is Collection) return !isEmpty()\n return iterator().hasNext()\n}\n\n/**\n * Returns `true` if at least one element matches the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.anyWithPredicate\n */\npublic inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return false\n for (element in this) if (predicate(element)) return true\n return false\n}\n\n/**\n * Returns the number of elements in this collection.\n */\npublic fun <T> Iterable<T>.count(): Int {\n if (this is Collection) return size\n var count = 0\n for (element in this) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Returns the number of elements in this collection.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.count(): Int {\n return size\n}\n\n/**\n * Returns the number of elements matching the given [predicate].\n */\npublic inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int {\n if (this is Collection && isEmpty()) return 0\n var count = 0\n for (element in this) if (predicate(element)) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns the specified [initial] value if the collection is empty.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n */\npublic inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R {\n var accumulator = initial\n for (element in this) accumulator = operation(accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Returns the specified [initial] value if the collection is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n */\npublic inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {\n var index = 0\n var accumulator = initial\n for (element in this) accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Returns the specified [initial] value if the list is empty.\n * \n * @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Returns the specified [initial] value if the list is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself\n * and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Performs the given [action] on each element.\n */\n@kotlin.internal.HidesMembers\npublic inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {\n for (element in this) action(element)\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n */\npublic inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {\n var index = 0\n for (item in this) action(checkIndexOverflow(index++), item)\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.max(): Double? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.max(): Float? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Iterable<T>.max(): T? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxByOrNull instead.\", ReplaceWith(\"this.maxByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T? {\n return maxByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the largest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.maxByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxElem = iterator.next()\n if (!iterator.hasNext()) return maxElem\n var maxValue = selector(maxElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (maxValue < v) {\n maxElem = e\n maxValue = v\n }\n } while (iterator.hasNext())\n return maxElem\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.maxOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.maxOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Double>.maxOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Float>.maxOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (max < e) max = e\n }\n return max\n}\n\n@Deprecated(\"Use maxWithOrNull instead.\", ReplaceWith(\"this.maxWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? {\n return maxWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Iterable<T>.maxWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(max, e) < 0) max = e\n }\n return max\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.min(): Double? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.min(): Float? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Iterable<T>.min(): T? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minByOrNull instead.\", ReplaceWith(\"this.minByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T? {\n return minByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.minByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minElem = iterator.next()\n if (!iterator.hasNext()) return minElem\n var minValue = selector(minElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (minValue > v) {\n minElem = e\n minValue = v\n }\n } while (iterator.hasNext())\n return minElem\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.minOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.minOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Double>.minOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Float>.minOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (min > e) min = e\n }\n return min\n}\n\n@Deprecated(\"Use minWithOrNull instead.\", ReplaceWith(\"this.minWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? {\n return minWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Iterable<T>.minWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(min, e) > 0) min = e\n }\n return min\n}\n\n/**\n * Returns `true` if the collection has no elements.\n * \n * @sample samples.collections.Collections.Aggregates.none\n */\npublic fun <T> Iterable<T>.none(): Boolean {\n if (this is Collection) return isEmpty()\n return !iterator().hasNext()\n}\n\n/**\n * Returns `true` if no elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.noneWithPredicate\n */\npublic inline fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (predicate(element)) return false\n return true\n}\n\n/**\n * Performs the given [action] on each element and returns the collection itself afterwards.\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C {\n return apply { for (element in this) action(element) }\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element,\n * and returns the collection itself afterwards.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, C : Iterable<T>> C.onEachIndexed(action: (index: Int, T) -> Unit): C {\n return apply { forEachIndexed(action) }\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Throws an exception if this collection is empty. If the collection can be empty in an expected way,\n * please use [reduceOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Throws an exception if this collection is empty. If the collection can be empty in an expected way,\n * please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Iterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Returns `null` if the collection is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Iterable<T>.reduceIndexedOrNull(operation: (index: Int, acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns `null` if the collection is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Iterable<T>.reduceOrNull(operation: (acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Throws an exception if this list is empty. If the list can be empty in an expected way,\n * please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes an element and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRight\n */\npublic inline fun <S, T : S> List<T>.reduceRight(operation: (T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Throws an exception if this list is empty. If the list can be empty in an expected way,\n * please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRight\n */\npublic inline fun <S, T : S> List<T>.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Returns `null` if the list is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRightOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> List<T>.reduceRightIndexedOrNull(operation: (index: Int, T, acc: S) -> S): S? {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n return null\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Returns `null` if the list is empty.\n * \n * @param [operation] function that takes an element and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRightOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> List<T>.reduceRightOrNull(operation: (T, acc: S) -> S): S? {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n return null\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R> Iterable<T>.runningFold(initial: R, operation: (acc: R, T) -> R): List<R> {\n val estimatedSize = collectionSizeOrDefault(9)\n if (estimatedSize == 0) return listOf(initial)\n val result = ArrayList<R>(estimatedSize + 1).apply { add(initial) }\n var accumulator = initial\n for (element in this) {\n accumulator = operation(accumulator, element)\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R> Iterable<T>.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): List<R> {\n val estimatedSize = collectionSizeOrDefault(9)\n if (estimatedSize == 0) return listOf(initial)\n val result = ArrayList<R>(estimatedSize + 1).apply { add(initial) }\n var index = 0\n var accumulator = initial\n for (element in this) {\n accumulator = operation(index++, accumulator, element)\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with the first element of this collection.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and the element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Iterable<T>.runningReduce(operation: (acc: S, T) -> S): List<S> {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return emptyList()\n var accumulator: S = iterator.next()\n val result = ArrayList<S>(collectionSizeOrDefault(10)).apply { add(accumulator) }\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with the first element of this collection.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Iterable<T>.runningReduceIndexed(operation: (index: Int, acc: S, T) -> S): List<S> {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return emptyList()\n var accumulator: S = iterator.next()\n val result = ArrayList<S>(collectionSizeOrDefault(10)).apply { add(accumulator) }\n var index = 1\n while (iterator.hasNext()) {\n accumulator = operation(index++, accumulator, iterator.next())\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <T, R> Iterable<T>.scan(initial: R, operation: (acc: R, T) -> R): List<R> {\n return runningFold(initial, operation)\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <T, R> Iterable<T>.scanIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): List<R> {\n return runningFoldIndexed(initial, operation)\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int {\n var sum: Int = 0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Iterable<T>.sumByDouble(selector: (T) -> Double): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfDouble\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double {\n var sum: Double = 0.toDouble()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfInt\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int {\n var sum: Int = 0.toInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfLong\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long {\n var sum: Long = 0.toLong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfUInt\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt {\n var sum: UInt = 0.toUInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfULong\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong {\n var sum: ULong = 0.toULong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as Iterable<T>\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> List<T?>.requireNoNulls(): List<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as List<T>\n}\n\n/**\n * Splits this collection into a list of lists each not exceeding the given [size].\n * \n * The last list in the resulting list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.collections.Collections.Transformations.chunked\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {\n return windowed(size, size, partialWindows = true)\n}\n\n/**\n * Splits this collection into several lists each not exceeding the given [size]\n * and applies the given [transform] function to an each.\n * \n * @return list of results of the [transform] applied to an each list.\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * The last list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.text.Strings.chunkedTransform\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {\n return windowed(size, size, partialWindows = true, transform = transform)\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\npublic operator fun <T> Iterable<T>.minus(element: T): List<T> {\n val result = ArrayList<T>(collectionSizeOrDefault(10))\n var removed = false\n return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] array.\n * \n * The [elements] array may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Array<out T>): List<T> {\n if (elements.isEmpty()) return this.toList()\n val other = elements.toHashSet()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] collection.\n * \n * The [elements] collection may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Iterable<T>): List<T> {\n val other = elements.convertToSetForSetOperationWith(this)\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] sequence.\n * \n * The [elements] sequence may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Sequence<T>): List<T> {\n val other = elements.toHashSet()\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minusElement(element: T): List<T> {\n return minus(element)\n}\n\n/**\n * Splits the original collection into pair of lists,\n * where *first* list contains elements for which [predicate] yielded `true`,\n * while *second* list contains elements for which [predicate] yielded `false`.\n * \n * @sample samples.collections.Iterables.Operations.partition\n */\npublic inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {\n val first = ArrayList<T>()\n val second = ArrayList<T>()\n for (element in this) {\n if (predicate(element)) {\n first.add(element)\n } else {\n second.add(element)\n }\n }\n return Pair(first, second)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Iterable<T>.plus(element: T): List<T> {\n if (this is Collection) return this.plus(element)\n val result = ArrayList<T>()\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Collection<T>.plus(element: T): List<T> {\n val result = ArrayList<T>(size + 1)\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Array<out T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Collection<T>.plus(elements: Array<out T>): List<T> {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> {\n if (elements is Collection) {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n } else {\n val result = ArrayList<T>(this)\n result.addAll(elements)\n return result\n }\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Collection<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>(this.size + 10)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list of snapshots of the window of the given [size]\n * sliding along this collection with the given [step], where each\n * snapshot is a list.\n * \n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.takeWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val resultCapacity = thisSize / step + if (thisSize % step == 0) 0 else 1\n val result = ArrayList<List<T>>(resultCapacity)\n var index = 0\n while (index in 0 until thisSize) {\n val windowSize = size.coerceAtMost(thisSize - index)\n if (windowSize < size && !partialWindows) break\n result.add(List(windowSize) { this[it + index] })\n index += step\n }\n return result\n }\n val result = ArrayList<List<T>>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {\n result.add(it)\n }\n return result\n}\n\n/**\n * Returns a list of results of applying the given [transform] function to\n * an each list representing a view over the window of the given [size]\n * sliding along this collection with the given [step].\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.averageWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val resultCapacity = thisSize / step + if (thisSize % step == 0) 0 else 1\n val result = ArrayList<R>(resultCapacity)\n val window = MovingSubList(this)\n var index = 0\n while (index in 0 until thisSize) {\n val windowSize = size.coerceAtMost(thisSize - index)\n if (!partialWindows && windowSize < size) break\n window.move(index, index + windowSize)\n result.add(transform(window))\n index += step\n }\n return result\n }\n val result = ArrayList<R>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {\n result.add(transform(it))\n }\n return result\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and the [other] array with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] array with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {\n val arraySize = other.size\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), arraySize))\n var i = 0\n for (element in this) {\n if (i >= arraySize) break\n list.add(transform(element, other[i++]))\n }\n return list\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and [other] collection with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] collection with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {\n val first = iterator()\n val second = other.iterator()\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))\n while (first.hasNext() && second.hasNext()) {\n list.add(transform(first.next(), second.next()))\n }\n return list\n}\n\n/**\n * Returns a list of pairs of each two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNext\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> {\n return zipWithNext { a, b -> a to b }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to an each pair of two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas\n */\n@SinceKotlin(\"1.2\")\npublic inline fun <T, R> Iterable<T>.zipWithNext(transform: (a: T, b: T) -> R): List<R> {\n val iterator = iterator()\n if (!iterator.hasNext()) return emptyList()\n val result = mutableListOf<R>()\n var current = iterator.next()\n while (iterator.hasNext()) {\n val next = iterator.next()\n result.add(transform(current, next))\n current = next\n }\n return result\n}\n\n/**\n * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinTo\n */\npublic fun <T, A : Appendable> Iterable<T>.joinTo(buffer: A, separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): A {\n buffer.append(prefix)\n var count = 0\n for (element in this) {\n if (++count > 1) buffer.append(separator)\n if (limit < 0 || count <= limit) {\n buffer.appendElement(element, transform)\n } else break\n }\n if (limit >= 0 && count > limit) buffer.append(truncated)\n buffer.append(postfix)\n return buffer\n}\n\n/**\n * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinToString\n */\npublic fun <T> Iterable<T>.joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): String {\n return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()\n}\n\n/**\n * Returns this collection as an [Iterable].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.asIterable(): Iterable<T> {\n return this\n}\n\n/**\n * Creates a [Sequence] instance that wraps the original collection returning its elements when being iterated.\n * \n * @sample samples.collections.Sequences.Building.sequenceFromCollection\n */\npublic fun <T> Iterable<T>.asSequence(): Sequence<T> {\n return Sequence { this.iterator() }\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfByte\")\npublic fun Iterable<Byte>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfShort\")\npublic fun Iterable<Short>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfInt\")\npublic fun Iterable<Int>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfLong\")\npublic fun Iterable<Long>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfFloat\")\npublic fun Iterable<Float>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfDouble\")\npublic fun Iterable<Double>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfByte\")\npublic fun Iterable<Byte>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfShort\")\npublic fun Iterable<Short>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfInt\")\npublic fun Iterable<Int>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfLong\")\npublic fun Iterable<Long>.sum(): Long {\n var sum: Long = 0L\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfFloat\")\npublic fun Iterable<Float>.sum(): Float {\n var sum: Float = 0.0f\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfDouble\")\npublic fun Iterable<Double>.sum(): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\npackage kotlin.collections\n\nimport kotlin.comparisons.naturalOrder\nimport kotlin.random.Random\n\n/** Returns the array if it's not `null`, or an empty array otherwise. */\n@kotlin.internal.InlineOnly\npublic actual inline fun <T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()\n\n@kotlin.internal.InlineOnly\npublic actual inline fun <T> Collection<T>.toTypedArray(): Array<T> = copyToArray(this)\n\n@JsName(\"copyToArray\")\n@PublishedApi\ninternal fun <T> copyToArray(collection: Collection<T>): Array<T> {\n return if (collection.asDynamic().toArray !== undefined)\n collection.asDynamic().toArray().unsafeCast<Array<T>>()\n else\n copyToArrayImpl(collection).unsafeCast<Array<T>>()\n}\n\n@JsName(\"copyToArrayImpl\")\ninternal actual fun copyToArrayImpl(collection: Collection<*>): Array<Any?> {\n val array = emptyArray<Any?>()\n val iterator = collection.iterator()\n while (iterator.hasNext())\n array.asDynamic().push(iterator.next())\n return array\n}\n\n@JsName(\"copyToExistingArrayImpl\")\ninternal actual fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> {\n if (array.size < collection.size)\n return copyToArrayImpl(collection).unsafeCast<Array<T>>()\n\n val iterator = collection.iterator()\n var index = 0\n while (iterator.hasNext()) {\n array[index++] = iterator.next().unsafeCast<T>()\n }\n if (index < array.size) {\n array[index] = null.unsafeCast<T>()\n }\n return array\n}\n\n\n/**\n * Returns an immutable list containing only the specified object [element].\n */\npublic fun <T> listOf(element: T): List<T> = arrayListOf(element)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildListInternal(builderAction: MutableList<E>.() -> Unit): List<E> {\n return ArrayList<E>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildListInternal(capacity: Int, builderAction: MutableList<E>.() -> Unit): List<E> {\n checkBuilderCapacity(capacity)\n return ArrayList<E>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Returns an immutable set containing only the specified object [element].\n */\npublic fun <T> setOf(element: T): Set<T> = hashSetOf(element)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildSetInternal(builderAction: MutableSet<E>.() -> Unit): Set<E> {\n return LinkedHashSet<E>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildSetInternal(capacity: Int, builderAction: MutableSet<E>.() -> Unit): Set<E> {\n return LinkedHashSet<E>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Returns an immutable map, mapping only the specified key to the\n * specified value.\n */\npublic fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <K, V> buildMapInternal(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n return LinkedHashMap<K, V>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <K, V> buildMapInternal(capacity: Int, builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n return LinkedHashMap<K, V>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Fills the list with the provided [value].\n *\n * Each element in the list gets replaced with the [value].\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> MutableList<T>.fill(value: T): Unit {\n for (index in 0..lastIndex) {\n this[index] = value\n }\n}\n\n/**\n * Randomly shuffles elements in this list.\n *\n * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> MutableList<T>.shuffle(): Unit = shuffle(Random)\n\n/**\n * Returns a new list with the elements of this list randomly shuffled.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply { shuffle() }\n\n/**\n * Sorts elements in the list in-place according to their natural sort order.\n *\n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit {\n collectionsSort(this, naturalOrder())\n}\n\n/**\n * Sorts elements in the list in-place according to the order specified with [comparator].\n *\n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {\n collectionsSort(this, comparator)\n}\n\nprivate fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in T>) {\n if (list.size <= 1) return\n\n val array = copyToArray(list)\n sortArrayWith(array, comparator)\n\n for (i in 0 until array.size) {\n list[i] = array[i]\n }\n}\n\ninternal actual fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> {\n return arrayOfNulls<Any>(size).unsafeCast<Array<T>>()\n}\n\n@SinceKotlin(\"1.3\")\n@PublishedApi\n@JsName(\"arrayCopy\")\ninternal fun <T> arrayCopy(source: Array<out T>, destination: Array<in T>, destinationOffset: Int, startIndex: Int, endIndex: Int) {\n AbstractList.checkRangeIndexes(startIndex, endIndex, source.size)\n val rangeSize = endIndex - startIndex\n AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)\n\n if (js(\"ArrayBuffer\").isView(destination) && js(\"ArrayBuffer\").isView(source)) {\n val subrange = source.asDynamic().subarray(startIndex, endIndex)\n destination.asDynamic().set(subrange, destinationOffset)\n } else {\n if (source !== destination || destinationOffset <= startIndex) {\n for (index in 0 until rangeSize) {\n destination[destinationOffset + index] = source[startIndex + index]\n }\n } else {\n for (index in rangeSize - 1 downTo 0) {\n destination[destinationOffset + index] = source[startIndex + index]\n }\n }\n }\n}\n\n// no singleton map implementation in js, return map as is\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = this\n\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> = this.toMutableMap()\n\n\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =\n if (isVarargs)\n // no need to copy vararg array in JS\n this\n else\n this.copyOf()\n\n\n\n@PublishedApi\ninternal actual fun checkIndexOverflow(index: Int): Int {\n if (index < 0) {\n throwIndexOverflow()\n }\n return index\n}\n\n@PublishedApi\ninternal actual fun checkCountOverflow(count: Int): Int {\n if (count < 0) {\n throwCountOverflow()\n }\n return count\n}\n\n\n/**\n * JS map and set implementations do not make use of capacities or load factors.\n */\n@PublishedApi\ninternal actual fun mapCapacity(expectedSize: Int) = expectedSize\n\n/**\n * Checks a collection builder function capacity argument.\n * In JS no validation is made in Map/Set constructor yet.\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@PublishedApi\ninternal fun checkBuilderCapacity(capacity: Int) {\n require(capacity >= 0) { \"capacity must be non-negative.\" }\n}","package it.unibo.tuprolog.argumentation.core\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgContext\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLoader\nimport it.unibo.tuprolog.argumentation.core.libs.basic.Cache\nimport it.unibo.tuprolog.argumentation.core.libs.basic.Context\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.argumentation.core.libs.basic.EngineInterface\nimport it.unibo.tuprolog.argumentation.core.libs.extra.MetaInterpreter\nimport it.unibo.tuprolog.argumentation.core.libs.extra.ModuleCalls\nimport it.unibo.tuprolog.argumentation.core.libs.graph.AbstractMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.builder.ArgumentationGraphBuilder\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.AttackRestrictionHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.BpMetaGraphHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.DefeasiblePreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.GenericDefeasiblePreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.StrictPreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BinaryStatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpCompleteLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpPartialLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.CompleteLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.GroundedLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.PassThroughStatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.StatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.language.RuleParser\nimport it.unibo.tuprolog.argumentation.core.libs.structured.StructuredMode\nimport it.unibo.tuprolog.argumentation.core.libs.utils.Debug\nimport it.unibo.tuprolog.argumentation.core.libs.utils.SuperiorityRelation\nimport it.unibo.tuprolog.argumentation.core.libs.utils.Utils\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.Libraries\n\ninterface Arg2pSolver {\n val loader: ArgLoader\n val context: ArgContext\n\n fun staticLibraries(): Iterable<ArgLibrary>\n fun dynamicLibraries(): Iterable<ArgLibrary>\n\n fun to2pLibraries() = Libraries.of(listOf(loader, context).plus(staticLibraries()).map { it.content() })\n fun operators() = listOf(loader, context).plus(staticLibraries())\n .map { it.theoryOperators }.reduce(OperatorSet::plus)\n\n companion object {\n fun of(staticLibs: Iterable<ArgLibrary>, dynamicLibs: Iterable<ArgLibrary>) =\n object : Arg2pSolver {\n\n override val loader = DynamicLoader(this)\n override val context: ArgContext = Context()\n\n override fun staticLibraries() = staticLibs\n override fun dynamicLibraries() = dynamicLibs\n }\n\n fun default(staticLibs: Iterable<ArgLibrary> = emptyList(), dynamicLibs: Iterable<ArgLibrary> = emptyList()) = of(\n listOf(EngineInterface, Cache()) + staticLibs,\n listOf(\n Utils,\n Debug,\n RuleParser,\n MetaInterpreter,\n ModuleCalls,\n ArgumentationGraphBuilder,\n AttackRestrictionHandler,\n BpMetaGraphHandler,\n DefeasiblePreferencesHandler,\n GenericDefeasiblePreferencesHandler,\n StrictPreferencesHandler,\n BpLabeller,\n CompleteLabeller,\n GroundedLabeller,\n StatementLabeller,\n AbstractMode,\n StructuredMode,\n SuperiorityRelation,\n BpPartialLabeller,\n BpCompleteLabeller,\n PassThroughStatementLabeller,\n BinaryStatementLabeller\n ) + dynamicLibs\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.dsl\n\nimport it.unibo.tuprolog.dsl.PrologScope\nimport it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories\nimport it.unibo.tuprolog.unify.Unificator\n\ninterface PrologWithArgumentation : PrologScopeWithTheories {\n infix fun Any.call(other: Any) = structOf(\"::\", this.toTerm(), other.toTerm())\n}\n\ninternal class PrologWithArgumentationImpl :\n PrologWithArgumentation, PrologScope by PrologScope.empty(), Unificator by Unificator.default\n\nfun <R> arg2pScope(function: PrologWithArgumentation.() -> R): R = PrologWithArgumentationImpl().function()\n","package it.unibo.tuprolog.argumentation.core.libs\n\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\ninterface ArgContext : ArgLibrary\ninterface ArgLoader : ArgLibrary\n\ninterface ArgLibrary {\n val alias: String\n val baseContent: AliasedLibrary\n val baseFlags: Iterable<ArgsFlag<*, *>>\n\n val theoryOperators: OperatorSet\n get() = OperatorSet.DEFAULT\n\n fun flags() = baseFlags\n fun content() = baseContent\n}\n\ninterface UnionArgLibrary<T> : ArgLibrary where T : ArgLibrary {\n\n val parentLibrary: T\n\n override fun flags() = baseFlags.union(parentLibrary.flags())\n override fun content() = Library.aliased(\n alias = baseContent.alias,\n theory = baseContent.theory.plus(parentLibrary.content().theory)\n )\n}\n\ninterface RawPrologContent {\n val prologTheory: Theory\n}\n\nabstract class LazyRawPrologContent : ArgLibrary, RawPrologContent {\n abstract val prologRawTheory: String\n override val prologTheory: Theory by lazy {\n Theory.parse(prologRawTheory, theoryOperators)\n }\n}\n\ninterface Loadable {\n fun identifier(): String\n}\n\ninterface ArgsFlag<T, G> {\n fun predicate(): String\n fun default(): T\n fun values(): G\n}\n\ninterface PrimitiveWithSignature : Primitive {\n val signature: Signature\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmName(\"LazyKt\")\n@file:kotlin.jvm.JvmMultifileClass\n\npackage kotlin\n\nimport kotlin.reflect.KProperty\n\n/**\n * Represents a value with lazy initialization.\n *\n * To create an instance of [Lazy] use the [lazy] function.\n */\npublic interface Lazy<out T> {\n /**\n * Gets the lazily initialized value of the current Lazy instance.\n * Once the value was initialized it must not change during the rest of lifetime of this Lazy instance.\n */\n public val value: T\n\n /**\n * Returns `true` if a value for this Lazy instance has been already initialized, and `false` otherwise.\n * Once this function has returned `true` it stays `true` for the rest of lifetime of this Lazy instance.\n */\n public fun isInitialized(): Boolean\n}\n\n/**\n * Creates a new instance of the [Lazy] that is already initialized with the specified [value].\n */\npublic fun <T> lazyOf(value: T): Lazy<T> = InitializedLazyImpl(value)\n\n/**\n * An extension to delegate a read-only property of type [T] to an instance of [Lazy].\n *\n * This extension allows to use instances of Lazy for property delegation:\n * `val property: String by lazy { initializer }`\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value\n\n/**\n * Specifies how a [Lazy] instance synchronizes initialization among multiple threads.\n */\npublic enum class LazyThreadSafetyMode {\n\n /**\n * Locks are used to ensure that only a single thread can initialize the [Lazy] instance.\n */\n SYNCHRONIZED,\n\n /**\n * Initializer function can be called several times on concurrent access to uninitialized [Lazy] instance value,\n * but only the first returned value will be used as the value of [Lazy] instance.\n */\n PUBLICATION,\n\n /**\n * No locks are used to synchronize an access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.\n *\n * This mode should not be used unless the [Lazy] instance is guaranteed never to be initialized from more than one thread.\n */\n NONE,\n}\n\n\ninternal object UNINITIALIZED_VALUE\n\n// internal to be called from lazy in JS\ninternal class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>, Serializable {\n private var initializer: (() -> T)? = initializer\n private var _value: Any? = UNINITIALIZED_VALUE\n\n override val value: T\n get() {\n if (_value === UNINITIALIZED_VALUE) {\n _value = initializer!!()\n initializer = null\n }\n @Suppress(\"UNCHECKED_CAST\")\n return _value as T\n }\n\n override fun isInitialized(): Boolean = _value !== UNINITIALIZED_VALUE\n\n override fun toString(): String = if (isInitialized()) value.toString() else \"Lazy value not initialized yet.\"\n\n private fun writeReplace(): Any = InitializedLazyImpl(value)\n}\n\ninternal class InitializedLazyImpl<out T>(override val value: T) : Lazy<T>, Serializable {\n\n override fun isInitialized(): Boolean = true\n\n override fun toString(): String = value.toString()\n\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.PrimitiveWithSignature\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.flags.Unknown\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.theory.MutableTheory\nimport it.unibo.tuprolog.theory.Theory\n\nclass Cache : ArgLibrary {\n\n private val solver: MutableSolver =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n\n inner class CacheAssert : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_assert\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Cache.solver.assertA(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class CacheRetract : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_retract\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Cache.solver.retractAll(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class CacheGet : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_check\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n\n return sequence {\n yieldAll(\n this@Cache.solver.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n override val alias = \"prolog.argumentation.cache\"\n\n override val baseContent: AliasedLibrary\n get() =\n listOf(\n CacheAssert(),\n CacheRetract(),\n CacheGet()\n ).let { primitives ->\n Library.aliased(\n alias = this.alias,\n primitives = primitives.associateBy { it.signature }\n )\n }\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"StandardKt\")\npackage kotlin\n\nimport kotlin.contracts.*\n\n/**\n * An exception is thrown to indicate that a method body remains to be implemented.\n */\npublic class NotImplementedError(message: String = \"An operation is not implemented.\") : Error(message)\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n */\n\n@kotlin.internal.InlineOnly\npublic inline fun TODO(): Nothing = throw NotImplementedError()\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n *\n * @param reason a string explaining why the implementation is missing.\n */\n@kotlin.internal.InlineOnly\npublic inline fun TODO(reason: String): Nothing = throw NotImplementedError(\"An operation is not implemented: $reason\")\n\n\n\n/**\n * Calls the specified function [block] and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#run).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <R> run(block: () -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#run).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> T.run(block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with the given [receiver] as its receiver and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#with).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> with(receiver: T, block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return receiver.block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns `this` value.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#apply).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> T.apply(block: T.() -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block()\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns `this` value.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#also).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.also(block: (T) -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block(this)\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#let).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> T.let(block: (T) -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block(this)\n}\n\n/**\n * Returns `this` value if it satisfies the given [predicate] or `null`, if it doesn't.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#takeif-and-takeunless).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (predicate(this)) this else null\n}\n\n/**\n * Returns `this` value if it _does not_ satisfy the given [predicate] or `null`, if it does.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#takeif-and-takeunless).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (!predicate(this)) this else null\n}\n\n/**\n * Executes the given function [action] specified number of [times].\n *\n * A zero-based index of current iteration is passed as a parameter to [action].\n *\n * @sample samples.misc.ControlFlow.repeat\n */\n@kotlin.internal.InlineOnly\npublic inline fun repeat(times: Int, action: (Int) -> Unit) {\n contract { callsInPlace(action) }\n\n for (index in 0 until times) {\n action(index)\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgContext\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.PrimitiveWithSignature\nimport it.unibo.tuprolog.core.Numeric\nimport it.unibo.tuprolog.core.Substitution\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.flags.Unknown\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.theory.MutableTheory\nimport it.unibo.tuprolog.theory.Theory\n\nclass Context : ArgLibrary, ArgContext {\n\n private var nextSolver: Int = 1\n private var selectedSolver: Int = 0\n private val dynamicSolver: MutableMap<Int, MutableSolver> = mutableMapOf(\n 0 to\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n )\n\n inner class DynamicCacheReset : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_reset\", 0)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n this@Context.selectedSolver = 0\n this@Context.nextSolver = 1\n this@Context.dynamicSolver.clear()\n this@Context.dynamicSolver[0] =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheSelected : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_active\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n return sequenceOf(request.replyWith(Substitution.of(term.castToVar(), Numeric.of(this@Context.selectedSolver))))\n }\n }\n\n inner class DynamicCacheCheckout : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_checkout\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val target: Int = request.arguments[0].castToInteger().intValue.toInt()\n val result = dynamicSolver.keys.contains(target)\n this@Context.selectedSolver = target\n return sequenceOf(request.replyWith(result))\n }\n }\n\n inner class DynamicCacheBranch : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_branch\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val target: Int = request.arguments[0].castToInteger().intValue.toInt()\n val result: Term = request.arguments[1]\n this@Context.dynamicSolver[this@Context.nextSolver] =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.of(this@Context.dynamicSolver[target]!!.dynamicKb))\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n this@Context.selectedSolver = this@Context.nextSolver++\n return sequenceOf(request.replyWith(Substitution.of(result.castToVar(), Numeric.of(this@Context.selectedSolver))))\n }\n }\n\n inner class DynamicCacheAssert : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_assert\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.assertA(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheRetract : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_retract\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.retractAll(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheGet : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_check\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n\n return sequence {\n yieldAll(\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n inner class DynamicCacheGetIndexed : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_check\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val index: Int = request.arguments[0].asNumeric()!!.intValue.toInt()\n val term: Term = request.arguments[1]\n\n return sequence {\n yieldAll(\n this@Context.dynamicSolver[index]!!.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n override val alias = \"prolog.argumentation.context\"\n\n override val baseContent: AliasedLibrary\n get() =\n listOf(\n DynamicCacheReset(),\n DynamicCacheCheckout(),\n DynamicCacheSelected(),\n DynamicCacheBranch(),\n DynamicCacheAssert(),\n DynamicCacheRetract(),\n DynamicCacheGet(),\n DynamicCacheGetIndexed()\n ).let { primitives ->\n Library.aliased(\n alias = this.alias,\n primitives = primitives.associateBy { it.signature }\n )\n }\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"MapsKt\")\n@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\n\nprivate object EmptyMap : Map<Any?, Nothing>, Serializable {\n private const val serialVersionUID: Long = 8246714829545688274\n\n override fun equals(other: Any?): Boolean = other is Map<*, *> && other.isEmpty()\n override fun hashCode(): Int = 0\n override fun toString(): String = \"{}\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n\n override fun containsKey(key: Any?): Boolean = false\n override fun containsValue(value: Nothing): Boolean = false\n override fun get(key: Any?): Nothing? = null\n override val entries: Set<Map.Entry<Any?, Nothing>> get() = EmptySet\n override val keys: Set<Any?> get() = EmptySet\n override val values: Collection<Nothing> get() = EmptyList\n\n private fun readResolve(): Any = EmptyMap\n}\n\n/**\n * Returns an empty read-only map of specified type.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\npublic fun <K, V> emptyMap(): Map<K, V> = @Suppress(\"UNCHECKED_CAST\") (EmptyMap as Map<K, V>)\n\n/**\n * Returns a new read-only map with the specified contents, given as a list of pairs\n * where the first value is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * The returned map is serializable (JVM).\n *\n * @sample samples.collections.Maps.Instantiation.mapFromPairs\n */\npublic fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> =\n if (pairs.size > 0) pairs.toMap(LinkedHashMap(mapCapacity(pairs.size))) else emptyMap()\n\n/**\n * Returns an empty read-only map.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> mapOf(): Map<K, V> = emptyMap()\n\n/**\n * Returns an empty new [MutableMap].\n *\n * The returned map preserves the entry iteration order.\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> mutableMapOf(): MutableMap<K, V> = LinkedHashMap()\n\n/**\n * Returns a new [MutableMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.mutableMapFromPairs\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\npublic fun <K, V> mutableMapOf(vararg pairs: Pair<K, V>): MutableMap<K, V> =\n LinkedHashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [HashMap].\n *\n * @sample samples.collections.Maps.Instantiation.emptyHashMap\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> hashMapOf(): HashMap<K, V> = HashMap<K, V>()\n\n/**\n * Returns a new [HashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * @sample samples.collections.Maps.Instantiation.hashMapFromPairs\n */\npublic fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> = HashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [LinkedHashMap].\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> linkedMapOf(): LinkedHashMap<K, V> = LinkedHashMap<K, V>()\n\n/**\n * Returns a new [LinkedHashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.linkedMapFromPairs\n */\npublic fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V> = pairs.toMap(LinkedHashMap(mapCapacity(pairs.size)))\n\n/**\n * Builds a new read-only [Map] by populating a [MutableMap] using the given [builderAction]\n * and returning a read-only map with the same key-value pairs.\n *\n * The map passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * Entries of the map are iterated in the order they were added by the [builderAction].\n *\n * @sample samples.collections.Builders.Maps.buildMapSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> buildMap(@BuilderInference builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildMapInternal(builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <K, V> buildMapInternal(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V>\n\n/**\n * Builds a new read-only [Map] by populating a [MutableMap] using the given [builderAction]\n * and returning a read-only map with the same key-value pairs.\n *\n * The map passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * [capacity] is used to hint the expected number of pairs added in the [builderAction].\n *\n * Entries of the map are iterated in the order they were added by the [builderAction].\n *\n * @throws IllegalArgumentException if the given [capacity] is negative.\n *\n * @sample samples.collections.Builders.Maps.buildMapSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> buildMap(capacity: Int, @BuilderInference builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildMapInternal(capacity, builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <K, V> buildMapInternal(capacity: Int, builderAction: MutableMap<K, V>.() -> Unit): Map<K, V>\n\n/**\n * Calculate the initial capacity of a map.\n */\n@PublishedApi\ninternal expect fun mapCapacity(expectedSize: Int): Int\n\n/**\n * Returns `true` if this map is not empty.\n * @sample samples.collections.Maps.Usage.mapIsNotEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<out K, V>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable map is either null or empty.\n * @sample samples.collections.Maps.Usage.mapIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || isEmpty()\n}\n\n/**\n * Returns the [Map] if its not `null`, or the empty [Map] otherwise.\n *\n * @sample samples.collections.Maps.Usage.mapOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> = this ?: emptyMap()\n\n/**\n * Returns this map if it's not empty\n * or the result of calling [defaultValue] function if the map is empty.\n *\n * @sample samples.collections.Maps.Usage.mapIfEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <M, R> M.ifEmpty(defaultValue: () -> R): R where M : Map<*, *>, M : R =\n if (isEmpty()) defaultValue() else this\n\n/**\n * Checks if the map contains the given key.\n *\n * This method allows to use the `x in map` syntax for checking whether an object is contained in the map.\n *\n * @sample samples.collections.Maps.Usage.containsKey\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.contains(key: K): Boolean = containsKey(key)\n\n/**\n * Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, V>).get(key)\n\n/**\n * Allows to use the index operator for storing values in a mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit {\n put(key, value)\n}\n\n/**\n * Returns `true` if the map contains the specified [key].\n *\n * Allows to overcome type-safety restriction of `containsKey` that requires to pass a key of type `K`.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(key: K): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, *>).containsKey(key)\n\n/**\n * Returns `true` if the map maps one or more keys to the specified [value].\n *\n * Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`.\n *\n * @sample samples.collections.Maps.Usage.containsValue\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\n@kotlin.internal.InlineOnly\npublic inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)\n\n\n/**\n * Removes the specified key and its corresponding value from this map.\n *\n * @return the previous value associated with the key, or `null` if the key was not present in the map.\n\n * Allows to overcome type-safety restriction of `remove` that requires to pass a key of type `K`.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes K, V> MutableMap<out K, V>.remove(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableMap<K, V>).remove(key)\n\n/**\n * Returns the key component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map.Entry<K, V>.component1(): K = key\n\n/**\n * Returns the value component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map.Entry<K, V>.component2(): V = value\n\n/**\n * Converts entry to [Pair] with key being first component and value being second.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map.Entry<K, V>.toPair(): Pair<K, V> = Pair(key, value)\n\n/**\n * Returns the value for the given key, or the result of the [defaultValue] function if there was no entry for the given key.\n *\n * @sample samples.collections.Maps.Usage.getOrElse\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<K, V>.getOrElse(key: K, defaultValue: () -> V): V = get(key) ?: defaultValue()\n\n\ninternal inline fun <K, V> Map<K, V>.getOrElseNullable(key: K, defaultValue: () -> V): V {\n val value = get(key)\n if (value == null && !containsKey(key)) {\n return defaultValue()\n } else {\n @Suppress(\"UNCHECKED_CAST\")\n return value as V\n }\n}\n\n/**\n * Returns the value for the given [key] or throws an exception if there is no such key in the map.\n *\n * If the map was created by [withDefault], resorts to its `defaultValue` provider function\n * instead of throwing an exception.\n *\n * @throws NoSuchElementException when the map doesn't contain a value for the specified key and\n * no implicit default value was provided for that map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<K, V>.getValue(key: K): V = getOrImplicitDefault(key)\n\n/**\n * Returns the value for the given key. If the key is not found in the map, calls the [defaultValue] function,\n * puts its result into the map under the given key and returns it.\n *\n * Note that the operation is not guaranteed to be atomic if the map is being modified concurrently.\n *\n * @sample samples.collections.Maps.Usage.getOrPut\n */\npublic inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {\n val value = get(key)\n return if (value == null) {\n val answer = defaultValue()\n put(key, answer)\n answer\n } else {\n value\n }\n}\n\n/**\n * Returns an [Iterator] over the entries in the [Map].\n *\n * @sample samples.collections.Maps.Usage.forOverEntries\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map<out K, V>.iterator(): Iterator<Map.Entry<K, V>> = entries.iterator()\n\n/**\n * Returns a [MutableIterator] over the mutable entries in the [MutableMap].\n *\n */\n@kotlin.jvm.JvmName(\"mutableIterator\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableMap.MutableEntry<K, V>> = entries.iterator()\n\n/**\n * Populates the given [destination] map with entries having the keys of this map and the values obtained\n * by applying the [transform] function to each entry in this [Map].\n */\npublic inline fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, { it.key }, transform)\n}\n\n/**\n * Populates the given [destination] map with entries having the keys obtained\n * by applying the [transform] function to each entry in this [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n */\npublic inline fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, transform, { it.value })\n}\n\n/**\n * Puts all the given [pairs] into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Array<out Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given collection into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Iterable<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given sequence into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Sequence<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Returns a new map with entries having the keys of this map and the values obtained by applying the [transform]\n * function to each entry in this [Map].\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapValues\n */\npublic inline fun <K, V, R> Map<out K, V>.mapValues(transform: (Map.Entry<K, V>) -> R): Map<K, R> {\n return mapValuesTo(LinkedHashMap<K, R>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a new Map with entries having the keys obtained by applying the [transform] function to each entry in this\n * [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapKeys\n */\npublic inline fun <K, V, R> Map<out K, V>.mapKeys(transform: (Map.Entry<K, V>) -> R): Map<R, V> {\n return mapKeysTo(LinkedHashMap<R, V>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a map containing all key-value pairs with keys matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterKeys\n */\npublic inline fun <K, V> Map<out K, V>.filterKeys(predicate: (K) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.key)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n/**\n * Returns a map containing all key-value pairs with values matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterValues\n */\npublic inline fun <K, V> Map<out K, V>.filterValues(predicate: (V) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.value)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n\n/**\n * Appends all entries matching the given [predicate] into the mutable map given as [destination] parameter.\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filter\n */\npublic inline fun <K, V> Map<out K, V>.filter(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Appends all entries not matching the given [predicate] into the given [destination].\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterNotTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (!predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs not matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterNot\n */\npublic inline fun <K, V> Map<out K, V>.filterNot(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterNotTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Returns a new map containing all key-value pairs from the given collection of pairs.\n *\n * The returned map preserves the entry iteration order of the original collection.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(if (this is List) this[0] else iterator().next())\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n }\n }\n return toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given collection of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given array of pairs.\n *\n * The returned map preserves the entry iteration order of the original array.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(this[0])\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given array of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given sequence of pairs.\n *\n * The returned map preserves the entry iteration order of the original sequence.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> = toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given sequence of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new read-only map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMap()\n else -> toMutableMap()\n}\n\n/**\n * Returns a new mutable map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> = LinkedHashMap(this)\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair].\n *\n * The returned map preserves the entry iteration order of the original map.\n * The [pair] is iterated in the end if it has a unique key.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pair: Pair<K, V>): Map<K, V> =\n if (this.isEmpty()) mapOf(pair) else LinkedHashMap(this).apply { put(pair.first, pair.second) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] collection.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] array.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Array<out Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] sequence.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(pairs) }.optimizeReadOnlyMap()\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from another [map].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those entries of another [map] that are missing in this map are iterated in the end in the order of that [map].\n */\npublic operator fun <K, V> Map<out K, V>.plus(map: Map<out K, V>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(map) }\n\n\n/**\n * Appends or replaces the given [pair] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pair: Pair<K, V>) {\n put(pair.first, pair.second)\n}\n\n/**\n * Appends or replaces all pairs from the given collection of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Iterable<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given array of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Array<out Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given sequence of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Sequence<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all entries from the given [map] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(map: Map<K, V>) {\n putAll(map)\n}\n\n/**\n * Returns a map containing all entries of the original map except the entry with the given [key].\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> =\n this.toMutableMap().apply { minusAssign(key) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] collection.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Iterable<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] array.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Array<out K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] sequence.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Sequence<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Removes the entry with the given [key] from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {\n remove(key)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] collection from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] array from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<out K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries from the keys of which are contained in the given [keys] sequence from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {\n this.keys.removeAll(keys)\n}\n\n\n// do not expose for now @PublishedApi\ninternal fun <K, V> Map<K, V>.optimizeReadOnlyMap() = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMapOrSelf()\n else -> this\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.Arg2pSolver\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLoader\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.core.Atom\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.Operator\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.core.operators.Specifier\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.exception.error.DomainError\nimport it.unibo.tuprolog.solve.exception.error.TypeError\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Libraries\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.solve.primitive.Solve\n\nclass DynamicLoader(private val solver: Arg2pSolver) : ArgLibrary, ArgLoader {\n\n abstract inner class AbstractWithLib : Primitive {\n\n abstract val signature: Signature\n abstract fun execute(module: String, solver: MutableSolver)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val lib: Term = request.arguments[0]\n val goal: Term = request.arguments[1]\n\n if (lib !is Atom) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.LIST,\n lib\n )\n }\n\n if (goal !is Struct) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.CALLABLE,\n goal\n )\n }\n\n val solver = (\n this@DynamicLoader.solver.dynamicLibraries().firstOrNull {\n (it as Loadable).identifier() == lib.toString()\n } ?: throw DomainError.forGoal(\n request.context,\n request.signature,\n DomainError.Expected.of(\"Loadable Lib\"),\n lib\n )\n ).let { library ->\n request.context.createMutableSolver(\n libraries = Libraries.of(\n request.context.libraries.libraries.filterNot { lib ->\n this@DynamicLoader.solver.dynamicLibraries()\n .map { it.alias }\n .contains(lib.alias)\n }\n ).plus(library.content()),\n staticKb = request.context.staticKb\n )\n }\n\n execute(lib.toString(), solver)\n\n return sequence {\n yieldAll(\n solver.solve(goal).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n inner class WithLib : AbstractWithLib() {\n override val signature = Signature(\"::\", 2)\n override fun execute(module: String, solver: MutableSolver) = Unit\n }\n\n inner class WithLibInNewContext : AbstractWithLib() {\n override val signature = Signature(\":::\", 2)\n override fun execute(module: String, solver: MutableSolver) =\n prolog {\n solver.solve(\"context_active\"(X))\n .filter { it.isYes }\n .forEach {\n solver.solve(\"context_branch\"(it.substitution[X]!!, `_`)).first()\n }\n }\n }\n\n override val alias = \"prolog.argumentation.loader\"\n\n override val baseContent: AliasedLibrary\n get() = listOf(WithLib(), WithLibInNewContext()).let {\n Library.aliased(\n alias = this.alias,\n primitives = it.associateBy { prim -> prim.signature },\n operatorSet = operators()\n )\n }\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override var theoryOperators = operators()\n\n companion object {\n fun operators() = OperatorSet(\n Operator(\"::\", Specifier.XFX, 700),\n Operator(\":::\", Specifier.XFX, 700),\n )\n }\n}\n","/*\n * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"SequencesKt\")\n\npackage kotlin.sequences\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\n\n/**\n * Returns `true` if [element] is found in the sequence.\n *\n * The operation is _terminal_.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.contains(element: T): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\npublic fun <T> Sequence<T>.elementAt(index: Int): T {\n return elementAtOrElse(index) { throw IndexOutOfBoundsException(\"Sequence doesn't contain element at index $index.\") }\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\npublic fun <T> Sequence<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n if (index < 0)\n return defaultValue(index)\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\npublic fun <T> Sequence<T>.elementAtOrNull(index: Int): T? {\n if (index < 0)\n return null\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the sequence is empty.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.first(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n return iterator.next()\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this sequence in iteration order,\n * or throws [NoSuchElementException] if no non-null value was produced.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Sequence<T>.firstNotNullOf(transform: (T) -> R?): R {\n return firstNotNullOfOrNull(transform) ?: throw NoSuchElementException(\"No element of the sequence was transformed to a non-null value.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this sequence in iteration order,\n * or `null` if no non-null value was produced.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Sequence<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? {\n for (element in this) {\n val result = transform(element)\n if (result != null) {\n return result\n }\n }\n return null\n}\n\n/**\n * Returns the first element, or `null` if the sequence is empty.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.firstOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n return iterator.next()\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns first index of [element], or -1 if the sequence does not contain element.\n *\n * The operation is _terminal_.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.indexOf(element: T): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the sequence does not contain such element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the sequence does not contain such element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns the last element.\n *\n * The operation is _terminal_.\n * \n * @throws NoSuchElementException if the sequence is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Sequence<T>.last(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T {\n var last: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n last = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return last as T\n}\n\n/**\n * Returns last index of [element], or -1 if the sequence does not contain element.\n *\n * The operation is _terminal_.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.lastIndexOf(element: T): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns the last element, or `null` if the sequence is empty.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Sequence<T>.lastOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Sequence<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n var last: T? = null\n for (element in this) {\n if (predicate(element)) {\n last = element\n }\n }\n return last\n}\n\n/**\n * Returns the single element, or throws an exception if the sequence is empty or has more than one element.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.single(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n val single = iterator.next()\n if (iterator.hasNext())\n throw IllegalArgumentException(\"Sequence has more than one element.\")\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Sequence contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns single element, or `null` if the sequence is empty or has more than one element.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.singleOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n val single = iterator.next()\n if (iterator.hasNext())\n return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a sequence containing all elements except first [n] elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Sequence<T>.drop(n: Int): Sequence<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return when {\n n == 0 -> this\n this is DropTakeSequence -> this.drop(n)\n else -> DropSequence(this, n)\n }\n}\n\n/**\n * Returns a sequence containing all elements except first elements that satisfy the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Sequence<T>.dropWhile(predicate: (T) -> Boolean): Sequence<T> {\n return DropWhileSequence(this, predicate)\n}\n\n/**\n * Returns a sequence containing only elements matching the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic fun <T> Sequence<T>.filter(predicate: (T) -> Boolean): Sequence<T> {\n return FilteringSequence(this, true, predicate)\n}\n\n/**\n * Returns a sequence containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexed\n */\npublic fun <T> Sequence<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence<T> {\n // TODO: Rewrite with generalized MapFilterIndexingSequence\n return TransformingSequence(FilteringSequence(IndexingSequence(this), true, { predicate(it.index, it.value) }), { it.value })\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexedTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a sequence containing all elements that are instances of specified type parameter R.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstance\n */\npublic inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<@kotlin.internal.NoInfer R> {\n @Suppress(\"UNCHECKED_CAST\")\n return filter { it is R } as Sequence<R>\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstanceTo\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a sequence containing all elements not matching the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic fun <T> Sequence<T>.filterNot(predicate: (T) -> Boolean): Sequence<T> {\n return FilteringSequence(this, false, predicate)\n}\n\n/**\n * Returns a sequence containing all elements that are not `null`.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNull\n */\npublic fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> {\n @Suppress(\"UNCHECKED_CAST\")\n return filterNot { it == null } as Sequence<T>\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNullTo\n */\npublic fun <C : MutableCollection<in T>, T : Any> Sequence<T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a sequence containing first [n] elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Sequence<T>.take(n: Int): Sequence<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return when {\n n == 0 -> emptySequence()\n this is DropTakeSequence -> this.take(n)\n else -> TakeSequence(this, n)\n }\n}\n\n/**\n * Returns a sequence containing first elements satisfying the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Sequence<T>.takeWhile(predicate: (T) -> Boolean): Sequence<T> {\n return TakeWhileSequence(this, predicate)\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> {\n return object : Sequence<T> {\n override fun iterator(): Iterator<T> {\n val sortedList = this@sorted.toMutableList()\n sortedList.sort()\n return sortedList.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Sorting.sortedBy\n */\npublic inline fun <T, R : Comparable<R>> Sequence<T>.sortedBy(crossinline selector: (T) -> R?): Sequence<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic inline fun <T, R : Comparable<R>> Sequence<T>.sortedByDescending(crossinline selector: (T) -> R?): Sequence<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T : Comparable<T>> Sequence<T>.sortedDescending(): Sequence<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T> Sequence<T>.sortedWith(comparator: Comparator<in T>): Sequence<T> {\n return object : Sequence<T> {\n override fun iterator(): Iterator<T> {\n val sortedList = this@sortedWith.toMutableList()\n sortedList.sortWith(comparator)\n return sortedList.iterator()\n }\n }\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given sequence.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associate\n */\npublic inline fun <T, K, V> Sequence<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n return associateTo(LinkedHashMap<K, V>(), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given sequence indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateBy\n */\npublic inline fun <T, K> Sequence<T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n return associateByTo(LinkedHashMap<K, T>(), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given sequence.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByWithValueTransform\n */\npublic inline fun <T, K, V> Sequence<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n return associateByTo(LinkedHashMap<K, V>(), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given sequence\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByTo\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given sequence.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given sequence.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateTo\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Returns a [Map] where keys are elements from the given sequence and values are\n * produced by the [valueSelector] function applied to each element.\n * \n * If any two elements are equal, the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateWith\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V> Sequence<K>.associateWith(valueSelector: (K) -> V): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n return associateWithTo(result, valueSelector)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs for each element of the given sequence,\n * where key is the element itself and value is provided by the [valueSelector] function applied to that key.\n * \n * If any two elements are equal, the last one overwrites the former value in the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateWithTo\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M {\n for (element in this) {\n destination.put(element, valueSelector(element))\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n *\n * The operation is _terminal_.\n */\npublic fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a new [HashSet] of all elements.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>())\n}\n\n/**\n * Returns a [List] containing all elements.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toList(): List<T> {\n return this.toMutableList().optimizeReadOnlyList()\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toMutableList(): MutableList<T> {\n return toCollection(ArrayList<T>())\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toSet(): Set<T> {\n return toCollection(LinkedHashSet<T>()).optimizeReadOnlySet()\n}\n\n/**\n * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIterable\")\npublic fun <T, R> Sequence<T>.flatMap(transform: (T) -> Iterable<R>): Sequence<R> {\n return FlatteningSequence(this, transform, Iterable<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\npublic fun <T, R> Sequence<T>.flatMap(transform: (T) -> Sequence<R>): Sequence<R> {\n return FlatteningSequence(this, transform, Sequence<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterable\")\npublic fun <T, R> Sequence<T>.flatMapIndexed(transform: (index: Int, T) -> Iterable<R>): Sequence<R> {\n return flatMapIndexed(this, transform, Iterable<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequence\")\npublic fun <T, R> Sequence<T>.flatMapIndexed(transform: (index: Int, T) -> Sequence<R>): Sequence<R> {\n return flatMapIndexed(this, transform, Sequence<R>::iterator)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterableTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Iterable<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequenceTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Sequence<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIterableTo\")\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(destination: C, transform: (T) -> Sequence<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original sequence by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Sequence<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original sequence\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Sequence<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original sequence by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original sequence\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from a sequence to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Sequence<T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = this@groupingBy.iterator()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to each element in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.map\n */\npublic fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> {\n return TransformingSequence(this, transform)\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to each element and its index in the original sequence.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T, R> Sequence<T>.mapIndexed(transform: (index: Int, T) -> R): Sequence<R> {\n return TransformingIndexedSequence(this, transform)\n}\n\n/**\n * Returns a sequence containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original sequence.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence<R> {\n return TransformingIndexedSequence(this, transform).filterNotNull()\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original sequence\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original sequence\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(checkIndexOverflow(index++), item))\n return destination\n}\n\n/**\n * Returns a sequence containing only the non-null results of applying the given [transform] function\n * to each element in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.mapNotNull\n */\npublic fun <T, R : Any> Sequence<T>.mapNotNull(transform: (T) -> R?): Sequence<R> {\n return TransformingSequence(this, transform).filterNotNull()\n}\n\n/**\n * Applies the given [transform] function to each element in the original sequence\n * and appends only the non-null results to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original sequence\n * and appends the results to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a sequence that wraps each element of the original sequence\n * into an [IndexedValue] containing the index of that element and the element itself.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T> Sequence<T>.withIndex(): Sequence<IndexedValue<T>> {\n return IndexingSequence(this)\n}\n\n/**\n * Returns a sequence containing only distinct elements from the given sequence.\n * \n * Among equal elements of the given sequence, only the first one will be present in the resulting sequence.\n * The elements in the resulting sequence are in the same order as they were in the source sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T> Sequence<T>.distinct(): Sequence<T> {\n return this.distinctBy { it }\n}\n\n/**\n * Returns a sequence containing only elements from the given sequence\n * having distinct keys returned by the given [selector] function.\n * \n * Among elements of the given sequence with equal keys, only the first one will be present in the resulting sequence.\n * The elements in the resulting sequence are in the same order as they were in the source sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T, K> Sequence<T>.distinctBy(selector: (T) -> K): Sequence<T> {\n return DistinctSequence(this, selector)\n}\n\n/**\n * Returns a new [MutableSet] containing all distinct elements from the given sequence.\n * \n * The returned set preserves the element iteration order of the original sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toMutableSet(): MutableSet<T> {\n val set = LinkedHashSet<T>()\n for (item in this) set.add(item)\n return set\n}\n\n/**\n * Returns `true` if all elements match the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.all\n */\npublic inline fun <T> Sequence<T>.all(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (!predicate(element)) return false\n return true\n}\n\n/**\n * Returns `true` if sequence has at least one element.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.any\n */\npublic fun <T> Sequence<T>.any(): Boolean {\n return iterator().hasNext()\n}\n\n/**\n * Returns `true` if at least one element matches the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.anyWithPredicate\n */\npublic inline fun <T> Sequence<T>.any(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (predicate(element)) return true\n return false\n}\n\n/**\n * Returns the number of elements in this sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.count(): Int {\n var count = 0\n for (element in this) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Returns the number of elements matching the given [predicate].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int {\n var count = 0\n for (element in this) if (predicate(element)) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns the specified [initial] value if the sequence is empty.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R> Sequence<T>.fold(initial: R, operation: (acc: R, T) -> R): R {\n var accumulator = initial\n for (element in this) accumulator = operation(accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Returns the specified [initial] value if the sequence is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {\n var index = 0\n var accumulator = initial\n for (element in this) accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n return accumulator\n}\n\n/**\n * Performs the given [action] on each element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.forEach(action: (T) -> Unit): Unit {\n for (element in this) action(element)\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {\n var index = 0\n for (item in this) action(checkIndexOverflow(index++), item)\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Double>.max(): Double? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Float>.max(): Float? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Sequence<T>.max(): T? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxByOrNull instead.\", ReplaceWith(\"this.maxByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(selector: (T) -> R): T? {\n return maxByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the largest value of the given function or `null` if there are no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.maxByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxElem = iterator.next()\n if (!iterator.hasNext()) return maxElem\n var maxValue = selector(maxElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (maxValue < v) {\n maxElem = e\n maxValue = v\n }\n } while (iterator.hasNext())\n return maxElem\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.maxOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.maxOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Double>.maxOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Float>.maxOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (max < e) max = e\n }\n return max\n}\n\n@Deprecated(\"Use maxWithOrNull instead.\", ReplaceWith(\"this.maxWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T? {\n return maxWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.maxWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(max, e) < 0) max = e\n }\n return max\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Double>.min(): Double? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Float>.min(): Float? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Sequence<T>.min(): T? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minByOrNull instead.\", ReplaceWith(\"this.minByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minBy(selector: (T) -> R): T? {\n return minByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.minByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minElem = iterator.next()\n if (!iterator.hasNext()) return minElem\n var minValue = selector(minElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (minValue > v) {\n minElem = e\n minValue = v\n }\n } while (iterator.hasNext())\n return minElem\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.minOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.minOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Double>.minOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Float>.minOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (min > e) min = e\n }\n return min\n}\n\n@Deprecated(\"Use minWithOrNull instead.\", ReplaceWith(\"this.minWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T? {\n return minWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.minWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(min, e) > 0) min = e\n }\n return min\n}\n\n/**\n * Returns `true` if the sequence has no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.none\n */\npublic fun <T> Sequence<T>.none(): Boolean {\n return !iterator().hasNext()\n}\n\n/**\n * Returns `true` if no elements match the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.noneWithPredicate\n */\npublic inline fun <T> Sequence<T>.none(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (predicate(element)) return false\n return true\n}\n\n/**\n * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@SinceKotlin(\"1.1\")\npublic fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> {\n return map {\n action(it)\n it\n }\n}\n\n/**\n * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.onEachIndexed(action: (index: Int, T) -> Unit): Sequence<T> {\n return mapIndexed { index, element ->\n action(index, element)\n element\n }\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,\n * please use [reduceOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Sequence<T>.reduce(operation: (acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty sequence can't be reduced.\")\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,\n * please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Sequence<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty sequence can't be reduced.\")\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Returns `null` if the sequence is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Sequence<T>.reduceIndexedOrNull(operation: (index: Int, acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns `null` if the sequence is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Sequence<T>.reduceOrNull(operation: (acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic fun <T, R> Sequence<T>.runningFold(initial: R, operation: (acc: R, T) -> R): Sequence<R> {\n return sequence {\n yield(initial)\n var accumulator = initial\n for (element in this@runningFold) {\n accumulator = operation(accumulator, element)\n yield(accumulator)\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic fun <T, R> Sequence<T>.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): Sequence<R> {\n return sequence {\n yield(initial)\n var index = 0\n var accumulator = initial\n for (element in this@runningFoldIndexed) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n yield(accumulator)\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with the first element of this sequence.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * \n * @param [operation] function that takes current accumulator value and the element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <S, T : S> Sequence<T>.runningReduce(operation: (acc: S, T) -> S): Sequence<S> {\n return sequence {\n val iterator = iterator()\n if (iterator.hasNext()) {\n var accumulator: S = iterator.next()\n yield(accumulator)\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n yield(accumulator)\n }\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\npublic fun <S, T : S> Sequence<T>.runningReduceIndexed(operation: (index: Int, acc: S, T) -> S): Sequence<S> {\n return sequence {\n val iterator = iterator()\n if (iterator.hasNext()) {\n var accumulator: S = iterator.next()\n yield(accumulator)\n var index = 1\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n yield(accumulator)\n }\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T, R> Sequence<T>.scan(initial: R, operation: (acc: R, T) -> R): Sequence<R> {\n return runningFold(initial, operation)\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T, R> Sequence<T>.scanIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): Sequence<R> {\n return runningFoldIndexed(initial, operation)\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Sequence<T>.sumBy(selector: (T) -> Int): Int {\n var sum: Int = 0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Sequence<T>.sumByDouble(selector: (T) -> Double): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfDouble\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Double): Double {\n var sum: Double = 0.toDouble()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfInt\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Int): Int {\n var sum: Int = 0.toInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfLong\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Long): Long {\n var sum: Long = 0.toLong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfUInt\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> UInt): UInt {\n var sum: UInt = 0.toUInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfULong\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> ULong): ULong {\n var sum: ULong = 0.toULong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {\n return map { it ?: throw IllegalArgumentException(\"null element found in $this.\") }\n}\n\n/**\n * Splits this sequence into a sequence of lists each not exceeding the given [size].\n * \n * The last list in the resulting sequence may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.chunked\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {\n return windowed(size, size, partialWindows = true)\n}\n\n/**\n * Splits this sequence into several lists each not exceeding the given [size]\n * and applies the given [transform] function to an each.\n * \n * @return sequence of results of the [transform] applied to an each list.\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * The last list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.text.Strings.chunkedTransform\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {\n return windowed(size, size, partialWindows = true, transform = transform)\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.minus(element: T): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n var removed = false\n return this@minus.filter { if (!removed && it == element) { removed = true; false } else true }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] array.\n * \n * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The [elements] array may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Array<out T>): Sequence<T> {\n if (elements.isEmpty()) return this\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.toHashSet()\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] collection.\n * \n * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The [elements] collection may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Iterable<T>): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.convertToSetForSetOperation()\n if (other.isEmpty())\n return this@minus.iterator()\n else\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] sequence.\n * \n * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The operation is _intermediate_ for this sequence and _terminal_ and _stateful_ for the [elements] sequence.\n * \n * The [elements] sequence may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Sequence<T>): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.toHashSet()\n if (other.isEmpty())\n return this@minus.iterator()\n else\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minusElement(element: T): Sequence<T> {\n return minus(element)\n}\n\n/**\n * Splits the original sequence into pair of lists,\n * where *first* list contains elements for which [predicate] yielded `true`,\n * while *second* list contains elements for which [predicate] yielded `false`.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Sequences.Transformations.partition\n */\npublic inline fun <T> Sequence<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {\n val first = ArrayList<T>()\n val second = ArrayList<T>()\n for (element in this) {\n if (predicate(element)) {\n first.add(element)\n } else {\n second.add(element)\n }\n }\n return Pair(first, second)\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence and then the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(element: T): Sequence<T> {\n return sequenceOf(this, sequenceOf(element)).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] array.\n * \n * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Array<out T>): Sequence<T> {\n return this.plus(elements.asList())\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] collection.\n * \n * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Iterable<T>): Sequence<T> {\n return sequenceOf(this, elements.asSequence()).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] sequence.\n * \n * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Sequence<T>): Sequence<T> {\n return sequenceOf(this, elements).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence and then the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.plusElement(element: T): Sequence<T> {\n return plus(element)\n}\n\n/**\n * Returns a sequence of snapshots of the window of the given [size]\n * sliding along this sequence with the given [step], where each\n * snapshot is a list.\n * \n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.takeWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<List<T>> {\n return windowedSequence(size, step, partialWindows, reuseBuffer = false)\n}\n\n/**\n * Returns a sequence of results of applying the given [transform] function to\n * an each list representing a view over the window of the given [size]\n * sliding along this sequence with the given [step].\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.averageWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): Sequence<R> {\n return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)\n}\n\n/**\n * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index.\n * The resulting sequence ends as soon as the shortest input sequence ends.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Sequences.Transformations.zip\n */\npublic infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pair<T, R>> {\n return MergingSequence(this, other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The resulting sequence ends as soon as the shortest input sequence ends.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Sequences.Transformations.zipWithTransform\n */\npublic fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (a: T, b: R) -> V): Sequence<V> {\n return MergingSequence(this, other, transform)\n}\n\n/**\n * Returns a sequence of pairs of each two adjacent elements in this sequence.\n * \n * The returned sequence is empty if this sequence contains less than two elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNext\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> {\n return zipWithNext { a, b -> a to b }\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to an each pair of two adjacent elements in this sequence.\n * \n * The returned sequence is empty if this sequence contains less than two elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.zipWithNext(transform: (a: T, b: T) -> R): Sequence<R> {\n return sequence result@ {\n val iterator = iterator()\n if (!iterator.hasNext()) return@result\n var current = iterator.next()\n while (iterator.hasNext()) {\n val next = iterator.next()\n yield(transform(current, next))\n current = next\n }\n }\n}\n\n/**\n * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.joinTo\n */\npublic fun <T, A : Appendable> Sequence<T>.joinTo(buffer: A, separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): A {\n buffer.append(prefix)\n var count = 0\n for (element in this) {\n if (++count > 1) buffer.append(separator)\n if (limit < 0 || count <= limit) {\n buffer.appendElement(element, transform)\n } else break\n }\n if (limit >= 0 && count > limit) buffer.append(truncated)\n buffer.append(postfix)\n return buffer\n}\n\n/**\n * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.joinToString\n */\npublic fun <T> Sequence<T>.joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): String {\n return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()\n}\n\n/**\n * Creates an [Iterable] instance that wraps the original sequence returning its elements when being iterated.\n */\npublic fun <T> Sequence<T>.asIterable(): Iterable<T> {\n return Iterable { this.iterator() }\n}\n\n/**\n * Returns this sequence as a [Sequence].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.asSequence(): Sequence<T> {\n return this\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfByte\")\npublic fun Sequence<Byte>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfShort\")\npublic fun Sequence<Short>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfInt\")\npublic fun Sequence<Int>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfLong\")\npublic fun Sequence<Long>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfFloat\")\npublic fun Sequence<Float>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfDouble\")\npublic fun Sequence<Double>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfByte\")\npublic fun Sequence<Byte>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfShort\")\npublic fun Sequence<Short>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfInt\")\npublic fun Sequence<Int>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfLong\")\npublic fun Sequence<Long>.sum(): Long {\n var sum: Long = 0L\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfFloat\")\npublic fun Sequence<Float>.sum(): Float {\n var sum: Float = 0.0f\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfDouble\")\npublic fun Sequence<Double>.sum(): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.language.RuleParserBase\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class EngineInterfaceBase : ArgLibrary, LazyRawPrologContent() {\n\n override val alias = \"prolog.argumentation.interface\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory,\n operatorSet = RuleParserBase.operators()\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override val theoryOperators = RuleParserBase.operators()\n .plus(DynamicLoader.operators())\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object EngineInterface : EngineInterfaceBase\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.extra.ModulesPath\nimport it.unibo.tuprolog.argumentation.core.libs.graph.ArgumentLabellingMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.GraphBuildMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.GraphExtension\nimport it.unibo.tuprolog.argumentation.core.libs.graph.StatementLabellingMode\nimport it.unibo.tuprolog.argumentation.core.libs.language.AutoTransposition\nimport it.unibo.tuprolog.argumentation.core.libs.language.PrologStrictCompatibility\nimport it.unibo.tuprolog.argumentation.core.libs.structured.QueryMode\nimport it.unibo.tuprolog.argumentation.core.libs.utils.OrderingComparator\nimport it.unibo.tuprolog.argumentation.core.libs.utils.OrderingPrinciple\nimport it.unibo.tuprolog.core.Clause\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.parsing.parse\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.MutableTheory\nimport kotlin.jvm.JvmStatic\n\ndata class FlagsBuilder(\n var queryMode: Boolean = QueryMode.default(),\n var autoTransposition: Boolean = AutoTransposition.default(),\n var prologStrictCompatibility: Boolean = PrologStrictCompatibility.default(),\n var graphBuildMode: String = GraphBuildMode.default(),\n var argumentLabellingMode: String = ArgumentLabellingMode.default(),\n var statementLabellingMode: String = StatementLabellingMode.default(),\n var orderingPrinciple: String = OrderingPrinciple.default(),\n var orderingComparator: String = OrderingComparator.default(),\n var modulesPath: String = ModulesPath.default(),\n var graphExtensions: Iterable<String> = GraphExtension.default()\n) {\n\n companion object {\n @JvmStatic\n fun setupSolver(target: FlagsBuilder) =\n MutableTheory.empty().also { kb ->\n target.graphExtensions.forEach { kb.assertA(Clause.parse(\"${GraphExtension.predicate()}(X) :- X = $it\")) }\n if (target.queryMode) kb.assertA(Struct.parse(QueryMode.predicate()))\n if (target.autoTransposition) kb.assertA(Struct.parse(AutoTransposition.predicate()))\n if (target.prologStrictCompatibility) kb.assertA(Struct.parse(PrologStrictCompatibility.predicate()))\n kb.assertA(Struct.parse(\"${GraphBuildMode.predicate()}(${target.graphBuildMode})\"))\n kb.assertA(Struct.parse(\"${ArgumentLabellingMode.predicate()}(${target.argumentLabellingMode})\"))\n kb.assertA(Struct.parse(\"${StatementLabellingMode.predicate()}(${target.statementLabellingMode})\"))\n kb.assertA(Struct.parse(\"${OrderingPrinciple.predicate()}(${target.orderingPrinciple})\"))\n kb.assertA(Struct.parse(\"${OrderingComparator.predicate()}(${target.orderingComparator})\"))\n kb.assertA(Struct.parse(\"${ModulesPath.predicate()}(${target.modulesPath})\"))\n }\n }\n\n fun queryMode(queryMode: Boolean) = apply { this.queryMode = queryMode }\n fun prologStrictCompatibility(prologStrictCompatibility: Boolean) =\n apply { this.prologStrictCompatibility = prologStrictCompatibility }\n fun graphBuildMode(graphBuildMode: String) = apply { this.graphBuildMode = graphBuildMode }\n fun argumentLabellingMode(argumentLabellingMode: String) =\n apply { this.argumentLabellingMode = argumentLabellingMode }\n fun statementLabellingMode(statementLabellingMode: String) =\n apply { this.statementLabellingMode = statementLabellingMode }\n\n fun orderingPrinciple(orderingPrinciple: String) = apply { this.orderingPrinciple = orderingPrinciple }\n fun orderingComparator(orderingComparator: String) = apply { this.orderingComparator = orderingComparator }\n fun modulesPath(modulesPath: String) = apply { this.modulesPath = modulesPath }\n fun graphExtensions(graphExtensions: Iterable<String>) = apply { this.graphExtensions = graphExtensions }\n\n fun create() = object : ArgLibrary {\n\n override val alias = \"prolog.argumentation.flags\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = setupSolver(this@FlagsBuilder),\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.extra\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\nobject MetaInterpreter : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.meta.crossjustice\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.parse(\n \"\"\"\n % with_facts_and_length/3\n with_facts_and_length(X, Y, L) :-\n solve(X, R),\n recover_facts(R, Y),\n length(Y, L).\n \n % lenght/2\n \n length([], 0).\n length([_|T], X) :- length(T, Y), X is Y + 1.\n \n % recover_facts/2\n \n recover_facts([], []) :- !.\n recover_facts([H|T], C) :-\n is_list(H), !,\n recover_facts(T, TC),\n recover_facts(H, HC),\n append(TC, HC, C).\n recover_facts([H|T], C) :-\n \\+ is_list(H),\n recover_facts(T, TC),\n evaluate(H, HC),\n append(TC, HC, C).\n \n evaluate(user_fact(X), [X]) :- !.\n evaluate(_, []) :- !.\n \n % solve/2\n \n solve((A,B), Result) :- !,\n solve(A, ARes),\n solve(B, BRes),\n append(ARes, BRes, Result).\n \n solve((A;B), Result) :- !,\n solve(A, Result);\n solve(B, Result).\n \n solve(member(A, B), [system_predicate]) :- !,\n call(member(A, B)).\n \n solve(\\+(A), [not(A)]) :- !,\n call(\\+(A)).\n \n solve((A)\\=(B), [doNotUnify(A, B)]) :- !,\n call((A)\\=(B)).\n \n solve(A, [system_predicate]) :-\n catch(clause(A, _), B, true),\n \\+ var(B), !,\n call(A).\n \n solve(A, [A]) :-\n \\+ clause(A, B), !,\n call(A).\n \n solve(A, [A|[Res]]) :-\n clause(A, B),\n solve(B, Res).\n \n % is_list/1\n \n is_list(X) :- var(X), !, fail.\n is_list([]).\n is_list([_|T]) :- is_list(T).\n \n % fetch_argument_facts/2\n \n fetch_argument_facts(Conclusion, Facts) :-\n argument([R, TR, [Conclusion]]),\n findall(user_fact(Fact), \n support([_, _, [user_fact(Fact)]], [R, TR, [Conclusion]]),\n Facts).\n \"\"\".trimIndent()\n )\n )\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"interpreter\"\n}\n","package it.unibo.tuprolog.argumentation.core.libs.extra\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.core.List\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.dsl.theory.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.Solution\nimport it.unibo.tuprolog.solve.Solver\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.exception.error.TypeError\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.solve.primitive.Solve\n\nobject ModuleCalls : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.modularity\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n primitives = mapOf(\n ModuleCall.signature to ModuleCall\n )\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(ModulesPath)\n\n override fun identifier(): String = \"module\"\n}\n\nobject ModulesPath : ArgsFlag<String, Unit> {\n override fun predicate(): String = \"modulesPath\"\n override fun default(): String = \"none\"\n override fun values() {}\n}\n\nobject ModuleCall : Primitive {\n\n val signature = Signature(\"call_module\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val modules: Term = request.arguments[0]\n val goal: Term = request.arguments[1]\n\n if (modules !is List) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.LIST,\n modules\n )\n }\n\n if (goal !is Struct) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.CALLABLE,\n goal\n )\n }\n\n val solver = getCleanSolver(request.context, mineModulesPath(request.context), modules.toList().map { it.toString() })\n return sequence {\n yieldAll(\n solver.solve(goal).map {\n when (it) {\n is Solution.Yes -> request.replySuccess(it.substitution)\n else -> request.replyFail()\n }\n }\n )\n }\n }\n\n private fun mineModulesPath(context: ExecutionContext): String {\n return prolog {\n Solver.classic(libraries = context.libraries)\n .solve(\"modulesPath\"(X))\n .map { if (it is Solution.Yes) it.substitution[X].toString() else \"\" }\n .first()\n }\n }\n\n private fun getCleanSolver(context: ExecutionContext, modulesPath: String, modules: Iterable<String>): Solver {\n val module = { mod: String -> if (mod.contains(\".pl\")) mod else \"${modulesPath.removeSurrounding(\"'\")}/$mod.pl\" }\n return prolog {\n Solver.classic(\n libraries = context.libraries\n ).also { solver: Solver -> modules.forEach { solver.solve(\"consult\"(module(it))).toList() } }\n }\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class AbstractModeBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.abstract\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(GraphExtension, ArgumentLabellingMode, StatementLabellingMode, GraphBuildMode)\n\n override fun identifier(): String = \"abstract\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object AbstractMode : AbstractModeBase\n\nobject GraphExtension : ArgsFlag<Iterable<String>, Iterable<String>> {\n override fun predicate(): String = \"graphExtension\"\n override fun default(): Iterable<String> = listOf(\"standardPref\")\n override fun values(): Iterable<String> = listOf(\"rebutRestriction\", \"bp\", \"standardPref\", \"defeasiblePref\", \"defeasibleAllPref\")\n}\n\nobject ArgumentLabellingMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"argumentLabellingMode\"\n override fun default(): String = \"grounded\"\n override fun values(): Iterable<String> = listOf(\n \"grounded\",\n \"complete\",\n \"bp_grounded\",\n \"bp_grounded_partial\",\n \"bp_grounded_complete\"\n )\n}\n\nobject StatementLabellingMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"statementLabellingMode\"\n override fun default(): String = \"statement\"\n override fun values(): Iterable<String> = listOf(\"statement\", \"statement_pass_through\", \"statement_binary\")\n}\n\nobject GraphBuildMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"graphBuildMode\"\n override fun default(): String = \"standard_af\"\n override fun values(): Iterable<String> = listOf(\"standard_af\")\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.builder\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class ArgumentationGraphBuilderBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"standard_af\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object ArgumentationGraphBuilder : ArgumentationGraphBuilderBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class AttackRestrictionHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.rebutrestriction\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"rebutRestriction\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object AttackRestrictionHandler : AttackRestrictionHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpMetaGraphHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.meta.bp\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpMetaGraphHandler : BpMetaGraphHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class DefeasiblePreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.defeasible\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"defeasiblePref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object DefeasiblePreferencesHandler : DefeasiblePreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class GenericDefeasiblePreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.defeasible.generic\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"defeasibleAllPref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object GenericDefeasiblePreferencesHandler : GenericDefeasiblePreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StrictPreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.strict\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"standardPref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StrictPreferencesHandler : StrictPreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Scope\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.rule.RuleWrapper\nimport it.unibo.tuprolog.theory.Theory\n\nobject BinaryStatementLabeller : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement.binary\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.of(BinaryLabelling.implementation)\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement_binary\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nprivate object BinaryLabelling : RuleWrapper<ExecutionContext>(\"statementLabelling\", 0) {\n override val Scope.body: Term\n get() = prolog {\n tupleOf(\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"in\"(listOf(`_`, `_`, X, `_`, `_`,))),\n not(\"contextCheck\"(\"statIn\"(X))),\n \"context_assert\"(\"statIn\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"out\"(listOf(`_`, `_`, X, `_`, `_`,))) or \"context_check\"(\"und\"(listOf(`_`, `_`, X, `_`, `_`,))),\n not(\"context_check\"(\"statOut\"(X))),\n \"context_assert\"(\"statOut\"(X))\n ),\n `_`\n )\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpCompleteLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgroundedcomplete\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded_complete\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpCompleteLabeller : BpCompleteLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgrounded\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpLabeller : BpLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpPartialLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgroundedpartial\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded_partial\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpPartialLabeller : BpPartialLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class CompleteLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.complete\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"complete\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object CompleteLabeller : CompleteLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class GroundedLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.grounded\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"grounded\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object GroundedLabeller : GroundedLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Scope\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.rule.RuleWrapper\nimport it.unibo.tuprolog.theory.Theory\n\nobject PassThroughStatementLabeller : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement.pt\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.of(Labelling.implementation)\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement_pass_through\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nprivate object Labelling : RuleWrapper<ExecutionContext>(\"statementLabelling\", 0) {\n override val Scope.body: Term\n get() = prolog {\n tupleOf(\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"in\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statIn\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"out\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statOut\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"und\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statUnd\"(X))\n ),\n `_`\n )\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StatementLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StatementLabeller : StatementLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.language\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Clause\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Substitution\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.Var\nimport it.unibo.tuprolog.core.operators.Operator\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.core.operators.Specifier\nimport it.unibo.tuprolog.core.parsing.parse\nimport it.unibo.tuprolog.core.toTerm\nimport it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories\nimport it.unibo.tuprolog.dsl.theory.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.PrimitiveWrapper.Companion.ensuringArgumentIsVariable\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.solve.primitive.UnaryPredicate\nimport kotlin.random.Random\n\nsealed class RuleParserBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.parser\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n primitives = mapOf(\n StrictRules::descriptionPair.get(),\n Axioms::descriptionPair.get(),\n Bps::descriptionPair.get(),\n Premises::descriptionPair.get(),\n DefeasibleRules::descriptionPair.get()\n ),\n theory = this.prologTheory,\n operatorSet = operators()\n )\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(AutoTransposition, PrologStrictCompatibility)\n\n override fun identifier() = \"parser\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(operators())\n .plus(OperatorSet.DEFAULT)\n\n companion object {\n fun operators() = OperatorSet(\n Operator(\"=>\", Specifier.XFX, 1199),\n Operator(\":=>\", Specifier.XFX, 1199),\n Operator(\":->\", Specifier.XFX, 1199),\n Operator(\":\", Specifier.XFX, 1001),\n Operator(\":=\", Specifier.XFX, 1199)\n )\n }\n}\n\nexpect object RuleParser : RuleParserBase\n\nobject AutoTransposition : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"autoTransposition\"\n override fun default(): Boolean = false\n override fun values() {}\n}\n\nobject PrologStrictCompatibility : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"prologStrictCompatibility\"\n override fun default(): Boolean = true\n override fun values() {}\n}\n\nobject ConversionUtils {\n fun modifiers(target: Clause, context: Solve.Request<ExecutionContext>): Term =\n prolog {\n target.bodyItems.map { term ->\n if (term.isStruct && term.asStruct()?.functor == \"\\\\+\") \"~\"(term.asStruct()!!.args[0])\n else if (context.solve(\"clause\"(term, Var.ANONYMOUS_NAME)).first().isHalt) \"prolog\"(term)\n else term\n }.let { if (it.count() > 1) tupleOf(it) else it.first() }\n }\n\n fun commonMap(\n context: Solve.Request<ExecutionContext>,\n first: Term,\n force: Boolean = false,\n mapper: (Iterable<Clause>, PrologScopeWithTheories) -> Term\n ): Sequence<Substitution> {\n context.ensuringArgumentIsVariable(0)\n return prolog {\n sequenceOf(\n Substitution.of(\n first.castToVar(),\n if (force || context.solve(Struct.parse(\"prologStrictCompatibility\")).first().isYes) {\n mapper(context.context.staticKb.clauses, this)\n } else {\n emptyList\n }\n )\n )\n }\n }\n}\n\nobject StrictRules : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologStrictRules\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses.filter { !it.isFact }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n ConversionUtils.modifiers(it, this@computeAllSubstitutions),\n it.head!!\n )\n }.toTerm()\n }\n}\n\nobject Axioms : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologAxioms\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter { it.isFact && !listOf(\":->\", \"->\", \"=>\", \":=>\", \":\", \":=\", \",\").contains(it.head!!.functor) }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n it.head!!\n )\n }.toTerm()\n }\n}\n\nobject Premises : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologPremises\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter { it.isFact && it.head!!.functor == \":=\" && it.head!!.arity == 1 }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n it.head!!.args[0]\n )\n }.toTerm()\n }\n}\n\nobject DefeasibleRules : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologDefeasibleRules\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter {\n it.isFact && (\n it.head!!.functor == \":=\" ||\n (it.head!!.functor == \",\" && it.head!!.args[0].asStruct()?.functor == \":=\")\n ) &&\n it.head!!.arity == 2\n }\n .map { clause ->\n if (clause.head!!.functor == \",\") {\n val head = clause.head!!.args[0].asStruct()\n val term = (\n listOf(head!![1]) + (\n clause.head!!.args[1].asTuple()?.args\n ?: listOf(clause.head!!.args[1])\n )\n ).toTypedArray()\n prologScope.clauseOf(head[0].asStruct(), *term)\n } else {\n prologScope.clauseOf(clause.head!!.args[0].asStruct(), clause.head!!.args[1])\n }.let {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n ConversionUtils.modifiers(it, this@computeAllSubstitutions),\n it.head!!\n )\n }\n }.toTerm()\n }\n}\n\nobject Bps : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"bpsNew\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first, true) { clauses, prologScope ->\n clauses\n .filter { it.isFact && it.head?.functor == \"bp\" }\n .map {\n prologScope.listOf(\n \"bps\",\n it.head!!\n )\n }.toTerm()\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.structured\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StructuredModeBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.structured\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(QueryMode, AmbiguityBlocking)\n\n override fun identifier(): String = \"structured\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StructuredMode : StructuredModeBase\n\nobject QueryMode : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"queryMode\"\n override fun default(): Boolean = true\n override fun values() {}\n}\n\nobject AmbiguityBlocking : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"ambiguityBlocking\"\n override fun default(): Boolean = true\n override fun values() {}\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class DebugBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.debug\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier() = \"debug\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object Debug : DebugBase\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class SuperiorityRelationBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.superiority\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(OrderingPrinciple, OrderingComparator)\n\n override fun identifier(): String = \"superiority\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object SuperiorityRelation : SuperiorityRelationBase\n\nobject OrderingPrinciple : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"orderingPrinciple\"\n override fun default(): String = \"last\"\n override fun values(): Iterable<String> = listOf(\"last\", \"weakest\")\n}\n\nobject OrderingComparator : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"orderingComparator\"\n override fun default(): String = \"elitist\"\n override fun values(): Iterable<String> = listOf(\"elitist\", \"democrat\", \"normal\")\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class UtilsBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.utils\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"utils\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object Utils : UtilsBase\n","package it.unibo.tuprolog.argumentation.core.meta\n\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\nobject MetaInterpreterLib : AliasedLibrary by\nLibrary.aliased(\n theory = Theory.parse(\n \"\"\"\n % with_facts_and_length/3\n with_facts_and_length(X, Y, L) :-\n solve(X, R),\n recover_facts(R, Y),\n length(Y, L).\n\n % lenght/2\n\n length([], 0).\n length([_|T], X) :- length(T, Y), X is Y + 1.\n\n % recover_facts/2\n\n recover_facts([], []) :- !.\n recover_facts([H|T], C) :-\n is_list(H), !,\n recover_facts(T, TC),\n recover_facts(H, HC),\n append(TC, HC, C).\n recover_facts([H|T], C) :-\n \\+ is_list(H),\n recover_facts(T, TC),\n evaluate(H, HC),\n append(TC, HC, C).\n\n evaluate(user_fact(X), [X]) :- !.\n evaluate(_, []) :- !.\n\n % solve/2\n\n solve((A,B), Result) :- !,\n solve(A, ARes),\n solve(B, BRes),\n append(ARes, BRes, Result).\n\n solve((A;B), Result) :- !,\n solve(A, Result);\n solve(B, Result).\n\n solve(member(A, B), [system_predicate]) :- !,\n call(member(A, B)).\n\n solve(\\+(A), [not(A)]) :- !,\n call(\\+(A)).\n\n solve((A)\\=(B), [doNotUnify(A, B)]) :- !,\n call((A)\\=(B)).\n\n solve(A, [system_predicate]) :-\n catch(clause(A, _), B, true),\n \\+ var(B), !,\n call(A).\n\n solve(A, [A]) :-\n \\+ clause(A, B), !,\n call(A).\n\n solve(A, [A|[Res]]) :-\n clause(A, B),\n solve(B, Res).\n\n % is_list/1\n\n is_list(X) :- var(X), !, fail.\n is_list([]).\n is_list([_|T]) :- is_list(T).\n \n % fetch_argument_facts/2\n \n fetch_argument_facts(Conclusion, Facts) :-\n argument([R, TR, [Conclusion]]),\n findall(user_fact(Fact), \n support([_, _, [user_fact(Fact)]], [R, TR, [Conclusion]]),\n Facts).\n \"\"\".trimIndent()\n ),\n alias = \"prolog.argumentation.meta\"\n)\n","package it.unibo.tuprolog.argumentation.core.mining\n\nimport it.unibo.tuprolog.argumentation.core.model.Argument\nimport it.unibo.tuprolog.argumentation.core.model.Attack\nimport it.unibo.tuprolog.argumentation.core.model.Graph\nimport it.unibo.tuprolog.argumentation.core.model.LabelledArgument\nimport it.unibo.tuprolog.argumentation.core.model.Support\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.Solver\nimport it.unibo.tuprolog.unify.Unificator\nimport kotlin.js.JsName\n\n@JsName(\"mineGraph\")\nfun Solver.graph(context: Int) =\n this.arguments(context).let {\n Graph.of(\n this.labels(context, it),\n this.attacks(context, it),\n this.supports(context, it)\n )\n }\n\n@JsName(\"mineArguments\")\nfun Solver.arguments(context: Int): List<Argument> =\n prolog {\n this@arguments.solve(\"context_check\"(context, \"argument\"(X)))\n .filter { it.isYes }\n .map { it.substitution[X]!! }\n .map { solution ->\n Argument.of(solution)\n }\n .sortedWith(compareBy({ it.supports.size }, { it.rules.size }, { it.conclusion }, { it.topRule }))\n .mapIndexed { index, arg ->\n arg.identifier = \"A$index\"\n arg\n }\n }.toList()\n\n@JsName(\"mineAttacks\")\nfun Solver.attacks(context: Int, arguments: List<Argument>): List<Attack> {\n if (arguments.isEmpty()) return emptyList()\n return prolog {\n this@attacks.solve(\"context_check\"(context, \"attack\"(`_`, X, Y, `_`)))\n .filter { it.isYes }\n .map { solution ->\n Attack(\n arguments.first { Unificator.default.match(it.termRepresentation(), solution.substitution[X]!!) },\n arguments.first { Unificator.default.match(it.termRepresentation(), solution.substitution[Y]!!) }\n )\n }\n }.toList()\n}\n\n@JsName(\"mineSupports\")\nfun Solver.supports(context: Int, arguments: List<Argument>): List<Support> =\n arguments.flatMap { argument ->\n prolog {\n this@supports.solve(\"context_check\"(context, \"support\"(X, argument.termRepresentation())))\n .filter { it.isYes }\n .map { it.substitution[X]!! }\n .map { solution ->\n Support(\n arguments.first { Unificator.default.match(it.termRepresentation(), solution) },\n argument\n ).also {\n argument.supports.add(it.supporter)\n }\n }.toList()\n }\n }\n\n@JsName(\"mineLabels\")\nfun Solver.labels(context: Int, arguments: List<Argument>): List<LabelledArgument> {\n fun checkFunctor(functor: String, argument: Argument) =\n prolog {\n this@labels.solve(\"context_check\"(context, functor(argument.termRepresentation())))\n .filter { it.isYes }\n .map { functor }\n .firstOrNull()\n }\n\n return arguments.map {\n LabelledArgument(\n it,\n checkFunctor(\"in\", it)\n ?: checkFunctor(\"out\", it) ?: \"und\"\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Cons\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Argument(\n val rules: List<RuleIdentifier>,\n val topRule: RuleIdentifier,\n val conclusion: Literal,\n val groundings: List<Literal> = emptyList(),\n val defeasibleRules: List<RuleIdentifier> = emptyList(),\n val defeasiblePremises: List<RuleIdentifier> = emptyList(),\n val lastDefeasibleRules: List<RuleIdentifier> = emptyList()\n) {\n\n var identifier: String = \"\"\n val supports: MutableList<Argument> = mutableListOf()\n\n val descriptor: String\n get() = \"$identifier : \" + (\n if (topRule == \"none\") rules.firstOrNull() ?: \"\" else {\n supports.map { it.identifier }.plus(topRule)\n .reduce { a: String, b: String -> \"$a,$b\" }\n }\n ) + \" : \" + conclusion\n\n fun termRepresentation(): Term = Struct.parse(\"[$rules, $topRule, $conclusion, $groundings, [$lastDefeasibleRules, $defeasibleRules, $defeasiblePremises]]\")\n\n override fun toString(): String {\n return \"argument(${this.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n\n companion object {\n\n fun of(term: Term): Argument {\n fun termAsList(t: Term?): List<Term> = (t as Cons).toList()\n\n fun toStringList(argument: List<Term>, target: Int): List<String> {\n return (\n if (argument[target].isEmptyList) emptyList()\n else (argument[target] as Cons).toList()\n ).map { x -> x.toString() }\n }\n\n fun argRules(argument: List<Term>): List<String> = toStringList(argument, 0)\n\n fun argTopRule(argument: List<Term>): String = argument[1].toString()\n\n fun argConclusion(argument: List<Term>): String = argument[2].toString()\n\n fun argGroundings(argument: List<Term>): List<String> = toStringList(argument, 3)\n\n fun argDefeasibleRules(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 1)\n\n fun argDefeasiblePremises(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 2)\n\n fun argLastDefeasibleRules(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 0)\n\n return termAsList(term).let {\n Argument(\n argRules(it),\n argTopRule(it),\n argConclusion(it),\n argGroundings(it),\n argDefeasibleRules(it),\n argDefeasiblePremises(it),\n argLastDefeasibleRules(it)\n )\n }\n }\n }\n}\n","/*\n * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\nimport kotlin.random.Random\n\ninternal object EmptyIterator : ListIterator<Nothing> {\n override fun hasNext(): Boolean = false\n override fun hasPrevious(): Boolean = false\n override fun nextIndex(): Int = 0\n override fun previousIndex(): Int = -1\n override fun next(): Nothing = throw NoSuchElementException()\n override fun previous(): Nothing = throw NoSuchElementException()\n}\n\ninternal object EmptyList : List<Nothing>, Serializable, RandomAccess {\n private const val serialVersionUID: Long = -7390468764508069838L\n\n override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty()\n override fun hashCode(): Int = 1\n override fun toString(): String = \"[]\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n override fun contains(element: Nothing): Boolean = false\n override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()\n\n override fun get(index: Int): Nothing = throw IndexOutOfBoundsException(\"Empty list doesn't contain element at index $index.\")\n override fun indexOf(element: Nothing): Int = -1\n override fun lastIndexOf(element: Nothing): Int = -1\n\n override fun iterator(): Iterator<Nothing> = EmptyIterator\n override fun listIterator(): ListIterator<Nothing> = EmptyIterator\n override fun listIterator(index: Int): ListIterator<Nothing> {\n if (index != 0) throw IndexOutOfBoundsException(\"Index: $index\")\n return EmptyIterator\n }\n\n override fun subList(fromIndex: Int, toIndex: Int): List<Nothing> {\n if (fromIndex == 0 && toIndex == 0) return this\n throw IndexOutOfBoundsException(\"fromIndex: $fromIndex, toIndex: $toIndex\")\n }\n\n private fun readResolve(): Any = EmptyList\n}\n\ninternal fun <T> Array<out T>.asCollection(): Collection<T> = ArrayAsCollection(this, isVarargs = false)\n\nprivate class ArrayAsCollection<T>(val values: Array<out T>, val isVarargs: Boolean) : Collection<T> {\n override val size: Int get() = values.size\n override fun isEmpty(): Boolean = values.isEmpty()\n override fun contains(element: T): Boolean = values.contains(element)\n override fun containsAll(elements: Collection<T>): Boolean = elements.all { contains(it) }\n override fun iterator(): Iterator<T> = values.iterator()\n // override hidden toArray implementation to prevent copying of values array\n public fun toArray(): Array<out Any?> = values.copyToArrayOfAny(isVarargs)\n}\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\npublic fun <T> emptyList(): List<T> = EmptyList\n\n/**\n * Returns a new read-only list of given elements. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.readOnlyList\n */\npublic fun <T> listOf(vararg elements: T): List<T> = if (elements.size > 0) elements.asList() else emptyList()\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> listOf(): List<T> = emptyList()\n\n/**\n * Returns an empty new [MutableList].\n * @sample samples.collections.Collections.Lists.emptyMutableList\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> mutableListOf(): MutableList<T> = ArrayList()\n\n/**\n * Returns an empty new [ArrayList].\n * @sample samples.collections.Collections.Lists.emptyArrayList\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> arrayListOf(): ArrayList<T> = ArrayList()\n\n/**\n * Returns a new [MutableList] with the given elements.\n * @sample samples.collections.Collections.Lists.mutableList\n */\npublic fun <T> mutableListOf(vararg elements: T): MutableList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new [ArrayList] with the given elements.\n * @sample samples.collections.Collections.Lists.arrayList\n */\npublic fun <T> arrayListOf(vararg elements: T): ArrayList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(element: T?): List<T> = if (element != null) listOf(element) else emptyList()\n\n/**\n * Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(vararg elements: T?): List<T> = elements.filterNotNull()\n\n/**\n * Creates a new read-only list with the specified [size], where each element is calculated by calling the specified\n * [init] function.\n *\n * The function [init] is called for each list element sequentially starting from the first one.\n * It should return the value for a list element given its index.\n *\n * @sample samples.collections.Collections.Lists.readOnlyListFromInitializer\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> List(size: Int, init: (index: Int) -> T): List<T> = MutableList(size, init)\n\n/**\n * Creates a new mutable list with the specified [size], where each element is calculated by calling the specified\n * [init] function.\n *\n * The function [init] is called for each list element sequentially starting from the first one.\n * It should return the value for a list element given its index.\n *\n * @sample samples.collections.Collections.Lists.mutableListFromInitializer\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> MutableList(size: Int, init: (index: Int) -> T): MutableList<T> {\n val list = ArrayList<T>(size)\n repeat(size) { index -> list.add(init(index)) }\n return list\n}\n\n/**\n * Builds a new read-only [List] by populating a [MutableList] using the given [builderAction]\n * and returning a read-only list with the same elements.\n *\n * The list passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * @sample samples.collections.Builders.Lists.buildListSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <E> buildList(@BuilderInference builderAction: MutableList<E>.() -> Unit): List<E> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildListInternal(builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <E> buildListInternal(builderAction: MutableList<E>.() -> Unit): List<E>\n\n/**\n * Builds a new read-only [List] by populating a [MutableList] using the given [builderAction]\n * and returning a read-only list with the same elements.\n *\n * The list passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * [capacity] is used to hint the expected number of elements added in the [builderAction].\n *\n * @throws IllegalArgumentException if the given [capacity] is negative.\n *\n * @sample samples.collections.Builders.Lists.buildListSampleWithCapacity\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <E> buildList(capacity: Int, @BuilderInference builderAction: MutableList<E>.() -> Unit): List<E> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildListInternal(capacity, builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <E> buildListInternal(capacity: Int, builderAction: MutableList<E>.() -> Unit): List<E>\n\n/**\n * Returns an [IntRange] of the valid indices for this collection.\n * @sample samples.collections.Collections.Collections.indicesOfCollection\n */\npublic val Collection<*>.indices: IntRange\n get() = 0..size - 1\n\n/**\n * Returns the index of the last item in the list or -1 if the list is empty.\n *\n * @sample samples.collections.Collections.Lists.lastIndexOfList\n */\npublic val <T> List<T>.lastIndex: Int\n get() = this.size - 1\n\n/**\n * Returns `true` if the collection is not empty.\n * @sample samples.collections.Collections.Collections.collectionIsNotEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable collection is either null or empty.\n * @sample samples.collections.Collections.Collections.collectionIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || this.isEmpty()\n}\n\n/**\n * Returns this Collection if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Collections.collectionOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>?.orEmpty(): Collection<T> = this ?: emptyList()\n\n/**\n * Returns this List if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Lists.listOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()\n\n/**\n * Returns this collection if it's not empty\n * or the result of calling [defaultValue] function if the collection is empty.\n *\n * @sample samples.collections.Collections.Collections.collectionIfEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <C, R> C.ifEmpty(defaultValue: () -> R): R where C : Collection<*>, C : R =\n if (isEmpty()) defaultValue() else this\n\n\n/**\n * Checks if all elements in the specified collection are contained in this collection.\n *\n * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.\n * @sample samples.collections.Collections.Collections.collectionContainsAll\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)\n\n\n/**\n * Returns a new list with the elements of this list randomly shuffled\n * using the specified [random] instance as the source of randomness.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Iterable<T>.shuffled(random: Random): List<T> = toMutableList().apply { shuffle(random) }\n\n\ninternal fun <T> List<T>.optimizeReadOnlyList() = when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements,\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchOnComparable\n * @sample samples.collections.Collections.Lists.binarySearchWithBoundaries\n */\npublic fun <T : Comparable<T>> List<T?>.binarySearch(element: T?, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = compareValues(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the specified [comparator],\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted according to the specified [comparator].\n * @sample samples.collections.Collections.Lists.binarySearchWithComparator\n */\npublic fun <T> List<T>.binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparator.compare(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for an element having the key returned by the specified [selector] function\n * equal to the provided [key] value using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements.\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements with the specified [key], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element with the specified [key], if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchByKey\n */\npublic inline fun <T, K : Comparable<K>> List<T>.binarySearchBy(\n key: K?,\n fromIndex: Int = 0,\n toIndex: Int = size,\n crossinline selector: (T) -> K?\n): Int =\n binarySearch(fromIndex, toIndex) { compareValues(selector(it), key) }\n\n// do not introduce this overload --- too rare\n//public fun <T, K> List<T>.binarySearchBy(key: K, comparator: Comparator<K>, fromIndex: Int = 0, toIndex: Int = size(), selector: (T) -> K): Int =\n// binarySearch(fromIndex, toIndex) { comparator.compare(selector(it), key) }\n\n\n/**\n * Searches this list or its range for an element for which the given [comparison] function returns zero using the binary search algorithm.\n *\n * The list is expected to be sorted so that the signs of the [comparison] function's return values ascend on the list elements,\n * i.e. negative values come before zero and zeroes come before positive values.\n * Otherwise, the result is undefined.\n *\n * If the list contains multiple elements for which [comparison] returns zero, there is no guarantee which one will be found.\n *\n * @param comparison function that returns zero when called on the list element being searched.\n * On the elements coming before the target element, the function must return negative values;\n * on the elements coming after the target element, the function must return positive values.\n *\n * @return the index of the found element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchWithComparisonFunction\n */\npublic fun <T> List<T>.binarySearch(fromIndex: Int = 0, toIndex: Int = size, comparison: (T) -> Int): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparison(midVal)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Checks that `from` and `to` are in\n * the range of [0..size] and throws an appropriate exception, if they aren't.\n */\nprivate fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {\n when {\n fromIndex > toIndex -> throw IllegalArgumentException(\"fromIndex ($fromIndex) is greater than toIndex ($toIndex).\")\n fromIndex < 0 -> throw IndexOutOfBoundsException(\"fromIndex ($fromIndex) is less than zero.\")\n toIndex > size -> throw IndexOutOfBoundsException(\"toIndex ($toIndex) is greater than size ($size).\")\n }\n}\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkIndexOverflow(index: Int): Int\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkCountOverflow(count: Int): Int\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwIndexOverflow() { throw ArithmeticException(\"Index overflow has happened.\") }\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwCountOverflow() { throw ArithmeticException(\"Count overflow has happened.\") }\n\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Attack(val attacker: Argument, val target: Argument, val type: AttackType? = null, val on: Argument? = null) {\n override fun toString(): String {\n return \"attack(${type ?: \"none\"}, ${attacker.termRepresentation()}, ${target.termRepresentation()}, ${on?.termRepresentation() ?: \"none\"})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\ndata class Graph(val arguments: List<Argument>, val attacks: List<Attack>, val supports: List<Support>) {\n\n var labellings: List<LabelledArgument> = emptyList()\n\n companion object {\n fun of(labellings: List<LabelledArgument>, attacks: List<Attack>, supports: List<Support>) =\n Graph(labellings.map { it.argument }, attacks, supports).also {\n it.labellings = labellings\n }\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class LabelledArgument(val argument: Argument, val label: Label) {\n override fun toString(): String {\n return \"$label(${argument.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.parsing.parse\n\ninterface ArgItem {\n val identifier: RuleIdentifier\n val conclusion: Term\n\n fun toTerm(): it.unibo.tuprolog.core.Term {\n return Struct.parse(this.toString())\n }\n}\n\ndata class Premise(override val identifier: RuleIdentifier, override val conclusion: Term, val strict: Boolean = false) : ArgItem {\n override fun toString(): String {\n return \"premise([$identifier, $conclusion])\"\n }\n}\n\ndata class Rule(override val identifier: RuleIdentifier, val premises: List<Term>, override val conclusion: Term, val strict: Boolean = false) : ArgItem {\n override fun toString(): String {\n return \"rule([$identifier, $premises, $conclusion])\"\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Support(val supporter: Argument, val supported: Argument) {\n override fun toString(): String {\n return \"support(${supporter.termRepresentation()}, ${supported.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.sources.ArgumentationEngineInterface\n\nactual object EngineInterface : EngineInterfaceBase() {\n override val prologRawTheory: String\n get() = ArgumentationEngineInterface.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph\n\nactual object AbstractMode : AbstractModeBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.AbstractMode.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.builder\n\nactual object ArgumentationGraphBuilder : ArgumentationGraphBuilderBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.ArgumentationGraph.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object AttackRestrictionHandler : AttackRestrictionHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.AttackRestriction.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object BpMetaGraphHandler : BpMetaGraphHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Bp.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object DefeasiblePreferencesHandler : DefeasiblePreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.DefPreferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object GenericDefeasiblePreferencesHandler : GenericDefeasiblePreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.GenericDefPreferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object StrictPreferencesHandler : StrictPreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Preferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpCompleteLabeller : BpCompleteLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGroundedComplete.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpLabeller : BpLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGrounded.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpPartialLabeller : BpPartialLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGroundedPartial.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object CompleteLabeller : CompleteLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Complete.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object GroundedLabeller : GroundedLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Grounded.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object StatementLabeller : StatementLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.StatementLabelling.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.language\n\nimport it.unibo.tuprolog.argumentation.core.libs.sources.RuleTranslator\n\nactual object RuleParser : RuleParserBase() {\n override val prologRawTheory: String\n get() = RuleTranslator.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject AbstractMode {\n val theoryCode: String =\n \"\"\"\n computeGlobalAcceptance :-\n buildGraph,\n modifyGraph,\n buildArgumentLabelling,\n buildStatementLabelling.\n computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]) :-\n computeGlobalAcceptance,\n utils::recoverGraph(Arguments, Attacks, Supports),\n utils::recoverArgumentLabelling(ArgsIn, ArgsOut, ArgsUnd),\n utils::recoverStatementLabelling(StatIn, StatOut, StatUnd).\n buildGraph :-\n graphBuildMode(X),\n X:::buildArgumentationGraph.\n modifyGraph :-\n findall(X, graphExtension(X), Ext),\n modifyGraph(Ext).\n modifyGraph([]).\n modifyGraph([X|Ext]) :-\n modifyGraph(Ext),\n X:::modifyArgumentationGraph.\n buildArgumentLabelling :-\n argumentLabellingMode(X),\n X:::argumentLabelling.\n buildStatementLabelling :-\n statementLabellingMode(X),\n X:::statementLabelling.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject ArgumentationEngineInterface {\n val theoryCode: String =\n \"\"\"\n argTuProlog.\n buildLabelSets([StatIn, StatOut, StatUnd], [ArgsIn, ArgsOut, ArgsUnd]) :-\n context_reset,\n parser:::convertAllRules(_),\n abstract::computeGlobalAcceptance(_, [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]).\n buildLabelSets(StatIn, StatOut, StatUnd) :-\n buildLabelSets([StatIn, StatOut, StatUnd], _).\n buildLabelSets :-\n context_reset,\n parser:::convertAllRules(ArgRules),\n debug::printTheory(ArgRules),\n abstract::computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]),\n debug::printArgumentationGraph(Arguments, Attacks, Supports),\n debug::printArgumentLabelling([ArgsIn, ArgsOut, ArgsUnd]),\n debug::printStatementLabelling([StatIn, StatOut, StatUnd]).\n answerQuery(Goal, Yes, No, Und) :-\n context_reset,\n parser:::convertAllRules(_),\n structured:::computeStatementAcceptance(Goal, Yes, No, Und).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject ArgumentationGraph {\n val theoryCode: String =\n \"\"\"\n buildArgumentationGraph :-\n buildArguments,\n buildAttacks.\n buildArguments :-\n \tbuildArgumentsFromPremises,\n \tfindall([RuleID, RuleBody, RuleHead], context_check(rule([RuleID, RuleBody, RuleHead])), Rules),\n \tbuildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromPremises :-\n findall(\n _,\n (\n context_check(premise([PremiseID, Premise])),\n checkStrict(PremiseID, DefPrem),\n ground(Premise),\n context_assert(argument([[PremiseID], none, Premise, [], [[], [], DefPrem]]))\n ),\n _\n ).\n buildArgumentsFromRules(Rules, [], n).\n buildArgumentsFromRules(Rules, [], y) :- buildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromRules(Rules, [H|T], _) :-\n copy_term(H, HH),\n buildArgumentsFromRule(HH),\n buildArgumentsFromRules(Rules, T, y), !.\n buildArgumentsFromRules(Rules, [_|T], X) :-\n buildArgumentsFromRules(Rules, T, X).\n buildArgumentsFromRule([RuleID, RuleBody, RuleHead]) :-\n \truleBodyIsSupported(RuleBody, [], [], SupportRules, ArgSupports),\n \t\\+ member(RuleID, SupportRules),\n \tground(RuleHead),\n \tutils::sort([RuleID|SupportRules], SortedPremises),\n \t\\+ context_check(argument([SortedPremises, RuleID, RuleHead, RuleBody, _])),\n \tbuildArgumentInfo(ArgSupports, RuleID, Info),\n NewArgument = [SortedPremises, RuleID, RuleHead, RuleBody, Info],\n \tcontext_assert(argument(NewArgument)),\n \tsupports(NewArgument, ArgSupports).\n supports(Argument, Supports) :-\n findall(_, (\n member(S, Supports),\n context_assert(support(S, Argument))\n ), _).\n checkStrict(Id, [Id]) :- \\+ context_check(strict(Id)).\n checkStrict(Id, []) :- context_check(strict(Id)).\n buildArgumentInfo(Supports, RuleId, [LastDefRules, DefRules, DefPrem]) :-\n defeasibleRules(RuleId, Supports, DefRules),\n ordinaryPremises(Supports, DefPrem),\n lastDefeasibleRules(Supports, RuleId, LastDefRules).\n ordinaryPremises(Supports, DefPrem) :-\n findall(Def, member([_, _, _, _, [_, _, Def]], Supports), Prem),\n utils::appendLists(Prem, TempPrem),\n utils::sortDistinct(TempPrem, DefPrem).\n defeasibleRules(RuleId, Supports, DefRules) :-\n \tfindall(Def, member([_, _, _, _, [_, Def, _]], Supports), UnsortedRules),\n \tcheckStrict(RuleId, DefRule),\n \tutils::appendLists([DefRule|UnsortedRules], TempRules),\n \tutils::sortDistinct(TempRules, DefRules).\n lastDefeasibleRules(_, TopRule, [TopRule]) :-\n TopRule \\== none, \\+ context_check(strict(TopRule)).\n lastDefeasibleRules(Supports, TopRule, LastRules) :-\n \tcontext_check(strict(TopRule)),\n \tfindall(Def, member([_, _, _, _, [Def, _, _]], Supports), Res),\n \tutils::appendLists(Res, TempLastRules),\n \tutils::sortDistinct(TempLastRules, LastRules).\n ruleBodyIsSupported([], ResultPremises, ResultSupports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [unless, _] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [prolog(Check)] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \t(callable(Check) -> call(Check); Check),\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([Statement|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n context_check(argument([ArgumentID, RuleID, Statement, Body, Info])),\n \tappend(ArgumentID, Premises, NewPremises),\n \truleBodyIsSupported(Others, NewPremises, [[ArgumentID, RuleID, Statement, Body, Info]|Supports], ResultPremises, ResultSupports).\n buildAttacks :-\n findall(X, context_check(argument(X)), Args),\n \tbuildDirectAttacks(Args),\n \tbuildTransitiveAttacks.\n buildDirectAttacks([]).\n buildDirectAttacks([H|T]) :-\n findall(_, buildDirectAttack(H), _),\n buildDirectAttacks(T).\n buildDirectAttack(A) :-\n \tcontext_check(argument(B)),\n \tA \\== B,\n attacks(T, A, B),\n \t\\+ context_check(attack(T, A, B, B)),\n \tcontext_assert(attack(T, A, B, B)).\n buildTransitiveAttacks :-\n \tcontext_check(attack(T, A, B, D)),\n \tcontext_check(support(B, C)),\n \t\\+ context_check(attack(T, A, C, D)), !,\n \tcontext_assert(attack(T, A, C, D)),\n buildTransitiveAttacks.\n buildTransitiveAttacks.\n attacks(rebut, A, B) :- rebuts(A, B), !.\n attacks(contrary_rebut, A, B) :- contraryRebuts(A, B), !.\n attacks(undermine, A, B) :- undermines(A, B), !.\n attacks(contrary_undermine, A, B) :- contraryUndermines(A, B), !.\n attacks(undercut, A, B) :- undercuts(A, B), !.\n rebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, _, Info]) :-\n \tRuleB \\== none,\n Info \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryRebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleA \\== none,\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undermines([IDPremisesA, RuleA, RuleHeadA, _, _], [[IDPremiseB], none, RuleHeadB, _, Info]) :-\n \tInfo \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryUndermines([IDPremisesA, none, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undercuts([_, _, [undercut(RuleB)], _, _], [_, RuleB, _, _, [[RuleB], _, _]]).\n conflict( [Atom], [neg, Atom]).\n conflict( [neg, Atom], [Atom]).\n conflict( [obl, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, Lit], [neg, obl, Lit]).\n conflict( [neg, obl, Lit], [obl, Lit]).\n conflict( [perm, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [perm, [Atom]]).\n conflict( [perm, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, [Atom]], [perm, [neg, Atom]]).\n conflict([bp, Atom], [neg, bp, Atom]).\n conflict([neg, bp, Atom], [bp, Atom]).\n conflict([sup(X, Y)], [sup(Y, X)]).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject AttackRestriction {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkRebutRestriction(T, A, B, C)\n ), _).\n checkRebutRestriction(T, A, B, C) :-\n \\+ rebutRestriction(T, A, B, C),\n context_retract(attack(T, A, B, C)).\n rebutRestriction(rebut, _, _, C) :- restrict(C).\n rebutRestriction(undermine, _, _, C).\n rebutRestriction(contrary_rebut, _, _, _).\n rebutRestriction(contrary_undermine, _, _, _).\n rebutRestriction(undercut, _, _, _).\n restrict([_, TopRule, _, _, [[TopRule], _, _]]) :- TopRule \\== none.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Bp {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(([Rules, Top, [bp, Checked], G, I], [Z, P, Y, GG, II]), (\n context_check(argument([Rules, Top, [bp, Checked], G, I])),\n member(Y, Checked),\n context_check(argument([Z, P, Y, GG, II]))\n ), TemplateBpPairs),\n checkBpArguments(TemplateBpPairs).\n checkBpArguments([]).\n checkBpArguments(TemplateBpPairs) :-\n createBpArguments(TemplateBpPairs, BpPairs),\n createBpAttacks(BpPairs).\n createBpArguments([], []).\n createBpArguments([(Original, [Z, P, Y, B, I])|Others], [(Conflict, [Z, P, Y, B, I])|BpPairs]) :-\n Conflict = [[artificial|Z], artificial, [neg, burdmet(Y)], [], [[artificial], [artificial], []]],\n context_assert(argument(Conflict)),\n context_assert(support(Original, Conflict)),\n liftBpAttacks(Original, Conflict),\n createBpArguments(Others, BpPairs).\n liftBpAttacks(Template, BpArg) :-\n findall(_, (\n context_check(attack(T, A, Template, O)),\n context_assert(attack(T, A, BpArg, O))\n ), _).\n createBpAttacks(BpPairs) :-\n generateBpsEvaluationChain(BpPairs, OrderedBpPairs),\n evaluateBurdenedArgs(OrderedBpPairs).\n generateBpsEvaluationChain([], []).\n generateBpsEvaluationChain([BpPair|BpPairs], OrderedBpPairs) :-\n generateBpsEvaluationChain(BpPairs, TempOrderedBpPairs),\n insertBpPair(BpPair, TempOrderedBpPairs, OrderedBpPairs).\n insertBpPair(BpPair, [], [BpPair]).\n insertBpPair((Bp, Burdened), [(BpL, BurdenedL)|Others], [(BpL, BurdenedL)|Return]) :-\n bp_grounded::argumentChain(BurdenedL, Burdened),\n insertBpPair((Bp, Burdened), Others, Return), !.\n insertBpPair((Bp, Burdened), [(BpL, BurdenedL)|Others], [(Bp, Burdened)|[(BpL, BurdenedL)|Others]]).\n evaluateBurdenedArgs([]).\n evaluateBurdenedArgs([(Bp, Burdened)|Others]) :-\n context_active(X),\n grounded:::argumentLabelling,\n statusToAttack((Bp, Burdened), Attack),\n context_checkout(X),\n context_assert(Attack),\n evaluateBurdenedArgs(Others).\n statusToAttack((Bp, Burdened), attack(bprebut, Burdened, Bp, Bp)) :-\n context_check(in(Burdened)).\n statusToAttack((Bp, Burdened), attack(bprebut, Bp, Burdened, Burdened)) :-\n \\+ context_check(in(Burdened)).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGrounded {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n reifyBurdenOfProofs,\n filterBpDefeats,\n findall(X, context_check(argument(X)), Arguments),\n bpLabelling(Arguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n grounded::allAttacksOUT(A), !,\n context_assert(in(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n \\+ isArgumentInBurdenOfProof(A),\n grounded::oneAttackIN(A), !,\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n context_active(Branch),\n mostGroundedBpUnd(Arguments, A),\n context_branch(Branch, _),\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Args) :-\n notLabelled(Args),\n findall(_, (member(A, Args), context_assert(und(A))), _).\n notLabelled(Args) :-\n \\+ (\n member(A, Args),\n (\n context_check(in(A));\n context_check(out(A));\n context_check(und(A))\n )\n ).\n isInBurdenOfProof(Conclusion) :-\n context_check(reifiedBp(Literals)),\n member(Conclusion, Literals), !.\n isArgumentInBurdenOfProof([_, _, Conclusion, _, _]) :-\n isInBurdenOfProof(Conclusion).\n filterBpDefeats :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n filterBpDefeat(T, A, B, C)\n ), _).\n filterBpDefeat(T, B, A, C) :-\n (T = rebut; T = undermine),\n isArgumentInBurdenOfProof(B),\n \\+ superiority::superiorArgument(B, C),\n context_retract(attack(T, B, A, C)).\n mostGroundedBpUnd(Arguments, Arg) :-\n member(Arg, Arguments),\n isArgumentInBurdenOfProof(Arg),\n \\+ (\n member(A, Arguments), Arg \\= A,\n isArgumentInBurdenOfProof(A),\n argumentChain(A, Arg)\n ).\n argumentChain(A, A) :- !.\n argumentChain(A, B) :-\n A \\== B,\n context_check(attack(_, A, C, _)),\n argumentChain(C, B).\n reifyBurdenOfProofs :-\n findall(_, (\n context_check(abstractBp(AbstractBp)),\n fillTemplate(AbstractBp, R),\n \\+ context_check(reifiedBp(R)),\n context_assert(reifiedBp(R))\n ), _).\n /*\n Fill the template (first parameter) using arguments conclusions\n */\n fillTemplate([], []).\n fillTemplate([H|T], [H|R]) :-\n context_check(argument([_, _, Conclusion, _, _])),\n fillTemplate(T, R).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGroundedComplete {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n bp_grounded::reifyBurdenOfProofs,\n findall(X, context_check(argument(X)), Arguments),\n completeBpLabelling(go, Arguments).\n completeBpLabelling(stop, _).\n completeBpLabelling(go, Arguments) :-\n bp_grounded_partial::partialBpLabelling(Arguments), !,\n findall(X, (context_check(und(X)), context_retract(und(X))), NewArgs),\n grounded::groundedLabelling(NewArgs),\n findall(X, context_check(und(X)), LeftArguments),\n stopCondition(Stop, Arguments, LeftArguments),\n completeBpLabelling(Stop, LeftArguments).\n stopCondition(stop, Args, NewArgs) :-\n utils::sort(Args, SortedArgs),\n utils::sort(NewArgs, SortedArgs), !.\n stopCondition(go, _, _) :- context_retract(und(_)).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGroundedPartial {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n bp_grounded::reifyBurdenOfProofs,\n findall(X, context_check(argument(X)), Arguments),\n partialBpLabelling(Arguments), !.\n partialBpLabelling([]).\n partialBpLabelling(Arguments) :-\n mostGroundedArgument(Arguments, A),\n debug::writeDebug(['Evaluating ', A]),\n demonstration(Arguments, A, [A], Evaluated),\n utils::subtract(Arguments, [Evaluated], NewArgs),\n partialBpLabelling(NewArgs).\n /*\n (a.i) BP(neg(\u03c6)), and no argument B for neg(\u03c6) such that A < B is IN*, and no A1,...An is OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tisComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n \t superiorComplementArgument(A, B),\n \t context_check(in(B))\n \t),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \t\\+ (\n \t context_check(support(X, A)),\n \t context_check(out(X))\n \t),\n \tdebug::writeDebug(['Adding argument: ', A, ' to IN* (2.a.i)']),\n context_assert(in(A)).\n /*\n (a.ii) not BP(neg(\u03c6)) and every argument B for neg(\u03c6) such that B(not <)A is OUT*, and every A1,...An is IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ isComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorOrEqualComplementArgument(A, B),\n \\+ context_check(out(B))\n ),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \t\\+ (\n context_check(support(X, A)),\n \\+ context_check(in(X))\n ),\n \tdebug::writeDebug(['Adding argument: ', A, ' to IN* (2.a.ii)']),\n context_assert(in(A)).\n /*\n (b.i.1) BP(\u03c6) and exists an argument B for neg(\u03c6) such that B(not <)A is not OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \tsuperiorOrEqualComplementArgument(A, B),\n \t\\+ context_check(out(B)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.i.1)']),\n context_assert(out(A)).\n /*\n (b.i.2) BP(\u03c6) and exist one of A1,...An is not IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \tcontext_check(support(X, A)),\n \\+ context_check(in(X)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.i.2)']),\n context_assert(out(A)).\n /*\n (b.ii.1) not BP(\u03c6) and an argument B for neg(\u03c6) such A < B is IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \tsuperiorComplementArgument(A, B),\n \tcontext_check(in(B)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.ii.1)']),\n context_assert(out(A)).\n /*\n (b.ii.2) not BP(\u03c6) and one of A1,...An is OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \tcontext_check(support(X, A)),\n context_check(out(X)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.ii.2)']),\n context_assert(out(A)).\n /*\n If above definitions do not apply try to decide on the arguments on which they depend\n */\n demonstration(Arguments, A, Resolving, Evaluated) :-\n isComplementInBurdenOfProof(A),\n \tnotEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tisComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorComplementArgument(A, X),\n context_check(in(X))\n ),\n notEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \\+ isComplementInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ isComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorOrEqualComplementArgument(A, X),\n \\+ context_check(out(X))\n ),\n notEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n /*\n (c) A is labelled UND* otherwise.\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tdebug::writeDebug(['Adding argument: ', A, ' to UND* (2.c)']),\n context_assert(und(A)).\n isComplementInBurdenOfProof(A) :-\n complement(A, Complement),\n bp_grounded::isInBurdenOfProof(Complement), !.\n mostGroundedArgument([], []).\n mostGroundedArgument([X], X).\n mostGroundedArgument([[L, _, _, _, _]|T], [L2, Q2, W2, B2, I2]) :-\n mostGroundedArgument(T, [L2, Q2, W2, B2, I2]),\n length(L, LN1),\n length(L2, LN2),\n LN1 > LN2, !.\n mostGroundedArgument([A|_], A).\n /*\n Get a conclusion complement\n */\n complement([_, _, Conclusion, _, _], A) :-\n standard_af::conflict(Conclusion, A).\n notEvaluatedSubArgument(Arguments, A, Resolving, B) :-\n context_check(support(B, A)),\n member(B, Arguments),\n \\+ member(B, Resolving).\n notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, B) :-\n superiorComplementArgument(A, B),\n member(B, Arguments),\n \\+ member(B, Resolving).\n notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B) :-\n superiorOrEqualComplementArgument(A, B),\n member(B, Arguments),\n \\+ member(B, Resolving).\n superiorComplementArgument(A, [A, B, CA, BB, I]) :-\n complement(A, CA),\n context_check(argument([R, B, CA, BB, I])),\n superiority::superiorArgument([R, B, CA, BB, I], A).\n superiorOrEqualComplementArgument(A, [R, B, CA, BB, I]) :-\n complement(A, CA),\n context_check(argument([R, B, CA, BB, I])),\n \\+ superiority::superiorArgument(A, [R, B, CA, BB, I]).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Complete {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n cache_retract(complete(_,_,_)),\n grounded:::argumentLabelling,\n context_active(Branch),\n completeLabelling(Branch).\n completeLabelling(_) :-\n admissibleSet,\n utils::recoverArgumentLabelling(In, Out, Und),\n \\+ cache_check(complete(In, Out, Und)),\n cache_assert(complete(In, Out, Und)).\n completeLabelling(Branch) :-\n context_check(und(X)),\n context_branch(Branch, NewBranch),\n findall(Y, (context_check(und(Y)), Y \\= X), Arguments),\n context_retract(und(_)),\n context_assert(in(X)),\n grounded::groundedLabelling(Arguments),\n completeLabelling(NewBranch).\n admissibleSet :-\n \\+ (context_check(in(H)), \\+ admissible(H)).\n admissible(H) :-\n \\+ (\n context_check(attack(_, Attacker, H, _)),\n \\+ (\n context_check(attack(_, Defendant, Attacker, _)),\n context_check(in(Defendant))\n )\n ).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Debug {\n val theoryCode: String =\n \"\"\"\n printTheory(Rules) :-\n write('HERE THE THEORY:'),nl,\n findall(rule([Id, Body, Head]), member(rule([Id, Body, Head]), Rules), ListRules),\n utils::writeListNl(ListRules),\n findall(premise([A, B]), member(premise([A, B]), Rules), ListPremises),\n utils::writeListNl(ListPremises),\n findall(sup(A, B), member(sup(A, B), Rules), ListSups),\n utils::writeListNl(ListSups).\n printArgumentationGraph(Arguments, Attacks, Supports) :-\n \tfindall(\n \t [IDPremises, '\\n', ' TOPRULE ', TopRule, '\\n', ' CONCLUSION ', RuleHead, '\\n', ' BODY ', Body, '\\n', ' INFO ', Info, '\\n'],\n \t member([IDPremises, TopRule, RuleHead, Body, Info], Arguments),\n ArgumentsToPrint\n ),\n findall((A1, ' SUPPORTS ', A2), member((A1, A2), Supports), SupportsToPrint),\n \tfindall((A1, ' ', T, ' ', A2, ' ON ', A3), member((T, A1, A2, A3), Attacks), AttacksToPrint),\n write('HERE THE GROUNDED SEMI-ABSTRACT ARGUMENTATION GRAPH'),nl,\n \tutils::writeListNl(ArgumentsToPrint),\n \tutils::writeListNl(SupportsToPrint),\n \tutils::writeListNl(AttacksToPrint).\n printArgumentLabelling([IN, OUT, UND]) :-\n write('HERE THE ARGUMENTS LABELLED IN: '),nl,\n utils::writeListNl(IN),\n write('HERE THE ARGUMENTS LABELLED OUT: '),nl,\n utils::writeListNl(OUT),\n write('HERE THE ARGUMENTS LABELLED UND: '),nl,\n utils::writeListNl(UND).\n printStatementLabelling([In, Ni, Und]) :-\n write('HERE THE STATEMENTS LABELLED IN: '),nl,\n utils::writeListNl(In),\n write('HERE THE STATEMENTS LABELLED NI: '),nl,\n utils::writeListNl(Ni),\n write('HERE THE STATEMENTS LABELLED UND: '),nl,\n utils::writeListNl(Und).\n debug.\n writeDebug(List) :-\n debug,\n utils::writeList(List).\n writeDebug(_) :- \\+ debug.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject DefPreferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n assertAllSup,\n findall((T, A, B, C), context_check(attack(T, A, B, C)), Attacks),\n filterSupRelatedAttacks(Attacks, InvalidAttacks),\n convertAttacks(InvalidAttacks),\n buildPrefAttacks.\n assertAllSup :-\n context_retract(sup(_, _)),\n findall(_,\n (\n context_check(argument([_, _, [sup(RuleOne, RuleTwo)], _, _])),\n \\+ context_check(sup(RuleOne, RuleTwo)),\n context_assert(sup(RuleOne, RuleTwo))\n ),\n _).\n filterSupRelatedAttacks([], []).\n filterSupRelatedAttacks([(T, A, B, C)|Attacks], [(T, A, B, C)|Invalid]) :-\n invalid(T, A, B, C, _),\n filterSupRelatedAttacks(Attacks, Invalid), !.\n filterSupRelatedAttacks([_|Attacks], Invalid) :-\n filterSupRelatedAttacks(Attacks, Invalid).\n invalid(rebut, A, B, C, SupSet) :- superiority::superiorArgument(C, A, SupSet), !.\n invalid(undermine, A, B, C, SupSet) :- superiority::superiorArgument(C, A, SupSet), !.\n /*\n * Translates the attack relations identified during the building phase.\n * Attack from A to B -> Argument [[], attack, Attack]\n * support(A, Argument)\n * attack(Argument, B)\n * If an Argument A built in this way attacks the argument B, and this one also attacks a third argument C\n * through the argument B1 we have to consider an attack from A to B1 (transitive attack)\n */\n convertAttacks(Attacks) :-\n conversion(Attacks),\n standard_af::buildTransitiveAttacks.\n conversion(List) :-\n member((T, A, B, B), List),\n generateDirectAttackArgument(T, A, B, B),\n fail.\n conversion(List) :-\n member((T, A, B, C), List),\n C \\= B,\n generateTransitiveAttackArgument(T, A, B, C),\n fail.\n conversion(_).\n generateTransitiveAttackArgument(T, A, B, C) :-\n context_check(argument([Id, attack, [attack(T, A, C, C)], G, I])),\n context_assert(attack(T, [Id, attack, [attack(T, A, C, C)], G, I], B, C)),\n context_retract(attack(T, A, B, C)).\n generateDirectAttackArgument(T, A, B, B) :-\n RArgument = [[attack], attack, [attack(T, A, B, B)], [], [[attack], [attack], []]],\n \\+ context_check(argument(RArgument)),\n context_assert(argument(RArgument)),\n context_assert(support(A, RArgument)),\n context_assert(attack(T, RArgument, B, B)),\n context_retract(attack(T, A, B, B)).\n /*\n * Computes the pref attack. If an Argument A has a conclusion in the form sup(a, b), we verify if\n * the attacks involving arguments built on the rules a or b are compatible with this preference.\n * If there are some contradictions we add an attack from the argument A towards the incompatible attack\n */\n buildPrefAttacks :-\n context_check(argument([IdB, attack, [attack(T, A, B, C)], G, I])),\n invalid(T, A, B, C, SupSet),\n member(X, SupSet),\n context_check(argument([IdA, TRA, [X], GG, II])),\n Attack = attack(pref, [IdA, TRA, [X], GG, II], [IdB, attack, [attack(T, A, B, C)], G, I], [IdB, attack, [attack(T, A, B, C)], G, I]),\n \\+ context_check(Attack),\n context_assert(Attack),\n fail.\n buildPrefAttacks.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject GenericDefPreferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n defeasiblePref::assertAllSup,\n findall((T, A, B, C), context_check(attack(T, A, B, C)), Attacks),\n defeasiblePref::filterSupRelatedAttacks(Attacks, InvalidAttacks),\n defeasiblePref::convertAttacks(InvalidAttacks),\n buildPrefAttacks,\n standard_af::buildTransitiveAttacks.\n buildPrefAttacks :-\n context_check(argument([IdB, attack, [attack(T, A, B, C)], G, I])),\n defeasiblePref::invalid(T, A, B, C, SupSet),\n createSuperiorityArgument(SupSet, Arg),\n write(Arg), nl,\n Attack = attack(pref, Arg, [IdB, attack, [attack(T, A, B, C)], G, I], [IdB, attack, [attack(T, A, B, C)], G, I]),\n \\+ context_check(Attack),\n context_assert(Attack),\n fail.\n buildPrefAttacks.\n createSuperiorityArgument(SupSet, Argument) :-\n findall([Id, TR, [X], G, I], (\n member(X, SupSet),\n context_check(argument([Id, TR, [X], G, I]))\n ), SupportArguments),\n mergeIds(SupportArguments, MergedId),\n Argument = [MergedId, pref, [mergedPreference], [], [[pref], MergedId, []]],\n \\+ context_check(argument(Argument)),\n context_assert(argument(Argument)),\n findall(_, (\n member(A, SupportArguments),\n \\+ context_check(support(A, Argument)),\n context_assert(support(A, Argument))\n ), _).\n mergeIds([], [pref]).\n mergeIds(Arguments, [pref|MergedId]) :-\n findall(Id, member([Id, _, _, _, _], Arguments), Res),\n utils::appendLists(Res, MergedId).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Grounded {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n findall(X, context_check(argument(X)), Arguments),\n groundedLabelling(Arguments).\n groundedLabelling(UND) :-\n member(A, UND), \n allAttacksOUT(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(in(A)),\n groundedLabelling(NewUND).\n groundedLabelling(UND) :-\n member(A, UND),\n oneAttackIN(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(out(A)),\n groundedLabelling(NewUND).\n groundedLabelling(Args) :- findall(_, (member(A, Args), context_assert(und(A))), _).\n allAttacksOUT(A) :-\n \\+ ( context_check(attack(_, B, A, _)), \\+ (context_check(out(B)))).\n oneAttackIN(A) :-\n context_check(attack(_, B, A, _)),\n context_check(in(B)), !.\n oneAttackIN(A) :-\n context_check(attack(_, A, B, _)),\n context_check(in(B)), !.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Preferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkStandardPreference(T, A, B, C)\n ), _).\n checkStandardPreference(T, A, B, C) :-\n \\+ standardPreferences(T, A, B, C),\n context_retract(attack(T, A, B, C)).\n standardPreferences(rebut, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(undermine, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(contrary_rebut, _, _, _).\n standardPreferences(contrary_undermine, _, _, _).\n standardPreferences(undercut, _, _, _).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject QueryMode {\n val theoryCode: String =\n \"\"\"\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n \\+ queryMode,\n abstract:::computeGlobalAcceptance,\n mineResults(Goal, YesResult, NoResult, UndResult).\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n queryMode,\n argumentLabellingMode(grounded),\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(_, query(X, _), _),\n (ambiguityBlocking ->\n statement_binary:::statementLabelling;\n statementLabellingMode(Y),\n Y:::statementLabelling\n ),\n mineResults(Goal, YesResult, NoResult, UndResult).\n mineResults(Goal, YesResult, NoResult, UndResult) :-\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(Goal, context_check(statIn(X)), In),\n findall(Goal, context_check(statOut(X)), Out),\n findall(Goal, context_check(statUnd(X)), Und),\n utils::sort(In, YesResult),\n utils::sort(Out, NoResult),\n utils::sort(Und, UndResult).\n query(Query, Res) :-\n buildArgument(Query, Argument),\n once(defend(Argument, [], Res)).\n query(Query, und) :- \\+ buildArgument(Query, _).\n defend(Argument, _, no) :- context_check(out(Argument)).\n defend(Argument, _, und) :- context_check(und(Argument)).\n defend(Argument, _, yes) :- context_check(in(Argument)).\n defend(Argument, QueryChain, no) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == yes,\n bufferResult(Argument, no), !.\n defend(Argument, QueryChain, Res) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == und,\n ambiguityCheck(Argument, Attacker, Res),\n bufferResult(Argument, Res), !.\n complementary([_, _, ConclusionA, _, _], [_, _, ConclusionB, _, _]) :-\n standard_af::conflict(ConclusionA, ConclusionB).\n ambiguityCheck(A, B, no) :- ambiguityBlocking,\n \\+ complementary(A, B),\n context_check(attack(direct, B, A, _)), !.\n ambiguityCheck(_, _, und).\n defend(Argument, QueryChain, und) :-\n findAttacker(Argument, QueryChain, Attacker, no),\n bufferResult(Argument, und), !.\n defend(Argument, QueryChain, yes) :- bufferResult(Argument, yes).\n bufferResult(Argument, no) :- \\+ context_check(out(Argument)), context_assert(out(Argument)), !.\n bufferResult(Argument, yes) :- \\+ context_check(in(Argument)), context_assert(in(Argument)), !.\n bufferResult(Argument, und) :- \\+ context_check(und(Argument)), context_assert(und(Argument)), !.\n bufferResult(_, _).\n findAttacker(Target, QueryChain, Attacker, IsValid) :-\n attacker(Target, Attacker, Type),\n bufferAttacker(Attacker, Target, Type),\n detectCycle(Attacker, QueryChain, IsValid).\n bufferAttacker(Attacker, Target, Type) :-\n \\+ context_check(attack(Type, Attacker, Target, none)),\n context_assert(attack(Type, Attacker, Target, none)), !.\n bufferAttacker(_, _, _).\n detectCycle(Attacker, QueryChain, yes) :- \\+ member(Attacker, QueryChain).\n detectCycle(Attacker, QueryChain, no) :- member(Attacker, QueryChain).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Rules),\n \\+ context_check(strict(X)),\n attackerOnRule(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Groundings),\n attackerOnTerm(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attackerOnRule(Rule, _, Argument, undercut) :-\n buildArgument([undercut(Rule)], Argument).\n attackerOnTerm(Term, [TargetRules, TopRule, Conclusion, Groundings, ArgInfo], Attacker, direct) :-\n Term \\= [unless, _],\n \\+ strict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]),\n (graphExtension(rebutRestriction) ->\n (\n buildSubArgument(Term, TargetRules, SubArgument),\n rebutRestriction(SubArgument)\n );\n true\n ),\n standard_af::conflict(Term, X),\n buildArgument(X, Attacker),\n (graphExtension(standardPref) ->\n (ground(SubArgument) ->\n true;\n buildSubArgument(Term, TargetRules, SubArgument)\n ),\n \\+ superiorArgument(SubArgument, Attacker);\n true\n ).\n attackerOnTerm([unless, X], _, Attacker, contrary) :-\n buildArgument(X, Attacker).\n strict([_, _, _, _, [_, [], []]]).\n rebutRestriction([TargetRules, none, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction).\n rebutRestriction([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction),\n TopRule \\= none,\n rebutRestriction::restrict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]).\n rebutRestriction(_) :- \\+ graphExtension(rebutRestriction).\n superiorArgument(SubArgument, Attacker) :-\n superiority::superiorArgument(SubArgument, Attacker).\n buildSubArgument(Term, Rules, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]) :-\n buildArgument(Term, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]),\n contained(SubRules, Rules).\n contained([], _).\n contained([H|T], Target) :- member(H, Target), contained(T, Target).\n buildArgument(Query, Argument) :-\n \\+ context_check(explored(Query)),\n findall(_, (\n buildSingleArgument(Query, Argument),\n context_assert(argument(Argument))\n ), _),\n context_assert(explored(Query)),\n fail.\n buildArgument(Query, [R, T, Query, B, I]) :- context_check(argument([R, T, Query, B, I])).\n buildSingleArgument(Query, Argument) :-\n build(Query, Groundings, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n utils::deduplicate(DefRules, CDefRules),\n utils::deduplicate(DefPremises, CDefPremises),\n utils::deduplicate(Groundings, CGroundings),\n Argument = [AllRules, TopRule, Query, CGroundings, [LastDefRules, CDefRules, CDefPremises]].\n build(Conclusion, [Conclusion], Rules) :-\n context_check(premise([Id, Conclusion])),\n premiseRules(Id, Rules).\n build(Conclusion, [Conclusion|Conclusions], Rules) :-\n context_check(rule([Id, Premises, Conclusion])),\n buildPremises(Premises, Conclusions, ResRules),\n ruleRules(Id, ResRules, Rules).\n build([prolog(Check)], [], []) :- (callable(Check) -> call(Check); Check).\n build([unless, Atom], [[unless, Atom]], []).\n buildPremises([], [], [[], [], [], []]).\n buildPremises([H|T], Conclusions, Rules) :-\n build(H, HConclusions, HRules),\n buildPremises(T, TConclusions, TRules),\n utils::appendLists([HConclusions, TConclusions], Conclusions),\n mergeRules(HRules, TRules, Rules).\n premiseRules(Id, [[Id], none, [], [], [Id]]) :- \\+ context_check(strict(Id)).\n premiseRules(Id, [[Id], none, [], [], []]) :- context_check(strict(Id)).\n ruleRules(Id, [AllRules, _, DefRules, DefPremises], \n [[Id|AllRules], Id, [Id], [Id|DefRules], DefPremises]) :- \\+ context_check(strict(Id)).\n ruleRules(Id, [AllRules, LastDefRules, DefRules, DefPremises], \n [[Id|AllRules], Id, LastDefRules, DefRules, DefPremises]) :- context_check(strict(Id)).\n mergeRules([], [AllRules, LastDefRules, DefRules, DefPremises], [AllRules, LastDefRules, DefRules, DefPremises]).\n mergeRules([HAR, _, HLDR, HDR, HDP], [TAR, TLDR, TDR, TDP], [AR, LDR, DR, DP]) :-\n utils::appendLists([HAR, TAR], AR),\n utils::appendLists([HLDR, TLDR], LDR),\n utils::appendLists([HDR, TDR], DR),\n utils::appendLists([HDP, TDP], DP).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject RuleTranslator {\n val theoryCode: String =\n \"\"\"\n /*\n * Main directive. Find all the rules in the theory in the format (Name : Preconditions => Conclusion)\n * or (Name : Effects) and then if:\n * - It is a standard rule, translate it in the standard format (rule([Name, Preconditions, Conclusions]));\n * - It is a bp rule, translate it to (abstractBp([Effects]))\n * During the process, clean them from the unallowed symbols (-, o, p).\n */\n convertAllRules(ArgRules) :-\n defeasibleRules(DefeasibleRules),\n strictRules(StrictRules, RulesIds),\n ordinaryPremises(Premises),\n axiomPremises(Axioms, AxiomsIds),\n specialRules(SpecialRules),\n utils::appendLists([DefeasibleRules, StrictRules, Premises, Axioms, SpecialRules], L),\n convertAllRules(L, Rules), !,\n findall(sup(X, Y), sup(X, Y), Sups),\n utils::appendLists([Rules, AxiomsIds, RulesIds, Sups], ArgRules),\n findall(_, (member(X, ArgRules), context_assert(X)), _).\n defeasibleRules(DefeasibleRules) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions => Effect), DefeasibleRulesOld),\n prologDefeasibleRules(DefeasibleRulesNew),\n append(DefeasibleRulesOld, DefeasibleRulesNew, DefeasibleRules).\n strictRules(CtrRules, Ids) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions -> Effect), StrictRulesOld),\n prologStrictRules(StrictRulesNew),\n append(StrictRulesOld, StrictRulesNew, StrictRules),\n transpose(StrictRules, StrictRules, CtrRules),\n findall(strict(RN), member([RN, _, _], CtrRules), Ids).\n ordinaryPremises(Premises) :-\n findall([RuleName, Effect], ((RuleName :=> Effect), atom(RuleName)), PremisesOld),\n prologPremises(PremisesNew),\n append(PremisesOld, PremisesNew, Premises).\n axiomPremises(Axioms, Ids) :-\n findall([RuleName, Effect], ((RuleName :-> Effect), atom(RuleName)), AxiomsOld),\n prologAxioms(AxiomsNew),\n append(AxiomsOld, AxiomsNew, Axioms),\n findall(strict(RN), member([RN, _], Axioms), Ids).\n specialRules(SpecialRules) :-\n bpsNew(SpecialRules).\n transpose(_, CtrRules, CtrRules) :- \\+ autoTransposition. \n transpose([], CtrRules, CtrRules).\n transpose([H|T], TempCtrRules, CtrRules) :-\n transpose(T, TempCtrRules, CR),\n findall(TrH, transposition(H, TrH), Tran),\n mergeCtrRules(CR, Tran, CtrRules).\n mergeCtrRules(All, ToMerge, X) :-\n append(All, ToMerge, XT),\n deduplicate(XT, X).\n deduplicate([], []).\n deduplicate([[RN,A,B]|T], X) :- deduplicate(T, TT), (member([RN,_,_], TT) -> X = TT; X = [[RN,A,B]|TT]). \n transposition([Id, Prec, Effect], [Id, Prec, Effect]).\n transposition([Id, Prec, Effect], [NewId, NewPrec ,XNegated]) :-\n compound(Prec),\n tuple_to_list(Prec, LPrec),!,\n transposition_sequential(LPrec, LPrec, Effect, Id, [], NewPrec, XNegated, NewId).\n transposition([Id, Prec, Effect], [NewId, EffectNegated ,XNegated]) :-\n \\+ compound(Prec),\n Prec \\== [],\n prologEscape(Prec),\n negate(Prec, XNegated),\n negate(Effect, EffectNegated),\n atom_concat(Id, '_i', NewId).\n transposition_sequential(LPrec, [H|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n transposition_sequential(LPrec, T, Effect, Id, [H|Skipped], NewPrec, XNegated, NewId).\n transposition_sequential(LPrec, [X|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n prologEscape(X),\n append(Skipped, T, CleanedPrec),\n negate(X, XNegated),\n negate(Effect, EffectNegated),\n list_to_tuple([EffectNegated|CleanedPrec], NewPrec),\n newIdentifier(Skipped, Id, NewId).\n newIdentifier(List, OldId, NewId) :-\n modifier(List, Mod),\n atom_concat(OldId, Mod, NewId).\n modifier([], '_i').\n modifier([_|Tail], Index):-\n modifier(Tail, Index1),\n atom_concat(Index1, 'i', Index).\n negate(X, Arg) :-\n functor(X, '-', _) -> (\n arg(1, X, Arg));\n functor(X, 'p', _) -> (\n arg(1, X, PX),\n (functor(PX, '-', _) -> (\n arg(1, PX, PNX),\n Arg = o(PNX)\n );\n Arg = o(-(PX))));\n Arg = -(X).\n prologEscape(X) :- \\+ functor(X, 'prolog', _), \\+ functor(X, '~', _).\n /*\n * Standard rules (RuleName : Preconditions => Effects)\n * Special rules (RuleName : Effects)\n */\n convertAllRules([], []).\n convertAllRules([[H,P,E]|T], [R|Rules]) :- convertRule(H, P, E, R), convertAllRules(T, Rules).\n convertAllRules([[H,E]|T], [R|Rules]) :- convertRule(H, E, R), convertAllRules(T, Rules).\n /*\n * Convert the given rule to the standard format\n * Example:\n * r2: followedGuidelines(X), doctor(X) => -liable(X)\n * rule([r2,[[followedGuidelines(X_e4149)],[doctor(X_e4149)]],[neg,liable(X_e4149)]]).\n */\n convertRule(RuleName, Preconditions, Effects, rule(List)) :-\n tuple_to_list(Preconditions, Lprecond),\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(preconditions, Lprecond, LprecondChecked),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened),\n List = [RuleName, LprecondChecked, LeffectsCheckedFlattened].\n /*\n * Convert the given special rule\n * Example:\n * bp(-liable(X)).\n * abastractBp([[neg, liable(X_e4149)]]).\n */\n convertRule(bps, Effects, abstractBp(Checked)) :-\n functor(Effects, 'bp', _),\n Effects =.. L,\n removehead(L, LC),\n check_modifiers_in_list(effects, LC, Checked).\n convertRule(Name, Effects, premise([Name, LeffectsCheckedFlattened])) :-\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened).\n /*\n * Find negations(-), obligations(o), permissions(p) on a list of preconditions/effects and\n * raplace them with the assigned literal (neg, obl, perm)\n */\n check_modifiers_in_list(MODE, [], []).\n check_modifiers_in_list(MODE, [H|T], L) :- H == [], L = [].\n check_modifiers_in_list(MODE, [H|T], L) :- H \\== [],\n check_modifiers(H, LH),\n check_admissibility(MODE, H, LH),\n check_modifiers_in_list(MODE, T, LT),\n append([LH], LT, L).\n check_admissibility(preconditions, H, LH) :-\n \\+ defeasible_admissible(LH),\n throw(['Premise ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(effects, H, LH) :-\n \\+ admissible(LH),\n throw(['Conclusion ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(_, _, _).\n check_modifiers([], []).\n check_modifiers(H, List) :-\n functor(H, '-', _) -> (\n arg(1, H, Arg),\n check_modifiers(Arg, Lobl),\n append([neg], Lobl, Lf),\n List = Lf);\n functor(H, 'o', _) -> (\n arg(1, H, Arg),\n check_modifiers(Arg, Lobl),\n List = [obl|[Lobl]]);\n functor(H, 'p', _) -> (\n arg(1, H, Arg),\n check_modifiers(Arg, Lper),\n List = [perm|[Lper]]);\n functor(H, '~', _) -> (\n arg(1, H, Arg),\n check_modifiers(Arg, Lper),\n List = [unless|[Lper]]);\n functor(H, 'bp', _) -> (\n H =.. [_|Arg],\n check_modifiers_in_list(effects, Arg, Lper),\n List = [bp|[Lper]]);\n List = [H].\n /*\n * Convert the given tuple to list\n */\n tuple_to_list((A,B),L) :- tuple_to_list(A, La), tuple_to_list(B, Lb), append(La, Lb,L).\n tuple_to_list(A,[A]) :- nonvar(A), A \\= (_ , _).\n list_to_tuple([H], (H)).\n list_to_tuple([H|T], (H,TT)) :- list_to_tuple(T,TT).\n /*\n * Replace all the occurences of a given element with the given argument\n */\n replace(_, _, [],[]).\n replace(O, R, [O|T], [R|T2]) :- replace(O, R, T, T2).\n replace(O, R, [H|T], [H|T2]) :- H \\= O, replace(O, R, T, T2).\n flatten_first_level([X], X).\n flatten_first_level.\n removehead([_|Tail], Tail).\n in(A, A) :- nonvar(A), A \\= (_ , _).\n in(A, (A, _)).\n in(A, (_ , Cs)) :- in(A, Cs).\n defeasible_admissible([unless, Term]) :- admissible(Term).\n defeasible_admissible(Term) :- admissible(Term).\n admissible([neg, bp, Term]) :- admissible_terms_complete(Term).\n admissible([bp, Term]) :- admissible_terms_complete(Term).\n admissible([neg, Term]) :- admissible_term(Term).\n admissible([obl, [Term]]) :- admissible_term(Term).\n admissible([obl, [neg, Term]]) :- admissible_term(Term).\n admissible([neg, obl, [Term]]) :- admissible_term(Term).\n admissible([neg, obl, [neg, Term]]) :- admissible_term(Term).\n admissible([perm, [Term]]) :- admissible_term(Term).\n admissible([perm, [neg, Term]]) :- admissible_term(Term).\n admissible([Term]) :- admissible_term(Term).\n admissible_term(Term) :-\n atomic(Term),\n Term \\== neg,\n Term \\== obl,\n Term \\== perm,\n Term \\== unless,\n Term \\== bp.\n admissible_term(Term) :- var(Term).\n admissible_term(Term) :-\n compound(Term),\n \\+ functor(Term, 'o', _),\n \\+ functor(Term, 'p', _),\n \\+ functor(Term, '-', _),\n \\+ functor(Term, '~', _),\n \\+ functor(Term, 'bp', _),\n Term =.. [_|Args],\n admissible_terms(Args).\n admissible_terms([]).\n admissible_terms([H|T]) :-\n admissible_term(H),\n admissible_terms(T).\n admissible_terms_complete([]).\n admissible_terms_complete([H|T]) :-\n admissible(H),\n admissible_terms_complete(T).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject StatementLabelling {\n val theoryCode: String =\n \"\"\"\n statementLabelling :-\n findall(_, (\n context_check(in([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n context_assert(statIn(Conc))\n ), _),\n findall(_, (\n context_check(out([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n \\+ context_check(statOut(Conc)),\n context_assert(statOut(Conc))\n ), _),\n findall(_, (\n context_check(und([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n \\+ context_check(statOut(Conc)),\n \\+ context_check(statUnd(Conc)),\n context_assert(statUnd(Conc))\n ), _).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject SuperiorityRelation {\n val theoryCode: String =\n \"\"\"\n superiorArgument(A, B) :- superiorArgumentSupportBuffered(A, B, _).\n superiorArgument(A, B, SupSet) :- superiorArgumentSupportBuffered(A, B, SupSet).\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n context_check(superior(A, B, SupSet, true)), !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n context_check(superior(A, B, SupSet, false)),\n fail, !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n \\+ context_check(superior(A, B, _, _)),\n superiorArgumentSupport(A, B, SupSet),\n context_assert(superior(A, B, SupSet, true)), !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n \\+ cache_check(superior(A, B, _, _)),\n context_assert(superior(A, B, [], false)),\n fail, !.\n superiorArgumentSupport([_, _, _, _, [LastDefRulesA, DefRulesA, DefPremisesA]], [_, _, _, _, [LastDefRulesB, DefRulesB, DefPremisesB]], SupSet) :-\n \tsuperiorArgumentSupport(LastDefRulesA, DefRulesA, DefPremisesA, LastDefRulesB, DefRulesB, DefPremisesB, SupSet).\n superiorArgumentSupport(LastDefRulesA, _, DefPremisesA, LastDefRulesB, _, DefPremisesB, SupSet) :-\n orderingPrinciple(last),\n \tsuperior(LastDefRulesA, DefPremisesA, LastDefRulesB, DefPremisesB, SupSet).\n superiorArgumentSupport(_, DefRulesA, DefPremisesA, _, DefRulesB, DefPremisesB, SupSet) :-\n orderingPrinciple(weakest),\n \tsuperior(DefRulesA, DefPremisesA, DefRulesB, DefPremisesB, SupSet).\n superior([], PremisesA, [], PremisesB, SupSet) :-\n \tweaker(PremisesB, PremisesA, SupSet).\n superior(DefRulesA, _, DefRulesB, _, SupSet) :-\n \torderingPrinciple(last),\n \t(DefRulesA \\== []; DefRulesB \\== []),\n \tweaker(DefRulesB, DefRulesA, SupSet).\n superior(DefRulesA, [], DefRulesB, [], SupSet) :-\n \torderingPrinciple(weakest),\n \tweaker(DefRulesB, DefRulesA, SupSet).\n superior(DefRulesA, PremisesA, DefRulesB, PremisesB, SupSet) :-\n \torderingPrinciple(weakest),\n \t(DefRulesA \\== []; DefRulesB \\== []),\n \t(PremisesA \\== []; PremisesB \\== []),\n \tweaker(DefRulesB, DefRulesA, SupSetA),\n \tweaker(PremisesB, PremisesA, SupSetB),\n \tutils::appendLists([SupSetA, SupSetB], SupSet).\n weaker(RulesA, [], []) :-\n \tRulesA \\== [].\n weaker(RulesA, RulesB, SupSet) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(elitist),\n \tmember(Rule, RulesA),\n \tallStronger(Rule, RulesB, SupSet), !.\n weaker(RulesA, RulesB, SupSet) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(democrat),\n \tweakerDemo(RulesA, RulesB, SupSet).\n weaker(RulesA, RulesB, [sup(X, W)]) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(normal),\n \tmember(W, RulesA),\n \tmember(X, RulesB),\n \tcontext_check(sup(X, W)), !.\n weakerDemo([], _, []).\n weakerDemo([H|T], Rules, [Sup|SupSet]) :-\n \tsingleStronger(H, Rules, Sup),\n \tweakerDemo(T, Rules, SupSet).\n singleStronger(Target, Rules, sup(Rule, Target)) :-\n \tmember(Rule, Rules),\n \tcontext_check(sup(Rule, Target)), !.\n allStronger(_, [], []).\n allStronger(Target, [Rule|Rules], [sup(Rule, Target)|SupSet]) :-\n \tcontext_check(sup(Rule, Target)),\n \tallStronger(Target, Rules, SupSet).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Utils {\n val theoryCode: String =\n \"\"\"\n writeList([]) :- nl.\n writeList([X|Others]) :-\n \twrite(X),\n \twriteList(Others).\n writeListNl([]).\n writeListNl([X|Others]) :-\n \twrite(X),nl,\n \twriteListNl(Others).\n sortDistinct(List, Sorted) :-\n deduplicate(List, Deduplicated),\n sort(Deduplicated, Sorted).\n deduplicate([], []).\n deduplicate(List, Output) :-\n List \\== [],\n setof(X, member(X, List), Output).\n sort(List,Sorted) :- q_sort(List, [], Sorted).\n q_sort([], Acc, Acc).\n q_sort([H|T], Acc, Sorted) :-\n \tpivoting(H, T, L1, L2),\n \tq_sort(L1, Acc, Sorted1),\n \tq_sort(L2, [H|Sorted1], Sorted).\n pivoting(H,[],[],[]).\n pivoting(H, [X|T], [X|L], G) :-\n H @>= X,\n pivoting(H, T, L, G).\n pivoting(H, [X|T], L, [X|G]) :-\n X @> H,\n pivoting(H, T, L, G).\n subtract([], _, []).\n subtract([Head|Tail], L2, L3) :-\n member(Head, L2), !,\n subtract(Tail, L2, L3).\n subtract([Head|Tail1], L2, [Head|Tail3]) :-\n subtract(Tail1, L2, Tail3).\n isEmptyList([]).\n appendLists([], []).\n appendLists([H|T], R) :-\n appendLists(T, AT),\n append(H, AT, R).\n search(F, L, S) :-\n between(1, L, N),\n functor(S, F, N),\n call(S).\n between(N, M, K) :- N < M, K = N.\n between(N, M, K) :- N == M, !, K = N.\n between(N, M, K) :- N < M, N1 is N+1, between(N1, M, K).\n recoverGraph(Args, Attacks, Supports) :-\n findall(X, context_check(argument(X)), TempArgs),\n findall((T, A, B, C), context_check(attack(T, A, B, C)), TempAttacks),\n findall((A, B), context_check(support(A, B)), TempSupports),\n utils::sort(TempArgs, Args),\n utils::sort(TempAttacks, Attacks),\n utils::sort(TempSupports, Supports).\n recoverArgumentLabelling(ArgsIn, ArgsOut, ArgsUnd) :-\n findall(X, context_check(in(X)), TempArgsIn),\n findall(X, context_check(out(X)), TempArgsOut),\n findall(X, context_check(und(X)), TempArgsUnd),\n utils::sort(TempArgsIn, ArgsIn),\n utils::sort(TempArgsOut, ArgsOut),\n utils::sort(TempArgsUnd, ArgsUnd).\n recoverStatementLabelling(In, Out, Und) :-\n findall(X, context_check(statIn(X)), TempIn),\n findall(X, context_check(statOut(X)), TempOut),\n findall(X, context_check(statUnd(X)), TempUnd),\n utils::sort(TempIn, In),\n utils::sort(TempOut, Out),\n utils::sort(TempUnd, Und).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.structured\n\nactual object StructuredMode : StructuredModeBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.QueryMode.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object Debug : DebugBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Debug.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object SuperiorityRelation : SuperiorityRelationBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.SuperiorityRelation.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object Utils : UtilsBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Utils.theoryCode\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAmgDA,yD;uBAAA,gD;2CAw7B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8B;MAAA,a;KAAA,uB;G;ECAA,iC;IAAA,qC;IAAoC,kC;G;;;SAE5B,Y;MAAQ,OAAsE,4C;K;;;;;;;;EAFtF,6C;IAAA,4C;MAAA,2B;KAAA,qC;G;ECAA,mB;IAAA,uB;IAAsB,oB;G;;;SAEd,Y;MAAQ,OAAwD,8B;K;;;;;;;;EAFxE,+B;IAAA,8B;MAAA,a;KAAA,uB;G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"arg2p-core.js","sources":["generated/_Collections.kt","kotlin/collections.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/Arg2p.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/dsl/Arg2pScope.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/ArgLibrary.kt","util/Lazy.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/Cache.kt","util/Standard.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/Context.kt","collections/Maps.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/DynamicLoader.kt","generated/_Sequences.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/EngineInterface.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/FlagManager.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/extra/MetaInterpreter.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/extra/ModuleCalls.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/AbstractMode.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/builder/ArgumentationGraphBuilder.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/AttackRestrictionHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/BpMetaGraphHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/DefeasiblePreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/GenericDefeasiblePreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/StrictPreferencesHandler.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BinaryStatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpCompleteLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpPartialLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/CompleteLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/GroundedLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/PassThroughStatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/StatementLabeller.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/language/RuleParser.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/structured/StructuredMode.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Debug.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/SuperiorityRelation.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Utils.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/meta/MetaInterpreterLib.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/mining/SolverMining.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Argument.kt","collections/Collections.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Attack.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Graph.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/LabelledArgument.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Rule.kt","../../../../../core/src/commonMain/kotlin/it/unibo/tuprolog/argumentation/core/model/Support.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/basic/EngineInterface.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/AbstractMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/builder/ArgumentationGraphBuilder.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/AttackRestrictionHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/BpMetaGraphHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/DefeasiblePreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/GenericDefeasiblePreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/extension/StrictPreferencesHandler.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpCompleteLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/BpPartialLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/CompleteLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/GroundedLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/graph/labelling/StatementLabeller.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/language/RuleParser.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/AbstractMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/ArgumentationEngineInterface.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/ArgumentationGraph.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/AttackRestriction.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Bp.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGrounded.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGroundedComplete.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/BpGroundedPartial.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Complete.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Debug.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/DefPreferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/GenericDefPreferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Grounded.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Preferences.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/QueryMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/RuleTranslator.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/StatementLabelling.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/SuperiorityRelation.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/sources/Utils.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/structured/StructuredMode.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Debug.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/SuperiorityRelation.kt","../../../../../core/src/jsMain/kotlin/it/unibo/tuprolog/argumentation/core/libs/utils/Utils.kt"],"sourcesContent":["/*\n * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n\npackage kotlin.collections\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\nimport kotlin.ranges.contains\nimport kotlin.ranges.reversed\n\n/**\n * Returns 1st *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 1.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component1(): T {\n return get(0)\n}\n\n/**\n * Returns 2nd *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 2.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component2(): T {\n return get(1)\n}\n\n/**\n * Returns 3rd *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 3.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component3(): T {\n return get(2)\n}\n\n/**\n * Returns 4th *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 4.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component4(): T {\n return get(3)\n}\n\n/**\n * Returns 5th *element* from the list.\n * \n * Throws an [IndexOutOfBoundsException] if the size of this list is less than 5.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> List<T>.component5(): T {\n return get(4)\n}\n\n/**\n * Returns `true` if [element] is found in the collection.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains(element: T): Boolean {\n if (this is Collection)\n return contains(element)\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\npublic fun <T> Iterable<T>.elementAt(index: Int): T {\n if (this is List)\n return get(index)\n return elementAtOrElse(index) { throw IndexOutOfBoundsException(\"Collection doesn't contain element at index $index.\") }\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAt(index: Int): T {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\npublic fun <T> Iterable<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n if (this is List)\n return this.getOrElse(index, defaultValue)\n if (index < 0)\n return defaultValue(index)\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\npublic fun <T> Iterable<T>.elementAtOrNull(index: Int): T? {\n if (this is List)\n return this.getOrNull(index)\n if (index < 0)\n return null\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.elementAtOrNull(index: Int): T? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the collection is empty.\n */\npublic fun <T> Iterable<T>.first(): T {\n when (this) {\n is List -> return this.first()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the list is empty.\n */\npublic fun <T> List<T>.first(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,\n * or throws [NoSuchElementException] if no non-null value was produced.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Iterable<T>.firstNotNullOf(transform: (T) -> R?): R {\n return firstNotNullOfOrNull(transform) ?: throw NoSuchElementException(\"No element of the collection was transformed to a non-null value.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,\n * or `null` if no non-null value was produced.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? {\n for (element in this) {\n val result = transform(element)\n if (result != null) {\n return result\n }\n }\n return null\n}\n\n/**\n * Returns the first element, or `null` if the collection is empty.\n */\npublic fun <T> Iterable<T>.firstOrNull(): T? {\n when (this) {\n is List -> {\n if (isEmpty())\n return null\n else\n return this[0]\n }\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns the first element, or `null` if the list is empty.\n */\npublic fun <T> List<T>.firstOrNull(): T? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>.getOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.getOrNull\n */\npublic fun <T> List<T>.getOrNull(index: Int): T? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns first index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T): Int {\n if (this is List) return this.indexOf(element)\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {\n return indexOf(element)\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n if (predicate(iterator.previous())) {\n return iterator.nextIndex()\n }\n }\n return -1\n}\n\n/**\n * Returns the last element.\n * \n * @throws NoSuchElementException if the collection is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Iterable<T>.last(): T {\n when (this) {\n is List -> return this.last()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element.\n * \n * @throws NoSuchElementException if the list is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> List<T>.last(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T {\n var last: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n last = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return last as T\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> List<T>.last(predicate: (T) -> Boolean): T {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"List contains no element matching the predicate.\")\n}\n\n/**\n * Returns last index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element: T): Int {\n if (this is List) return this.lastIndexOf(element)\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns last index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {\n return lastIndexOf(element)\n}\n\n/**\n * Returns the last element, or `null` if the collection is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Iterable<T>.lastOrNull(): T? {\n when (this) {\n is List -> return if (isEmpty()) null else this[size - 1]\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element, or `null` if the list is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> List<T>.lastOrNull(): T? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n var last: T? = null\n for (element in this) {\n if (predicate(element)) {\n last = element\n }\n }\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns a random element from this collection.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.random(): T {\n return random(Random)\n}\n\n/**\n * Returns a random element from this collection using the specified source of randomness.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Collection<T>.random(random: Random): T {\n if (isEmpty())\n throw NoSuchElementException(\"Collection is empty.\")\n return elementAt(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this collection, or `null` if this collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.randomOrNull(): T? {\n return randomOrNull(Random)\n}\n\n/**\n * Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T> Collection<T>.randomOrNull(random: Random): T? {\n if (isEmpty())\n return null\n return elementAt(random.nextInt(size))\n}\n\n/**\n * Returns the single element, or throws an exception if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.single(): T {\n when (this) {\n is List -> return this.single()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n val single = iterator.next()\n if (iterator.hasNext())\n throw IllegalArgumentException(\"Collection has more than one element.\")\n return single\n }\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.single(): T {\n return when (size) {\n 0 -> throw NoSuchElementException(\"List is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"List has more than one element.\")\n }\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Collection contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns single element, or `null` if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.singleOrNull(): T? {\n when (this) {\n is List -> return if (size == 1) this[0] else null\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n val single = iterator.next()\n if (iterator.hasNext())\n return null\n return single\n }\n }\n}\n\n/**\n * Returns single element, or `null` if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.singleOrNull(): T? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun <T> Iterable<T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Iterable<T>.drop(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return toList()\n val list: ArrayList<T>\n if (this is Collection<*>) {\n val resultSize = size - n\n if (resultSize <= 0)\n return emptyList()\n if (resultSize == 1)\n return listOf(last())\n list = ArrayList<T>(resultSize)\n if (this is List<T>) {\n if (this is RandomAccess) {\n for (index in n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(n))\n list.add(item)\n }\n return list\n }\n }\n else {\n list = ArrayList<T>()\n }\n var count = 0\n for (item in this) {\n if (count >= n) list.add(item) else ++count\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> List<T>.dropLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n return take(iterator.nextIndex() + 1)\n }\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> Iterable<T>.dropWhile(predicate: (T) -> Boolean): List<T> {\n var yielding = false\n val list = ArrayList<T>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> {\n return filterTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexed\n */\npublic inline fun <T> Iterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T> {\n return filterIndexedTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexedTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a list containing all elements that are instances of specified type parameter R.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstance\n */\npublic inline fun <reified R> Iterable<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {\n return filterIsInstanceTo(ArrayList<R>())\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstanceTo\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic inline fun <T> Iterable<T>.filterNot(predicate: (T) -> Boolean): List<T> {\n return filterNotTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing all elements that are not `null`.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNull\n */\npublic fun <T : Any> Iterable<T?>.filterNotNull(): List<T> {\n return filterNotNullTo(ArrayList<T>())\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterNotNullTo\n */\npublic fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun <T> List<T>.slice(indices: IntRange): List<T> {\n if (indices.isEmpty()) return listOf()\n return this.subList(indices.start, indices.endInclusive + 1).toList()\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun <T> List<T>.slice(indices: Iterable<Int>): List<T> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<T>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Iterable<T>.take(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (this is Collection<T>) {\n if (n >= size) return toList()\n if (n == 1) return listOf(first())\n }\n var count = 0\n val list = ArrayList<T>(n)\n for (item in this) {\n list.add(item)\n if (++count == n)\n break\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> List<T>.takeLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(last())\n val list = ArrayList<T>(n)\n if (this is RandomAccess) {\n for (index in size - n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(size - n))\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> List<T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {\n if (isEmpty())\n return emptyList()\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n iterator.next()\n val expectedSize = size - iterator.nextIndex()\n if (expectedSize == 0) return emptyList()\n return ArrayList<T>(expectedSize).apply {\n while (iterator.hasNext())\n add(iterator.next())\n }\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T> {\n val list = ArrayList<T>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Reverses elements in the list in-place.\n */\npublic expect fun <T> MutableList<T>.reverse(): Unit\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun <T> Iterable<T>.reversed(): List<T> {\n if (this is Collection && size <= 1) return toList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Randomly shuffles elements in this list in-place using the specified [random] instance as the source of randomness.\n * \n * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> MutableList<T>.shuffle(random: Random): Unit {\n for (i in lastIndex downTo 1) {\n val j = random.nextInt(i + 1)\n this[j] = this.set(i, this[j])\n }\n}\n\n/**\n * Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortBy(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareBy(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareByDescending(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> MutableList<T>.sortDescending(): Unit {\n sortWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()\n }\n return toMutableList().apply { sort() }\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n * \n * @sample samples.collections.Collections.Sorting.sortedBy\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedBy(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()\n }\n return toMutableList().apply { sortWith(comparator) }\n}\n\n/**\n * Returns an array of Boolean containing all of the elements of this collection.\n */\npublic fun Collection<Boolean>.toBooleanArray(): BooleanArray {\n val result = BooleanArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Byte containing all of the elements of this collection.\n */\npublic fun Collection<Byte>.toByteArray(): ByteArray {\n val result = ByteArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Char containing all of the elements of this collection.\n */\npublic fun Collection<Char>.toCharArray(): CharArray {\n val result = CharArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Double containing all of the elements of this collection.\n */\npublic fun Collection<Double>.toDoubleArray(): DoubleArray {\n val result = DoubleArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Float containing all of the elements of this collection.\n */\npublic fun Collection<Float>.toFloatArray(): FloatArray {\n val result = FloatArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Int containing all of the elements of this collection.\n */\npublic fun Collection<Int>.toIntArray(): IntArray {\n val result = IntArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Long containing all of the elements of this collection.\n */\npublic fun Collection<Long>.toLongArray(): LongArray {\n val result = LongArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Short containing all of the elements of this collection.\n */\npublic fun Collection<Short>.toShortArray(): ShortArray {\n val result = ShortArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associate\n */\npublic inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given collection indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateBy\n */\npublic inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateByWithValueTransform\n */\npublic inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given collection\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateByTo\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * @sample samples.collections.Collections.Transformations.associateTo\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Returns a [Map] where keys are elements from the given collection and values are\n * produced by the [valueSelector] function applied to each element.\n * \n * If any two elements are equal, the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateWith\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V> Iterable<K>.associateWith(valueSelector: (K) -> V): Map<K, V> {\n val result = LinkedHashMap<K, V>(mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16))\n return associateWithTo(result, valueSelector)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs for each element of the given collection,\n * where key is the element itself and value is provided by the [valueSelector] function applied to that key.\n * \n * If any two elements are equal, the last one overwrites the former value in the map.\n * \n * @sample samples.collections.Collections.Transformations.associateWithTo\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M {\n for (element in this) {\n destination.put(element, valueSelector(element))\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a new [HashSet] of all elements.\n */\npublic fun <T> Iterable<T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun <T> Iterable<T>.toList(): List<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(if (this is List) get(0) else iterator().next())\n else -> this.toMutableList()\n }\n }\n return this.toMutableList().optimizeReadOnlyList()\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Iterable<T>.toMutableList(): MutableList<T> {\n if (this is Collection<T>)\n return this.toMutableList()\n return toCollection(ArrayList<T>())\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Collection<T>.toMutableList(): MutableList<T> {\n return ArrayList(this)\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toSet(): Set<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(if (this is List) this[0] else iterator().next())\n else -> toCollection(LinkedHashSet<T>(mapCapacity(size)))\n }\n }\n return toCollection(LinkedHashSet<T>()).optimizeReadOnlySet()\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\npublic inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapSequence\")\npublic inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Sequence<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterable\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.flatMapIndexed(transform: (index: Int, T) -> Iterable<R>): List<R> {\n return flatMapIndexedTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequence\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.flatMapIndexed(transform: (index: Int, T) -> Sequence<R>): List<R> {\n return flatMapIndexedTo(ArrayList<R>(), transform)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterableTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Iterable<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequenceTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Sequence<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapSequenceTo\")\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Sequence<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Iterable<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Iterable<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from a collection to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Iterable<T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = this@groupingBy.iterator()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.map\n */\npublic inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {\n return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R> Iterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R> {\n return mapIndexedNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(checkIndexOverflow(index++), item))\n return destination\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element in the original collection.\n * \n * @sample samples.collections.Collections.Transformations.mapNotNull\n */\npublic inline fun <T, R : Any> Iterable<T>.mapNotNull(transform: (T) -> R?): List<R> {\n return mapNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element in the original collection\n * and appends only the non-null results to the given [destination].\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original collection\n * and appends the results to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a lazy [Iterable] that wraps each element of the original collection\n * into an [IndexedValue] containing the index of that element and the element itself.\n */\npublic fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a list containing only distinct elements from the given collection.\n * \n * Among equal elements of the given collection, only the first one will be present in the resulting list.\n * The elements in the resulting list are in the same order as they were in the source collection.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T> Iterable<T>.distinct(): List<T> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only elements from the given collection\n * having distinct keys returned by the given [selector] function.\n * \n * Among elements of the given collection with equal keys, only the first one will be present in the resulting list.\n * The elements in the resulting list are in the same order as they were in the source collection.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic inline fun <T, K> Iterable<T>.distinctBy(selector: (T) -> K): List<T> {\n val set = HashSet<K>()\n val list = ArrayList<T>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a set containing all elements that are contained by both this collection and the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n * \n * To get a set containing all elements that are contained at least in one of these collections use [union].\n */\npublic infix fun <T> Iterable<T>.intersect(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.retainAll(other)\n return set\n}\n\n/**\n * Returns a set containing all elements that are contained by this collection and not contained by the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic infix fun <T> Iterable<T>.subtract(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.removeAll(other)\n return set\n}\n\n/**\n * Returns a new [MutableSet] containing all distinct elements from the given collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toMutableSet(): MutableSet<T> {\n return when (this) {\n is Collection<T> -> LinkedHashSet(this)\n else -> toCollection(LinkedHashSet<T>())\n }\n}\n\n/**\n * Returns a set containing all distinct elements from both collections.\n * \n * The returned set preserves the element iteration order of the original collection.\n * Those elements of the [other] collection that are unique are iterated in the end\n * in the order of the [other] collection.\n * \n * To get a set containing all elements that are contained in both collections use [intersect].\n */\npublic infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.addAll(other)\n return set\n}\n\n/**\n * Returns `true` if all elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.all\n */\npublic inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (!predicate(element)) return false\n return true\n}\n\n/**\n * Returns `true` if collection has at least one element.\n * \n * @sample samples.collections.Collections.Aggregates.any\n */\npublic fun <T> Iterable<T>.any(): Boolean {\n if (this is Collection) return !isEmpty()\n return iterator().hasNext()\n}\n\n/**\n * Returns `true` if at least one element matches the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.anyWithPredicate\n */\npublic inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return false\n for (element in this) if (predicate(element)) return true\n return false\n}\n\n/**\n * Returns the number of elements in this collection.\n */\npublic fun <T> Iterable<T>.count(): Int {\n if (this is Collection) return size\n var count = 0\n for (element in this) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Returns the number of elements in this collection.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.count(): Int {\n return size\n}\n\n/**\n * Returns the number of elements matching the given [predicate].\n */\npublic inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int {\n if (this is Collection && isEmpty()) return 0\n var count = 0\n for (element in this) if (predicate(element)) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns the specified [initial] value if the collection is empty.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n */\npublic inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R {\n var accumulator = initial\n for (element in this) accumulator = operation(accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Returns the specified [initial] value if the collection is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n */\npublic inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {\n var index = 0\n var accumulator = initial\n for (element in this) accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Returns the specified [initial] value if the list is empty.\n * \n * @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Returns the specified [initial] value if the list is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself\n * and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Performs the given [action] on each element.\n */\n@kotlin.internal.HidesMembers\npublic inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {\n for (element in this) action(element)\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n */\npublic inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {\n var index = 0\n for (item in this) action(checkIndexOverflow(index++), item)\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.max(): Double? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.max(): Float? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Iterable<T>.max(): T? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxByOrNull instead.\", ReplaceWith(\"this.maxByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T? {\n return maxByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the largest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.maxByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxElem = iterator.next()\n if (!iterator.hasNext()) return maxElem\n var maxValue = selector(maxElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (maxValue < v) {\n maxElem = e\n maxValue = v\n }\n } while (iterator.hasNext())\n return maxElem\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.maxOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.maxOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.maxOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Double>.maxOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Float>.maxOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (max < e) max = e\n }\n return max\n}\n\n@Deprecated(\"Use maxWithOrNull instead.\", ReplaceWith(\"this.maxWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? {\n return maxWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Iterable<T>.maxWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(max, e) < 0) max = e\n }\n return max\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.min(): Double? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.min(): Float? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Iterable<T>.min(): T? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minByOrNull instead.\", ReplaceWith(\"this.minByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T? {\n return minByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.minByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minElem = iterator.next()\n if (!iterator.hasNext()) return minElem\n var minValue = selector(minElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (minValue > v) {\n minElem = e\n minValue = v\n }\n } while (iterator.hasNext())\n return minElem\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection.\n * \n * @throws NoSuchElementException if the collection is empty.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.minOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the collection or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Iterable<T>.minOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Double>.minOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.4\")\npublic fun Iterable<Float>.minOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (min > e) min = e\n }\n return min\n}\n\n@Deprecated(\"Use minWithOrNull instead.\", ReplaceWith(\"this.minWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? {\n return minWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Iterable<T>.minWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(min, e) > 0) min = e\n }\n return min\n}\n\n/**\n * Returns `true` if the collection has no elements.\n * \n * @sample samples.collections.Collections.Aggregates.none\n */\npublic fun <T> Iterable<T>.none(): Boolean {\n if (this is Collection) return isEmpty()\n return !iterator().hasNext()\n}\n\n/**\n * Returns `true` if no elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.noneWithPredicate\n */\npublic inline fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (predicate(element)) return false\n return true\n}\n\n/**\n * Performs the given [action] on each element and returns the collection itself afterwards.\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C {\n return apply { for (element in this) action(element) }\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element,\n * and returns the collection itself afterwards.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, C : Iterable<T>> C.onEachIndexed(action: (index: Int, T) -> Unit): C {\n return apply { forEachIndexed(action) }\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Throws an exception if this collection is empty. If the collection can be empty in an expected way,\n * please use [reduceOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Throws an exception if this collection is empty. If the collection can be empty in an expected way,\n * please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Iterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * \n * Returns `null` if the collection is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Iterable<T>.reduceIndexedOrNull(operation: (index: Int, acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns `null` if the collection is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Iterable<T>.reduceOrNull(operation: (acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Throws an exception if this list is empty. If the list can be empty in an expected way,\n * please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes an element and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRight\n */\npublic inline fun <S, T : S> List<T>.reduceRight(operation: (T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Throws an exception if this list is empty. If the list can be empty in an expected way,\n * please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRight\n */\npublic inline fun <S, T : S> List<T>.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * \n * Returns `null` if the list is empty.\n * \n * @param [operation] function that takes the index of an element, the element itself and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRightOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> List<T>.reduceRightIndexedOrNull(operation: (index: Int, T, acc: S) -> S): S? {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n return null\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the last element and applying [operation] from right to left\n * to each element and current accumulator value.\n * \n * Returns `null` if the list is empty.\n * \n * @param [operation] function that takes an element and current accumulator value,\n * and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.reduceRightOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> List<T>.reduceRightOrNull(operation: (T, acc: S) -> S): S? {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n return null\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R> Iterable<T>.runningFold(initial: R, operation: (acc: R, T) -> R): List<R> {\n val estimatedSize = collectionSizeOrDefault(9)\n if (estimatedSize == 0) return listOf(initial)\n val result = ArrayList<R>(estimatedSize + 1).apply { add(initial) }\n var accumulator = initial\n for (element in this) {\n accumulator = operation(accumulator, element)\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R> Iterable<T>.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): List<R> {\n val estimatedSize = collectionSizeOrDefault(9)\n if (estimatedSize == 0) return listOf(initial)\n val result = ArrayList<R>(estimatedSize + 1).apply { add(initial) }\n var index = 0\n var accumulator = initial\n for (element in this) {\n accumulator = operation(index++, accumulator, element)\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with the first element of this collection.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and the element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Iterable<T>.runningReduce(operation: (acc: S, T) -> S): List<S> {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return emptyList()\n var accumulator: S = iterator.next()\n val result = ArrayList<S>(collectionSizeOrDefault(10)).apply { add(accumulator) }\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with the first element of this collection.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Iterable<T>.runningReduceIndexed(operation: (index: Int, acc: S, T) -> S): List<S> {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return emptyList()\n var accumulator: S = iterator.next()\n val result = ArrayList<S>(collectionSizeOrDefault(10)).apply { add(accumulator) }\n var index = 1\n while (iterator.hasNext()) {\n accumulator = operation(index++, accumulator, iterator.next())\n result.add(accumulator)\n }\n return result\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <T, R> Iterable<T>.scan(initial: R, operation: (acc: R, T) -> R): List<R> {\n return runningFold(initial, operation)\n}\n\n/**\n * Returns a list containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original collection and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting list.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <T, R> Iterable<T>.scanIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): List<R> {\n return runningFoldIndexed(initial, operation)\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int {\n var sum: Int = 0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Iterable<T>.sumByDouble(selector: (T) -> Double): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfDouble\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double {\n var sum: Double = 0.toDouble()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfInt\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int {\n var sum: Int = 0.toInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfLong\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long {\n var sum: Long = 0.toLong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfUInt\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt {\n var sum: UInt = 0.toUInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfULong\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong {\n var sum: ULong = 0.toULong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as Iterable<T>\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> List<T?>.requireNoNulls(): List<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as List<T>\n}\n\n/**\n * Splits this collection into a list of lists each not exceeding the given [size].\n * \n * The last list in the resulting list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.collections.Collections.Transformations.chunked\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {\n return windowed(size, size, partialWindows = true)\n}\n\n/**\n * Splits this collection into several lists each not exceeding the given [size]\n * and applies the given [transform] function to an each.\n * \n * @return list of results of the [transform] applied to an each list.\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * The last list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.text.Strings.chunkedTransform\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {\n return windowed(size, size, partialWindows = true, transform = transform)\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\npublic operator fun <T> Iterable<T>.minus(element: T): List<T> {\n val result = ArrayList<T>(collectionSizeOrDefault(10))\n var removed = false\n return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] array.\n * \n * The [elements] array may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Array<out T>): List<T> {\n if (elements.isEmpty()) return this.toList()\n val other = elements.toHashSet()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] collection.\n * \n * The [elements] collection may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Iterable<T>): List<T> {\n val other = elements.convertToSetForSetOperationWith(this)\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] sequence.\n * \n * The [elements] sequence may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Sequence<T>): List<T> {\n val other = elements.toHashSet()\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.minusElement(element: T): List<T> {\n return minus(element)\n}\n\n/**\n * Splits the original collection into pair of lists,\n * where *first* list contains elements for which [predicate] yielded `true`,\n * while *second* list contains elements for which [predicate] yielded `false`.\n * \n * @sample samples.collections.Iterables.Operations.partition\n */\npublic inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {\n val first = ArrayList<T>()\n val second = ArrayList<T>()\n for (element in this) {\n if (predicate(element)) {\n first.add(element)\n } else {\n second.add(element)\n }\n }\n return Pair(first, second)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Iterable<T>.plus(element: T): List<T> {\n if (this is Collection) return this.plus(element)\n val result = ArrayList<T>()\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Collection<T>.plus(element: T): List<T> {\n val result = ArrayList<T>(size + 1)\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Array<out T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Collection<T>.plus(elements: Array<out T>): List<T> {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> {\n if (elements is Collection) {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n } else {\n val result = ArrayList<T>(this)\n result.addAll(elements)\n return result\n }\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Collection<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>(this.size + 10)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list of snapshots of the window of the given [size]\n * sliding along this collection with the given [step], where each\n * snapshot is a list.\n * \n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.takeWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val resultCapacity = thisSize / step + if (thisSize % step == 0) 0 else 1\n val result = ArrayList<List<T>>(resultCapacity)\n var index = 0\n while (index in 0 until thisSize) {\n val windowSize = size.coerceAtMost(thisSize - index)\n if (windowSize < size && !partialWindows) break\n result.add(List(windowSize) { this[it + index] })\n index += step\n }\n return result\n }\n val result = ArrayList<List<T>>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {\n result.add(it)\n }\n return result\n}\n\n/**\n * Returns a list of results of applying the given [transform] function to\n * an each list representing a view over the window of the given [size]\n * sliding along this collection with the given [step].\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.averageWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val resultCapacity = thisSize / step + if (thisSize % step == 0) 0 else 1\n val result = ArrayList<R>(resultCapacity)\n val window = MovingSubList(this)\n var index = 0\n while (index in 0 until thisSize) {\n val windowSize = size.coerceAtMost(thisSize - index)\n if (!partialWindows && windowSize < size) break\n window.move(index, index + windowSize)\n result.add(transform(window))\n index += step\n }\n return result\n }\n val result = ArrayList<R>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {\n result.add(transform(it))\n }\n return result\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and the [other] array with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] array with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {\n val arraySize = other.size\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), arraySize))\n var i = 0\n for (element in this) {\n if (i >= arraySize) break\n list.add(transform(element, other[i++]))\n }\n return list\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and [other] collection with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] collection with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {\n val first = iterator()\n val second = other.iterator()\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))\n while (first.hasNext() && second.hasNext()) {\n list.add(transform(first.next(), second.next()))\n }\n return list\n}\n\n/**\n * Returns a list of pairs of each two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNext\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> {\n return zipWithNext { a, b -> a to b }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to an each pair of two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas\n */\n@SinceKotlin(\"1.2\")\npublic inline fun <T, R> Iterable<T>.zipWithNext(transform: (a: T, b: T) -> R): List<R> {\n val iterator = iterator()\n if (!iterator.hasNext()) return emptyList()\n val result = mutableListOf<R>()\n var current = iterator.next()\n while (iterator.hasNext()) {\n val next = iterator.next()\n result.add(transform(current, next))\n current = next\n }\n return result\n}\n\n/**\n * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinTo\n */\npublic fun <T, A : Appendable> Iterable<T>.joinTo(buffer: A, separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): A {\n buffer.append(prefix)\n var count = 0\n for (element in this) {\n if (++count > 1) buffer.append(separator)\n if (limit < 0 || count <= limit) {\n buffer.appendElement(element, transform)\n } else break\n }\n if (limit >= 0 && count > limit) buffer.append(truncated)\n buffer.append(postfix)\n return buffer\n}\n\n/**\n * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinToString\n */\npublic fun <T> Iterable<T>.joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): String {\n return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()\n}\n\n/**\n * Returns this collection as an [Iterable].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Iterable<T>.asIterable(): Iterable<T> {\n return this\n}\n\n/**\n * Creates a [Sequence] instance that wraps the original collection returning its elements when being iterated.\n * \n * @sample samples.collections.Sequences.Building.sequenceFromCollection\n */\npublic fun <T> Iterable<T>.asSequence(): Sequence<T> {\n return Sequence { this.iterator() }\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfByte\")\npublic fun Iterable<Byte>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfShort\")\npublic fun Iterable<Short>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfInt\")\npublic fun Iterable<Int>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfLong\")\npublic fun Iterable<Long>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfFloat\")\npublic fun Iterable<Float>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\n@kotlin.jvm.JvmName(\"averageOfDouble\")\npublic fun Iterable<Double>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfByte\")\npublic fun Iterable<Byte>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfShort\")\npublic fun Iterable<Short>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfInt\")\npublic fun Iterable<Int>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfLong\")\npublic fun Iterable<Long>.sum(): Long {\n var sum: Long = 0L\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfFloat\")\npublic fun Iterable<Float>.sum(): Float {\n var sum: Float = 0.0f\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\n@kotlin.jvm.JvmName(\"sumOfDouble\")\npublic fun Iterable<Double>.sum(): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\npackage kotlin.collections\n\nimport kotlin.comparisons.naturalOrder\nimport kotlin.random.Random\n\n/** Returns the array if it's not `null`, or an empty array otherwise. */\n@kotlin.internal.InlineOnly\npublic actual inline fun <T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()\n\n@kotlin.internal.InlineOnly\npublic actual inline fun <T> Collection<T>.toTypedArray(): Array<T> = copyToArray(this)\n\n@JsName(\"copyToArray\")\n@PublishedApi\ninternal fun <T> copyToArray(collection: Collection<T>): Array<T> {\n return if (collection.asDynamic().toArray !== undefined)\n collection.asDynamic().toArray().unsafeCast<Array<T>>()\n else\n copyToArrayImpl(collection).unsafeCast<Array<T>>()\n}\n\n@JsName(\"copyToArrayImpl\")\ninternal actual fun copyToArrayImpl(collection: Collection<*>): Array<Any?> {\n val array = emptyArray<Any?>()\n val iterator = collection.iterator()\n while (iterator.hasNext())\n array.asDynamic().push(iterator.next())\n return array\n}\n\n@JsName(\"copyToExistingArrayImpl\")\ninternal actual fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> {\n if (array.size < collection.size)\n return copyToArrayImpl(collection).unsafeCast<Array<T>>()\n\n val iterator = collection.iterator()\n var index = 0\n while (iterator.hasNext()) {\n array[index++] = iterator.next().unsafeCast<T>()\n }\n if (index < array.size) {\n array[index] = null.unsafeCast<T>()\n }\n return array\n}\n\n\n/**\n * Returns an immutable list containing only the specified object [element].\n */\npublic fun <T> listOf(element: T): List<T> = arrayListOf(element)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildListInternal(builderAction: MutableList<E>.() -> Unit): List<E> {\n return ArrayList<E>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildListInternal(capacity: Int, builderAction: MutableList<E>.() -> Unit): List<E> {\n checkBuilderCapacity(capacity)\n return ArrayList<E>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Returns an immutable set containing only the specified object [element].\n */\npublic fun <T> setOf(element: T): Set<T> = hashSetOf(element)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildSetInternal(builderAction: MutableSet<E>.() -> Unit): Set<E> {\n return LinkedHashSet<E>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <E> buildSetInternal(capacity: Int, builderAction: MutableSet<E>.() -> Unit): Set<E> {\n return LinkedHashSet<E>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Returns an immutable map, mapping only the specified key to the\n * specified value.\n */\npublic fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <K, V> buildMapInternal(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n return LinkedHashMap<K, V>().apply(builderAction).build()\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal actual inline fun <K, V> buildMapInternal(capacity: Int, builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n return LinkedHashMap<K, V>(capacity).apply(builderAction).build()\n}\n\n\n/**\n * Fills the list with the provided [value].\n *\n * Each element in the list gets replaced with the [value].\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> MutableList<T>.fill(value: T): Unit {\n for (index in 0..lastIndex) {\n this[index] = value\n }\n}\n\n/**\n * Randomly shuffles elements in this list.\n *\n * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> MutableList<T>.shuffle(): Unit = shuffle(Random)\n\n/**\n * Returns a new list with the elements of this list randomly shuffled.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply { shuffle() }\n\n/**\n * Sorts elements in the list in-place according to their natural sort order.\n *\n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit {\n collectionsSort(this, naturalOrder())\n}\n\n/**\n * Sorts elements in the list in-place according to the order specified with [comparator].\n *\n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {\n collectionsSort(this, comparator)\n}\n\nprivate fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in T>) {\n if (list.size <= 1) return\n\n val array = copyToArray(list)\n sortArrayWith(array, comparator)\n\n for (i in 0 until array.size) {\n list[i] = array[i]\n }\n}\n\ninternal actual fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> {\n return arrayOfNulls<Any>(size).unsafeCast<Array<T>>()\n}\n\n@SinceKotlin(\"1.3\")\n@PublishedApi\n@JsName(\"arrayCopy\")\ninternal fun <T> arrayCopy(source: Array<out T>, destination: Array<in T>, destinationOffset: Int, startIndex: Int, endIndex: Int) {\n AbstractList.checkRangeIndexes(startIndex, endIndex, source.size)\n val rangeSize = endIndex - startIndex\n AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)\n\n if (js(\"ArrayBuffer\").isView(destination) && js(\"ArrayBuffer\").isView(source)) {\n val subrange = source.asDynamic().subarray(startIndex, endIndex)\n destination.asDynamic().set(subrange, destinationOffset)\n } else {\n if (source !== destination || destinationOffset <= startIndex) {\n for (index in 0 until rangeSize) {\n destination[destinationOffset + index] = source[startIndex + index]\n }\n } else {\n for (index in rangeSize - 1 downTo 0) {\n destination[destinationOffset + index] = source[startIndex + index]\n }\n }\n }\n}\n\n// no singleton map implementation in js, return map as is\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = this\n\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> = this.toMutableMap()\n\n\n@Suppress(\"NOTHING_TO_INLINE\")\ninternal actual inline fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =\n if (isVarargs)\n // no need to copy vararg array in JS\n this\n else\n this.copyOf()\n\n\n\n@PublishedApi\ninternal actual fun checkIndexOverflow(index: Int): Int {\n if (index < 0) {\n throwIndexOverflow()\n }\n return index\n}\n\n@PublishedApi\ninternal actual fun checkCountOverflow(count: Int): Int {\n if (count < 0) {\n throwCountOverflow()\n }\n return count\n}\n\n\n/**\n * JS map and set implementations do not make use of capacities or load factors.\n */\n@PublishedApi\ninternal actual fun mapCapacity(expectedSize: Int) = expectedSize\n\n/**\n * Checks a collection builder function capacity argument.\n * In JS no validation is made in Map/Set constructor yet.\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@PublishedApi\ninternal fun checkBuilderCapacity(capacity: Int) {\n require(capacity >= 0) { \"capacity must be non-negative.\" }\n}","package it.unibo.tuprolog.argumentation.core\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgContext\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLoader\nimport it.unibo.tuprolog.argumentation.core.libs.basic.Cache\nimport it.unibo.tuprolog.argumentation.core.libs.basic.Context\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.argumentation.core.libs.basic.EngineInterface\nimport it.unibo.tuprolog.argumentation.core.libs.extra.MetaInterpreter\nimport it.unibo.tuprolog.argumentation.core.libs.extra.ModuleCalls\nimport it.unibo.tuprolog.argumentation.core.libs.graph.AbstractMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.builder.ArgumentationGraphBuilder\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.AttackRestrictionHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.BpMetaGraphHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.DefeasiblePreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.GenericDefeasiblePreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.extension.StrictPreferencesHandler\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BinaryStatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpCompleteLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.BpPartialLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.CompleteLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.GroundedLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.PassThroughStatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.graph.labelling.StatementLabeller\nimport it.unibo.tuprolog.argumentation.core.libs.language.RuleParser\nimport it.unibo.tuprolog.argumentation.core.libs.structured.StructuredMode\nimport it.unibo.tuprolog.argumentation.core.libs.utils.Debug\nimport it.unibo.tuprolog.argumentation.core.libs.utils.SuperiorityRelation\nimport it.unibo.tuprolog.argumentation.core.libs.utils.Utils\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.Libraries\n\ninterface Arg2pSolver {\n val loader: ArgLoader\n val context: ArgContext\n\n fun staticLibraries(): Iterable<ArgLibrary>\n fun dynamicLibraries(): Iterable<ArgLibrary>\n\n fun to2pLibraries() = Libraries.of(listOf(loader, context).plus(staticLibraries()).map { it.content() })\n fun operators() = listOf(loader, context).plus(staticLibraries())\n .map { it.theoryOperators }.reduce(OperatorSet::plus)\n\n companion object {\n fun of(staticLibs: Iterable<ArgLibrary>, dynamicLibs: Iterable<ArgLibrary>) =\n object : Arg2pSolver {\n\n override val loader = DynamicLoader(this)\n override val context: ArgContext = Context()\n\n override fun staticLibraries() = staticLibs\n override fun dynamicLibraries() = dynamicLibs\n }\n\n fun default(staticLibs: Iterable<ArgLibrary> = emptyList(), dynamicLibs: Iterable<ArgLibrary> = emptyList()) = of(\n listOf(EngineInterface, Cache()) + staticLibs,\n listOf(\n Utils,\n Debug,\n RuleParser,\n MetaInterpreter,\n ModuleCalls,\n ArgumentationGraphBuilder,\n AttackRestrictionHandler,\n BpMetaGraphHandler,\n DefeasiblePreferencesHandler,\n GenericDefeasiblePreferencesHandler,\n StrictPreferencesHandler,\n BpLabeller,\n CompleteLabeller,\n GroundedLabeller,\n StatementLabeller,\n AbstractMode,\n StructuredMode,\n SuperiorityRelation,\n BpPartialLabeller,\n BpCompleteLabeller,\n PassThroughStatementLabeller,\n BinaryStatementLabeller\n ) + dynamicLibs\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.dsl\n\nimport it.unibo.tuprolog.dsl.PrologScope\nimport it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories\nimport it.unibo.tuprolog.unify.Unificator\n\ninterface PrologWithArgumentation : PrologScopeWithTheories {\n infix fun Any.call(other: Any) = structOf(\"::\", this.toTerm(), other.toTerm())\n}\n\ninternal class PrologWithArgumentationImpl :\n PrologWithArgumentation, PrologScope by PrologScope.empty(), Unificator by Unificator.default\n\nfun <R> arg2pScope(function: PrologWithArgumentation.() -> R): R = PrologWithArgumentationImpl().function()\n","package it.unibo.tuprolog.argumentation.core.libs\n\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\ninterface ArgContext : ArgLibrary\ninterface ArgLoader : ArgLibrary\n\ninterface ArgLibrary {\n val alias: String\n val baseContent: AliasedLibrary\n val baseFlags: Iterable<ArgsFlag<*, *>>\n\n val theoryOperators: OperatorSet\n get() = OperatorSet.DEFAULT\n\n fun flags() = baseFlags\n fun content() = baseContent\n}\n\ninterface UnionArgLibrary<T> : ArgLibrary where T : ArgLibrary {\n\n val parentLibrary: T\n\n override fun flags() = baseFlags.union(parentLibrary.flags())\n override fun content() = Library.aliased(\n alias = baseContent.alias,\n theory = baseContent.theory.plus(parentLibrary.content().theory)\n )\n}\n\ninterface RawPrologContent {\n val prologTheory: Theory\n}\n\nabstract class LazyRawPrologContent : ArgLibrary, RawPrologContent {\n abstract val prologRawTheory: String\n override val prologTheory: Theory by lazy {\n Theory.parse(prologRawTheory, theoryOperators)\n }\n}\n\ninterface Loadable {\n fun identifier(): String\n}\n\ninterface ArgsFlag<T, G> {\n fun predicate(): String\n fun default(): T\n fun values(): G\n}\n\ninterface PrimitiveWithSignature : Primitive {\n val signature: Signature\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmName(\"LazyKt\")\n@file:kotlin.jvm.JvmMultifileClass\n\npackage kotlin\n\nimport kotlin.reflect.KProperty\n\n/**\n * Represents a value with lazy initialization.\n *\n * To create an instance of [Lazy] use the [lazy] function.\n */\npublic interface Lazy<out T> {\n /**\n * Gets the lazily initialized value of the current Lazy instance.\n * Once the value was initialized it must not change during the rest of lifetime of this Lazy instance.\n */\n public val value: T\n\n /**\n * Returns `true` if a value for this Lazy instance has been already initialized, and `false` otherwise.\n * Once this function has returned `true` it stays `true` for the rest of lifetime of this Lazy instance.\n */\n public fun isInitialized(): Boolean\n}\n\n/**\n * Creates a new instance of the [Lazy] that is already initialized with the specified [value].\n */\npublic fun <T> lazyOf(value: T): Lazy<T> = InitializedLazyImpl(value)\n\n/**\n * An extension to delegate a read-only property of type [T] to an instance of [Lazy].\n *\n * This extension allows to use instances of Lazy for property delegation:\n * `val property: String by lazy { initializer }`\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value\n\n/**\n * Specifies how a [Lazy] instance synchronizes initialization among multiple threads.\n */\npublic enum class LazyThreadSafetyMode {\n\n /**\n * Locks are used to ensure that only a single thread can initialize the [Lazy] instance.\n */\n SYNCHRONIZED,\n\n /**\n * Initializer function can be called several times on concurrent access to uninitialized [Lazy] instance value,\n * but only the first returned value will be used as the value of [Lazy] instance.\n */\n PUBLICATION,\n\n /**\n * No locks are used to synchronize an access to the [Lazy] instance value; if the instance is accessed from multiple threads, its behavior is undefined.\n *\n * This mode should not be used unless the [Lazy] instance is guaranteed never to be initialized from more than one thread.\n */\n NONE,\n}\n\n\ninternal object UNINITIALIZED_VALUE\n\n// internal to be called from lazy in JS\ninternal class UnsafeLazyImpl<out T>(initializer: () -> T) : Lazy<T>, Serializable {\n private var initializer: (() -> T)? = initializer\n private var _value: Any? = UNINITIALIZED_VALUE\n\n override val value: T\n get() {\n if (_value === UNINITIALIZED_VALUE) {\n _value = initializer!!()\n initializer = null\n }\n @Suppress(\"UNCHECKED_CAST\")\n return _value as T\n }\n\n override fun isInitialized(): Boolean = _value !== UNINITIALIZED_VALUE\n\n override fun toString(): String = if (isInitialized()) value.toString() else \"Lazy value not initialized yet.\"\n\n private fun writeReplace(): Any = InitializedLazyImpl(value)\n}\n\ninternal class InitializedLazyImpl<out T>(override val value: T) : Lazy<T>, Serializable {\n\n override fun isInitialized(): Boolean = true\n\n override fun toString(): String = value.toString()\n\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.PrimitiveWithSignature\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.flags.Unknown\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.theory.MutableTheory\nimport it.unibo.tuprolog.theory.Theory\n\nclass Cache : ArgLibrary {\n\n private val solver: MutableSolver =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n\n inner class CacheAssert : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_assert\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Cache.solver.assertA(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class CacheRetract : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_retract\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Cache.solver.retractAll(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class CacheGet : PrimitiveWithSignature {\n\n override val signature = Signature(\"cache_check\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n\n return sequence {\n yieldAll(\n this@Cache.solver.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n override val alias = \"prolog.argumentation.cache\"\n\n override val baseContent: AliasedLibrary\n get() =\n listOf(\n CacheAssert(),\n CacheRetract(),\n CacheGet()\n ).let { primitives ->\n Library.aliased(\n alias = this.alias,\n primitives = primitives.associateBy { it.signature }\n )\n }\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"StandardKt\")\npackage kotlin\n\nimport kotlin.contracts.*\n\n/**\n * An exception is thrown to indicate that a method body remains to be implemented.\n */\npublic class NotImplementedError(message: String = \"An operation is not implemented.\") : Error(message)\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n */\n\n@kotlin.internal.InlineOnly\npublic inline fun TODO(): Nothing = throw NotImplementedError()\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n *\n * @param reason a string explaining why the implementation is missing.\n */\n@kotlin.internal.InlineOnly\npublic inline fun TODO(reason: String): Nothing = throw NotImplementedError(\"An operation is not implemented: $reason\")\n\n\n\n/**\n * Calls the specified function [block] and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#run).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <R> run(block: () -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#run).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> T.run(block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with the given [receiver] as its receiver and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#with).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> with(receiver: T, block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return receiver.block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns `this` value.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#apply).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> T.apply(block: T.() -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block()\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns `this` value.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#also).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.also(block: (T) -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block(this)\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns its result.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#let).\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> T.let(block: (T) -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block(this)\n}\n\n/**\n * Returns `this` value if it satisfies the given [predicate] or `null`, if it doesn't.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#takeif-and-takeunless).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (predicate(this)) this else null\n}\n\n/**\n * Returns `this` value if it _does not_ satisfy the given [predicate] or `null`, if it does.\n *\n * For detailed usage information see the documentation for [scope functions](https://kotlinlang.org/docs/reference/scope-functions.html#takeif-and-takeunless).\n */\n@kotlin.internal.InlineOnly\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (!predicate(this)) this else null\n}\n\n/**\n * Executes the given function [action] specified number of [times].\n *\n * A zero-based index of current iteration is passed as a parameter to [action].\n *\n * @sample samples.misc.ControlFlow.repeat\n */\n@kotlin.internal.InlineOnly\npublic inline fun repeat(times: Int, action: (Int) -> Unit) {\n contract { callsInPlace(action) }\n\n for (index in 0 until times) {\n action(index)\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgContext\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.PrimitiveWithSignature\nimport it.unibo.tuprolog.core.Numeric\nimport it.unibo.tuprolog.core.Substitution\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.flags.Unknown\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.theory.MutableTheory\nimport it.unibo.tuprolog.theory.Theory\n\nclass Context : ArgLibrary, ArgContext {\n\n private var nextSolver: Int = 1\n private var selectedSolver: Int = 0\n private val dynamicSolver: MutableMap<Int, MutableSolver> = mutableMapOf(\n 0 to\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n )\n\n inner class DynamicCacheReset : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_reset\", 0)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n this@Context.selectedSolver = 0\n this@Context.nextSolver = 1\n this@Context.dynamicSolver.clear()\n this@Context.dynamicSolver[0] =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.empty())\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheSelected : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_active\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n return sequenceOf(request.replyWith(Substitution.of(term.castToVar(), Numeric.of(this@Context.selectedSolver))))\n }\n }\n\n inner class DynamicCacheCheckout : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_checkout\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val target: Int = request.arguments[0].castToInteger().intValue.toInt()\n val result = dynamicSolver.keys.contains(target)\n this@Context.selectedSolver = target\n return sequenceOf(request.replyWith(result))\n }\n }\n\n inner class DynamicCacheBranch : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_branch\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val target: Int = request.arguments[0].castToInteger().intValue.toInt()\n val result: Term = request.arguments[1]\n this@Context.dynamicSolver[this@Context.nextSolver] =\n MutableSolver.classic(staticKb = Theory.empty(), dynamicKb = MutableTheory.of(this@Context.dynamicSolver[target]!!.dynamicKb))\n .also { it.setFlag(Unknown.name, Unknown.FAIL) }\n this@Context.selectedSolver = this@Context.nextSolver++\n return sequenceOf(request.replyWith(Substitution.of(result.castToVar(), Numeric.of(this@Context.selectedSolver))))\n }\n }\n\n inner class DynamicCacheAssert : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_assert\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.assertA(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheRetract : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_retract\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.retractAll(term.castToStruct())\n return sequenceOf(request.replyWith(true))\n }\n }\n\n inner class DynamicCacheGet : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_check\", 1)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val term: Term = request.arguments[0]\n\n return sequence {\n yieldAll(\n this@Context.dynamicSolver[this@Context.selectedSolver]!!.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n inner class DynamicCacheGetIndexed : PrimitiveWithSignature {\n\n override val signature = Signature(\"context_check\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val index: Int = request.arguments[0].asNumeric()!!.intValue.toInt()\n val term: Term = request.arguments[1]\n\n return sequence {\n yieldAll(\n this@Context.dynamicSolver[index]!!.solve(term.castToStruct()).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n override val alias = \"prolog.argumentation.context\"\n\n override val baseContent: AliasedLibrary\n get() =\n listOf(\n DynamicCacheReset(),\n DynamicCacheCheckout(),\n DynamicCacheSelected(),\n DynamicCacheBranch(),\n DynamicCacheAssert(),\n DynamicCacheRetract(),\n DynamicCacheGet(),\n DynamicCacheGetIndexed()\n ).let { primitives ->\n Library.aliased(\n alias = this.alias,\n primitives = primitives.associateBy { it.signature }\n )\n }\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n}\n","/*\n * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"MapsKt\")\n@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\n\nprivate object EmptyMap : Map<Any?, Nothing>, Serializable {\n private const val serialVersionUID: Long = 8246714829545688274\n\n override fun equals(other: Any?): Boolean = other is Map<*, *> && other.isEmpty()\n override fun hashCode(): Int = 0\n override fun toString(): String = \"{}\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n\n override fun containsKey(key: Any?): Boolean = false\n override fun containsValue(value: Nothing): Boolean = false\n override fun get(key: Any?): Nothing? = null\n override val entries: Set<Map.Entry<Any?, Nothing>> get() = EmptySet\n override val keys: Set<Any?> get() = EmptySet\n override val values: Collection<Nothing> get() = EmptyList\n\n private fun readResolve(): Any = EmptyMap\n}\n\n/**\n * Returns an empty read-only map of specified type.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\npublic fun <K, V> emptyMap(): Map<K, V> = @Suppress(\"UNCHECKED_CAST\") (EmptyMap as Map<K, V>)\n\n/**\n * Returns a new read-only map with the specified contents, given as a list of pairs\n * where the first value is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * The returned map is serializable (JVM).\n *\n * @sample samples.collections.Maps.Instantiation.mapFromPairs\n */\npublic fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> =\n if (pairs.size > 0) pairs.toMap(LinkedHashMap(mapCapacity(pairs.size))) else emptyMap()\n\n/**\n * Returns an empty read-only map.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> mapOf(): Map<K, V> = emptyMap()\n\n/**\n * Returns an empty new [MutableMap].\n *\n * The returned map preserves the entry iteration order.\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> mutableMapOf(): MutableMap<K, V> = LinkedHashMap()\n\n/**\n * Returns a new [MutableMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.mutableMapFromPairs\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\npublic fun <K, V> mutableMapOf(vararg pairs: Pair<K, V>): MutableMap<K, V> =\n LinkedHashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [HashMap].\n *\n * @sample samples.collections.Maps.Instantiation.emptyHashMap\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> hashMapOf(): HashMap<K, V> = HashMap<K, V>()\n\n/**\n * Returns a new [HashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * @sample samples.collections.Maps.Instantiation.hashMapFromPairs\n */\npublic fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> = HashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [LinkedHashMap].\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> linkedMapOf(): LinkedHashMap<K, V> = LinkedHashMap<K, V>()\n\n/**\n * Returns a new [LinkedHashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.linkedMapFromPairs\n */\npublic fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V> = pairs.toMap(LinkedHashMap(mapCapacity(pairs.size)))\n\n/**\n * Builds a new read-only [Map] by populating a [MutableMap] using the given [builderAction]\n * and returning a read-only map with the same key-value pairs.\n *\n * The map passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * Entries of the map are iterated in the order they were added by the [builderAction].\n *\n * @sample samples.collections.Builders.Maps.buildMapSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> buildMap(@BuilderInference builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildMapInternal(builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <K, V> buildMapInternal(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V>\n\n/**\n * Builds a new read-only [Map] by populating a [MutableMap] using the given [builderAction]\n * and returning a read-only map with the same key-value pairs.\n *\n * The map passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * [capacity] is used to hint the expected number of pairs added in the [builderAction].\n *\n * Entries of the map are iterated in the order they were added by the [builderAction].\n *\n * @throws IllegalArgumentException if the given [capacity] is negative.\n *\n * @sample samples.collections.Builders.Maps.buildMapSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> buildMap(capacity: Int, @BuilderInference builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildMapInternal(capacity, builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <K, V> buildMapInternal(capacity: Int, builderAction: MutableMap<K, V>.() -> Unit): Map<K, V>\n\n/**\n * Calculate the initial capacity of a map.\n */\n@PublishedApi\ninternal expect fun mapCapacity(expectedSize: Int): Int\n\n/**\n * Returns `true` if this map is not empty.\n * @sample samples.collections.Maps.Usage.mapIsNotEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<out K, V>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable map is either null or empty.\n * @sample samples.collections.Maps.Usage.mapIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || isEmpty()\n}\n\n/**\n * Returns the [Map] if its not `null`, or the empty [Map] otherwise.\n *\n * @sample samples.collections.Maps.Usage.mapOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> = this ?: emptyMap()\n\n/**\n * Returns this map if it's not empty\n * or the result of calling [defaultValue] function if the map is empty.\n *\n * @sample samples.collections.Maps.Usage.mapIfEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <M, R> M.ifEmpty(defaultValue: () -> R): R where M : Map<*, *>, M : R =\n if (isEmpty()) defaultValue() else this\n\n/**\n * Checks if the map contains the given key.\n *\n * This method allows to use the `x in map` syntax for checking whether an object is contained in the map.\n *\n * @sample samples.collections.Maps.Usage.containsKey\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.contains(key: K): Boolean = containsKey(key)\n\n/**\n * Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, V>).get(key)\n\n/**\n * Allows to use the index operator for storing values in a mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit {\n put(key, value)\n}\n\n/**\n * Returns `true` if the map contains the specified [key].\n *\n * Allows to overcome type-safety restriction of `containsKey` that requires to pass a key of type `K`.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(key: K): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, *>).containsKey(key)\n\n/**\n * Returns `true` if the map maps one or more keys to the specified [value].\n *\n * Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`.\n *\n * @sample samples.collections.Maps.Usage.containsValue\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\n@kotlin.internal.InlineOnly\npublic inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)\n\n\n/**\n * Removes the specified key and its corresponding value from this map.\n *\n * @return the previous value associated with the key, or `null` if the key was not present in the map.\n\n * Allows to overcome type-safety restriction of `remove` that requires to pass a key of type `K`.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes K, V> MutableMap<out K, V>.remove(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableMap<K, V>).remove(key)\n\n/**\n * Returns the key component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map.Entry<K, V>.component1(): K = key\n\n/**\n * Returns the value component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map.Entry<K, V>.component2(): V = value\n\n/**\n * Converts entry to [Pair] with key being first component and value being second.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map.Entry<K, V>.toPair(): Pair<K, V> = Pair(key, value)\n\n/**\n * Returns the value for the given key, or the result of the [defaultValue] function if there was no entry for the given key.\n *\n * @sample samples.collections.Maps.Usage.getOrElse\n */\n@kotlin.internal.InlineOnly\npublic inline fun <K, V> Map<K, V>.getOrElse(key: K, defaultValue: () -> V): V = get(key) ?: defaultValue()\n\n\ninternal inline fun <K, V> Map<K, V>.getOrElseNullable(key: K, defaultValue: () -> V): V {\n val value = get(key)\n if (value == null && !containsKey(key)) {\n return defaultValue()\n } else {\n @Suppress(\"UNCHECKED_CAST\")\n return value as V\n }\n}\n\n/**\n * Returns the value for the given [key] or throws an exception if there is no such key in the map.\n *\n * If the map was created by [withDefault], resorts to its `defaultValue` provider function\n * instead of throwing an exception.\n *\n * @throws NoSuchElementException when the map doesn't contain a value for the specified key and\n * no implicit default value was provided for that map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<K, V>.getValue(key: K): V = getOrImplicitDefault(key)\n\n/**\n * Returns the value for the given key. If the key is not found in the map, calls the [defaultValue] function,\n * puts its result into the map under the given key and returns it.\n *\n * Note that the operation is not guaranteed to be atomic if the map is being modified concurrently.\n *\n * @sample samples.collections.Maps.Usage.getOrPut\n */\npublic inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {\n val value = get(key)\n return if (value == null) {\n val answer = defaultValue()\n put(key, answer)\n answer\n } else {\n value\n }\n}\n\n/**\n * Returns an [Iterator] over the entries in the [Map].\n *\n * @sample samples.collections.Maps.Usage.forOverEntries\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> Map<out K, V>.iterator(): Iterator<Map.Entry<K, V>> = entries.iterator()\n\n/**\n * Returns a [MutableIterator] over the mutable entries in the [MutableMap].\n *\n */\n@kotlin.jvm.JvmName(\"mutableIterator\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableMap.MutableEntry<K, V>> = entries.iterator()\n\n/**\n * Populates the given [destination] map with entries having the keys of this map and the values obtained\n * by applying the [transform] function to each entry in this [Map].\n */\npublic inline fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, { it.key }, transform)\n}\n\n/**\n * Populates the given [destination] map with entries having the keys obtained\n * by applying the [transform] function to each entry in this [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n */\npublic inline fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, transform, { it.value })\n}\n\n/**\n * Puts all the given [pairs] into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Array<out Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given collection into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Iterable<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given sequence into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Sequence<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Returns a new map with entries having the keys of this map and the values obtained by applying the [transform]\n * function to each entry in this [Map].\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapValues\n */\npublic inline fun <K, V, R> Map<out K, V>.mapValues(transform: (Map.Entry<K, V>) -> R): Map<K, R> {\n return mapValuesTo(LinkedHashMap<K, R>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a new Map with entries having the keys obtained by applying the [transform] function to each entry in this\n * [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapKeys\n */\npublic inline fun <K, V, R> Map<out K, V>.mapKeys(transform: (Map.Entry<K, V>) -> R): Map<R, V> {\n return mapKeysTo(LinkedHashMap<R, V>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a map containing all key-value pairs with keys matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterKeys\n */\npublic inline fun <K, V> Map<out K, V>.filterKeys(predicate: (K) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.key)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n/**\n * Returns a map containing all key-value pairs with values matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterValues\n */\npublic inline fun <K, V> Map<out K, V>.filterValues(predicate: (V) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.value)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n\n/**\n * Appends all entries matching the given [predicate] into the mutable map given as [destination] parameter.\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filter\n */\npublic inline fun <K, V> Map<out K, V>.filter(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Appends all entries not matching the given [predicate] into the given [destination].\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterNotTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (!predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs not matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterNot\n */\npublic inline fun <K, V> Map<out K, V>.filterNot(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterNotTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Returns a new map containing all key-value pairs from the given collection of pairs.\n *\n * The returned map preserves the entry iteration order of the original collection.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(if (this is List) this[0] else iterator().next())\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n }\n }\n return toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given collection of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given array of pairs.\n *\n * The returned map preserves the entry iteration order of the original array.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(this[0])\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given array of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given sequence of pairs.\n *\n * The returned map preserves the entry iteration order of the original sequence.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> = toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given sequence of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new read-only map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMap()\n else -> toMutableMap()\n}\n\n/**\n * Returns a new mutable map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> = LinkedHashMap(this)\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair].\n *\n * The returned map preserves the entry iteration order of the original map.\n * The [pair] is iterated in the end if it has a unique key.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pair: Pair<K, V>): Map<K, V> =\n if (this.isEmpty()) mapOf(pair) else LinkedHashMap(this).apply { put(pair.first, pair.second) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] collection.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] array.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Array<out Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] sequence.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(pairs) }.optimizeReadOnlyMap()\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from another [map].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those entries of another [map] that are missing in this map are iterated in the end in the order of that [map].\n */\npublic operator fun <K, V> Map<out K, V>.plus(map: Map<out K, V>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(map) }\n\n\n/**\n * Appends or replaces the given [pair] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pair: Pair<K, V>) {\n put(pair.first, pair.second)\n}\n\n/**\n * Appends or replaces all pairs from the given collection of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Iterable<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given array of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Array<out Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given sequence of [pairs] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Sequence<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all entries from the given [map] in this mutable map.\n */\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(map: Map<K, V>) {\n putAll(map)\n}\n\n/**\n * Returns a map containing all entries of the original map except the entry with the given [key].\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> =\n this.toMutableMap().apply { minusAssign(key) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] collection.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Iterable<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] array.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Array<out K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] sequence.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Sequence<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Removes the entry with the given [key] from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {\n remove(key)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] collection from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] array from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<out K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries from the keys of which are contained in the given [keys] sequence from this mutable map.\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {\n this.keys.removeAll(keys)\n}\n\n\n// do not expose for now @PublishedApi\ninternal fun <K, V> Map<K, V>.optimizeReadOnlyMap() = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMapOrSelf()\n else -> this\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.Arg2pSolver\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLoader\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.core.Atom\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.Operator\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.core.operators.Specifier\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.MutableSolver\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.exception.error.DomainError\nimport it.unibo.tuprolog.solve.exception.error.TypeError\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Libraries\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.solve.primitive.Solve\n\nclass DynamicLoader(private val solver: Arg2pSolver) : ArgLibrary, ArgLoader {\n\n abstract inner class AbstractWithLib : Primitive {\n\n abstract val signature: Signature\n abstract fun execute(module: String, solver: MutableSolver)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val lib: Term = request.arguments[0]\n val goal: Term = request.arguments[1]\n\n if (lib !is Atom) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.LIST,\n lib\n )\n }\n\n if (goal !is Struct) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.CALLABLE,\n goal\n )\n }\n\n val solver = (\n this@DynamicLoader.solver.dynamicLibraries().firstOrNull {\n (it as Loadable).identifier() == lib.toString()\n } ?: throw DomainError.forGoal(\n request.context,\n request.signature,\n DomainError.Expected.of(\"Loadable Lib\"),\n lib\n )\n ).let { library ->\n request.context.createMutableSolver(\n libraries = Libraries.of(\n request.context.libraries.libraries.filterNot { lib ->\n this@DynamicLoader.solver.dynamicLibraries()\n .map { it.alias }\n .contains(lib.alias)\n }\n ).plus(library.content()),\n staticKb = request.context.staticKb\n )\n }\n\n execute(lib.toString(), solver)\n\n return sequence {\n yieldAll(\n solver.solve(goal).map {\n request.replyWith(it.substitution)\n }\n )\n }\n }\n }\n\n inner class WithLib : AbstractWithLib() {\n override val signature = Signature(\"::\", 2)\n override fun execute(module: String, solver: MutableSolver) = Unit\n }\n\n inner class WithLibInNewContext : AbstractWithLib() {\n override val signature = Signature(\":::\", 2)\n override fun execute(module: String, solver: MutableSolver) =\n prolog {\n solver.solve(\"context_active\"(X))\n .filter { it.isYes }\n .forEach {\n solver.solve(\"context_branch\"(it.substitution[X]!!, `_`)).first()\n }\n }\n }\n\n override val alias = \"prolog.argumentation.loader\"\n\n override val baseContent: AliasedLibrary\n get() = listOf(WithLib(), WithLibInNewContext()).let {\n Library.aliased(\n alias = this.alias,\n primitives = it.associateBy { prim -> prim.signature },\n operatorSet = operators()\n )\n }\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override var theoryOperators = operators()\n\n companion object {\n fun operators() = OperatorSet(\n Operator(\"::\", Specifier.XFX, 700),\n Operator(\":::\", Specifier.XFX, 700),\n )\n }\n}\n","/*\n * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"SequencesKt\")\n\npackage kotlin.sequences\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\n\n/**\n * Returns `true` if [element] is found in the sequence.\n *\n * The operation is _terminal_.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.contains(element: T): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\npublic fun <T> Sequence<T>.elementAt(index: Int): T {\n return elementAtOrElse(index) { throw IndexOutOfBoundsException(\"Sequence doesn't contain element at index $index.\") }\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\npublic fun <T> Sequence<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n if (index < 0)\n return defaultValue(index)\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\npublic fun <T> Sequence<T>.elementAtOrNull(index: Int): T? {\n if (index < 0)\n return null\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.find\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the sequence is empty.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.first(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n return iterator.next()\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this sequence in iteration order,\n * or throws [NoSuchElementException] if no non-null value was produced.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Sequence<T>.firstNotNullOf(transform: (T) -> R?): R {\n return firstNotNullOfOrNull(transform) ?: throw NoSuchElementException(\"No element of the sequence was transformed to a non-null value.\")\n}\n\n/**\n * Returns the first non-null value produced by [transform] function being applied to elements of this sequence in iteration order,\n * or `null` if no non-null value was produced.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.firstNotNullOf\n */\n@SinceKotlin(\"1.5\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Any> Sequence<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? {\n for (element in this) {\n val result = transform(element)\n if (result != null) {\n return result\n }\n }\n return null\n}\n\n/**\n * Returns the first element, or `null` if the sequence is empty.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.firstOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n return iterator.next()\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns first index of [element], or -1 if the sequence does not contain element.\n *\n * The operation is _terminal_.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.indexOf(element: T): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the sequence does not contain such element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the sequence does not contain such element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns the last element.\n *\n * The operation is _terminal_.\n * \n * @throws NoSuchElementException if the sequence is empty.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Sequence<T>.last(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @throws NoSuchElementException if no such element is found.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Sequence<T>.last(predicate: (T) -> Boolean): T {\n var last: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n last = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return last as T\n}\n\n/**\n * Returns last index of [element], or -1 if the sequence does not contain element.\n *\n * The operation is _terminal_.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Sequence<T>.lastIndexOf(element: T): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns the last element, or `null` if the sequence is empty.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic fun <T> Sequence<T>.lastOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Elements.last\n */\npublic inline fun <T> Sequence<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n var last: T? = null\n for (element in this) {\n if (predicate(element)) {\n last = element\n }\n }\n return last\n}\n\n/**\n * Returns the single element, or throws an exception if the sequence is empty or has more than one element.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.single(): T {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Sequence is empty.\")\n val single = iterator.next()\n if (iterator.hasNext())\n throw IllegalArgumentException(\"Sequence has more than one element.\")\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Sequence contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Sequence contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns single element, or `null` if the sequence is empty or has more than one element.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.singleOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n val single = iterator.next()\n if (iterator.hasNext())\n return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a sequence containing all elements except first [n] elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Sequence<T>.drop(n: Int): Sequence<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return when {\n n == 0 -> this\n this is DropTakeSequence -> this.drop(n)\n else -> DropSequence(this, n)\n }\n}\n\n/**\n * Returns a sequence containing all elements except first elements that satisfy the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Sequence<T>.dropWhile(predicate: (T) -> Boolean): Sequence<T> {\n return DropWhileSequence(this, predicate)\n}\n\n/**\n * Returns a sequence containing only elements matching the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic fun <T> Sequence<T>.filter(predicate: (T) -> Boolean): Sequence<T> {\n return FilteringSequence(this, true, predicate)\n}\n\n/**\n * Returns a sequence containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexed\n */\npublic fun <T> Sequence<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence<T> {\n // TODO: Rewrite with generalized MapFilterIndexingSequence\n return TransformingSequence(FilteringSequence(IndexingSequence(this), true, { predicate(it.index, it.value) }), { it.value })\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterIndexedTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a sequence containing all elements that are instances of specified type parameter R.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstance\n */\npublic inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<@kotlin.internal.NoInfer R> {\n @Suppress(\"UNCHECKED_CAST\")\n return filter { it is R } as Sequence<R>\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterIsInstanceTo\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Sequence<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a sequence containing all elements not matching the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filter\n */\npublic fun <T> Sequence<T>.filterNot(predicate: (T) -> Boolean): Sequence<T> {\n return FilteringSequence(this, false, predicate)\n}\n\n/**\n * Returns a sequence containing all elements that are not `null`.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNull\n */\npublic fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> {\n @Suppress(\"UNCHECKED_CAST\")\n return filterNot { it == null } as Sequence<T>\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterNotNullTo\n */\npublic fun <C : MutableCollection<in T>, T : Any> Sequence<T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Filtering.filterTo\n */\npublic inline fun <T, C : MutableCollection<in T>> Sequence<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a sequence containing first [n] elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @throws IllegalArgumentException if [n] is negative.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Sequence<T>.take(n: Int): Sequence<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return when {\n n == 0 -> emptySequence()\n this is DropTakeSequence -> this.take(n)\n else -> TakeSequence(this, n)\n }\n}\n\n/**\n * Returns a sequence containing first elements satisfying the given [predicate].\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Sequence<T>.takeWhile(predicate: (T) -> Boolean): Sequence<T> {\n return TakeWhileSequence(this, predicate)\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T : Comparable<T>> Sequence<T>.sorted(): Sequence<T> {\n return object : Sequence<T> {\n override fun iterator(): Iterator<T> {\n val sortedList = this@sorted.toMutableList()\n sortedList.sort()\n return sortedList.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Sorting.sortedBy\n */\npublic inline fun <T, R : Comparable<R>> Sequence<T>.sortedBy(crossinline selector: (T) -> R?): Sequence<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic inline fun <T, R : Comparable<R>> Sequence<T>.sortedByDescending(crossinline selector: (T) -> R?): Sequence<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T : Comparable<T>> Sequence<T>.sortedDescending(): Sequence<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a sequence that yields elements of this sequence sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic fun <T> Sequence<T>.sortedWith(comparator: Comparator<in T>): Sequence<T> {\n return object : Sequence<T> {\n override fun iterator(): Iterator<T> {\n val sortedList = this@sortedWith.toMutableList()\n sortedList.sortWith(comparator)\n return sortedList.iterator()\n }\n }\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given sequence.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associate\n */\npublic inline fun <T, K, V> Sequence<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n return associateTo(LinkedHashMap<K, V>(), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given sequence indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateBy\n */\npublic inline fun <T, K> Sequence<T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n return associateByTo(LinkedHashMap<K, T>(), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given sequence.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByWithValueTransform\n */\npublic inline fun <T, K, V> Sequence<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n return associateByTo(LinkedHashMap<K, V>(), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given sequence\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByTo\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Sequence<T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given sequence.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given sequence.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateTo\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Sequence<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Returns a [Map] where keys are elements from the given sequence and values are\n * produced by the [valueSelector] function applied to each element.\n * \n * If any two elements are equal, the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateWith\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V> Sequence<K>.associateWith(valueSelector: (K) -> V): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n return associateWithTo(result, valueSelector)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs for each element of the given sequence,\n * where key is the element itself and value is provided by the [valueSelector] function applied to that key.\n * \n * If any two elements are equal, the last one overwrites the former value in the map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.associateWithTo\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V, M : MutableMap<in K, in V>> Sequence<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M {\n for (element in this) {\n destination.put(element, valueSelector(element))\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n *\n * The operation is _terminal_.\n */\npublic fun <T, C : MutableCollection<in T>> Sequence<T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a new [HashSet] of all elements.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>())\n}\n\n/**\n * Returns a [List] containing all elements.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toList(): List<T> {\n return this.toMutableList().optimizeReadOnlyList()\n}\n\n/**\n * Returns a new [MutableList] filled with all elements of this sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toMutableList(): MutableList<T> {\n return toCollection(ArrayList<T>())\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toSet(): Set<T> {\n return toCollection(LinkedHashSet<T>()).optimizeReadOnlySet()\n}\n\n/**\n * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIterable\")\npublic fun <T, R> Sequence<T>.flatMap(transform: (T) -> Iterable<R>): Sequence<R> {\n return FlatteningSequence(this, transform, Iterable<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMap\n */\npublic fun <T, R> Sequence<T>.flatMap(transform: (T) -> Sequence<R>): Sequence<R> {\n return FlatteningSequence(this, transform, Sequence<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterable\")\npublic fun <T, R> Sequence<T>.flatMapIndexed(transform: (index: Int, T) -> Iterable<R>): Sequence<R> {\n return flatMapIndexed(this, transform, Iterable<R>::iterator)\n}\n\n/**\n * Returns a single sequence of all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.flatMapIndexed\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequence\")\npublic fun <T, R> Sequence<T>.flatMapIndexed(transform: (index: Int, T) -> Sequence<R>): Sequence<R> {\n return flatMapIndexed(this, transform, Sequence<R>::iterator)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedIterableTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Iterable<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element\n * and its index in the original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIndexedSequenceTo\")\n@kotlin.internal.InlineOnly\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapIndexedTo(destination: C, transform: (index: Int, T) -> Sequence<R>): C {\n var index = 0\n for (element in this) {\n val list = transform(checkIndexOverflow(index++), element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"flatMapIterableTo\")\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.flatMapTo(destination: C, transform: (T) -> Sequence<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original sequence by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Sequence<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original sequence\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original sequence.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Sequence<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original sequence by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original sequence\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from a sequence to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Sequence<T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = this@groupingBy.iterator()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to each element in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.map\n */\npublic fun <T, R> Sequence<T>.map(transform: (T) -> R): Sequence<R> {\n return TransformingSequence(this, transform)\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to each element and its index in the original sequence.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T, R> Sequence<T>.mapIndexed(transform: (index: Int, T) -> R): Sequence<R> {\n return TransformingIndexedSequence(this, transform)\n}\n\n/**\n * Returns a sequence containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original sequence.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T, R : Any> Sequence<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence<R> {\n return TransformingIndexedSequence(this, transform).filterNotNull()\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original sequence\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original sequence\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(checkIndexOverflow(index++), item))\n return destination\n}\n\n/**\n * Returns a sequence containing only the non-null results of applying the given [transform] function\n * to each element in the original sequence.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.mapNotNull\n */\npublic fun <T, R : Any> Sequence<T>.mapNotNull(transform: (T) -> R?): Sequence<R> {\n return TransformingSequence(this, transform).filterNotNull()\n}\n\n/**\n * Applies the given [transform] function to each element in the original sequence\n * and appends only the non-null results to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Sequence<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original sequence\n * and appends the results to the given [destination].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a sequence that wraps each element of the original sequence\n * into an [IndexedValue] containing the index of that element and the element itself.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T> Sequence<T>.withIndex(): Sequence<IndexedValue<T>> {\n return IndexingSequence(this)\n}\n\n/**\n * Returns a sequence containing only distinct elements from the given sequence.\n * \n * Among equal elements of the given sequence, only the first one will be present in the resulting sequence.\n * The elements in the resulting sequence are in the same order as they were in the source sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T> Sequence<T>.distinct(): Sequence<T> {\n return this.distinctBy { it }\n}\n\n/**\n * Returns a sequence containing only elements from the given sequence\n * having distinct keys returned by the given [selector] function.\n * \n * Among elements of the given sequence with equal keys, only the first one will be present in the resulting sequence.\n * The elements in the resulting sequence are in the same order as they were in the source sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy\n */\npublic fun <T, K> Sequence<T>.distinctBy(selector: (T) -> K): Sequence<T> {\n return DistinctSequence(this, selector)\n}\n\n/**\n * Returns a new [MutableSet] containing all distinct elements from the given sequence.\n * \n * The returned set preserves the element iteration order of the original sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.toMutableSet(): MutableSet<T> {\n val set = LinkedHashSet<T>()\n for (item in this) set.add(item)\n return set\n}\n\n/**\n * Returns `true` if all elements match the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.all\n */\npublic inline fun <T> Sequence<T>.all(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (!predicate(element)) return false\n return true\n}\n\n/**\n * Returns `true` if sequence has at least one element.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.any\n */\npublic fun <T> Sequence<T>.any(): Boolean {\n return iterator().hasNext()\n}\n\n/**\n * Returns `true` if at least one element matches the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.anyWithPredicate\n */\npublic inline fun <T> Sequence<T>.any(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (predicate(element)) return true\n return false\n}\n\n/**\n * Returns the number of elements in this sequence.\n *\n * The operation is _terminal_.\n */\npublic fun <T> Sequence<T>.count(): Int {\n var count = 0\n for (element in this) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Returns the number of elements matching the given [predicate].\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int {\n var count = 0\n for (element in this) if (predicate(element)) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns the specified [initial] value if the sequence is empty.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R> Sequence<T>.fold(initial: R, operation: (acc: R, T) -> R): R {\n var accumulator = initial\n for (element in this) accumulator = operation(accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Returns the specified [initial] value if the sequence is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T, R> Sequence<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {\n var index = 0\n var accumulator = initial\n for (element in this) accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n return accumulator\n}\n\n/**\n * Performs the given [action] on each element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.forEach(action: (T) -> Unit): Unit {\n for (element in this) action(element)\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n *\n * The operation is _terminal_.\n */\npublic inline fun <T> Sequence<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {\n var index = 0\n for (item in this) action(checkIndexOverflow(index++), item)\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Double>.max(): Double? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Float>.max(): Float? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxOrNull instead.\", ReplaceWith(\"this.maxOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Sequence<T>.max(): T? {\n return maxOrNull()\n}\n\n@Deprecated(\"Use maxByOrNull instead.\", ReplaceWith(\"this.maxByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(selector: (T) -> R): T? {\n return maxByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the largest value of the given function or `null` if there are no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.maxByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxElem = iterator.next()\n if (!iterator.hasNext()) return maxElem\n var maxValue = selector(maxElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (maxValue < v) {\n maxElem = e\n maxValue = v\n }\n } while (iterator.hasNext())\n return maxElem\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.maxOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n maxValue = maxOf(maxValue, v)\n }\n return maxValue\n}\n\n/**\n * Returns the largest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.maxOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (maxValue < v) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.maxOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.maxOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(maxValue, v) < 0) {\n maxValue = v\n }\n }\n return maxValue\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Double>.maxOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Float>.maxOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n max = maxOf(max, e)\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (max < e) max = e\n }\n return max\n}\n\n@Deprecated(\"Use maxWithOrNull instead.\", ReplaceWith(\"this.maxWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T? {\n return maxWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.maxWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(max, e) < 0) max = e\n }\n return max\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Double>.min(): Double? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\n@SinceKotlin(\"1.1\")\npublic fun Sequence<Float>.min(): Float? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minOrNull instead.\", ReplaceWith(\"this.minOrNull()\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T : Comparable<T>> Sequence<T>.min(): T? {\n return minOrNull()\n}\n\n@Deprecated(\"Use minByOrNull instead.\", ReplaceWith(\"this.minByOrNull(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minBy(selector: (T) -> R): T? {\n return minByOrNull(selector)\n}\n\n/**\n * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.minByOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minElem = iterator.next()\n if (!iterator.hasNext()) return minElem\n var minValue = selector(minElem)\n do {\n val e = iterator.next()\n val v = selector(e)\n if (minValue > v) {\n minElem = e\n minValue = v\n }\n } while (iterator.hasNext())\n return minElem\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOf(selector: (T) -> Double): Double {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOf(selector: (T) -> Float): Float {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minOf(selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOfOrNull(selector: (T) -> Double): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n * \n * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minOfOrNull(selector: (T) -> Float): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n minValue = minOf(minValue, v)\n }\n return minValue\n}\n\n/**\n * Returns the smallest value among all values produced by [selector] function\n * applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R : Comparable<R>> Sequence<T>.minOfOrNull(selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (minValue > v) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence.\n * \n * @throws NoSuchElementException if the sequence is empty.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.minOfWith(comparator: Comparator<in R>, selector: (T) -> R): R {\n val iterator = iterator()\n if (!iterator.hasNext()) throw NoSuchElementException()\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest value according to the provided [comparator]\n * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.internal.InlineOnly\npublic inline fun <T, R> Sequence<T>.minOfWithOrNull(comparator: Comparator<in R>, selector: (T) -> R): R? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minValue = selector(iterator.next())\n while (iterator.hasNext()) {\n val v = selector(iterator.next())\n if (comparator.compare(minValue, v) > 0) {\n minValue = v\n }\n }\n return minValue\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Double>.minOrNull(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun Sequence<Float>.minOrNull(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n min = minOf(min, e)\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (min > e) min = e\n }\n return min\n}\n\n@Deprecated(\"Use minWithOrNull instead.\", ReplaceWith(\"this.minWithOrNull(comparator)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.4\", errorSince = \"1.5\")\npublic fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T? {\n return minWithOrNull(comparator)\n}\n\n/**\n * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.minWithOrNull(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(min, e) > 0) min = e\n }\n return min\n}\n\n/**\n * Returns `true` if the sequence has no elements.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.none\n */\npublic fun <T> Sequence<T>.none(): Boolean {\n return !iterator().hasNext()\n}\n\n/**\n * Returns `true` if no elements match the given [predicate].\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.noneWithPredicate\n */\npublic inline fun <T> Sequence<T>.none(predicate: (T) -> Boolean): Boolean {\n for (element in this) if (predicate(element)) return false\n return true\n}\n\n/**\n * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@SinceKotlin(\"1.1\")\npublic fun <T> Sequence<T>.onEach(action: (T) -> Unit): Sequence<T> {\n return map {\n action(it)\n it\n }\n}\n\n/**\n * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the action on the element.\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@SinceKotlin(\"1.4\")\npublic fun <T> Sequence<T>.onEachIndexed(action: (index: Int, T) -> Unit): Sequence<T> {\n return mapIndexed { index, element ->\n action(index, element)\n element\n }\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,\n * please use [reduceOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Sequence<T>.reduce(operation: (acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty sequence can't be reduced.\")\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,\n * please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduce\n */\npublic inline fun <S, T : S> Sequence<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty sequence can't be reduced.\")\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original sequence.\n * \n * Returns `null` if the sequence is empty.\n * \n * @param [operation] function that takes the index of an element, current accumulator value and the element itself,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\npublic inline fun <S, T : S> Sequence<T>.reduceIndexedOrNull(operation: (index: Int, acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element.\n * \n * Returns `null` if the sequence is empty.\n * \n * @param [operation] function that takes current accumulator value and an element,\n * and calculates the next accumulator value.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Aggregates.reduceOrNull\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic inline fun <S, T : S> Sequence<T>.reduceOrNull(operation: (acc: S, T) -> S): S? {\n val iterator = this.iterator()\n if (!iterator.hasNext()) return null\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic fun <T, R> Sequence<T>.runningFold(initial: R, operation: (acc: R, T) -> R): Sequence<R> {\n return sequence {\n yield(initial)\n var accumulator = initial\n for (element in this@runningFold) {\n accumulator = operation(accumulator, element)\n yield(accumulator)\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningFold\n */\n@SinceKotlin(\"1.4\")\npublic fun <T, R> Sequence<T>.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): Sequence<R> {\n return sequence {\n yield(initial)\n var index = 0\n var accumulator = initial\n for (element in this@runningFoldIndexed) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n yield(accumulator)\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with the first element of this sequence.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * \n * @param [operation] function that takes current accumulator value and the element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <S, T : S> Sequence<T>.runningReduce(operation: (acc: S, T) -> S): Sequence<S> {\n return sequence {\n val iterator = iterator()\n if (iterator.hasNext()) {\n var accumulator: S = iterator.next()\n yield(accumulator)\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n yield(accumulator)\n }\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.runningReduce\n */\n@SinceKotlin(\"1.4\")\npublic fun <S, T : S> Sequence<T>.runningReduceIndexed(operation: (index: Int, acc: S, T) -> S): Sequence<S> {\n return sequence {\n val iterator = iterator()\n if (iterator.hasNext()) {\n var accumulator: S = iterator.next()\n yield(accumulator)\n var index = 1\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n yield(accumulator)\n }\n }\n }\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T, R> Sequence<T>.scan(initial: R, operation: (acc: R, T) -> R): Sequence<R> {\n return runningFold(initial, operation)\n}\n\n/**\n * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right\n * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.\n * \n * Note that `acc` value passed to [operation] function should not be mutated;\n * otherwise it would affect the previous value in resulting sequence.\n * The [initial] value should also be immutable (or should not be mutated)\n * as it may be passed to [operation] function later because of sequence's lazy nature.\n * \n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Aggregates.scan\n */\n@SinceKotlin(\"1.4\")\n@WasExperimental(ExperimentalStdlibApi::class)\npublic fun <T, R> Sequence<T>.scanIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): Sequence<R> {\n return runningFoldIndexed(initial, operation)\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Sequence<T>.sumBy(selector: (T) -> Int): Int {\n var sum: Int = 0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@Deprecated(\"Use sumOf instead.\", ReplaceWith(\"this.sumOf(selector)\"))\n@DeprecatedSinceKotlin(warningSince = \"1.5\")\npublic inline fun <T> Sequence<T>.sumByDouble(selector: (T) -> Double): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfDouble\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Double): Double {\n var sum: Double = 0.toDouble()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfInt\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Int): Int {\n var sum: Int = 0.toInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.4\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfLong\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> Long): Long {\n var sum: Long = 0.toLong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfUInt\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> UInt): UInt {\n var sum: UInt = 0.toUInt()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the sequence.\n *\n * The operation is _terminal_.\n */\n@SinceKotlin(\"1.5\")\n@OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n@OverloadResolutionByLambdaReturnType\n@kotlin.jvm.JvmName(\"sumOfULong\")\n@WasExperimental(ExperimentalUnsignedTypes::class)\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.sumOf(selector: (T) -> ULong): ULong {\n var sum: ULong = 0.toULong()\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {\n return map { it ?: throw IllegalArgumentException(\"null element found in $this.\") }\n}\n\n/**\n * Splits this sequence into a sequence of lists each not exceeding the given [size].\n * \n * The last list in the resulting sequence may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.collections.Collections.Transformations.chunked\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.chunked(size: Int): Sequence<List<T>> {\n return windowed(size, size, partialWindows = true)\n}\n\n/**\n * Splits this sequence into several lists each not exceeding the given [size]\n * and applies the given [transform] function to an each.\n * \n * @return sequence of results of the [transform] applied to an each list.\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * The last list may have fewer elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.\n *\n * The operation is _intermediate_ and _stateful_.\n * \n * @sample samples.text.Strings.chunkedTransform\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.chunked(size: Int, transform: (List<T>) -> R): Sequence<R> {\n return windowed(size, size, partialWindows = true, transform = transform)\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.minus(element: T): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n var removed = false\n return this@minus.filter { if (!removed && it == element) { removed = true; false } else true }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] array.\n * \n * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The [elements] array may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Array<out T>): Sequence<T> {\n if (elements.isEmpty()) return this\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.toHashSet()\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] collection.\n * \n * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The [elements] collection may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n *\n * The operation is _intermediate_ and _stateful_.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Iterable<T>): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.convertToSetForSetOperation()\n if (other.isEmpty())\n return this@minus.iterator()\n else\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] sequence.\n * \n * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n * \n * The operation is _intermediate_ for this sequence and _terminal_ and _stateful_ for the [elements] sequence.\n * \n * The [elements] sequence may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Sequence<T>.minus(elements: Sequence<T>): Sequence<T> {\n return object: Sequence<T> {\n override fun iterator(): Iterator<T> {\n val other = elements.toHashSet()\n if (other.isEmpty())\n return this@minus.iterator()\n else\n return this@minus.filterNot { it in other }.iterator()\n }\n }\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.minusElement(element: T): Sequence<T> {\n return minus(element)\n}\n\n/**\n * Splits the original sequence into pair of lists,\n * where *first* list contains elements for which [predicate] yielded `true`,\n * while *second* list contains elements for which [predicate] yielded `false`.\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Sequences.Transformations.partition\n */\npublic inline fun <T> Sequence<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {\n val first = ArrayList<T>()\n val second = ArrayList<T>()\n for (element in this) {\n if (predicate(element)) {\n first.add(element)\n } else {\n second.add(element)\n }\n }\n return Pair(first, second)\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence and then the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(element: T): Sequence<T> {\n return sequenceOf(this, sequenceOf(element)).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] array.\n * \n * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Array<out T>): Sequence<T> {\n return this.plus(elements.asList())\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] collection.\n * \n * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Iterable<T>): Sequence<T> {\n return sequenceOf(this, elements.asSequence()).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] sequence.\n * \n * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from\n * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.\n *\n * The operation is _intermediate_ and _stateless_.\n */\npublic operator fun <T> Sequence<T>.plus(elements: Sequence<T>): Sequence<T> {\n return sequenceOf(this, elements).flatten()\n}\n\n/**\n * Returns a sequence containing all elements of the original sequence and then the given [element].\n *\n * The operation is _intermediate_ and _stateless_.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.plusElement(element: T): Sequence<T> {\n return plus(element)\n}\n\n/**\n * Returns a sequence of snapshots of the window of the given [size]\n * sliding along this sequence with the given [step], where each\n * snapshot is a list.\n * \n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.takeWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): Sequence<List<T>> {\n return windowedSequence(size, step, partialWindows, reuseBuffer = false)\n}\n\n/**\n * Returns a sequence of results of applying the given [transform] function to\n * an each list representing a view over the window of the given [size]\n * sliding along this sequence with the given [step].\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * Several last lists may have fewer elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.averageWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): Sequence<R> {\n return windowedSequence(size, step, partialWindows, reuseBuffer = true).map(transform)\n}\n\n/**\n * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index.\n * The resulting sequence ends as soon as the shortest input sequence ends.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Sequences.Transformations.zip\n */\npublic infix fun <T, R> Sequence<T>.zip(other: Sequence<R>): Sequence<Pair<T, R>> {\n return MergingSequence(this, other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The resulting sequence ends as soon as the shortest input sequence ends.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Sequences.Transformations.zipWithTransform\n */\npublic fun <T, R, V> Sequence<T>.zip(other: Sequence<R>, transform: (a: T, b: R) -> V): Sequence<V> {\n return MergingSequence(this, other, transform)\n}\n\n/**\n * Returns a sequence of pairs of each two adjacent elements in this sequence.\n * \n * The returned sequence is empty if this sequence contains less than two elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNext\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> {\n return zipWithNext { a, b -> a to b }\n}\n\n/**\n * Returns a sequence containing the results of applying the given [transform] function\n * to an each pair of two adjacent elements in this sequence.\n * \n * The returned sequence is empty if this sequence contains less than two elements.\n *\n * The operation is _intermediate_ and _stateless_.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Sequence<T>.zipWithNext(transform: (a: T, b: T) -> R): Sequence<R> {\n return sequence result@ {\n val iterator = iterator()\n if (!iterator.hasNext()) return@result\n var current = iterator.next()\n while (iterator.hasNext()) {\n val next = iterator.next()\n yield(transform(current, next))\n current = next\n }\n }\n}\n\n/**\n * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.joinTo\n */\npublic fun <T, A : Appendable> Sequence<T>.joinTo(buffer: A, separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): A {\n buffer.append(prefix)\n var count = 0\n for (element in this) {\n if (++count > 1) buffer.append(separator)\n if (limit < 0 || count <= limit) {\n buffer.appendElement(element, transform)\n } else break\n }\n if (limit >= 0 && count > limit) buffer.append(truncated)\n buffer.append(postfix)\n return buffer\n}\n\n/**\n * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n *\n * The operation is _terminal_.\n * \n * @sample samples.collections.Collections.Transformations.joinToString\n */\npublic fun <T> Sequence<T>.joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): String {\n return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()\n}\n\n/**\n * Creates an [Iterable] instance that wraps the original sequence returning its elements when being iterated.\n */\npublic fun <T> Sequence<T>.asIterable(): Iterable<T> {\n return Iterable { this.iterator() }\n}\n\n/**\n * Returns this sequence as a [Sequence].\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Sequence<T>.asSequence(): Sequence<T> {\n return this\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfByte\")\npublic fun Sequence<Byte>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfShort\")\npublic fun Sequence<Short>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfInt\")\npublic fun Sequence<Int>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfLong\")\npublic fun Sequence<Long>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfFloat\")\npublic fun Sequence<Float>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"averageOfDouble\")\npublic fun Sequence<Double>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfByte\")\npublic fun Sequence<Byte>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfShort\")\npublic fun Sequence<Short>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfInt\")\npublic fun Sequence<Int>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfLong\")\npublic fun Sequence<Long>.sum(): Long {\n var sum: Long = 0L\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfFloat\")\npublic fun Sequence<Float>.sum(): Float {\n var sum: Float = 0.0f\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the sequence.\n *\n * The operation is _terminal_.\n */\n@kotlin.jvm.JvmName(\"sumOfDouble\")\npublic fun Sequence<Double>.sum(): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.language.RuleParserBase\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class EngineInterfaceBase : ArgLibrary, LazyRawPrologContent() {\n\n override val alias = \"prolog.argumentation.interface\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory,\n operatorSet = RuleParserBase.operators()\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override val theoryOperators = RuleParserBase.operators()\n .plus(DynamicLoader.operators())\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object EngineInterface : EngineInterfaceBase\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.extra.ModulesPath\nimport it.unibo.tuprolog.argumentation.core.libs.graph.ArgumentLabellingMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.GraphBuildMode\nimport it.unibo.tuprolog.argumentation.core.libs.graph.GraphExtension\nimport it.unibo.tuprolog.argumentation.core.libs.graph.StatementLabellingMode\nimport it.unibo.tuprolog.argumentation.core.libs.language.AutoTransposition\nimport it.unibo.tuprolog.argumentation.core.libs.language.PrologStrictCompatibility\nimport it.unibo.tuprolog.argumentation.core.libs.structured.QueryMode\nimport it.unibo.tuprolog.argumentation.core.libs.utils.OrderingComparator\nimport it.unibo.tuprolog.argumentation.core.libs.utils.OrderingPrinciple\nimport it.unibo.tuprolog.core.Clause\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.parsing.parse\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.MutableTheory\nimport kotlin.jvm.JvmStatic\n\ndata class FlagsBuilder(\n var queryMode: Boolean = QueryMode.default(),\n var autoTransposition: Boolean = AutoTransposition.default(),\n var prologStrictCompatibility: Boolean = PrologStrictCompatibility.default(),\n var graphBuildMode: String = GraphBuildMode.default(),\n var argumentLabellingMode: String = ArgumentLabellingMode.default(),\n var statementLabellingMode: String = StatementLabellingMode.default(),\n var orderingPrinciple: String = OrderingPrinciple.default(),\n var orderingComparator: String = OrderingComparator.default(),\n var modulesPath: String = ModulesPath.default(),\n var graphExtensions: Iterable<String> = GraphExtension.default()\n) {\n\n companion object {\n @JvmStatic\n fun setupSolver(target: FlagsBuilder) =\n MutableTheory.empty().also { kb ->\n target.graphExtensions.forEach { kb.assertA(Clause.parse(\"${GraphExtension.predicate()}(X) :- X = $it\")) }\n if (target.queryMode) kb.assertA(Struct.parse(QueryMode.predicate()))\n if (target.autoTransposition) kb.assertA(Struct.parse(AutoTransposition.predicate()))\n if (target.prologStrictCompatibility) kb.assertA(Struct.parse(PrologStrictCompatibility.predicate()))\n kb.assertA(Struct.parse(\"${GraphBuildMode.predicate()}(${target.graphBuildMode})\"))\n kb.assertA(Struct.parse(\"${ArgumentLabellingMode.predicate()}(${target.argumentLabellingMode})\"))\n kb.assertA(Struct.parse(\"${StatementLabellingMode.predicate()}(${target.statementLabellingMode})\"))\n kb.assertA(Struct.parse(\"${OrderingPrinciple.predicate()}(${target.orderingPrinciple})\"))\n kb.assertA(Struct.parse(\"${OrderingComparator.predicate()}(${target.orderingComparator})\"))\n kb.assertA(Struct.parse(\"${ModulesPath.predicate()}(${target.modulesPath})\"))\n }\n }\n\n fun queryMode(queryMode: Boolean) = apply { this.queryMode = queryMode }\n fun prologStrictCompatibility(prologStrictCompatibility: Boolean) =\n apply { this.prologStrictCompatibility = prologStrictCompatibility }\n fun graphBuildMode(graphBuildMode: String) = apply { this.graphBuildMode = graphBuildMode }\n fun argumentLabellingMode(argumentLabellingMode: String) =\n apply { this.argumentLabellingMode = argumentLabellingMode }\n fun statementLabellingMode(statementLabellingMode: String) =\n apply { this.statementLabellingMode = statementLabellingMode }\n\n fun orderingPrinciple(orderingPrinciple: String) = apply { this.orderingPrinciple = orderingPrinciple }\n fun orderingComparator(orderingComparator: String) = apply { this.orderingComparator = orderingComparator }\n fun modulesPath(modulesPath: String) = apply { this.modulesPath = modulesPath }\n fun graphExtensions(graphExtensions: Iterable<String>) = apply { this.graphExtensions = graphExtensions }\n\n fun create() = object : ArgLibrary {\n\n override val alias = \"prolog.argumentation.flags\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = setupSolver(this@FlagsBuilder),\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.extra\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\nobject MetaInterpreter : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.meta.crossjustice\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.parse(\n \"\"\"\n % with_facts_and_length/3\n with_facts_and_length(X, Y, L) :-\n solve(X, R),\n recover_facts(R, Y),\n length(Y, L).\n \n % lenght/2\n \n length([], 0).\n length([_|T], X) :- length(T, Y), X is Y + 1.\n \n % recover_facts/2\n \n recover_facts([], []) :- !.\n recover_facts([H|T], C) :-\n is_list(H), !,\n recover_facts(T, TC),\n recover_facts(H, HC),\n append(TC, HC, C).\n recover_facts([H|T], C) :-\n \\+ is_list(H),\n recover_facts(T, TC),\n evaluate(H, HC),\n append(TC, HC, C).\n \n evaluate(user_fact(X), [X]) :- !.\n evaluate(_, []) :- !.\n \n % solve/2\n \n solve((A,B), Result) :- !,\n solve(A, ARes),\n solve(B, BRes),\n append(ARes, BRes, Result).\n \n solve((A;B), Result) :- !,\n solve(A, Result);\n solve(B, Result).\n \n solve(member(A, B), [system_predicate]) :- !,\n call(member(A, B)).\n \n solve(\\+(A), [not(A)]) :- !,\n call(\\+(A)).\n \n solve((A)\\=(B), [doNotUnify(A, B)]) :- !,\n call((A)\\=(B)).\n \n solve(A, [system_predicate]) :-\n catch(clause(A, _), B, true),\n \\+ var(B), !,\n call(A).\n \n solve(A, [A]) :-\n \\+ clause(A, B), !,\n call(A).\n \n solve(A, [A|[Res]]) :-\n clause(A, B),\n solve(B, Res).\n \n % is_list/1\n \n is_list(X) :- var(X), !, fail.\n is_list([]).\n is_list([_|T]) :- is_list(T).\n \n % fetch_argument_facts/2\n \n fetch_argument_facts(Conclusion, Facts) :-\n argument([R, TR, [Conclusion]]),\n findall(user_fact(Fact), \n support([_, _, [user_fact(Fact)]], [R, TR, [Conclusion]]),\n Facts).\n \"\"\".trimIndent()\n )\n )\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"interpreter\"\n}\n","package it.unibo.tuprolog.argumentation.core.libs.extra\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.core.List\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.dsl.theory.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.Signature\nimport it.unibo.tuprolog.solve.Solution\nimport it.unibo.tuprolog.solve.Solver\nimport it.unibo.tuprolog.solve.classic.classic\nimport it.unibo.tuprolog.solve.exception.error.TypeError\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.Primitive\nimport it.unibo.tuprolog.solve.primitive.Solve\n\nobject ModuleCalls : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.modularity\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n primitives = mapOf(\n ModuleCall.signature to ModuleCall\n )\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(ModulesPath)\n\n override fun identifier(): String = \"module\"\n}\n\nobject ModulesPath : ArgsFlag<String, Unit> {\n override fun predicate(): String = \"modulesPath\"\n override fun default(): String = \"none\"\n override fun values() {}\n}\n\nobject ModuleCall : Primitive {\n\n val signature = Signature(\"call_module\", 2)\n\n override fun solve(request: Solve.Request<ExecutionContext>): Sequence<Solve.Response> {\n val modules: Term = request.arguments[0]\n val goal: Term = request.arguments[1]\n\n if (modules !is List) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.LIST,\n modules\n )\n }\n\n if (goal !is Struct) {\n throw TypeError.forGoal(\n request.context,\n request.signature,\n TypeError.Expected.CALLABLE,\n goal\n )\n }\n\n val solver = getCleanSolver(request.context, mineModulesPath(request.context), modules.toList().map { it.toString() })\n return sequence {\n yieldAll(\n solver.solve(goal).map {\n when (it) {\n is Solution.Yes -> request.replySuccess(it.substitution)\n else -> request.replyFail()\n }\n }\n )\n }\n }\n\n private fun mineModulesPath(context: ExecutionContext): String {\n return prolog {\n Solver.classic(libraries = context.libraries)\n .solve(\"modulesPath\"(X))\n .map { if (it is Solution.Yes) it.substitution[X].toString() else \"\" }\n .first()\n }\n }\n\n private fun getCleanSolver(context: ExecutionContext, modulesPath: String, modules: Iterable<String>): Solver {\n val module = { mod: String -> if (mod.contains(\".pl\")) mod else \"${modulesPath.removeSurrounding(\"'\")}/$mod.pl\" }\n return prolog {\n Solver.classic(\n libraries = context.libraries\n ).also { solver: Solver -> modules.forEach { solver.solve(\"consult\"(module(it))).toList() } }\n }\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class AbstractModeBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.abstract\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(GraphExtension, ArgumentLabellingMode, StatementLabellingMode, GraphBuildMode)\n\n override fun identifier(): String = \"abstract\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object AbstractMode : AbstractModeBase\n\nobject GraphExtension : ArgsFlag<Iterable<String>, Iterable<String>> {\n override fun predicate(): String = \"graphExtension\"\n override fun default(): Iterable<String> = listOf(\"standardPref\")\n override fun values(): Iterable<String> = listOf(\"rebutRestriction\", \"bp\", \"standardPref\", \"defeasiblePref\", \"defeasibleAllPref\")\n}\n\nobject ArgumentLabellingMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"argumentLabellingMode\"\n override fun default(): String = \"grounded\"\n override fun values(): Iterable<String> = listOf(\n \"grounded\",\n \"complete\",\n \"bp_grounded\",\n \"bp_grounded_partial\",\n \"bp_grounded_complete\"\n )\n}\n\nobject StatementLabellingMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"statementLabellingMode\"\n override fun default(): String = \"statement\"\n override fun values(): Iterable<String> = listOf(\"statement\", \"statement_pass_through\", \"statement_binary\")\n}\n\nobject GraphBuildMode : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"graphBuildMode\"\n override fun default(): String = \"standard_af\"\n override fun values(): Iterable<String> = listOf(\"standard_af\")\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.builder\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class ArgumentationGraphBuilderBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"standard_af\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object ArgumentationGraphBuilder : ArgumentationGraphBuilderBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class AttackRestrictionHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.rebutrestriction\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"rebutRestriction\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object AttackRestrictionHandler : AttackRestrictionHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpMetaGraphHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.meta.bp\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpMetaGraphHandler : BpMetaGraphHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class DefeasiblePreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.defeasible\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"defeasiblePref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object DefeasiblePreferencesHandler : DefeasiblePreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class GenericDefeasiblePreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.defeasible.generic\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"defeasibleAllPref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object GenericDefeasiblePreferencesHandler : GenericDefeasiblePreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StrictPreferencesHandlerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.preferences.strict\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"standardPref\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StrictPreferencesHandler : StrictPreferencesHandlerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Scope\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.rule.RuleWrapper\nimport it.unibo.tuprolog.theory.Theory\n\nobject BinaryStatementLabeller : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement.binary\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.of(BinaryLabelling.implementation)\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement_binary\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nprivate object BinaryLabelling : RuleWrapper<ExecutionContext>(\"statementLabelling\", 0) {\n override val Scope.body: Term\n get() = prolog {\n tupleOf(\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"in\"(listOf(`_`, `_`, X, `_`, `_`,))),\n not(\"contextCheck\"(\"statIn\"(X))),\n \"context_assert\"(\"statIn\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"out\"(listOf(`_`, `_`, X, `_`, `_`,))) or \"context_check\"(\"und\"(listOf(`_`, `_`, X, `_`, `_`,))),\n not(\"context_check\"(\"statOut\"(X))),\n \"context_assert\"(\"statOut\"(X))\n ),\n `_`\n )\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpCompleteLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgroundedcomplete\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded_complete\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpCompleteLabeller : BpCompleteLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgrounded\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpLabeller : BpLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class BpPartialLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.bpgroundedpartial\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"bp_grounded_partial\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object BpPartialLabeller : BpPartialLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class CompleteLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.complete\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"complete\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object CompleteLabeller : CompleteLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class GroundedLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.grounded\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"grounded\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object GroundedLabeller : GroundedLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Scope\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.rule.RuleWrapper\nimport it.unibo.tuprolog.theory.Theory\n\nobject PassThroughStatementLabeller : ArgLibrary, Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement.pt\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = Theory.of(Labelling.implementation)\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement_pass_through\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nprivate object Labelling : RuleWrapper<ExecutionContext>(\"statementLabelling\", 0) {\n override val Scope.body: Term\n get() = prolog {\n tupleOf(\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"in\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statIn\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"out\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statOut\"(X))\n ),\n `_`\n ),\n \"findall\"(\n `_`,\n tupleOf(\n \"context_check\"(\"und\"(listOf(`_`, `_`, X, `_`, `_`,))),\n \"context_assert\"(\"statUnd\"(X))\n ),\n `_`\n )\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StatementLabellerBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.graph.labelling.statement\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"statement\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StatementLabeller : StatementLabellerBase\n","package it.unibo.tuprolog.argumentation.core.libs.language\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.Clause\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Substitution\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.Var\nimport it.unibo.tuprolog.core.operators.Operator\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.core.operators.Specifier\nimport it.unibo.tuprolog.core.parsing.parse\nimport it.unibo.tuprolog.core.toTerm\nimport it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories\nimport it.unibo.tuprolog.dsl.theory.prolog\nimport it.unibo.tuprolog.solve.ExecutionContext\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.solve.primitive.PrimitiveWrapper.Companion.ensuringArgumentIsVariable\nimport it.unibo.tuprolog.solve.primitive.Solve\nimport it.unibo.tuprolog.solve.primitive.UnaryPredicate\nimport kotlin.random.Random\n\nsealed class RuleParserBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.parser\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n primitives = mapOf(\n StrictRules::descriptionPair.get(),\n Axioms::descriptionPair.get(),\n Bps::descriptionPair.get(),\n Premises::descriptionPair.get(),\n DefeasibleRules::descriptionPair.get()\n ),\n theory = this.prologTheory,\n operatorSet = operators()\n )\n\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(AutoTransposition, PrologStrictCompatibility)\n\n override fun identifier() = \"parser\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(operators())\n .plus(OperatorSet.DEFAULT)\n\n companion object {\n fun operators() = OperatorSet(\n Operator(\"=>\", Specifier.XFX, 1199),\n Operator(\":=>\", Specifier.XFX, 1199),\n Operator(\":->\", Specifier.XFX, 1199),\n Operator(\":\", Specifier.XFX, 1001),\n Operator(\":=\", Specifier.XFX, 1199)\n )\n }\n}\n\nexpect object RuleParser : RuleParserBase\n\nobject AutoTransposition : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"autoTransposition\"\n override fun default(): Boolean = false\n override fun values() {}\n}\n\nobject PrologStrictCompatibility : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"prologStrictCompatibility\"\n override fun default(): Boolean = false\n override fun values() {}\n}\n\nobject ConversionUtils {\n fun modifiers(target: Clause, context: Solve.Request<ExecutionContext>): Term =\n prolog {\n target.bodyItems.map { term ->\n if (term.isStruct && term.asStruct()?.functor == \"\\\\+\") \"~\"(term.asStruct()!!.args[0])\n else if (context.solve(\"clause\"(term, Var.ANONYMOUS_NAME)).first().isHalt) \"prolog\"(term)\n else term\n }.let { if (it.count() > 1) tupleOf(it) else it.first() }\n }\n\n fun commonMap(\n context: Solve.Request<ExecutionContext>,\n first: Term,\n force: Boolean = false,\n mapper: (Iterable<Clause>, PrologScopeWithTheories) -> Term\n ): Sequence<Substitution> {\n context.ensuringArgumentIsVariable(0)\n return prolog {\n sequenceOf(\n Substitution.of(\n first.castToVar(),\n if (force || context.solve(Struct.parse(\"prologStrictCompatibility\")).first().isYes) {\n mapper(context.context.staticKb.clauses, this)\n } else {\n emptyList\n }\n )\n )\n }\n }\n}\n\nobject StrictRules : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologStrictRules\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses.filter { !it.isFact }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n ConversionUtils.modifiers(it, this@computeAllSubstitutions),\n it.head!!\n )\n }.toTerm()\n }\n}\n\nobject Axioms : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologAxioms\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter { it.isFact && !listOf(\":->\", \"->\", \"=>\", \":=>\", \":\", \":=\", \",\").contains(it.head!!.functor) }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n it.head!!\n )\n }.toTerm()\n }\n}\n\nobject Premises : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologPremises\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter { it.isFact && it.head!!.functor == \":=\" && it.head!!.arity == 1 }\n .map {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n it.head!!.args[0]\n )\n }.toTerm()\n }\n}\n\nobject DefeasibleRules : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"prologDefeasibleRules\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first) { clauses, prologScope ->\n clauses\n .filter {\n it.isFact && (\n it.head!!.functor == \":=\" ||\n (it.head!!.functor == \",\" && it.head!!.args[0].asStruct()?.functor == \":=\")\n ) &&\n it.head!!.arity == 2\n }\n .map { clause ->\n if (clause.head!!.functor == \",\") {\n val head = clause.head!!.args[0].asStruct()\n val term = (\n listOf(head!![1]) + (\n clause.head!!.args[1].asTuple()?.args\n ?: listOf(clause.head!!.args[1])\n )\n ).toTypedArray()\n prologScope.clauseOf(head[0].asStruct(), *term)\n } else {\n prologScope.clauseOf(clause.head!!.args[0].asStruct(), clause.head!!.args[1])\n }.let {\n prologScope.listOf(\n \"rule_${Random.nextInt(0, Int.MAX_VALUE)}\",\n ConversionUtils.modifiers(it, this@computeAllSubstitutions),\n it.head!!\n )\n }\n }.toTerm()\n }\n}\n\nobject Bps : UnaryPredicate.WithoutSideEffects<ExecutionContext>(\"bpsNew\") {\n override fun Solve.Request<ExecutionContext>.computeAllSubstitutions(first: Term): Sequence<Substitution> =\n ConversionUtils.commonMap(this, first, true) { clauses, prologScope ->\n clauses\n .filter { it.isFact && it.head?.functor == \"bp\" }\n .map {\n prologScope.listOf(\n \"bps\",\n it.head!!\n )\n }.toTerm()\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.structured\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class StructuredModeBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.structured\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(QueryMode, AmbiguityBlocking)\n\n override fun identifier(): String = \"structured\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object StructuredMode : StructuredModeBase\n\nobject QueryMode : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"queryMode\"\n override fun default(): Boolean = true\n override fun values() {}\n}\n\nobject AmbiguityBlocking : ArgsFlag<Boolean, Unit> {\n override fun predicate(): String = \"ambiguityBlocking\"\n override fun default(): Boolean = true\n override fun values() {}\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class DebugBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.debug\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier() = \"debug\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object Debug : DebugBase\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class SuperiorityRelationBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.superiority\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = listOf(OrderingPrinciple, OrderingComparator)\n\n override fun identifier(): String = \"superiority\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object SuperiorityRelation : SuperiorityRelationBase\n\nobject OrderingPrinciple : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"orderingPrinciple\"\n override fun default(): String = \"last\"\n override fun values(): Iterable<String> = listOf(\"last\", \"weakest\")\n}\n\nobject OrderingComparator : ArgsFlag<String, Iterable<String>> {\n override fun predicate(): String = \"orderingComparator\"\n override fun default(): String = \"elitist\"\n override fun values(): Iterable<String> = listOf(\"elitist\", \"democrat\", \"normal\")\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nimport it.unibo.tuprolog.argumentation.core.libs.ArgLibrary\nimport it.unibo.tuprolog.argumentation.core.libs.ArgsFlag\nimport it.unibo.tuprolog.argumentation.core.libs.LazyRawPrologContent\nimport it.unibo.tuprolog.argumentation.core.libs.Loadable\nimport it.unibo.tuprolog.argumentation.core.libs.basic.DynamicLoader\nimport it.unibo.tuprolog.core.operators.OperatorSet\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\n\nsealed class UtilsBase : ArgLibrary, LazyRawPrologContent(), Loadable {\n\n override val alias = \"prolog.argumentation.utils\"\n\n override val baseContent: AliasedLibrary\n get() = Library.aliased(\n alias = this.alias,\n theory = this.prologTheory\n )\n override val baseFlags: Iterable<ArgsFlag<*, *>>\n get() = emptyList()\n\n override fun identifier(): String = \"utils\"\n\n override val theoryOperators = DynamicLoader.operators()\n .plus(OperatorSet.DEFAULT)\n}\n\nexpect object Utils : UtilsBase\n","package it.unibo.tuprolog.argumentation.core.meta\n\nimport it.unibo.tuprolog.solve.library.AliasedLibrary\nimport it.unibo.tuprolog.solve.library.Library\nimport it.unibo.tuprolog.theory.Theory\nimport it.unibo.tuprolog.theory.parsing.parse\n\nobject MetaInterpreterLib : AliasedLibrary by\nLibrary.aliased(\n theory = Theory.parse(\n \"\"\"\n % with_facts_and_length/3\n with_facts_and_length(X, Y, L) :-\n solve(X, R),\n recover_facts(R, Y),\n length(Y, L).\n\n % lenght/2\n\n length([], 0).\n length([_|T], X) :- length(T, Y), X is Y + 1.\n\n % recover_facts/2\n\n recover_facts([], []) :- !.\n recover_facts([H|T], C) :-\n is_list(H), !,\n recover_facts(T, TC),\n recover_facts(H, HC),\n append(TC, HC, C).\n recover_facts([H|T], C) :-\n \\+ is_list(H),\n recover_facts(T, TC),\n evaluate(H, HC),\n append(TC, HC, C).\n\n evaluate(user_fact(X), [X]) :- !.\n evaluate(_, []) :- !.\n\n % solve/2\n\n solve((A,B), Result) :- !,\n solve(A, ARes),\n solve(B, BRes),\n append(ARes, BRes, Result).\n\n solve((A;B), Result) :- !,\n solve(A, Result);\n solve(B, Result).\n\n solve(member(A, B), [system_predicate]) :- !,\n call(member(A, B)).\n\n solve(\\+(A), [not(A)]) :- !,\n call(\\+(A)).\n\n solve((A)\\=(B), [doNotUnify(A, B)]) :- !,\n call((A)\\=(B)).\n\n solve(A, [system_predicate]) :-\n catch(clause(A, _), B, true),\n \\+ var(B), !,\n call(A).\n\n solve(A, [A]) :-\n \\+ clause(A, B), !,\n call(A).\n\n solve(A, [A|[Res]]) :-\n clause(A, B),\n solve(B, Res).\n\n % is_list/1\n\n is_list(X) :- var(X), !, fail.\n is_list([]).\n is_list([_|T]) :- is_list(T).\n \n % fetch_argument_facts/2\n \n fetch_argument_facts(Conclusion, Facts) :-\n argument([R, TR, [Conclusion]]),\n findall(user_fact(Fact), \n support([_, _, [user_fact(Fact)]], [R, TR, [Conclusion]]),\n Facts).\n \"\"\".trimIndent()\n ),\n alias = \"prolog.argumentation.meta\"\n)\n","package it.unibo.tuprolog.argumentation.core.mining\n\nimport it.unibo.tuprolog.argumentation.core.model.Argument\nimport it.unibo.tuprolog.argumentation.core.model.Attack\nimport it.unibo.tuprolog.argumentation.core.model.Graph\nimport it.unibo.tuprolog.argumentation.core.model.LabelledArgument\nimport it.unibo.tuprolog.argumentation.core.model.Support\nimport it.unibo.tuprolog.dsl.prolog\nimport it.unibo.tuprolog.solve.Solver\nimport it.unibo.tuprolog.unify.Unificator\nimport kotlin.js.JsName\n\n@JsName(\"mineGraph\")\nfun Solver.graph(context: Int) =\n this.arguments(context).let {\n Graph.of(\n this.labels(context, it),\n this.attacks(context, it),\n this.supports(context, it)\n )\n }\n\n@JsName(\"mineArguments\")\nfun Solver.arguments(context: Int): List<Argument> =\n prolog {\n this@arguments.solve(\"context_check\"(context, \"argument\"(X)))\n .filter { it.isYes }\n .map { it.substitution[X]!! }\n .map { solution ->\n Argument.of(solution)\n }\n .sortedWith(compareBy({ it.supports.size }, { it.rules.size }, { it.conclusion }, { it.topRule }))\n .mapIndexed { index, arg ->\n arg.identifier = \"A$index\"\n arg\n }\n }.toList()\n\n@JsName(\"mineAttacks\")\nfun Solver.attacks(context: Int, arguments: List<Argument>): List<Attack> {\n if (arguments.isEmpty()) return emptyList()\n return prolog {\n this@attacks.solve(\"context_check\"(context, \"attack\"(`_`, X, Y, `_`)))\n .filter { it.isYes }\n .map { solution ->\n Attack(\n arguments.first { Unificator.default.match(it.termRepresentation(), solution.substitution[X]!!) },\n arguments.first { Unificator.default.match(it.termRepresentation(), solution.substitution[Y]!!) }\n )\n }\n }.toList()\n}\n\n@JsName(\"mineSupports\")\nfun Solver.supports(context: Int, arguments: List<Argument>): List<Support> =\n arguments.flatMap { argument ->\n prolog {\n this@supports.solve(\"context_check\"(context, \"support\"(X, argument.termRepresentation())))\n .filter { it.isYes }\n .map { it.substitution[X]!! }\n .map { solution ->\n Support(\n arguments.first { Unificator.default.match(it.termRepresentation(), solution) },\n argument\n ).also {\n argument.supports.add(it.supporter)\n }\n }.toList()\n }\n }\n\n@JsName(\"mineLabels\")\nfun Solver.labels(context: Int, arguments: List<Argument>): List<LabelledArgument> {\n fun checkFunctor(functor: String, argument: Argument) =\n prolog {\n this@labels.solve(\"context_check\"(context, functor(argument.termRepresentation())))\n .filter { it.isYes }\n .map { functor }\n .firstOrNull()\n }\n\n return arguments.map {\n LabelledArgument(\n it,\n checkFunctor(\"in\", it)\n ?: checkFunctor(\"out\", it) ?: \"und\"\n )\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Cons\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Argument(\n val rules: List<RuleIdentifier>,\n val topRule: RuleIdentifier,\n val conclusion: Literal,\n val groundings: List<Literal> = emptyList(),\n val defeasibleRules: List<RuleIdentifier> = emptyList(),\n val defeasiblePremises: List<RuleIdentifier> = emptyList(),\n val lastDefeasibleRules: List<RuleIdentifier> = emptyList()\n) {\n\n var identifier: String = \"\"\n val supports: MutableList<Argument> = mutableListOf()\n\n val descriptor: String\n get() = \"$identifier : \" + (\n if (topRule == \"none\") rules.firstOrNull() ?: \"\" else {\n supports.map { it.identifier }.plus(topRule)\n .reduce { a: String, b: String -> \"$a,$b\" }\n }\n ) + \" : \" + conclusion\n\n fun termRepresentation(): Term = Struct.parse(\"[$rules, $topRule, $conclusion, $groundings, [$lastDefeasibleRules, $defeasibleRules, $defeasiblePremises]]\")\n\n override fun toString(): String {\n return \"argument(${this.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n\n companion object {\n\n fun of(term: Term): Argument {\n fun termAsList(t: Term?): List<Term> = (t as Cons).toList()\n\n fun toStringList(argument: List<Term>, target: Int): List<String> {\n return (\n if (argument[target].isEmptyList) emptyList()\n else (argument[target] as Cons).toList()\n ).map { x -> x.toString() }\n }\n\n fun argRules(argument: List<Term>): List<String> = toStringList(argument, 0)\n\n fun argTopRule(argument: List<Term>): String = argument[1].toString()\n\n fun argConclusion(argument: List<Term>): String = argument[2].toString()\n\n fun argGroundings(argument: List<Term>): List<String> = toStringList(argument, 3)\n\n fun argDefeasibleRules(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 1)\n\n fun argDefeasiblePremises(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 2)\n\n fun argLastDefeasibleRules(argument: List<Term>): List<String> =\n toStringList(termAsList(argument[4]), 0)\n\n return termAsList(term).let {\n Argument(\n argRules(it),\n argTopRule(it),\n argConclusion(it),\n argGroundings(it),\n argDefeasibleRules(it),\n argDefeasiblePremises(it),\n argLastDefeasibleRules(it)\n )\n }\n }\n }\n}\n","/*\n * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.\n * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class)\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\nimport kotlin.random.Random\n\ninternal object EmptyIterator : ListIterator<Nothing> {\n override fun hasNext(): Boolean = false\n override fun hasPrevious(): Boolean = false\n override fun nextIndex(): Int = 0\n override fun previousIndex(): Int = -1\n override fun next(): Nothing = throw NoSuchElementException()\n override fun previous(): Nothing = throw NoSuchElementException()\n}\n\ninternal object EmptyList : List<Nothing>, Serializable, RandomAccess {\n private const val serialVersionUID: Long = -7390468764508069838L\n\n override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty()\n override fun hashCode(): Int = 1\n override fun toString(): String = \"[]\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n override fun contains(element: Nothing): Boolean = false\n override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()\n\n override fun get(index: Int): Nothing = throw IndexOutOfBoundsException(\"Empty list doesn't contain element at index $index.\")\n override fun indexOf(element: Nothing): Int = -1\n override fun lastIndexOf(element: Nothing): Int = -1\n\n override fun iterator(): Iterator<Nothing> = EmptyIterator\n override fun listIterator(): ListIterator<Nothing> = EmptyIterator\n override fun listIterator(index: Int): ListIterator<Nothing> {\n if (index != 0) throw IndexOutOfBoundsException(\"Index: $index\")\n return EmptyIterator\n }\n\n override fun subList(fromIndex: Int, toIndex: Int): List<Nothing> {\n if (fromIndex == 0 && toIndex == 0) return this\n throw IndexOutOfBoundsException(\"fromIndex: $fromIndex, toIndex: $toIndex\")\n }\n\n private fun readResolve(): Any = EmptyList\n}\n\ninternal fun <T> Array<out T>.asCollection(): Collection<T> = ArrayAsCollection(this, isVarargs = false)\n\nprivate class ArrayAsCollection<T>(val values: Array<out T>, val isVarargs: Boolean) : Collection<T> {\n override val size: Int get() = values.size\n override fun isEmpty(): Boolean = values.isEmpty()\n override fun contains(element: T): Boolean = values.contains(element)\n override fun containsAll(elements: Collection<T>): Boolean = elements.all { contains(it) }\n override fun iterator(): Iterator<T> = values.iterator()\n // override hidden toArray implementation to prevent copying of values array\n public fun toArray(): Array<out Any?> = values.copyToArrayOfAny(isVarargs)\n}\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\npublic fun <T> emptyList(): List<T> = EmptyList\n\n/**\n * Returns a new read-only list of given elements. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.readOnlyList\n */\npublic fun <T> listOf(vararg elements: T): List<T> = if (elements.size > 0) elements.asList() else emptyList()\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> listOf(): List<T> = emptyList()\n\n/**\n * Returns an empty new [MutableList].\n * @sample samples.collections.Collections.Lists.emptyMutableList\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> mutableListOf(): MutableList<T> = ArrayList()\n\n/**\n * Returns an empty new [ArrayList].\n * @sample samples.collections.Collections.Lists.emptyArrayList\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> arrayListOf(): ArrayList<T> = ArrayList()\n\n/**\n * Returns a new [MutableList] with the given elements.\n * @sample samples.collections.Collections.Lists.mutableList\n */\npublic fun <T> mutableListOf(vararg elements: T): MutableList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new [ArrayList] with the given elements.\n * @sample samples.collections.Collections.Lists.arrayList\n */\npublic fun <T> arrayListOf(vararg elements: T): ArrayList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(element: T?): List<T> = if (element != null) listOf(element) else emptyList()\n\n/**\n * Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(vararg elements: T?): List<T> = elements.filterNotNull()\n\n/**\n * Creates a new read-only list with the specified [size], where each element is calculated by calling the specified\n * [init] function.\n *\n * The function [init] is called for each list element sequentially starting from the first one.\n * It should return the value for a list element given its index.\n *\n * @sample samples.collections.Collections.Lists.readOnlyListFromInitializer\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> List(size: Int, init: (index: Int) -> T): List<T> = MutableList(size, init)\n\n/**\n * Creates a new mutable list with the specified [size], where each element is calculated by calling the specified\n * [init] function.\n *\n * The function [init] is called for each list element sequentially starting from the first one.\n * It should return the value for a list element given its index.\n *\n * @sample samples.collections.Collections.Lists.mutableListFromInitializer\n */\n@SinceKotlin(\"1.1\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> MutableList(size: Int, init: (index: Int) -> T): MutableList<T> {\n val list = ArrayList<T>(size)\n repeat(size) { index -> list.add(init(index)) }\n return list\n}\n\n/**\n * Builds a new read-only [List] by populating a [MutableList] using the given [builderAction]\n * and returning a read-only list with the same elements.\n *\n * The list passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * @sample samples.collections.Builders.Lists.buildListSample\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <E> buildList(@BuilderInference builderAction: MutableList<E>.() -> Unit): List<E> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildListInternal(builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <E> buildListInternal(builderAction: MutableList<E>.() -> Unit): List<E>\n\n/**\n * Builds a new read-only [List] by populating a [MutableList] using the given [builderAction]\n * and returning a read-only list with the same elements.\n *\n * The list passed as a receiver to the [builderAction] is valid only inside that function.\n * Using it outside of the function produces an unspecified behavior.\n *\n * [capacity] is used to hint the expected number of elements added in the [builderAction].\n *\n * @throws IllegalArgumentException if the given [capacity] is negative.\n *\n * @sample samples.collections.Builders.Lists.buildListSampleWithCapacity\n */\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\npublic inline fun <E> buildList(capacity: Int, @BuilderInference builderAction: MutableList<E>.() -> Unit): List<E> {\n contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }\n return buildListInternal(capacity, builderAction)\n}\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\n@ExperimentalStdlibApi\n@kotlin.internal.InlineOnly\ninternal expect inline fun <E> buildListInternal(capacity: Int, builderAction: MutableList<E>.() -> Unit): List<E>\n\n/**\n * Returns an [IntRange] of the valid indices for this collection.\n * @sample samples.collections.Collections.Collections.indicesOfCollection\n */\npublic val Collection<*>.indices: IntRange\n get() = 0..size - 1\n\n/**\n * Returns the index of the last item in the list or -1 if the list is empty.\n *\n * @sample samples.collections.Collections.Lists.lastIndexOfList\n */\npublic val <T> List<T>.lastIndex: Int\n get() = this.size - 1\n\n/**\n * Returns `true` if the collection is not empty.\n * @sample samples.collections.Collections.Collections.collectionIsNotEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable collection is either null or empty.\n * @sample samples.collections.Collections.Collections.collectionIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || this.isEmpty()\n}\n\n/**\n * Returns this Collection if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Collections.collectionOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>?.orEmpty(): Collection<T> = this ?: emptyList()\n\n/**\n * Returns this List if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Lists.listOrEmpty\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()\n\n/**\n * Returns this collection if it's not empty\n * or the result of calling [defaultValue] function if the collection is empty.\n *\n * @sample samples.collections.Collections.Collections.collectionIfEmpty\n */\n@SinceKotlin(\"1.3\")\n@kotlin.internal.InlineOnly\npublic inline fun <C, R> C.ifEmpty(defaultValue: () -> R): R where C : Collection<*>, C : R =\n if (isEmpty()) defaultValue() else this\n\n\n/**\n * Checks if all elements in the specified collection are contained in this collection.\n *\n * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.\n * @sample samples.collections.Collections.Collections.collectionContainsAll\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\n@kotlin.internal.InlineOnly\npublic inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)\n\n\n/**\n * Returns a new list with the elements of this list randomly shuffled\n * using the specified [random] instance as the source of randomness.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Iterable<T>.shuffled(random: Random): List<T> = toMutableList().apply { shuffle(random) }\n\n\ninternal fun <T> List<T>.optimizeReadOnlyList() = when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements,\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchOnComparable\n * @sample samples.collections.Collections.Lists.binarySearchWithBoundaries\n */\npublic fun <T : Comparable<T>> List<T?>.binarySearch(element: T?, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = compareValues(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the specified [comparator],\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted according to the specified [comparator].\n * @sample samples.collections.Collections.Lists.binarySearchWithComparator\n */\npublic fun <T> List<T>.binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparator.compare(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for an element having the key returned by the specified [selector] function\n * equal to the provided [key] value using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements.\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements with the specified [key], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element with the specified [key], if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchByKey\n */\npublic inline fun <T, K : Comparable<K>> List<T>.binarySearchBy(\n key: K?,\n fromIndex: Int = 0,\n toIndex: Int = size,\n crossinline selector: (T) -> K?\n): Int =\n binarySearch(fromIndex, toIndex) { compareValues(selector(it), key) }\n\n// do not introduce this overload --- too rare\n//public fun <T, K> List<T>.binarySearchBy(key: K, comparator: Comparator<K>, fromIndex: Int = 0, toIndex: Int = size(), selector: (T) -> K): Int =\n// binarySearch(fromIndex, toIndex) { comparator.compare(selector(it), key) }\n\n\n/**\n * Searches this list or its range for an element for which the given [comparison] function returns zero using the binary search algorithm.\n *\n * The list is expected to be sorted so that the signs of the [comparison] function's return values ascend on the list elements,\n * i.e. negative values come before zero and zeroes come before positive values.\n * Otherwise, the result is undefined.\n *\n * If the list contains multiple elements for which [comparison] returns zero, there is no guarantee which one will be found.\n *\n * @param comparison function that returns zero when called on the list element being searched.\n * On the elements coming before the target element, the function must return negative values;\n * on the elements coming after the target element, the function must return positive values.\n *\n * @return the index of the found element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchWithComparisonFunction\n */\npublic fun <T> List<T>.binarySearch(fromIndex: Int = 0, toIndex: Int = size, comparison: (T) -> Int): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparison(midVal)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Checks that `from` and `to` are in\n * the range of [0..size] and throws an appropriate exception, if they aren't.\n */\nprivate fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {\n when {\n fromIndex > toIndex -> throw IllegalArgumentException(\"fromIndex ($fromIndex) is greater than toIndex ($toIndex).\")\n fromIndex < 0 -> throw IndexOutOfBoundsException(\"fromIndex ($fromIndex) is less than zero.\")\n toIndex > size -> throw IndexOutOfBoundsException(\"toIndex ($toIndex) is greater than size ($size).\")\n }\n}\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkIndexOverflow(index: Int): Int\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkCountOverflow(count: Int): Int\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwIndexOverflow() { throw ArithmeticException(\"Index overflow has happened.\") }\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwCountOverflow() { throw ArithmeticException(\"Count overflow has happened.\") }\n\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Attack(val attacker: Argument, val target: Argument, val type: AttackType? = null, val on: Argument? = null) {\n override fun toString(): String {\n return \"attack(${type ?: \"none\"}, ${attacker.termRepresentation()}, ${target.termRepresentation()}, ${on?.termRepresentation() ?: \"none\"})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\ndata class Graph(val arguments: List<Argument>, val attacks: List<Attack>, val supports: List<Support>) {\n\n var labellings: List<LabelledArgument> = emptyList()\n\n companion object {\n fun of(labellings: List<LabelledArgument>, attacks: List<Attack>, supports: List<Support>) =\n Graph(labellings.map { it.argument }, attacks, supports).also {\n it.labellings = labellings\n }\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class LabelledArgument(val argument: Argument, val label: Label) {\n override fun toString(): String {\n return \"$label(${argument.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.parsing.parse\n\ninterface ArgItem {\n val identifier: RuleIdentifier\n val conclusion: Term\n\n fun toTerm(): it.unibo.tuprolog.core.Term {\n return Struct.parse(this.toString())\n }\n}\n\ndata class Premise(override val identifier: RuleIdentifier, override val conclusion: Term, val strict: Boolean = false) : ArgItem {\n override fun toString(): String {\n return \"premise([$identifier, $conclusion])\"\n }\n}\n\ndata class Rule(override val identifier: RuleIdentifier, val premises: List<Term>, override val conclusion: Term, val strict: Boolean = false) : ArgItem {\n override fun toString(): String {\n return \"rule([$identifier, $premises, $conclusion])\"\n }\n}\n","package it.unibo.tuprolog.argumentation.core.model\n\nimport it.unibo.tuprolog.core.Struct\nimport it.unibo.tuprolog.core.Term\nimport it.unibo.tuprolog.core.parsing.parse\n\ndata class Support(val supporter: Argument, val supported: Argument) {\n override fun toString(): String {\n return \"support(${supporter.termRepresentation()}, ${supported.termRepresentation()})\"\n }\n\n fun toTerm(): Term {\n return Struct.parse(this.toString())\n }\n}\n","package it.unibo.tuprolog.argumentation.core.libs.basic\n\nimport it.unibo.tuprolog.argumentation.core.libs.sources.ArgumentationEngineInterface\n\nactual object EngineInterface : EngineInterfaceBase() {\n override val prologRawTheory: String\n get() = ArgumentationEngineInterface.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph\n\nactual object AbstractMode : AbstractModeBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.AbstractMode.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.builder\n\nactual object ArgumentationGraphBuilder : ArgumentationGraphBuilderBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.ArgumentationGraph.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object AttackRestrictionHandler : AttackRestrictionHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.AttackRestriction.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object BpMetaGraphHandler : BpMetaGraphHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Bp.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object DefeasiblePreferencesHandler : DefeasiblePreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.DefPreferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object GenericDefeasiblePreferencesHandler : GenericDefeasiblePreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.GenericDefPreferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.extension\n\nactual object StrictPreferencesHandler : StrictPreferencesHandlerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Preferences.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpCompleteLabeller : BpCompleteLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGroundedComplete.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpLabeller : BpLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGrounded.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object BpPartialLabeller : BpPartialLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.BpGroundedPartial.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object CompleteLabeller : CompleteLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Complete.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object GroundedLabeller : GroundedLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Grounded.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.graph.labelling\n\nactual object StatementLabeller : StatementLabellerBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.StatementLabelling.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.language\n\nimport it.unibo.tuprolog.argumentation.core.libs.sources.RuleTranslator\n\nactual object RuleParser : RuleParserBase() {\n override val prologRawTheory: String\n get() = RuleTranslator.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject AbstractMode {\n val theoryCode: String =\n \"\"\"\n computeGlobalAcceptance :-\n buildGraph,\n modifyGraph,\n buildArgumentLabelling,\n buildStatementLabelling.\n computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]) :-\n computeGlobalAcceptance,\n utils::recoverGraph(Arguments, Attacks, Supports),\n utils::recoverArgumentLabelling(ArgsIn, ArgsOut, ArgsUnd),\n utils::recoverStatementLabelling(StatIn, StatOut, StatUnd).\n buildGraph :-\n graphBuildMode(X),\n X:::buildArgumentationGraph.\n modifyGraph :-\n findall(X, graphExtension(X), Ext),\n modifyGraph(Ext).\n modifyGraph([]).\n modifyGraph([X|Ext]) :-\n modifyGraph(Ext),\n X:::modifyArgumentationGraph.\n buildArgumentLabelling :-\n argumentLabellingMode(X),\n X:::argumentLabelling.\n buildStatementLabelling :-\n statementLabellingMode(X),\n X:::statementLabelling.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject ArgumentationEngineInterface {\n val theoryCode: String =\n \"\"\"\n argTuProlog.\n buildLabelSets([StatIn, StatOut, StatUnd], [ArgsIn, ArgsOut, ArgsUnd]) :-\n context_reset,\n parser:::convertAllRules(_),\n abstract::computeGlobalAcceptance(_, [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]).\n buildLabelSets(StatIn, StatOut, StatUnd) :-\n buildLabelSets([StatIn, StatOut, StatUnd], _).\n buildLabelSets :-\n context_reset,\n parser:::convertAllRules(ArgRules),\n debug::printTheory(ArgRules),\n abstract::computeGlobalAcceptance([Arguments, Attacks, Supports], [ArgsIn, ArgsOut, ArgsUnd], [StatIn, StatOut, StatUnd]),\n debug::printArgumentationGraph(Arguments, Attacks, Supports),\n debug::printArgumentLabelling([ArgsIn, ArgsOut, ArgsUnd]),\n debug::printStatementLabelling([StatIn, StatOut, StatUnd]).\n answerQuery(Goal, Yes, No, Und) :-\n context_reset,\n parser:::convertAllRules(_),\n structured:::computeStatementAcceptance(Goal, Yes, No, Und).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject ArgumentationGraph {\n val theoryCode: String =\n \"\"\"\n buildArgumentationGraph :-\n buildArguments,\n buildAttacks.\n buildArguments :-\n \tbuildArgumentsFromPremises,\n \tbuildArgumentsFromEmptyRules,\n \tfindall([RuleID, RuleBody, RuleHead], (\n \t context_check(rule([RuleID, RuleBody, RuleHead])),\n \t \\+ emptyRule([RuleID, RuleBody, RuleHead])\n ), Rules),\n \tbuildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromPremises :-\n findall(\n _,\n (\n context_check(premise([PremiseID, Premise])),\n checkStrict(PremiseID, DefPrem),\n ground(Premise),\n context_assert(argument([[PremiseID], none, Premise, [], [[], [], DefPrem]]))\n ),\n _\n ).\n buildArgumentsFromEmptyRules :-\n findall(\n _,\n (\n emptyRule([RuleID, RulePrem, RuleHead]),\n checkStrict(RuleID, DefRule),\n ground(RuleHead),\n context_assert(argument([[RuleID], RuleID, RuleHead, RulePrem, [DefRule, DefRule, []]]))\n ),\n _\n ).\n emptyRule([RuleID, [], RuleHead]) :-\n context_check(rule([RuleID, [], RuleHead])).\n emptyRule([RuleID, [[unless, X]], RuleHead]) :-\n context_check(rule([RuleID, [[unless, X]], RuleHead])).\n emptyRule([RuleID, [[prolog(Check)]], RuleHead]) :-\n context_check(rule([RuleID, [[prolog(Check)]], RuleHead])),\n (callable(Check) -> call(Check); Check).\n buildArgumentsFromRules(Rules, [], n).\n buildArgumentsFromRules(Rules, [], y) :- buildArgumentsFromRules(Rules, Rules, n).\n buildArgumentsFromRules(Rules, [H|T], _) :-\n copy_term(H, HH),\n buildArgumentsFromRule(HH),\n buildArgumentsFromRules(Rules, T, y), !.\n buildArgumentsFromRules(Rules, [_|T], X) :-\n buildArgumentsFromRules(Rules, T, X).\n buildArgumentsFromRule([RuleID, RuleBody, RuleHead]) :-\n \truleBodyIsSupported(RuleBody, [], [], SupportRules, ArgSupports),\n \t\\+ member(RuleID, SupportRules),\n \tground(RuleHead),\n \tutils::sort([RuleID|SupportRules], SortedPremises),\n \t\\+ context_check(argument([SortedPremises, RuleID, RuleHead, RuleBody, _])),\n \tbuildArgumentInfo(ArgSupports, RuleID, Info),\n NewArgument = [SortedPremises, RuleID, RuleHead, RuleBody, Info],\n \tcontext_assert(argument(NewArgument)),\n \tsupports(NewArgument, ArgSupports).\n supports(Argument, Supports) :-\n findall(_, (\n member(S, Supports),\n context_assert(support(S, Argument))\n ), _).\n checkStrict(Id, [Id]) :- \\+ context_check(strict(Id)).\n checkStrict(Id, []) :- context_check(strict(Id)).\n buildArgumentInfo(Supports, RuleId, [LastDefRules, DefRules, DefPrem]) :-\n defeasibleRules(RuleId, Supports, DefRules),\n ordinaryPremises(Supports, DefPrem),\n lastDefeasibleRules(Supports, RuleId, LastDefRules).\n ordinaryPremises(Supports, DefPrem) :-\n findall(Def, member([_, _, _, _, [_, _, Def]], Supports), Prem),\n utils::appendLists(Prem, TempPrem),\n utils::sortDistinct(TempPrem, DefPrem).\n defeasibleRules(RuleId, Supports, DefRules) :-\n \tfindall(Def, member([_, _, _, _, [_, Def, _]], Supports), UnsortedRules),\n \tcheckStrict(RuleId, DefRule),\n \tutils::appendLists([DefRule|UnsortedRules], TempRules),\n \tutils::sortDistinct(TempRules, DefRules).\n lastDefeasibleRules(_, TopRule, [TopRule]) :-\n TopRule \\== none, \\+ context_check(strict(TopRule)).\n lastDefeasibleRules(Supports, TopRule, LastRules) :-\n \tcontext_check(strict(TopRule)),\n \tfindall(Def, member([_, _, _, _, [Def, _, _]], Supports), Res),\n \tutils::appendLists(Res, TempLastRules),\n \tutils::sortDistinct(TempLastRules, LastRules).\n ruleBodyIsSupported([], ResultPremises, ResultSupports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [unless, _] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([ [prolog(Check)] | Others], Premises, Supports, ResultPremises, ResultSupports) :-\n \t(callable(Check) -> call(Check); Check),\n \truleBodyIsSupported(Others, Premises, Supports, ResultPremises, ResultSupports).\n ruleBodyIsSupported([Statement|Others], Premises, Supports, ResultPremises, ResultSupports) :-\n context_check(argument([ArgumentID, RuleID, Statement, Body, Info])),\n \tappend(ArgumentID, Premises, NewPremises),\n \truleBodyIsSupported(Others, NewPremises, [[ArgumentID, RuleID, Statement, Body, Info]|Supports], ResultPremises, ResultSupports).\n findPossibleAttackers([_, _, Head, _, _], [_, _, Conf, _, _]) :-\n conflict(Head, Conf).\n findPossibleAttackers([_, _, _, Prem, _], [_, _, Conf, _, _]) :-\n member([unless, Conf], Prem).\n findPossibleAttackers([_, RuleID, _, _, _], [_, _, [undercut(RuleID)], _, _]).\n buildAttacks :-\n findall(X, context_check(argument(X)), Args),\n \tbuildDirectAttacks(Args),\n \tbuildTransitiveAttacks.\n buildDirectAttacks([]).\n buildDirectAttacks([H|T]) :-\n findall(_, buildDirectAttack(H), _),\n buildDirectAttacks(T).\n buildDirectAttack(A) :-\n \tcontext_check(argument(B)),\n \tA \\== B,\n attacks(T, B, A),\n \t\\+ context_check(attack(T, B, A, A)),\n \tcontext_assert(attack(T, B, A, A)).\n buildTransitiveAttacks :-\n \tcontext_check(attack(T, A, B, D)),\n \tcontext_check(support(B, C)),\n \t\\+ context_check(attack(T, A, C, D)), !,\n \tcontext_assert(attack(T, A, C, D)),\n buildTransitiveAttacks.\n buildTransitiveAttacks.\n attacks(rebut, A, B) :- rebuts(A, B), !.\n attacks(contrary_rebut, A, B) :- contraryRebuts(A, B), !.\n attacks(undermine, A, B) :- undermines(A, B), !.\n attacks(contrary_undermine, A, B) :- contraryUndermines(A, B), !.\n attacks(undercut, A, B) :- undercuts(A, B), !.\n rebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, _, Info]) :-\n \tRuleB \\== none,\n Info \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryRebuts([IDPremisesA, RuleA, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleA \\== none,\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undermines([IDPremisesA, RuleA, RuleHeadA, _, _], [[IDPremiseB], none, RuleHeadB, _, Info]) :-\n \tInfo \\== [[], [], []],\n \tconflict(RuleHeadA, RuleHeadB).\n contraryUndermines([IDPremisesA, none, RuleHeadA, _, _], [IDPremisesB, RuleB, RuleHeadB, Body, Info]) :-\n \tRuleB \\== none,\n \tmember([unless, RuleHeadA], Body).\n undercuts([_, _, [undercut(RuleB)], _, _], [_, RuleB, _, _, [[RuleB], _, _]]).\n conflict( [Atom], [neg, Atom]).\n conflict( [neg, Atom], [Atom]).\n conflict( [obl, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, Lit], [neg, obl, Lit]).\n conflict( [neg, obl, Lit], [obl, Lit]).\n conflict( [perm, [Atom]], [obl, [neg, Atom]]).\n conflict( [obl, [neg, Atom]], [perm, [Atom]]).\n conflict( [perm, [neg, Atom]], [obl, [Atom]]).\n conflict( [obl, [Atom]], [perm, [neg, Atom]]).\n conflict([bp, Atom], [neg, bp, Atom]).\n conflict([neg, bp, Atom], [bp, Atom]).\n conflict([sup(X, Y)], [sup(Y, X)]).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject AttackRestriction {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkRebutRestriction(T, A, B, C)\n ), _).\n checkRebutRestriction(T, A, B, C) :-\n \\+ rebutRestriction(T, A, B, C),\n context_retract(attack(T, A, B, C)).\n rebutRestriction(rebut, _, _, C) :- restrict(C).\n rebutRestriction(undermine, _, _, C).\n rebutRestriction(contrary_rebut, _, _, _).\n rebutRestriction(contrary_undermine, _, _, _).\n rebutRestriction(undercut, _, _, _).\n restrict([_, TopRule, _, _, [[TopRule], _, _]]) :- TopRule \\== none.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Bp {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(([Rules, Top, [bp, Checked], G, I], [Z, P, Y, GG, II]), (\n context_check(argument([Rules, Top, [bp, Checked], G, I])),\n member(Y, Checked),\n context_check(argument([Z, P, Y, GG, II]))\n ), TemplateBpPairs),\n checkBpArguments(TemplateBpPairs).\n checkBpArguments([]).\n checkBpArguments(TemplateBpPairs) :-\n createBpArguments(TemplateBpPairs, BpPairs),\n createBpAttacks(BpPairs).\n createBpArguments([], []).\n createBpArguments([(Original, [Z, P, Y, B, I])|Others], [(Conflict, [Z, P, Y, B, I])|BpPairs]) :-\n Conflict = [[artificial|Z], artificial, [neg, burdmet(Y)], [], [[artificial], [artificial], []]],\n context_assert(argument(Conflict)),\n context_assert(support(Original, Conflict)),\n liftBpAttacks(Original, Conflict),\n createBpArguments(Others, BpPairs).\n liftBpAttacks(Template, BpArg) :-\n findall(_, (\n context_check(attack(T, A, Template, O)),\n context_assert(attack(T, A, BpArg, O))\n ), _).\n createBpAttacks(BpPairs) :-\n generateBpsEvaluationChain(BpPairs, OrderedBpPairs),\n evaluateBurdenedArgs(OrderedBpPairs).\n generateBpsEvaluationChain([], []).\n generateBpsEvaluationChain([BpPair|BpPairs], OrderedBpPairs) :-\n generateBpsEvaluationChain(BpPairs, TempOrderedBpPairs),\n insertBpPair(BpPair, TempOrderedBpPairs, OrderedBpPairs).\n insertBpPair(BpPair, [], [BpPair]).\n insertBpPair((Bp, Burdened), [(BpL, BurdenedL)|Others], [(BpL, BurdenedL)|Return]) :-\n bp_grounded::argumentChain(BurdenedL, Burdened),\n insertBpPair((Bp, Burdened), Others, Return), !.\n insertBpPair((Bp, Burdened), [(BpL, BurdenedL)|Others], [(Bp, Burdened)|[(BpL, BurdenedL)|Others]]).\n evaluateBurdenedArgs([]).\n evaluateBurdenedArgs([(Bp, Burdened)|Others]) :-\n context_active(X),\n grounded:::argumentLabelling,\n statusToAttack((Bp, Burdened), Attack),\n context_checkout(X),\n context_assert(Attack),\n evaluateBurdenedArgs(Others).\n statusToAttack((Bp, Burdened), attack(bprebut, Burdened, Bp, Bp)) :-\n context_check(in(Burdened)).\n statusToAttack((Bp, Burdened), attack(bprebut, Bp, Burdened, Burdened)) :-\n \\+ context_check(in(Burdened)).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGrounded {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n reifyBurdenOfProofs,\n filterBpDefeats,\n findall(X, context_check(argument(X)), Arguments),\n bpLabelling(Arguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n grounded::allAttacksOUT(A), !,\n context_assert(in(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n member(A, Arguments),\n \\+ isArgumentInBurdenOfProof(A),\n grounded::oneAttackIN(A), !,\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Arguments) :-\n context_active(Branch),\n mostGroundedBpUnd(Arguments, A),\n context_branch(Branch, _),\n context_assert(out(A)),\n utils::subtract(Arguments, [A], NewArguments),\n bpLabelling(NewArguments).\n bpLabelling(Args) :-\n notLabelled(Args),\n findall(_, (member(A, Args), context_assert(und(A))), _).\n notLabelled(Args) :-\n \\+ (\n member(A, Args),\n (\n context_check(in(A));\n context_check(out(A));\n context_check(und(A))\n )\n ).\n isInBurdenOfProof(Conclusion) :-\n context_check(reifiedBp(Literals)),\n member(Conclusion, Literals), !.\n isArgumentInBurdenOfProof([_, _, Conclusion, _, _]) :-\n isInBurdenOfProof(Conclusion).\n filterBpDefeats :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n filterBpDefeat(T, A, B, C)\n ), _).\n filterBpDefeat(T, B, A, C) :-\n (T = rebut; T = undermine),\n isArgumentInBurdenOfProof(B),\n \\+ superiority::superiorArgument(B, C),\n context_retract(attack(T, B, A, C)).\n mostGroundedBpUnd(Arguments, Arg) :-\n member(Arg, Arguments),\n isArgumentInBurdenOfProof(Arg),\n \\+ (\n member(A, Arguments), Arg \\= A,\n isArgumentInBurdenOfProof(A),\n argumentChain(A, Arg)\n ).\n argumentChain(A, A) :- !.\n argumentChain(A, B) :-\n A \\== B,\n context_check(attack(_, A, C, _)),\n argumentChain(C, B).\n reifyBurdenOfProofs :-\n findall(_, (\n context_check(abstractBp(AbstractBp)),\n fillTemplate(AbstractBp, R),\n \\+ context_check(reifiedBp(R)),\n context_assert(reifiedBp(R))\n ), _).\n /*\n Fill the template (first parameter) using arguments conclusions\n */\n fillTemplate([], []).\n fillTemplate([H|T], [H|R]) :-\n context_check(argument([_, _, Conclusion, _, _])),\n fillTemplate(T, R).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGroundedComplete {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n bp_grounded::reifyBurdenOfProofs,\n findall(X, context_check(argument(X)), Arguments),\n completeBpLabelling(go, Arguments).\n completeBpLabelling(stop, _).\n completeBpLabelling(go, Arguments) :-\n bp_grounded_partial::partialBpLabelling(Arguments), !,\n findall(X, (context_check(und(X)), context_retract(und(X))), NewArgs),\n grounded::groundedLabelling(NewArgs),\n findall(X, context_check(und(X)), LeftArguments),\n stopCondition(Stop, Arguments, LeftArguments),\n completeBpLabelling(Stop, LeftArguments).\n stopCondition(stop, Args, NewArgs) :-\n utils::sort(Args, SortedArgs),\n utils::sort(NewArgs, SortedArgs), !.\n stopCondition(go, _, _) :- context_retract(und(_)).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject BpGroundedPartial {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n bp_grounded::reifyBurdenOfProofs,\n findall(X, context_check(argument(X)), Arguments),\n partialBpLabelling(Arguments), !.\n partialBpLabelling([]).\n partialBpLabelling(Arguments) :-\n mostGroundedArgument(Arguments, A),\n debug::writeDebug(['Evaluating ', A]),\n demonstration(Arguments, A, [A], Evaluated),\n utils::subtract(Arguments, [Evaluated], NewArgs),\n partialBpLabelling(NewArgs).\n /*\n (a.i) BP(neg(\u03c6)), and no argument B for neg(\u03c6) such that A < B is IN*, and no A1,...An is OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tisComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n \t superiorComplementArgument(A, B),\n \t context_check(in(B))\n \t),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \t\\+ (\n \t context_check(support(X, A)),\n \t context_check(out(X))\n \t),\n \tdebug::writeDebug(['Adding argument: ', A, ' to IN* (2.a.i)']),\n context_assert(in(A)).\n /*\n (a.ii) not BP(neg(\u03c6)) and every argument B for neg(\u03c6) such that B(not <)A is OUT*, and every A1,...An is IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ isComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorOrEqualComplementArgument(A, B),\n \\+ context_check(out(B))\n ),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \t\\+ (\n context_check(support(X, A)),\n \\+ context_check(in(X))\n ),\n \tdebug::writeDebug(['Adding argument: ', A, ' to IN* (2.a.ii)']),\n context_assert(in(A)).\n /*\n (b.i.1) BP(\u03c6) and exists an argument B for neg(\u03c6) such that B(not <)A is not OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \tsuperiorOrEqualComplementArgument(A, B),\n \t\\+ context_check(out(B)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.i.1)']),\n context_assert(out(A)).\n /*\n (b.i.2) BP(\u03c6) and exist one of A1,...An is not IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \tcontext_check(support(X, A)),\n \\+ context_check(in(X)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.i.2)']),\n context_assert(out(A)).\n /*\n (b.ii.1) not BP(\u03c6) and an argument B for neg(\u03c6) such A < B is IN*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \tsuperiorComplementArgument(A, B),\n \tcontext_check(in(B)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.ii.1)']),\n context_assert(out(A)).\n /*\n (b.ii.2) not BP(\u03c6) and one of A1,...An is OUT*\n */\n demonstration(Arguments, A, Resolving, A) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \t\\+ notEvaluatedSubArgument(Arguments, A, Resolving, _),\n \tcontext_check(support(X, A)),\n context_check(out(X)),\n debug::writeDebug(['Adding argument: ', A, ' to OUT* (2.b.ii.2)']),\n context_assert(out(A)).\n /*\n If above definitions do not apply try to decide on the arguments on which they depend\n */\n demonstration(Arguments, A, Resolving, Evaluated) :-\n isComplementInBurdenOfProof(A),\n \tnotEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tisComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorComplementArgument(A, X),\n context_check(in(X))\n ),\n notEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \\+ isComplementInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ isComplementInBurdenOfProof(A),\n \t\\+ notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, _),\n \t\\+ (\n superiorOrEqualComplementArgument(A, X),\n \\+ context_check(out(X))\n ),\n notEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \tbp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n demonstration(Arguments, A, Resolving, Evaluated) :-\n \t\\+ bp_grounded::isArgumentInBurdenOfProof(A),\n \tnotEvaluatedSubArgument(Arguments, A, Resolving, B),\n demonstration(Arguments, B, [B|Resolving], Evaluated).\n /*\n (c) A is labelled UND* otherwise.\n */\n demonstration(Arguments, A, Resolving, A) :-\n \tdebug::writeDebug(['Adding argument: ', A, ' to UND* (2.c)']),\n context_assert(und(A)).\n isComplementInBurdenOfProof(A) :-\n complement(A, Complement),\n bp_grounded::isInBurdenOfProof(Complement), !.\n mostGroundedArgument([], []).\n mostGroundedArgument([X], X).\n mostGroundedArgument([[L, _, _, _, _]|T], [L2, Q2, W2, B2, I2]) :-\n mostGroundedArgument(T, [L2, Q2, W2, B2, I2]),\n length(L, LN1),\n length(L2, LN2),\n LN1 > LN2, !.\n mostGroundedArgument([A|_], A).\n /*\n Get a conclusion complement\n */\n complement([_, _, Conclusion, _, _], A) :-\n standard_af::conflict(Conclusion, A).\n notEvaluatedSubArgument(Arguments, A, Resolving, B) :-\n context_check(support(B, A)),\n member(B, Arguments),\n \\+ member(B, Resolving).\n notEvaluatedSuperiorComplementArgument(Arguments, A, Resolving, B) :-\n superiorComplementArgument(A, B),\n member(B, Arguments),\n \\+ member(B, Resolving).\n notEvaluatedSuperiorOrEqualComplementArgument(Arguments, A, Resolving, B) :-\n superiorOrEqualComplementArgument(A, B),\n member(B, Arguments),\n \\+ member(B, Resolving).\n superiorComplementArgument(A, [A, B, CA, BB, I]) :-\n complement(A, CA),\n context_check(argument([R, B, CA, BB, I])),\n superiority::superiorArgument([R, B, CA, BB, I], A).\n superiorOrEqualComplementArgument(A, [R, B, CA, BB, I]) :-\n complement(A, CA),\n context_check(argument([R, B, CA, BB, I])),\n \\+ superiority::superiorArgument(A, [R, B, CA, BB, I]).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Complete {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n cache_retract(complete(_,_,_)),\n grounded:::argumentLabelling,\n context_active(Branch),\n completeLabelling(Branch).\n completeLabelling(_) :-\n admissibleSet,\n utils::recoverArgumentLabelling(In, Out, Und),\n \\+ cache_check(complete(In, Out, Und)),\n cache_assert(complete(In, Out, Und)).\n completeLabelling(Branch) :-\n context_check(und(X)),\n context_branch(Branch, NewBranch),\n findall(Y, (context_check(und(Y)), Y \\= X), Arguments),\n context_retract(und(_)),\n context_assert(in(X)),\n grounded::groundedLabelling(Arguments),\n completeLabelling(NewBranch).\n admissibleSet :-\n \\+ (context_check(in(H)), \\+ admissible(H)).\n admissible(H) :-\n \\+ (\n context_check(attack(_, Attacker, H, _)),\n \\+ (\n context_check(attack(_, Defendant, Attacker, _)),\n context_check(in(Defendant))\n )\n ).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Debug {\n val theoryCode: String =\n \"\"\"\n printTheory(Rules) :-\n write('HERE THE THEORY:'),nl,\n findall(rule([Id, Body, Head]), member(rule([Id, Body, Head]), Rules), ListRules),\n utils::writeListNl(ListRules),\n findall(premise([A, B]), member(premise([A, B]), Rules), ListPremises),\n utils::writeListNl(ListPremises),\n findall(sup(A, B), member(sup(A, B), Rules), ListSups),\n utils::writeListNl(ListSups).\n printArgumentationGraph(Arguments, Attacks, Supports) :-\n \tfindall(\n \t [IDPremises, '\\n', ' TOPRULE ', TopRule, '\\n', ' CONCLUSION ', RuleHead, '\\n', ' BODY ', Body, '\\n', ' INFO ', Info, '\\n'],\n \t member([IDPremises, TopRule, RuleHead, Body, Info], Arguments),\n ArgumentsToPrint\n ),\n findall((A1, ' SUPPORTS ', A2), member((A1, A2), Supports), SupportsToPrint),\n \tfindall((A1, ' ', T, ' ', A2, ' ON ', A3), member((T, A1, A2, A3), Attacks), AttacksToPrint),\n write('HERE THE GROUNDED SEMI-ABSTRACT ARGUMENTATION GRAPH'),nl,\n \tutils::writeListNl(ArgumentsToPrint),\n \tutils::writeListNl(SupportsToPrint),\n \tutils::writeListNl(AttacksToPrint).\n printArgumentLabelling([IN, OUT, UND]) :-\n write('HERE THE ARGUMENTS LABELLED IN: '),nl,\n utils::writeListNl(IN),\n write('HERE THE ARGUMENTS LABELLED OUT: '),nl,\n utils::writeListNl(OUT),\n write('HERE THE ARGUMENTS LABELLED UND: '),nl,\n utils::writeListNl(UND).\n printStatementLabelling([In, Ni, Und]) :-\n write('HERE THE STATEMENTS LABELLED IN: '),nl,\n utils::writeListNl(In),\n write('HERE THE STATEMENTS LABELLED NI: '),nl,\n utils::writeListNl(Ni),\n write('HERE THE STATEMENTS LABELLED UND: '),nl,\n utils::writeListNl(Und).\n debug.\n writeDebug(List) :-\n debug,\n utils::writeList(List).\n writeDebug(_) :- \\+ debug.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject DefPreferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n assertAllSup,\n findall((T, A, B, C), context_check(attack(T, A, B, C)), Attacks),\n filterSupRelatedAttacks(Attacks, InvalidAttacks),\n convertAttacks(InvalidAttacks),\n buildPrefAttacks.\n assertAllSup :-\n context_retract(sup(_, _)),\n findall(_,\n (\n context_check(argument([_, _, [sup(RuleOne, RuleTwo)], _, _])),\n \\+ context_check(sup(RuleOne, RuleTwo)),\n context_assert(sup(RuleOne, RuleTwo))\n ),\n _).\n filterSupRelatedAttacks([], []).\n filterSupRelatedAttacks([(T, A, B, C)|Attacks], [(T, A, B, C)|Invalid]) :-\n invalid(T, A, B, C, _),\n filterSupRelatedAttacks(Attacks, Invalid), !.\n filterSupRelatedAttacks([_|Attacks], Invalid) :-\n filterSupRelatedAttacks(Attacks, Invalid).\n invalid(rebut, A, B, C, SupSet) :- superiority::superiorArgument(C, A, SupSet), !.\n invalid(undermine, A, B, C, SupSet) :- superiority::superiorArgument(C, A, SupSet), !.\n /*\n * Translates the attack relations identified during the building phase.\n * Attack from A to B -> Argument [[], attack, Attack]\n * support(A, Argument)\n * attack(Argument, B)\n * If an Argument A built in this way attacks the argument B, and this one also attacks a third argument C\n * through the argument B1 we have to consider an attack from A to B1 (transitive attack)\n */\n convertAttacks(Attacks) :-\n conversion(Attacks),\n standard_af::buildTransitiveAttacks.\n conversion(List) :-\n member((T, A, B, B), List),\n generateDirectAttackArgument(T, A, B, B),\n fail.\n conversion(List) :-\n member((T, A, B, C), List),\n C \\= B,\n generateTransitiveAttackArgument(T, A, B, C),\n fail.\n conversion(_).\n generateTransitiveAttackArgument(T, A, B, C) :-\n context_check(argument([Id, attack, [attack(T, A, C, C)], G, I])),\n context_assert(attack(T, [Id, attack, [attack(T, A, C, C)], G, I], B, C)),\n context_retract(attack(T, A, B, C)).\n generateDirectAttackArgument(T, A, B, B) :-\n RArgument = [[attack], attack, [attack(T, A, B, B)], [], [[attack], [attack], []]],\n \\+ context_check(argument(RArgument)),\n context_assert(argument(RArgument)),\n context_assert(support(A, RArgument)),\n context_assert(attack(T, RArgument, B, B)),\n context_retract(attack(T, A, B, B)).\n /*\n * Computes the pref attack. If an Argument A has a conclusion in the form sup(a, b), we verify if\n * the attacks involving arguments built on the rules a or b are compatible with this preference.\n * If there are some contradictions we add an attack from the argument A towards the incompatible attack\n */\n buildPrefAttacks :-\n context_check(argument([IdB, attack, [attack(T, A, B, C)], G, I])),\n invalid(T, A, B, C, SupSet),\n member(X, SupSet),\n context_check(argument([IdA, TRA, [X], GG, II])),\n Attack = attack(pref, [IdA, TRA, [X], GG, II], [IdB, attack, [attack(T, A, B, C)], G, I], [IdB, attack, [attack(T, A, B, C)], G, I]),\n \\+ context_check(Attack),\n context_assert(Attack),\n fail.\n buildPrefAttacks.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject GenericDefPreferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n defeasiblePref::assertAllSup,\n findall((T, A, B, C), context_check(attack(T, A, B, C)), Attacks),\n defeasiblePref::filterSupRelatedAttacks(Attacks, InvalidAttacks),\n defeasiblePref::convertAttacks(InvalidAttacks),\n buildPrefAttacks,\n standard_af::buildTransitiveAttacks.\n buildPrefAttacks :-\n context_check(argument([IdB, attack, [attack(T, A, B, C)], G, I])),\n defeasiblePref::invalid(T, A, B, C, SupSet),\n createSuperiorityArgument(SupSet, Arg),\n write(Arg), nl,\n Attack = attack(pref, Arg, [IdB, attack, [attack(T, A, B, C)], G, I], [IdB, attack, [attack(T, A, B, C)], G, I]),\n \\+ context_check(Attack),\n context_assert(Attack),\n fail.\n buildPrefAttacks.\n createSuperiorityArgument(SupSet, Argument) :-\n findall([Id, TR, [X], G, I], (\n member(X, SupSet),\n context_check(argument([Id, TR, [X], G, I]))\n ), SupportArguments),\n mergeIds(SupportArguments, MergedId),\n Argument = [MergedId, pref, [mergedPreference], [], [[pref], MergedId, []]],\n \\+ context_check(argument(Argument)),\n context_assert(argument(Argument)),\n findall(_, (\n member(A, SupportArguments),\n \\+ context_check(support(A, Argument)),\n context_assert(support(A, Argument))\n ), _).\n mergeIds([], [pref]).\n mergeIds(Arguments, [pref|MergedId]) :-\n findall(Id, member([Id, _, _, _, _], Arguments), Res),\n utils::appendLists(Res, MergedId).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Grounded {\n val theoryCode: String =\n \"\"\"\n argumentLabelling :-\n findall(X, context_check(argument(X)), Arguments),\n groundedLabelling(Arguments).\n groundedLabelling(UND) :-\n member(A, UND), \n allAttacksOUT(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(in(A)),\n groundedLabelling(NewUND).\n groundedLabelling(UND) :-\n member(A, UND),\n oneAttackIN(A), !,\n utils::subtract(UND, [A], NewUND),\n context_assert(out(A)),\n groundedLabelling(NewUND).\n groundedLabelling(Args) :- findall(_, (member(A, Args), context_assert(und(A))), _).\n allAttacksOUT(A) :-\n \\+ ( context_check(attack(_, B, A, _)), \\+ (context_check(out(B)))).\n oneAttackIN(A) :-\n context_check(attack(_, B, A, _)),\n context_check(in(B)), !.\n oneAttackIN(A) :-\n context_check(attack(_, A, B, _)),\n context_check(in(B)), !.\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Preferences {\n val theoryCode: String =\n \"\"\"\n modifyArgumentationGraph :-\n findall(_, (\n context_check(attack(T, A, B, C)),\n checkStandardPreference(T, A, B, C)\n ), _).\n checkStandardPreference(T, A, B, C) :-\n \\+ standardPreferences(T, A, B, C),\n context_retract(attack(T, A, B, C)).\n standardPreferences(rebut, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(undermine, A, _, C) :- \\+ superiority::superiorArgument(C, A).\n standardPreferences(contrary_rebut, _, _, _).\n standardPreferences(contrary_undermine, _, _, _).\n standardPreferences(undercut, _, _, _).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject QueryMode {\n val theoryCode: String =\n \"\"\"\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n \\+ queryMode,\n abstract:::computeGlobalAcceptance,\n mineResults(Goal, YesResult, NoResult, UndResult).\n computeStatementAcceptance(Goal, YesResult, NoResult, UndResult) :-\n queryMode,\n argumentLabellingMode(grounded),\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(_, query(X, _), _),\n (ambiguityBlocking ->\n statement_binary:::statementLabelling;\n statementLabellingMode(Y),\n Y:::statementLabelling\n ),\n mineResults(Goal, YesResult, NoResult, UndResult).\n mineResults(Goal, YesResult, NoResult, UndResult) :-\n parser::check_modifiers_in_list(effects, [Goal], [X]),\n findall(Goal, context_check(statIn(X)), In),\n findall(Goal, context_check(statOut(X)), Out),\n findall(Goal, context_check(statUnd(X)), Und),\n utils::sort(In, YesResult),\n utils::sort(Out, NoResult),\n utils::sort(Und, UndResult).\n query(Query, Res) :-\n buildArgument(Query, Argument),\n once(defend(Argument, [], Res)).\n query(Query, und) :- \\+ buildArgument(Query, _).\n defend(Argument, _, no) :- context_check(out(Argument)).\n defend(Argument, _, und) :- context_check(und(Argument)).\n defend(Argument, _, yes) :- context_check(in(Argument)).\n defend(Argument, QueryChain, no) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == yes,\n bufferResult(Argument, no), !.\n defend(Argument, QueryChain, Res) :-\n findAttacker(Argument, QueryChain, Attacker, yes),\n once(defend(Attacker, [Argument|QueryChain], X)),\n X == und,\n ambiguityCheck(Argument, Attacker, Res),\n bufferResult(Argument, Res), !.\n complementary([_, _, ConclusionA, _, _], [_, _, ConclusionB, _, _]) :-\n standard_af::conflict(ConclusionA, ConclusionB).\n ambiguityCheck(A, B, no) :- ambiguityBlocking,\n \\+ complementary(A, B),\n context_check(attack(direct, B, A, _)), !.\n ambiguityCheck(_, _, und).\n defend(Argument, QueryChain, und) :-\n findAttacker(Argument, QueryChain, Attacker, no),\n bufferResult(Argument, und), !.\n defend(Argument, QueryChain, yes) :- bufferResult(Argument, yes).\n bufferResult(Argument, no) :- \\+ context_check(out(Argument)), context_assert(out(Argument)), !.\n bufferResult(Argument, yes) :- \\+ context_check(in(Argument)), context_assert(in(Argument)), !.\n bufferResult(Argument, und) :- \\+ context_check(und(Argument)), context_assert(und(Argument)), !.\n bufferResult(_, _).\n findAttacker(Target, QueryChain, Attacker, IsValid) :-\n attacker(Target, Attacker, Type),\n bufferAttacker(Attacker, Target, Type),\n detectCycle(Attacker, QueryChain, IsValid).\n bufferAttacker(Attacker, Target, Type) :-\n \\+ context_check(attack(Type, Attacker, Target, none)),\n context_assert(attack(Type, Attacker, Target, none)), !.\n bufferAttacker(_, _, _).\n detectCycle(Attacker, QueryChain, yes) :- \\+ member(Attacker, QueryChain).\n detectCycle(Attacker, QueryChain, no) :- member(Attacker, QueryChain).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Rules),\n \\+ context_check(strict(X)),\n attackerOnRule(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attacker([Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type) :-\n member(X, Groundings),\n attackerOnTerm(X, [Rules, TopRule, Conclusion, Groundings, ArgInfo], Argument, Type).\n attackerOnRule(Rule, _, Argument, undercut) :-\n buildArgument([undercut(Rule)], Argument).\n attackerOnTerm(Term, [TargetRules, TopRule, Conclusion, Groundings, ArgInfo], Attacker, direct) :-\n Term \\= [unless, _],\n \\+ strict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]),\n (graphExtension(rebutRestriction) ->\n (\n buildSubArgument(Term, TargetRules, SubArgument),\n rebutRestriction(SubArgument)\n );\n true\n ),\n standard_af::conflict(Term, X),\n buildArgument(X, Attacker),\n (graphExtension(standardPref) ->\n (ground(SubArgument) ->\n true;\n buildSubArgument(Term, TargetRules, SubArgument)\n ),\n \\+ superiorArgument(SubArgument, Attacker);\n true\n ).\n attackerOnTerm([unless, X], _, Attacker, contrary) :-\n buildArgument(X, Attacker).\n strict([_, _, _, _, [_, [], []]]).\n rebutRestriction([TargetRules, none, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction).\n rebutRestriction([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]) :-\n graphExtension(rebutRestriction),\n TopRule \\= none,\n rebutRestriction::restrict([TargetRules, TopRule, Conclusion, Groundings, ArgInfo]).\n rebutRestriction(_) :- \\+ graphExtension(rebutRestriction).\n superiorArgument(SubArgument, Attacker) :-\n superiority::superiorArgument(SubArgument, Attacker).\n buildSubArgument(Term, Rules, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]) :-\n buildArgument(Term, [SubRules, SubTopRule, SubConclusion, SubGrounds, Info]),\n contained(SubRules, Rules).\n contained([], _).\n contained([H|T], Target) :- member(H, Target), contained(T, Target).\n buildArgument(Query, Argument) :-\n \\+ context_check(explored(Query)),\n findall(_, (\n buildSingleArgument(Query, Argument),\n context_assert(argument(Argument))\n ), _),\n context_assert(explored(Query)),\n fail.\n buildArgument(Query, [R, T, Query, B, I]) :- context_check(argument([R, T, Query, B, I])).\n buildSingleArgument(Query, Argument) :-\n build(Query, [], Groundings, [AllRules, TopRule, LastDefRules, DefRules, DefPremises]),\n utils::deduplicate(DefRules, CDefRules),\n utils::deduplicate(DefPremises, CDefPremises),\n utils::deduplicate(Groundings, CGroundings),\n Argument = [AllRules, TopRule, Query, CGroundings, [LastDefRules, CDefRules, CDefPremises]].\n build(Conclusion, _, [Conclusion], Rules) :-\n context_check(premise([Id, Conclusion])),\n premiseRules(Id, Rules).\n build(Conclusion, Ids, [Conclusion|Conclusions], Rules) :-\n context_check(rule([Id, Premises, Conclusion])),\n \\+ member(Id, Ids),\n buildPremises(Premises, [Id|Ids], Conclusions, ResRules),\n ruleRules(Id, ResRules, Rules).\n build([prolog(Check)], _, [], []) :- (callable(Check) -> call(Check); Check).\n build([unless, Atom], _, [[unless, Atom]], []).\n buildPremises([], _, [], [[], [], [], []]).\n buildPremises([H|T], Ids, Conclusions, Rules) :-\n build(H, Ids, HConclusions, HRules),\n buildPremises(T, Ids, TConclusions, TRules),\n utils::appendLists([HConclusions, TConclusions], Conclusions),\n mergeRules(HRules, TRules, Rules).\n premiseRules(Id, [[Id], none, [], [], [Id]]) :- \\+ context_check(strict(Id)).\n premiseRules(Id, [[Id], none, [], [], []]) :- context_check(strict(Id)).\n ruleRules(Id, [AllRules, _, DefRules, DefPremises], \n [[Id|AllRules], Id, [Id], [Id|DefRules], DefPremises]) :- \\+ context_check(strict(Id)).\n ruleRules(Id, [AllRules, LastDefRules, DefRules, DefPremises], \n [[Id|AllRules], Id, LastDefRules, DefRules, DefPremises]) :- context_check(strict(Id)).\n mergeRules([], [AllRules, LastDefRules, DefRules, DefPremises], [AllRules, LastDefRules, DefRules, DefPremises]).\n mergeRules([HAR, _, HLDR, HDR, HDP], [TAR, TLDR, TDR, TDP], [AR, LDR, DR, DP]) :-\n utils::appendLists([HAR, TAR], AR),\n utils::appendLists([HLDR, TLDR], LDR),\n utils::appendLists([HDR, TDR], DR),\n utils::appendLists([HDP, TDP], DP).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject RuleTranslator {\n val theoryCode: String =\n \"\"\"\n /*\n * Main directive. Find all the rules in the theory in the format (Name : Preconditions => Conclusion)\n * or (Name : Effects) and then if:\n * - It is a standard rule, translate it in the standard format (rule([Name, Preconditions, Conclusions]));\n * - It is a bp rule, translate it to (abstractBp([Effects]))\n * During the process, clean them from the unallowed symbols (-, o, p).\n */\n convertAllRules(ArgRules) :-\n defeasibleRules(DefeasibleRules),\n strictRules(StrictRules, RulesIds),\n ordinaryPremises(Premises),\n axiomPremises(Axioms, AxiomsIds),\n specialRules(SpecialRules),\n utils::appendLists([DefeasibleRules, StrictRules, Premises, Axioms, SpecialRules], L),\n convertAllRules(L, Rules),\n findall(sup(X, Y), sup(X, Y), Sups),\n utils::appendLists([Rules, AxiomsIds, RulesIds, Sups], ArgRules),\n findall(_, (member(X, ArgRules), context_assert(X)), _), !.\n defeasibleRules(DefeasibleRules) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions => Effect), DefeasibleRulesOld),\n prologDefeasibleRules(DefeasibleRulesNew),\n append(DefeasibleRulesOld, DefeasibleRulesNew, DefeasibleRules).\n strictRules(CtrRules, Ids) :-\n findall([RuleName, Preconditions, Effect], (RuleName : Preconditions -> Effect), StrictRulesOld),\n prologStrictRules(StrictRulesNew),\n append(StrictRulesOld, StrictRulesNew, StrictRules),\n transpose(StrictRules, StrictRules, CtrRules),\n findall(strict(RN), member([RN, _, _], CtrRules), Ids).\n ordinaryPremises(Premises) :-\n findall([RuleName, Effect], ((RuleName :=> Effect), atom(RuleName)), PremisesOld),\n prologPremises(PremisesNew),\n append(PremisesOld, PremisesNew, Premises).\n axiomPremises(Axioms, Ids) :-\n findall([RuleName, Effect], ((RuleName :-> Effect), atom(RuleName)), AxiomsOld),\n prologAxioms(AxiomsNew),\n append(AxiomsOld, AxiomsNew, Axioms),\n findall(strict(RN), member([RN, _], Axioms), Ids).\n specialRules(SpecialRules) :-\n bpsNew(SpecialRules).\n transpose(_, CtrRules, CtrRules) :- \\+ autoTransposition, !.\n transpose([], CtrRules, CtrRules).\n transpose([H|T], TempCtrRules, CtrRules) :-\n transpose(T, TempCtrRules, CR),\n findall(TrH, transposition(H, TrH), Tran),\n mergeCtrRules(CR, Tran, CtrRules).\n mergeCtrRules(All, ToMerge, X) :-\n append(All, ToMerge, XT),\n deduplicate(XT, X).\n deduplicate([], []).\n deduplicate([[RN,A,B]|T], X) :- deduplicate(T, TT), (member([RN,_,_], TT) -> X = TT; X = [[RN,A,B]|TT]). \n transposition([Id, Prec, Effect], [Id, Prec, Effect]).\n transposition([Id, Prec, Effect], [NewId, NewPrec ,XNegated]) :-\n compound(Prec),\n tuple_to_list(Prec, LPrec),!,\n transposition_sequential(LPrec, LPrec, Effect, Id, [], NewPrec, XNegated, NewId).\n transposition([Id, Prec, Effect], [NewId, EffectNegated ,XNegated]) :-\n \\+ compound(Prec),\n Prec \\== [],\n prologEscape(Prec),\n negate(Prec, XNegated),\n negate(Effect, EffectNegated),\n atom_concat(Id, '_i', NewId).\n transposition_sequential(LPrec, [H|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n transposition_sequential(LPrec, T, Effect, Id, [H|Skipped], NewPrec, XNegated, NewId).\n transposition_sequential(LPrec, [X|T], Effect, Id, Skipped, NewPrec, XNegated, NewId) :-\n prologEscape(X),\n append(Skipped, T, CleanedPrec),\n negate(X, XNegated),\n negate(Effect, EffectNegated),\n list_to_tuple([EffectNegated|CleanedPrec], NewPrec),\n newIdentifier(Skipped, Id, NewId).\n newIdentifier(List, OldId, NewId) :-\n modifier(List, Mod),\n atom_concat(OldId, Mod, NewId).\n modifier([], '_i').\n modifier([_|Tail], Index):-\n modifier(Tail, Index1),\n atom_concat(Index1, 'i', Index).\n negate(X, Arg) :-\n functor(X, '-', _) -> (\n arg(1, X, Arg));\n functor(X, 'p', _) -> (\n arg(1, X, PX),\n (functor(PX, '-', _) -> (\n arg(1, PX, PNX),\n Arg = o(PNX)\n );\n Arg = o(-(PX))));\n Arg = -(X).\n prologEscape(X) :- \\+ functor(X, 'prolog', _), \\+ functor(X, '~', _).\n /*\n * Standard rules (RuleName : Preconditions => Effects)\n * Special rules (RuleName : Effects)\n */\n convertAllRules([], []).\n convertAllRules([[H,P,E]|T], [R|Rules]) :- convertRule(H, P, E, R), convertAllRules(T, Rules).\n convertAllRules([[H,E]|T], [R|Rules]) :- convertRule(H, E, R), convertAllRules(T, Rules).\n /*\n * Convert the given rule to the standard format\n * Example:\n * r2: followedGuidelines(X), doctor(X) => -liable(X)\n * rule([r2,[[followedGuidelines(X_e4149)],[doctor(X_e4149)]],[neg,liable(X_e4149)]]).\n */\n convertRule(RuleName, Preconditions, Effects, rule(List)) :-\n tuple_to_list(Preconditions, Lprecond),\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(preconditions, Lprecond, LprecondChecked),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened),\n List = [RuleName, LprecondChecked, LeffectsCheckedFlattened], !.\n /*\n * Convert the given special rule\n * Example:\n * bp(-liable(X)).\n * abastractBp([[neg, liable(X_e4149)]]).\n */\n convertRule(bps, Effects, abstractBp(Checked)) :-\n functor(Effects, 'bp', _),\n Effects =.. L,\n removehead(L, LC),\n check_modifiers_in_list(effects, LC, Checked), !.\n convertRule(Name, Effects, premise([Name, LeffectsCheckedFlattened])) :-\n tuple_to_list(Effects, Leffects),\n check_modifiers_in_list(effects, Leffects, LeffectsChecked),\n flatten_first_level(LeffectsChecked, LeffectsCheckedFlattened).\n /*\n * Find negations(-), obligations(o), permissions(p) on a list of preconditions/effects and\n * raplace them with the assigned literal (neg, obl, perm)\n */\n check_modifiers_in_list(MODE, [], []) :- !.\n check_modifiers_in_list(MODE, [H|T], L) :- H == [], L = [], !.\n check_modifiers_in_list(MODE, [H|T], L) :- H \\== [],\n check_modifiers_once(H, LH),\n check_modifiers_in_list(MODE, T, LT),\n append([LH], LT, L).\n check_modifiers_once(H, List) :- once(check_modifiers(H, List)).\n check_modifiers([], []).\n check_modifiers(H, List) :-\n functor(H, '-', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n append([neg], Lobl, Lf),\n List = Lf);\n functor(H, 'o', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lobl),\n List = [obl|[Lobl]]);\n functor(H, 'p', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [perm|[Lper]]);\n functor(H, '~', _) -> (\n arg(1, H, Arg),\n check_modifiers_once(Arg, Lper),\n List = [unless|[Lper]]);\n functor(H, 'bp', _) -> (\n H =.. [_|Arg],\n check_modifiers_in_list(effects, Arg, Lper),\n List = [bp|[Lper]]);\n List = [H].\n /*\n * Convert the given tuple to list\n */\n tuple_to_list(A,[A]) :- nonvar(A), A \\= (_ , _), !.\n tuple_to_list((A,B),L) :-\n tuple_to_list(A, La),\n tuple_to_list(B, Lb),\n append(La, Lb,L).\n list_to_tuple([H], (H)) :- !.\n list_to_tuple([H|T], (H,TT)) :- list_to_tuple(T,TT).\n /*\n * Replace all the occurences of a given element with the given argument\n */\n replace(_, _, [],[]) :- !.\n replace(O, R, [O|T], [R|T2]) :- replace(O, R, T, T2), !.\n replace(O, R, [H|T], [H|T2]) :- H \\= O, replace(O, R, T, T2).\n flatten_first_level([X], X) :- !.\n flatten_first_level.\n removehead([_|Tail], Tail).\n in(A, A) :- nonvar(A), A \\= (_ , _), !.\n in(A, (A, _)) :- !.\n in(A, (_ , Cs)) :- in(A, Cs).\n check_admissibility(preconditions, H, LH) :-\n \\+ defeasible_admissible(LH),\n throw(['Premise ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(effects, H, LH) :-\n \\+ admissible(LH),\n throw(['Conclusion ', H, ' is not a well formed member of the argumentation language.']).\n check_admissibility(_, _, _).\n defeasible_admissible([unless, Term]) :- admissible(Term).\n defeasible_admissible(Term) :- admissible(Term).\n admissible([neg, bp, Term]) :- admissible_terms_complete(Term).\n admissible([bp, Term]) :- admissible_terms_complete(Term).\n admissible([neg, Term]) :- admissible_term(Term).\n admissible([obl, [Term]]) :- admissible_term(Term).\n admissible([obl, [neg, Term]]) :- admissible_term(Term).\n admissible([neg, obl, [Term]]) :- admissible_term(Term).\n admissible([neg, obl, [neg, Term]]) :- admissible_term(Term).\n admissible([perm, [Term]]) :- admissible_term(Term).\n admissible([perm, [neg, Term]]) :- admissible_term(Term).\n admissible([Term]) :- admissible_term(Term).\n admissible_term(Term) :-\n atomic(Term),\n Term \\== neg,\n Term \\== obl,\n Term \\== perm,\n Term \\== unless,\n Term \\== bp.\n admissible_term(Term) :- var(Term).\n admissible_term(Term) :-\n compound(Term),\n \\+ functor(Term, 'o', _),\n \\+ functor(Term, 'p', _),\n \\+ functor(Term, '-', _),\n \\+ functor(Term, '~', _),\n \\+ functor(Term, 'bp', _),\n Term =.. [_|Args],\n admissible_terms(Args).\n admissible_terms([]).\n admissible_terms([H|T]) :-\n admissible_term(H),\n admissible_terms(T).\n admissible_terms_complete([]).\n admissible_terms_complete([H|T]) :-\n admissible(H),\n admissible_terms_complete(T).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject StatementLabelling {\n val theoryCode: String =\n \"\"\"\n statementLabelling :-\n findall(_, (\n context_check(in([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n context_assert(statIn(Conc))\n ), _),\n findall(_, (\n context_check(out([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n \\+ context_check(statOut(Conc)),\n context_assert(statOut(Conc))\n ), _),\n findall(_, (\n context_check(und([_, _, Conc, _, _])),\n \\+ context_check(statIn(Conc)),\n \\+ context_check(statOut(Conc)),\n \\+ context_check(statUnd(Conc)),\n context_assert(statUnd(Conc))\n ), _).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject SuperiorityRelation {\n val theoryCode: String =\n \"\"\"\n superiorArgument(A, B) :- superiorArgumentSupportBuffered(A, B, _).\n superiorArgument(A, B, SupSet) :- superiorArgumentSupportBuffered(A, B, SupSet).\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n context_check(superior(A, B, SupSet, true)), !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n context_check(superior(A, B, SupSet, false)),\n fail, !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n \\+ context_check(superior(A, B, _, _)),\n superiorArgumentSupport(A, B, SupSet),\n context_assert(superior(A, B, SupSet, true)), !.\n superiorArgumentSupportBuffered(A, B, SupSet) :-\n \\+ cache_check(superior(A, B, _, _)),\n context_assert(superior(A, B, [], false)),\n fail, !.\n superiorArgumentSupport([_, _, _, _, [LastDefRulesA, DefRulesA, DefPremisesA]], [_, _, _, _, [LastDefRulesB, DefRulesB, DefPremisesB]], SupSet) :-\n \tsuperiorArgumentSupport(LastDefRulesA, DefRulesA, DefPremisesA, LastDefRulesB, DefRulesB, DefPremisesB, SupSet).\n superiorArgumentSupport(LastDefRulesA, _, DefPremisesA, LastDefRulesB, _, DefPremisesB, SupSet) :-\n orderingPrinciple(last),\n \tsuperior(LastDefRulesA, DefPremisesA, LastDefRulesB, DefPremisesB, SupSet).\n superiorArgumentSupport(_, DefRulesA, DefPremisesA, _, DefRulesB, DefPremisesB, SupSet) :-\n orderingPrinciple(weakest),\n \tsuperior(DefRulesA, DefPremisesA, DefRulesB, DefPremisesB, SupSet).\n superior([], PremisesA, [], PremisesB, SupSet) :-\n \tweaker(PremisesB, PremisesA, SupSet).\n superior(DefRulesA, _, DefRulesB, _, SupSet) :-\n \torderingPrinciple(last),\n \t(DefRulesA \\== []; DefRulesB \\== []),\n \tweaker(DefRulesB, DefRulesA, SupSet).\n superior(DefRulesA, [], DefRulesB, [], SupSet) :-\n \torderingPrinciple(weakest),\n \tweaker(DefRulesB, DefRulesA, SupSet).\n superior(DefRulesA, PremisesA, DefRulesB, PremisesB, SupSet) :-\n \torderingPrinciple(weakest),\n \t(DefRulesA \\== []; DefRulesB \\== []),\n \t(PremisesA \\== []; PremisesB \\== []),\n \tweaker(DefRulesB, DefRulesA, SupSetA),\n \tweaker(PremisesB, PremisesA, SupSetB),\n \tutils::appendLists([SupSetA, SupSetB], SupSet).\n weaker(RulesA, [], []) :-\n \tRulesA \\== [].\n weaker(RulesA, RulesB, SupSet) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(elitist),\n \tmember(Rule, RulesA),\n \tallStronger(Rule, RulesB, SupSet), !.\n weaker(RulesA, RulesB, SupSet) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(democrat),\n \tweakerDemo(RulesA, RulesB, SupSet).\n weaker(RulesA, RulesB, [sup(X, W)]) :-\n \tRulesA \\== [],\n \tRulesB \\== [],\n \torderingComparator(normal),\n \tmember(W, RulesA),\n \tmember(X, RulesB),\n \tcontext_check(sup(X, W)), !.\n weakerDemo([], _, []).\n weakerDemo([H|T], Rules, [Sup|SupSet]) :-\n \tsingleStronger(H, Rules, Sup),\n \tweakerDemo(T, Rules, SupSet).\n singleStronger(Target, Rules, sup(Rule, Target)) :-\n \tmember(Rule, Rules),\n \tcontext_check(sup(Rule, Target)), !.\n allStronger(_, [], []).\n allStronger(Target, [Rule|Rules], [sup(Rule, Target)|SupSet]) :-\n \tcontext_check(sup(Rule, Target)),\n \tallStronger(Target, Rules, SupSet).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.sources\n\nobject Utils {\n val theoryCode: String =\n \"\"\"\n writeList([]) :- nl.\n writeList([X|Others]) :-\n \twrite(X),\n \twriteList(Others).\n writeListNl([]).\n writeListNl([X|Others]) :-\n \twrite(X),nl,\n \twriteListNl(Others).\n sortDistinct(List, Sorted) :-\n deduplicate(List, Deduplicated),\n sort(Deduplicated, Sorted).\n deduplicate([], []).\n deduplicate(List, Output) :-\n List \\== [],\n setof(X, member(X, List), Output).\n sort(List,Sorted) :- q_sort(List, [], Sorted).\n q_sort([], Acc, Acc).\n q_sort([H|T], Acc, Sorted) :-\n \tpivoting(H, T, L1, L2),\n \tq_sort(L1, Acc, Sorted1),\n \tq_sort(L2, [H|Sorted1], Sorted).\n pivoting(H,[],[],[]).\n pivoting(H, [X|T], [X|L], G) :-\n H @>= X,\n pivoting(H, T, L, G).\n pivoting(H, [X|T], L, [X|G]) :-\n X @> H,\n pivoting(H, T, L, G).\n subtract([], _, []).\n subtract([Head|Tail], L2, L3) :-\n member(Head, L2), !,\n subtract(Tail, L2, L3).\n subtract([Head|Tail1], L2, [Head|Tail3]) :-\n subtract(Tail1, L2, Tail3).\n isEmptyList([]).\n appendLists([], []).\n appendLists([H|T], R) :-\n appendLists(T, AT),\n append(H, AT, R).\n search(F, L, S) :-\n between(1, L, N),\n functor(S, F, N),\n call(S).\n between(N, M, K) :- N < M, K = N.\n between(N, M, K) :- N == M, !, K = N.\n between(N, M, K) :- N < M, N1 is N+1, between(N1, M, K).\n recoverGraph(Args, Attacks, Supports) :-\n findall(X, context_check(argument(X)), TempArgs),\n findall((T, A, B, C), context_check(attack(T, A, B, C)), TempAttacks),\n findall((A, B), context_check(support(A, B)), TempSupports),\n utils::sort(TempArgs, Args),\n utils::sort(TempAttacks, Attacks),\n utils::sort(TempSupports, Supports).\n recoverArgumentLabelling(ArgsIn, ArgsOut, ArgsUnd) :-\n findall(X, context_check(in(X)), TempArgsIn),\n findall(X, context_check(out(X)), TempArgsOut),\n findall(X, context_check(und(X)), TempArgsUnd),\n utils::sort(TempArgsIn, ArgsIn),\n utils::sort(TempArgsOut, ArgsOut),\n utils::sort(TempArgsUnd, ArgsUnd).\n recoverStatementLabelling(In, Out, Und) :-\n findall(X, context_check(statIn(X)), TempIn),\n findall(X, context_check(statOut(X)), TempOut),\n findall(X, context_check(statUnd(X)), TempUnd),\n utils::sort(TempIn, In),\n utils::sort(TempOut, Out),\n utils::sort(TempUnd, Und).\n \"\"\".trimIndent()\n}\n","package it.unibo.tuprolog.argumentation.core.libs.structured\n\nactual object StructuredMode : StructuredModeBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.QueryMode.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object Debug : DebugBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Debug.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object SuperiorityRelation : SuperiorityRelationBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.SuperiorityRelation.theoryCode\n}\n","package it.unibo.tuprolog.argumentation.core.libs.utils\n\nactual object Utils : UtilsBase() {\n override val prologRawTheory: String\n get() = it.unibo.tuprolog.argumentation.core.libs.sources.Utils.theoryCode\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAmgDA,yD;uBAAA,gD;2CAw7BA,wD;;;;;;;;;;;;;;;;;;;;;oBA/xCA,6C;sBAAA,0C;2BAAA,mD;;;;;;;;;;;;;;;;;;;;;yBAlXA,+C;;;;;;;;;;;;;;;;;;;;;;;;;;;oBC5xBA,qC;;;;;;oCDyMA,oC;eAwsCA,wC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IEl3CI,mC;;wCAJA,Y;IAAsB,8B;IAA6D,gBAAxB,KAAxB,QAAO,WAAP,EAAe,YAAf,EAAwB,EAAK,sBAAL,C;IFi+CpD,kBAAM,eAAa,mCAAwB,EAAxB,CAAb,C;IAuEA,U;IAAA,6B;IAAb,OAAa,gBAAb,C;MAAa,wB;MACT,WAAY,WAAc,IEziD8D,UFyiD5E,C;;IEziDM,OAAU,gBF0iDzB,WE1iDyB,C;G;oCAChC,Y;IACK,gBADqC,KAAxB,QAAO,WAAP,EAAe,YAAf,EAAwB,EAAK,sBAAL,C;IFg+CnC,kBAAM,eAAa,mCAAwB,EAAxB,CAAb,C;IAuEA,Q;IAAA,2B;IAAb,OAAa,cAAb,C;MAAa,sB;MACT,WAAY,WAAc,IEviDhB,gBFuiDE,C;;IAs3BhB,eAr3BO,WAq3Ba,W;IACpB,IAAI,CAAC,QAAS,UAAd,C;MAAyB,MAAM,mCAA8B,oCAA9B,C;IAC/B,kBAAqB,QAAS,O;IAC9B,OAAO,QAAS,UAAhB,C;MACI,cAAwB,4BAAa,QAAS,Q;;IEl6EhC,OFo6EX,W;G;EEj6EP,iC;IAAA,qC;G;EAEQ,yF;IAAA,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