val ps = Seq(1 -> NEXT_SCREEN_PARAMETER_NAME, -1 -> PREV_SCREEN_PARAMETER_NAME, Int.MaxValue -> LAST_SCREEN_PARAMETER_NAME) val test = StringUtils.isNotBlank(request.getParameter(_ : String)) (ps.view map { case (i,n) => i -> test(n) }) collect { case (i, true) => i } headOption getOrElse 0
Using scalaz, you can use the map map (ββ) function:
ps.ββ[PartialApply1Of2[Tuple2, Int]#Apply, String, Boolean](test) collect { case (i, true) => i } headOption orZero
As with Scalaz, this is a real shame that scala type inference cannot invoke partially applied type constructors. Then you will have:
(ps ββ test) collect { case (i, true) => i } headOption orZero
source share