55
66import scala .runtime .*;
77import static scala .runtime .test .TestAPI .*;
8+ import static scala .runtime .F .func ;
9+ import static scala .runtime .F .proc ;
810
911public class Test {
1012 public static void main (String [] args ) {
@@ -40,13 +42,13 @@ public static void main(String[] args) {
4042 scala .Function1 <String , String > f2 = f1 ;
4143
4244 // Factory methods in `F` can reduce the verbosity a little:
43- // `f1 ` is actually just an identity method; it only exists to
45+ // `func ` is actually just an identity method; it only exists to
4446 // trigger lambda creation using the `F1` functional interface.
45- scala .Function1 <String , String > f3 = F . f1 ((String s ) -> s );
47+ scala .Function1 <String , String > f3 = func ((String s ) -> s );
4648
4749 // Note that javac's type inference can infer the parameter type here,
4850 // based on the acribed type of `f4`.
49- scala .Function1 <String , String > f4 = F . f1 (s -> s );
51+ scala .Function1 <String , String > f4 = func (s -> s );
5052
5153 // f1.apply("");
5254
@@ -58,37 +60,37 @@ public static void main(String[] args) {
5860
5961 // as are `curried`, `tupled`, `compose`, `andThen`.
6062 f3 .compose (f3 ).andThen (f3 ).apply ("" );
61- scala .Function2 <String , String , String > f6 = F . f2 ((s1 , s2 ) -> join (s1 , s2 ));
63+ scala .Function2 <String , String , String > f6 = func ((s1 , s2 ) -> join (s1 , s2 ));
6264 assert (f6 .curried ().apply ("1" ).apply ("2" ) == "12" );
6365
6466 // Functions returning unit must use the `P1`, ... functional interfaces
6567 // in order to convert a void lamdba return to Scala's Unit.
6668 //
67- // The easiest way to do this is via `F.p1 `, ....
69+ // The easiest way to do this is via `F.proc `, ....
6870 //
6971 // Note that the lambda has a return type of `void` if the last
7072 // statement is a call to a `void` returning method, or if it is
7173 // a `return`.
72- scala .Function1 <String , BoxedUnit > f7 = F . p1 (s -> sideEffect ());
73- scala .Function1 <String , BoxedUnit > f8 = F . p1 (s -> {s .toUpperCase (); return ;});
74+ scala .Function1 <String , BoxedUnit > f7 = proc (s -> sideEffect ());
75+ scala .Function1 <String , BoxedUnit > f8 = proc (s -> {s .toUpperCase (); return ;});
7476
7577 // Function0 is also available
7678 scala .Function0 <String > f9 = F .f0 (() -> "42" );
7779 assert (f9 .apply () == "42" );
7880
7981 // You can go up to 22 (the highest arity function defined in the Scala standard library.)
80- assert (acceptFunction1 (F . f1 (v1 -> v1 .toUpperCase ())) == "1" );
81- acceptFunction1Unit (F . p1 (v1 -> sideEffect ()));
82- acceptFunction1Unit (F . p1 (v1 -> {v1 .toUpperCase (); return ;}));
82+ assert (acceptFunction1 (func (v1 -> v1 .toUpperCase ())) == "1" );
83+ acceptFunction1Unit (proc (v1 -> sideEffect ()));
84+ acceptFunction1Unit (proc (v1 -> {v1 .toUpperCase (); return ;}));
8385
84- assert (acceptFunction2 (F . f2 ((v1 , v2 ) -> join (v1 , v2 ))) == "12" );
85- acceptFunction2Unit (F . p2 ((v1 , v2 ) -> {v1 .toUpperCase (); return ;}));
86+ assert (acceptFunction2 (func ((v1 , v2 ) -> join (v1 , v2 ))) == "12" );
87+ acceptFunction2Unit (proc ((v1 , v2 ) -> {v1 .toUpperCase (); return ;}));
8688
87- assert (acceptFunction3 (F . f3 ((v1 , v2 , v3 ) -> join (v1 , v2 , v3 ))) == "123" );
88- acceptFunction3Unit (F . p3 ((v1 , v2 , v3 ) -> {v1 .toUpperCase (); return ;}));
89+ assert (acceptFunction3 (func ((v1 , v2 , v3 ) -> join (v1 , v2 , v3 ))) == "123" );
90+ acceptFunction3Unit (proc ((v1 , v2 , v3 ) -> {v1 .toUpperCase (); return ;}));
8991
90- assert (acceptFunction22 (F . f22 ((v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ) -> join (v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ))) == "12345678910111213141516171819202122" );
91- acceptFunction22Unit ( F . p22 ((v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ) -> {v1 .toUpperCase (); return ;}));
92+ assert (acceptFunction22 (func ((v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ) -> join (v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ))) == "12345678910111213141516171819202122" );
93+ acceptFunction22Unit ( proc ((v1 , v2 , v3 , v4 , v5 , v6 , v7 , v8 , v9 , v10 , v11 , v12 , v13 , v14 , v15 , v16 , v17 , v18 , v19 , v20 , v21 , v22 ) -> {v1 .toUpperCase (); return ;}));
9294 }
9395
9496 private static void sideEffect () {
0 commit comments