<commit_before>package reagent.source

import kotlinx.coroutines.experimental.delay
import reagent.Emitter
import reagent.Many

fun <I> many(body: suspend (emit: Emitter<I>) -> Unit): Many<I> = ManyFromSuspendingLambda(body)

fun <I> emptyMany(): Many<I> = TaskComplete
fun <I> manyOf(item: I): Many<I> = OneJust(item)
fun <I> manyOf(vararg items: I): Many<I> = ManyFromArray(items)
fun <I> manyReturning(func: () -> I): Many<I> = OneFromLambda(func)
fun <I> manyRunning(func: () -> Unit): Many<I> = TaskFromLambda(func)

fun <I> deferMany(func: () -> Many<I>): Many<I> = ManyDeferred(func)

fun <I> Throwable.toMany(): Many<I> = OneError(this)
fun <T> Array<T>.toMany(): Many<T> = ManyFromArray(this)<commit_msg>Specialize vararg factory for 0 and 1 items.<commit_after>package reagent.source

import kotlinx.coroutines.experimental.delay
import reagent.Emitter
import reagent.Many

fun <I> many(body: suspend (emit: Emitter<I>) -> Unit): Many<I> = ManyFromSuspendingLambda(body)

fun <I> emptyMany(): Many<I> = TaskComplete
fun <I> manyOf(item: I): Many<I> = OneJust(item)
fun <I> manyOf(vararg items: I): Many<I> = when (items.size) {
  0 -> TaskComplete
  1 -> OneJust(items[0])
  else -> ManyFromArray(items)
}
fun <I> manyReturning(func: () -> I): Many<I> = OneFromLambda(func)
fun <I> manyRunning(func: () -> Unit): Many<I> = TaskFromLambda(func)

fun <I> deferMany(func: () -> Many<I>): Many<I> = ManyDeferred(func)

fun <I> Throwable.toMany(): Many<I> = OneError(this)
fun <T> Array<T>.toMany(): Many<T> = ManyFromArray(this)
{'fraction_non_alphanumeric': 0.1773142112125163, 'fraction_numerical': 0.003259452411994785, 'mean_word_length': 5.9457013574660635, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2264473', 'n_tokens_mistral': 576, 'n_tokens_neox': 562, 'n_words': 139}