langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,4 @@
type fruit =
| Apple
| Banana
| Cherry

View file

@ -0,0 +1,11 @@
enum Color := -3 {
Red,
White,
Blue
}
enum Dog {
Pug,
Boxer,
Terrier
}

View file

@ -0,0 +1,6 @@
declare
fun {IsFruit A}
{Member A [apple banana cherry]}
end
in
{Show {IsFruit banana}}

View file

@ -0,0 +1,4 @@
declare
Apple = 1
Banana = 2
Cherry = 3

View file

@ -0,0 +1,8 @@
declare
proc {Enumeration Xs}
Xs = {List.number 1 {Length Xs} 1}
end
[Apple Banana Cherry] = {Enumeration}
in
{Show Cherry}

View file

@ -0,0 +1,3 @@
define ordinal animal (frog, gnu, elephant, snake);
define ordinal color (red value (1), green value (3), blue value (5));

View file

@ -0,0 +1,8 @@
enum Fruit <Apple Banana Cherry>; # Numbered 0 through 2.
enum ClassicalElement (
Earth => 5,
'Air', # Gets the value 6.
Fire => 'hot',
Water => 'wet'
);

View file

@ -0,0 +1,5 @@
Enumeration
#Apple
#Banana
#Cherry
EndEnumeration

View file

@ -0,0 +1,7 @@
Enumeration 10200 Step 12
#Constant1 ; 10200
#Constant2 ; 10212
#Constant3 ; 10224
#Constant4 = 10117 ; 10117
#Constant5 ; 10229
EndEnumeration

View file

@ -0,0 +1,4 @@
Enumeration #PB_Compiler_EnumerationValue
#Constant_A ; 10241
#Constant_B ; 10242
EndEnumeration

View file

@ -0,0 +1 @@
{ 'apple' 0 'banana' 1 'cherry' 2 } as fruits

View file

@ -0,0 +1,6 @@
needs enum'
( Creating a series of values )
0 ^enum'enum| a b c d |
( Create values individually )
0 ^enum'enum a ^enum'enum b

View file

@ -0,0 +1,3 @@
with enum'
[ 10 * ] is step
0 ^enum'enum| a b c d |

View file

@ -0,0 +1,3 @@
const type: fruits is new enum
apple, banana, cherry
end enum;

View file

@ -0,0 +1,4 @@
define: #Fruit &parents: {Cloneable}.
Fruit traits define: #Apple -> Fruit clone.
Fruit traits define: #Banana -> Fruit clone.
Fruit traits define: #Cherry -> Fruit clone.

View file

@ -0,0 +1,3 @@
define: #Apple -> 1.
define: #Banana -> 2.
define: #Cherry -> 3.

View file

@ -0,0 +1 @@
ensureNamespace: #fruit &slots: {#Apple -> 1. #Banana -> 2. #Cherry -> 3}.

View file

@ -0,0 +1 @@
define: #fruit &builder: [{#Apple -> 1. #Banana -> 2. #Cherry -> 3} as: Dictionary].

View file

@ -0,0 +1,4 @@
datatype fruit =
Apple
| Banana
| Cherry

View file

@ -0,0 +1,3 @@
needs enum
0 enum| apple banana carrot |
10 enum| foo bar baz |

View file

@ -0,0 +1,23 @@
'this enumerates from 0
Enum fruits
apple
banana
cherry
End Enum
'here we use our own enumeration
Enum fruits2
pear = 5
mango = 10
kiwi = 20
pineapple = 20
End Enum
Sub test()
Dim f As fruits
f = apple
Debug.Print "apple equals "; f
Debug.Print "kiwi equals "; kiwi
Debug.Print "cherry plus kiwi plus pineapple equals "; cherry + kiwi + pineapple
End Sub

View file

@ -0,0 +1,13 @@
' Is this valid?!
Enum fruits
apple
banana
cherry
End Enum
' This is correct
Enum fruits
apple = 0
banana = 1
cherry = 2
End Enum

View file

@ -0,0 +1,2 @@
def \Fruit\ Apple, Banana, Cherry; \Apple=0, Banana=1, Cherry=2
def Apple=1, Banana=2, Cherry=4;