author | Christian Urban <christian.urban@kcl.ac.uk> |
Thu, 13 Jun 2024 13:13:33 +0100 | |
changeset 491 | e2ffe8642f55 |
parent 463 | 0315d9983cd0 |
permissions | -rw-r--r-- |
424 | 1 |
import M4a._ |
391
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
|
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
val f_urban = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None |
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
463 | 6 |
|
7 |
import scala.concurrent._ |
|
8 |
import scala.concurrent.duration._ |
|
9 |
import ExecutionContext.Implicits.global |
|
10 |
import scala.language.postfixOps |
|
11 |
||
12 |
lazy val f = Future { |
|
13 |
||
391
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
assert(first(List((1,0),(2,0),(3,0),(4,0)), f_urban) == Some(List((4,0)))) |
0930e4555b60
added main4 marking
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
assert(first(List((1,0),(2,0),(3,0)), f_urban) == None) |
463 | 16 |
} |
17 |
||
18 |
Await.result(f, 32 second) |
|
19 |