an introduction
Introduce some higher-order functions of List
two code
C:\Users\lenovo>scala
Welcome to Scala2.12.1(JavaHotSpot(TM)64-BitServer VM,Java1.8.0_101).
Typein expressions for evaluation.Ortry:help.
scala> val l =List(1,2,3)
l:List[Int]=List(1,2,3)
scala> l.filter(x=>x%2==1)
res0:List[Int]=List(1,3)
scala>"99 Red Balloons".toList
res1:List[Char]=List(9,9,, R, e, d,, B, a, l, l, o, o, n, s)
scala>"99 Red Balloons".toList.filter(x=>Character.isDigit(x))
res2:List[Char]=List(9,9)
scala>"99 Red Balloons".toList.takeWhile(x=>x!='B')
res3:List[Char]=List(9,9,, R, e, d,)