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

org.hnau.emitter.extensions.long.EmitterLongWithLongExtensions.kt Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package org.hnau.emitter.extensions.long

import org.hnau.emitter.Emitter
import org.hnau.emitter.observing.value.possible.state.combine.combineWith
import org.hnau.emitter.extensions.map


fun Emitter.toLong() = map(Long::toLong)

operator fun Emitter.plus(other: Emitter) = combineWith(other, Long::plus)
operator fun Emitter.minus(other: Emitter) = combineWith(other, Long::minus)
operator fun Emitter.times(other: Emitter) = combineWith(other, Long::times)
operator fun Emitter.div(other: Emitter) = combineWith(other, Long::div)
operator fun Emitter.rem(other: Emitter) = combineWith(other, Long::rem)
operator fun Emitter.rangeTo(other: Emitter) = combineWith(other, Long::rangeTo)

operator fun Emitter.plus(other: Long) = map { it + other }
operator fun Emitter.minus(other: Long) = map { it - other }
operator fun Emitter.times(other: Long) = map { it * other }
operator fun Emitter.div(other: Long) = map { it / other }
operator fun Emitter.rem(other: Long) = map { it % other }
operator fun Emitter.rangeTo(other: Long) = map { it..other }

operator fun Long.plus(other: Emitter) = other.map { this + it }
operator fun Long.minus(other: Emitter) = other.map { this - it }
operator fun Long.times(other: Emitter) = other.map { this * it }
operator fun Long.div(other: Emitter) = other.map { this / it }
operator fun Long.rem(other: Emitter) = other.map { this % it }
operator fun Long.rangeTo(other: Emitter) = other.map { this..it }

infix fun Emitter.and(other: Emitter) = combineWith(other, Long::and)
infix fun Emitter.or(other: Emitter) = combineWith(other, Long::or)
infix fun Emitter.xor(other: Emitter) = combineWith(other, Long::xor)
infix fun Emitter.and(other: Long) = map { it and other }
infix fun Emitter.or(other: Long) = map { it or other }
infix fun Emitter.xor(other: Long) = map { it xor other }
infix fun Long.and(other: Emitter) = other.map { this and it }
infix fun Long.or(other: Emitter) = other.map { this or it }
infix fun Long.xor(other: Emitter) = other.map { this xor it }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy