Chapter 7 exercise 7.5

35 views
Skip to first unread message

pn.tru...@gmail.com

unread,
Jul 20, 2017, 1:23:21 PM7/20/17
to scala-functional
Exercise:
```
Hard: Write this function, called sequence . No additional primitives are required. Do not call run .
def sequence[A](ps: List[Par[A]]): Par[List[A]]
```

Is it ok if I do this?

```
def sequence[A](ps: List[Par[A]]): Par[List[A]] = {
ps.reduceLeft((a1, a2) => map2(a1, a2)(List(_, _)))
}
```
If not, what's wrong with that?

Best regards
Phuc

Reply all
Reply to author
Forward
0 new messages