Switch.sql 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --sanitizer ignore memory
  2. /* syntax version 1 */
  3. $x = AsList(1,2,3);
  4. $s1 = @@
  5. def f(input):
  6. for x in input:
  7. yield x
  8. @@;
  9. $s2 = @@
  10. class Iter:
  11. def __init__(self, input):
  12. self.input = input
  13. def __next__(self):
  14. return next(self.input)
  15. @@;
  16. $s3 = @@
  17. class CallableIter:
  18. def __init__(self, input):
  19. self.input = input
  20. def __call__(self):
  21. def f(input):
  22. for x in input:
  23. yield x
  24. return f(self.input)
  25. @@;
  26. $s4 = @@
  27. class Iterable:
  28. def __init__(self, input):
  29. self.input = input
  30. def __iter__(self):
  31. return iter(self.input)
  32. @@;
  33. $f1 = Python3::f(Callable<(Stream<Int32>)->Stream<Int32>>, $s1);
  34. $f2 = Python3::Iter(Callable<(Stream<Int32>)->Stream<Int32>>, $s2);
  35. $f3 = Python3::CallableIter(Callable<(Stream<Int32>)->Stream<Int32>>, $s3);
  36. $f4 = Python3::Iterable(Callable<(Stream<Int32>)->Stream<Int32>>, $s4);
  37. $g = ($stream)->{
  38. return $stream;
  39. };
  40. select Yql::Collect($g(Yql::Iterator($x, Yql::DependsOn("A1"))));
  41. select Yql::Collect($f1(Yql::Iterator($x, Yql::DependsOn("A2"))));
  42. select Yql::Collect($f2(Yql::Iterator($x, Yql::DependsOn("A3"))));
  43. select Yql::Collect($f3(Yql::Iterator($x, Yql::DependsOn("A4"))));
  44. select Yql::Collect($f4(Yql::Iterator($x, Yql::DependsOn("A5"))));
  45. select Yql::Collect(Yql::Switch(
  46. Yql::Iterator($x, Yql::DependsOn("B1")),
  47. AsAtom('0'),
  48. AsTuple(AsAtom('0')),
  49. $g));
  50. select Yql::Collect(Yql::Switch(
  51. Yql::Iterator($x, Yql::DependsOn("B2")),
  52. AsAtom('0'),
  53. AsTuple(AsAtom('0')),
  54. $f1));
  55. select Yql::Collect(Yql::Switch(
  56. Yql::Iterator($x, Yql::DependsOn("B3")),
  57. AsAtom('0'),
  58. AsTuple(AsAtom('0')),
  59. $f2));
  60. select Yql::Collect(Yql::Switch(
  61. Yql::Iterator($x, Yql::DependsOn("B4")),
  62. AsAtom('0'),
  63. AsTuple(AsAtom('0')),
  64. $f3));
  65. select Yql::Collect(Yql::Switch(
  66. Yql::Iterator($x, Yql::DependsOn("B5")),
  67. AsAtom('0'),
  68. AsTuple(AsAtom('0')),
  69. $f4));