shorthand constructor for Left
shorthand constructor for Left
scala> import sclib.ops.either._ scala> "BOOM".left res0: Either[String,Nothing] = Left(BOOM)
shorthand constructor for Right
shorthand constructor for Right
scala> import sclib.ops.either._ scala> 1.right res0: Either[Nothing,Int] = Right(1)
shorthand constructor for Some
shorthand constructor for Some
shorthand constructor for scala.util.Success
shorthand constructor for scala.util.Success
scala> import sclib.ops.`try`._ scala> 3.success res0: scala.util.Try[Int] = Success(3)
extensions on Either
instances
extensions on Either
instances
extend Stream
extend Stream
extensions on List
instances
extensions on List
instances
you have to add an implicit parameter for the 'Ordering' and import the parameter in the function to use it's members (<, <=, >, >=)
you have to add an implicit parameter for the 'Ordering' and import the parameter in the function to use it's members (<, <=, >, >=)
scala> def isSorted[A](xs: List[A])(implicit ordering: Ordering[A]): Boolean = { | import ordering._ | xs match { | case a :: b :: ys => a <= b && isSorted(b :: ys) | case _ => true | } | } isSorted: [A](xs: List[A])(implicit ordering: Ordering[A])Boolean
only add the context bound for 'Ordering'
scala> import sclib.ops.ordering._ scala> def isSorted2[A: Ordering](xs: List[A]): Boolean = xs match { | case a :: b :: ys => a <= b && isSorted2(b :: ys) | case _ => true | } isSorted2: [A](xs: List[A])(implicit evidence$1: Ordering[A])Boolean
Type-Class for the result of StringOps.parseXX
Type-Class for the result of StringOps.parseXX
shorthand constructor for Failure
from a String
shorthand constructor for Failure
from a String
scala> import sclib.ops.`try`._ scala> "BOOM".failure res0: scala.util.Try[Nothing] = Failure(java.lang.Exception: BOOM)
shorthand constructor for Failure
from a Throwable
shorthand constructor for Failure
from a Throwable
scala> import sclib.ops.`try`._ scala> new IllegalArgumentException("BOOM").failure[Int] res0: scala.util.Try[Int] = Failure(java.lang.IllegalArgumentException: BOOM)
reducing many Either
s into a single Either
reducing many Either
s into a single Either
reducing many Option
s into a single Option
reducing many Option
s into a single Option
reducing many Try
s into a single Try
reducing many Try
s into a single Try
extensions on Try
instances
extensions on Try
instances
utility's for List
utility's for List
convert a scala.Function2
to a java.util.function.BinaryOperator
convert a scala.Function2
to a java.util.function.BinaryOperator
without the import:
scala> java.util.stream.Stream.of(1, 2, 3, 4).reduce(0, (_: Int) + (_: Int)) <console>:12: error: overloaded method value reduce with alternatives: [U](x$1: U, x$2: java.util.function.BiFunction[U, _ >: Int, U], x$3: java.util.function.BinaryOperator[U])U <and> (x$1: java.util.function.BinaryOperator[Int])java.util.Optional[Int] <and> (x$1: Int,x$2: java.util.function.BinaryOperator[Int])Int cannot be applied to (Int, (Int, Int) => Int) java.util.stream.Stream.of(1, 2, 3, 4).reduce(0, (_: Int) + (_: Int))
with the import:
scala> import sclib.ops.java8._ scala> java.util.stream.Stream.of(1, 2, 3, 4).reduce(0, (_: Int) + (_: Int)) res1: Int = 10
convert a scala.Function1
to a java.util.function.Consumer
convert a scala.Function1
to a java.util.function.Consumer
without the import:
scala> java.util.stream.Stream.of(1, 2, 3, 4).forEach(println(_: Int)) <console>:12: error: type mismatch; found : Int => Unit required: java.util.function.Consumer[_ >: Int] java.util.stream.Stream.of(1, 2, 3, 4).forEach(println(_: Int))
with the import:
scala> import sclib.ops.java8._ scala> java.util.stream.Stream.of(1, 2, 3, 4).forEach(println(_: Int)) 1 2 3 4
convert a scala.Function1
to a java.util.function.Function
convert a scala.Function1
to a java.util.function.Function
without the import:
scala> java.util.stream.Stream.of(1, 2, 3,4).map((_: Int) * 10).toArray <console>:12: error: type mismatch; found : Int => Int required: java.util.function.Function[_ >: Int, _] java.util.stream.Stream.of(1, 2, 3,4).map((_: Int) * 10).toArray
with the import:
scala> import sclib.ops.java8._ scala> java.util.stream.Stream.of(1, 2, 3,4).map((_: Int) * 10).toArray res1: Array[Object] = Array(10, 20, 30, 40)
convert a scala.Function1
to a java.util.function.Predicate
convert a scala.Function1
to a java.util.function.Predicate
without the import:
scala> java.util.stream.Stream.of(1, 2, 3, 4).filter((_: Int) < 3).toArray <console>:12: error: type mismatch; found : Int => Boolean required: java.util.function.Predicate[_ >: Int] java.util.stream.Stream.of(1, 2, 3, 4).filter((_: Int) < 3).toArray
with the import:
scala> import sclib.ops.java8._ scala> java.util.stream.Stream.of(1, 2, 3, 4).filter((_: Int) < 3).toArray res1: Array[Object] = Array(1, 2)
shorthand constructor for None
shorthand constructor for None
use
import sclib.ops.all._
to import all