Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Jichao Ouyang edited this page Nov 23, 2016 · 5 revisions

flatMap is simply flatten compose map

imaging when you

  1. map an Array [1,2,3] with function x=>[x], you'll get [[1],[2],[3]]
  2. flatten will flatten the nested array into a flat array [1,2,3]

same thing happen to Stream

  1. map --1--2--3--> with function x=>Stream(x+1) will return --S(1+1)--S(2+1)--S(3+1)-->
  2. 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.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /