Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
17
Task/Enumerations/FreeBASIC/enumerations.freebasic
Normal file
17
Task/Enumerations/FreeBASIC/enumerations.freebasic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Enum Animals
|
||||
Cat
|
||||
Dog
|
||||
Zebra
|
||||
End Enum
|
||||
|
||||
Enum Dogs
|
||||
Bulldog = 1
|
||||
Terrier = 2
|
||||
WolfHound = 4
|
||||
End Enum
|
||||
|
||||
Print Cat, Dog, Zebra
|
||||
Print Bulldog, Terrier, WolfHound
|
||||
Sleep
|
||||
21
Task/Enumerations/FutureBasic/enumerations.futurebasic
Normal file
21
Task/Enumerations/FutureBasic/enumerations.futurebasic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
begin enum 1
|
||||
_apple
|
||||
_banana
|
||||
_cherry
|
||||
end enum
|
||||
|
||||
begin enum
|
||||
_appleExplicit = 10
|
||||
_bananaExplicit = 15
|
||||
_cherryExplicit = 30
|
||||
end enum
|
||||
|
||||
print "_apple ="; _apple
|
||||
print "_banana ="; _banana
|
||||
print "_cherry ="; _cherry
|
||||
print
|
||||
print "_appleExplicit ="; _appleExplicit
|
||||
print "_bananaExplicit ="; _bananaExplicit
|
||||
print "_cherryExplicit ="; _cherryExplicit
|
||||
32
Task/Enumerations/Lingo/enumerations-1.lingo
Normal file
32
Task/Enumerations/Lingo/enumerations-1.lingo
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
-- parent script "Enumeration"
|
||||
|
||||
property ancestor
|
||||
|
||||
on new (me)
|
||||
data = [:]
|
||||
repeat with i = 2 to the paramCount
|
||||
data[param(i)] = i-1
|
||||
end repeat
|
||||
me.ancestor = data
|
||||
return me
|
||||
end
|
||||
|
||||
on setAt (me)
|
||||
-- do nothing
|
||||
end
|
||||
|
||||
on setProp (me)
|
||||
-- do nothing
|
||||
end
|
||||
|
||||
on deleteAt (me)
|
||||
-- do nothing
|
||||
end
|
||||
|
||||
on deleteProp (me)
|
||||
-- do nothing
|
||||
end
|
||||
|
||||
on addProp (me)
|
||||
-- do nothing
|
||||
end
|
||||
34
Task/Enumerations/Lingo/enumerations-2.lingo
Normal file
34
Task/Enumerations/Lingo/enumerations-2.lingo
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
enumeration = script("Enumeration").new("APPLE", "BANANA", "CHERRY")
|
||||
|
||||
put enumeration["BANANA"]
|
||||
-- 2
|
||||
|
||||
-- try to change a value after construction (fails)
|
||||
enumeration["BANANA"] = 666
|
||||
put enumeration["BANANA"]
|
||||
-- 2
|
||||
|
||||
-- try to change a value after construction using setProp (fails)
|
||||
enumeration.setProp("BANANA", 666)
|
||||
put enumeration["BANANA"]
|
||||
-- 2
|
||||
|
||||
-- try to delete a value after construction (fails)
|
||||
enumeration.deleteAt(2)
|
||||
put enumeration["BANANA"]
|
||||
-- 2
|
||||
|
||||
-- try to delete a value after construction using deleteProp (fails)
|
||||
enumeration.deleteProp("BANANA")
|
||||
put enumeration["BANANA"]
|
||||
-- 2
|
||||
|
||||
-- try to add a new value after construction (fails)
|
||||
enumeration["FOO"] = 666
|
||||
put enumeration["FOO"]
|
||||
-- <Void>
|
||||
|
||||
-- try to add a new value after construction using addProp (fails)
|
||||
enumeration.addProp("FOO", 666)
|
||||
put enumeration["FOO"]
|
||||
-- <Void>
|
||||
8
Task/Enumerations/Nim/enumerations.nim
Normal file
8
Task/Enumerations/Nim/enumerations.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
type Fruits = enum Apple, Banana, Cherry
|
||||
|
||||
type Fruits = enum Apple = 0, Banana = 1, Cherry = 2 # with values
|
||||
|
||||
type Fruits {.pure.} = enum Apple, Banana, Cherry # scoped enum
|
||||
var i: int = Apple # error for scoped enum
|
||||
|
||||
type Fruits = enum Apple = "Apple", Banana = "Banana", Cherry = "Cherry" # with string literals
|
||||
1
Task/Enumerations/Oforth/enumerations.oforth
Normal file
1
Task/Enumerations/Oforth/enumerations.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
[ $apple, $banana, $cherry ] const: Fruits
|
||||
2
Task/Enumerations/Phix/enumerations.phix
Normal file
2
Task/Enumerations/Phix/enumerations.phix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
enum apple, banana, orange
|
||||
enum apple=5, banana=10, orange=15
|
||||
6
Task/Enumerations/Ring/enumerations.ring
Normal file
6
Task/Enumerations/Ring/enumerations.ring
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
apple = 0
|
||||
banana = 1
|
||||
cherry = 2
|
||||
see "apple : " + apple + nl
|
||||
see "banana : " + banana + nl
|
||||
see "cherry : " + cherry + nl
|
||||
1
Task/Enumerations/Sidef/enumerations-1.sidef
Normal file
1
Task/Enumerations/Sidef/enumerations-1.sidef
Normal file
|
|
@ -0,0 +1 @@
|
|||
enum {Apple, Banana, Cherry}; # numbered 0 through 2
|
||||
6
Task/Enumerations/Sidef/enumerations-2.sidef
Normal file
6
Task/Enumerations/Sidef/enumerations-2.sidef
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
enum {
|
||||
Apple=3,
|
||||
Banana, # gets the value 4
|
||||
Cherry="a",
|
||||
Orange, # gets the value "b"
|
||||
};
|
||||
16
Task/Enumerations/Swift/enumerations.swift
Normal file
16
Task/Enumerations/Swift/enumerations.swift
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
enum Fruit {
|
||||
case Apple
|
||||
case Banana
|
||||
case Cherry
|
||||
}
|
||||
// or
|
||||
enum Fruit {
|
||||
case Apple, Banana, Cherry
|
||||
}
|
||||
|
||||
enum Season : Int {
|
||||
case Winter = 1
|
||||
case Spring = 2
|
||||
case Summer = 3
|
||||
case Autumn = 4
|
||||
}
|
||||
2
Task/Enumerations/jq/enumerations.jq
Normal file
2
Task/Enumerations/jq/enumerations.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{"fruits" : { "apple" : null, "banana" : null, "cherry" : null }
|
||||
{"fruits" : { "apple" : 0, "banana" : 1, "cherry" : 2 }
|
||||
Loading…
Add table
Add a link
Reference in a new issue