All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.extensions.CharRange.kt Maven / Gradle / Ivy

The newest version!
package com.github.fluidsonic.fluid.stdlib

import kotlin.jvm.*


operator fun CharRange.component1() =
	first


operator fun CharRange.component2() =
	last


fun CharRange.flipped() =
	last .. first


fun > CharRange.mapBounds(transform: (Char) -> R) =
	transform(first) .. transform(last)


@JvmName("mapBoundsToDouble")
fun CharRange.mapBounds(transform: (Char) -> Double) =
	transform(first) .. transform(last)


@JvmName("mapBoundsToFloat")
fun CharRange.mapBounds(transform: (Char) -> Float) =
	transform(first) .. transform(last)


fun CharRange.mapBounds(transform: (Char) -> Int) =
	transform(first) .. transform(last)


fun CharRange.mapBounds(transform: (Char) -> Long) =
	transform(first) .. transform(last)


@ExperimentalUnsignedTypes
fun CharRange.mapBounds(transform: (Char) -> UInt) =
	transform(first) .. transform(last)


@ExperimentalUnsignedTypes
fun CharRange.mapBounds(transform: (Char) -> ULong) =
	transform(first) .. transform(last)


fun CharRange.intersection(other: CharRange) =
	overlaps(other).thenTake { maxOf(first, other.first) rangeToExcluding minOf(last, other.last) }


fun CharRange.overlaps(other: CharRange) =
	contains(other.first) || other.contains(first)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy