Created
February 18, 2023 00:48
-
-
Save Ichoran/632597c5792d86d2697b3b540f480290 to your computer and use it in GitHub Desktop.
Early return converted to break
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Simple { | |
import scala.util.boundary | |
import kse.flow.{given, _} | |
def exists[T](xs: Iterable[T], fn: T => Boolean) = | |
boundary: | |
iFor(xs.iterator): (x, _) => | |
if fn(x) then boundary.break(true) | |
false | |
} | |
/* | |
public <T> boolean exists(scala.collection.Iterable<T>, scala.Function1<T, java.lang.Object>); | |
Code: | |
0: aload_1 | |
1: invokeinterface #22, 1 // InterfaceMethod scala/collection/Iterable.iterator:()Lscala/collection/Iterator; | |
6: astore_3 | |
7: iconst_0 | |
8: istore 4 | |
10: aload_3 | |
11: invokeinterface #28, 1 // InterfaceMethod scala/collection/Iterator.hasNext:()Z | |
16: ifeq 53 | |
19: aload_3 | |
20: invokeinterface #32, 1 // InterfaceMethod scala/collection/Iterator.next:()Ljava/lang/Object; | |
25: astore 5 | |
27: iload 4 | |
29: istore 6 | |
31: aload_2 | |
32: aload 5 | |
34: invokeinterface #38, 2 // InterfaceMethod scala/Function1.apply:(Ljava/lang/Object;)Ljava/lang/Object; | |
39: invokestatic #44 // Method scala/runtime/BoxesRunTime.unboxToBoolean:(Ljava/lang/Object;)Z | |
42: ifeq 47 | |
45: iconst_1 | |
46: ireturn | |
47: iinc 4, 1 | |
50: goto 10 | |
53: iconst_0 | |
54: ireturn | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment