Skip to content

Commit 6dfbe9d

Browse files
committed
Implement zip (nested/linear)
1 parent 9748f0d commit 6dfbe9d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/run-with-compiler-custom-args/staged-streams_1.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

1313
12
1414

15+
15
16+
1517
15

tests/run-with-compiler-custom-args/staged-streams_1.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ object Test {
228228
Linear(zip_producer(producer1, producer2))
229229

230230
case (Linear(producer1), Nested(producer2, nestf2)) =>
231-
pushLinear(producer1, producer2, nestf2)
231+
pushLinear[A, _, B](producer1, producer2, nestf2)
232232

233-
case (Nested(producer1, nestf1), Linear(producer2)) => ???
233+
case (Nested(producer1, nestf1), Linear(producer2)) =>
234+
mapRaw[(B, A), (A, B)]((t => k => '{ ~k((t._2, t._1)) }), pushLinear[B, _, A](producer2, producer1, nestf1))
234235

235236
case (Nested(producer1, nestf1), Nested(producer2, nestf2)) => ???
236237
}
@@ -376,6 +377,11 @@ object Test {
376377
.zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp })))
377378
.fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b }))
378379

380+
def test9() = Stream
381+
.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ ~d + ~dp }))
382+
.zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ ~a + ~b }), Stream.of('{Array(1, 2, 3)}) )
383+
.fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ ~a + ~b }))
384+
379385
def main(args: Array[String]): Unit = {
380386
println(test1().run)
381387
println
@@ -392,6 +398,8 @@ object Test {
392398
println(test7().run)
393399
println
394400
println(test8().run)
401+
println
402+
println(test9().run)
395403
}
396404
}
397405

0 commit comments

Comments
 (0)