Parcourir la source

Test script changes

kindlich il y a 5 ans
Parent
révision
dcebf0edbe
Aucune clé connue n'a été trouvée dans la base pour cette signature

+ 24
- 3
ScriptingExample/scripts/arrays.zs Voir le fichier

@@ -48,7 +48,28 @@ val e = new string[,,]<string>(
48 48
 );
49 49
 
50 50
 
51
-//val a = new string[](5, "HelloWorld");
52
-//val b = new string[]<string>(a, projection);
51
+val aSomeArray = new string[](5, "HelloWorld");
52
+val bSomeArray = new string[]<string>(aSomeArray, projection);
53
+println("HelloWorldProjectedArray");
54
+println(bSomeArray[1]);
55
+
56
+println(e[2,3,4]);
57
+
58
+
59
+val constructorLambdaArray = new string[](5, i => "No" + i);
60
+println(constructorLambdaArray[1]);
61
+
62
+val constructorLambdaArrayMulti = new string[,](5, 5, (i1, i2) => "No" + i1 + i2);
63
+println(constructorLambdaArrayMulti[1, 2]);
64
+
65
+
66
+val testArray = new string[,](5, 5, "helloWorld");
67
+
68
+val indexedProjectionWithLambdaNonInlined = new string[,]<string>(testArray as string[,], (index1, index2, value) => {
69
+    return value + "" + index1 + index2;
70
+} as function(index1 as usize, index2 as usize, value as string`borrow) as string);
71
+
72
+val indexedProjectionWithLambdaInlined = new string[,]<string>(testArray, ((i as usize, j as usize, s as string`borrow) => (s + "" + i + j) as string) as function(i as usize, j as usize, s as string`borrow) as string);
53 73
 
54
-println(e[2,3,4]);
74
+println(indexedProjectionWithLambdaNonInlined[1, 2]);
75
+println(indexedProjectionWithLambdaInlined[1, 2]);

+ 7
- 1
ScriptingExample/scripts/functionalInterfaces.zs Voir le fichier

@@ -8,4 +8,10 @@ val y = (a as int, b as int) => a + b;
8 8
 invokeFunctionalInt(y);
9 9
 
10 10
 
11
-println(((x as int) => x)(10));
11
+println(((x as int) => x)(10));
12
+
13
+//TODO: Globals can't be "captured"
14
+//invokeFunctionalInt((a, b) => {
15
+//	println("a");
16
+//	return a + b;
17
+//});

Loading…
Annuler
Enregistrer