September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,18 @@
' Enumerations
' Start at zero
ENUM
cat, dog, parrot
END ENUM
PRINT "Dogs are #", dog
' Set value
ENUM
Sunday=1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
END ENUM
PRINT Sunday, " ", Wednesday, " ", Saturday
' Change values, ENUM names must be unique
ENUM
sunday=7, monday=1, tuesday, wednesday, thursday, friday, saturday
END ENUM
PRINT sunday, " ", wednesday, " ", saturday

View file

@ -1,2 +1,7 @@
var fruits = { APPLE : 0, BANANA : 1, CHERRY : 2 };
Object.freeze(fruits);
// enum fruits { apple, banana, cherry }
var f = "apple";
if(f == "apple"){
f = "banana";
}

View file

@ -0,0 +1 @@
@enum Fruits APPLE BANANA CHERRY

View file

@ -0,0 +1,15 @@
// version 1.0.5-2
enum class Animals {
CAT, DOG, ZEBRA
}
enum class Dogs(val id: Int) {
BULLDOG(1), TERRIER(2), WOLFHOUND(4)
}
fun main(args: Array<String>) {
for (value in Animals.values()) println("${value.name.padEnd(5)} : ${value.ordinal}")
println()
for (value in Dogs.values()) println("${value.name.padEnd(9)} : ${value.id}")
}

View file

@ -0,0 +1,19 @@
;This starts the enumeration of a named group 'NamedGroup'.
Enumeration NamedGroup 5
#Green ; 5
#Orange ; 6
EndEnumeration
;EnumerationBinary will use values that are a double of the previous value (or starting value).
EnumerationBinary
#North ; 1
#West ; 2
#South ; 4
#East ; 8
EndEnumeration
;This continues the enumeration of the previously named group 'NamedGroup'.
Enumeration NamedGroup
#Yellow ; 7
#Red ; 8
EndEnumeration

View file

@ -0,0 +1,6 @@
const RGB_COLOR{ // put color names in a name space
const RED =0xf00;
const BLUE=0x0f0, GREEN = 0x00f;
const CYAN=BLUE + GREEN; // → 0x0ff
}
println(RGB_COLOR.BLUE);

View file

@ -0,0 +1,4 @@
const X0=N; // --> 0
const A=N,B=N,C=N; // --> 1,2,3
const{ _n=-1; } // reset Enum, this should be a const space function
const X=N; // -->0

View file

@ -0,0 +1,3 @@
#continuing ...
z:=N; // -->2 NOT 1 as it is set AFTER Y (compile time vs parse time)
const Y=N; // -->1! because it is set before z

View file

@ -1,2 +0,0 @@
{"fruits" : { "apple" : null, "banana" : null, "cherry" : null }
{"fruits" : { "apple" : 0, "banana" : 1, "cherry" : 2 }