Applying logical and to list of boolean values

后端 未结 4 1204
囚心锁ツ
囚心锁ツ 2021-02-05 07:01

Consider the following list of Boolean values in Scala

List(true, false, false, true)

How would you using either foldRight or foldLeft emulate

4条回答
  •  梦毁少年i
    2021-02-05 07:28

    Without initial value as in foldLeft,

    List(true, false, false, true).reduce(_&&_)
    

    Yet this works not for List.empty[Boolean].

提交回复
热议问题