-
Notifications
You must be signed in to change notification settings - Fork 25
flatMap
Jichao Ouyang edited this page Nov 23, 2016
·
5 revisions
flatMap is simply flatten
compose map
imaging when you
- map an Array
[1,2,3]
with functionx=>[x]
, you'll get[[1],[2],[3]]
-
flatten
will flatten the nested array into a flat array[1,2,3]
same thing happen to Stream
- map
--1--2--3-->
with functionx=>Stream(x+1)
will return--S(1+1)--S(2+1)--S(3+1)-->
- so if
S(1+1)
represent as--2-->
,flatten
will flatten the nested Stream into flat Stream----2----3----4-->
ref to Notation if these symbols make no sense to you.