Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Foo {
- type Trans[T] = T => Option[T]
- def foo[T](t: T, ts: List[Trans[T]]): Option[T] = {
- def aux(acc: T, ts: List[Trans[T]], success: Boolean = false): Option[T] = ts match {
- case t :: rest => t(acc) match {
- case Some(v) => aux(v, rest, success = true)
- case None => aux(acc, rest)
- }
- case _ => Option(acc)
- }
- aux(t, ts)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement