112 lines
1.8 KiB
Plaintext
112 lines
1.8 KiB
Plaintext
y = -1 + 2 * 3 / 4 * 5 - 6 + 7 multiply-by:2.
|
|
z = w = 2 + 3 multiply-by:2.
|
|
x = (((1 + 2 * 3) multiply-by:3) add: 5) + 2.
|
|
x = ((1 + 2 * 3) multiply-by:3).
|
|
p = 5 multiply(by:3, add:(2 + 1)).
|
|
q = 10 squared squared.
|
|
|
|
p1
|
|
set-age:2 squared squared + 4 squared multiply(by:2, add:4 + 1 * 3)
|
|
in:"mon" + "ths".
|
|
|
|
m = xz multiply(by:3 add:2) squared.
|
|
|
|
m = xz multiply(by:3 add:2); squared.
|
|
|
|
x = Ordered-Collection new
|
|
add: 2;
|
|
add: 4;
|
|
add: 6;
|
|
yourself.
|
|
|
|
age = Person new(name:"John Doe", age:34)
|
|
set-age:144 in-unit:"months";
|
|
age-in-months.
|
|
|
|
x = 5.
|
|
q = 10 if x > 2 else 20.
|
|
q = if x > 2 then 10 else 20 end.
|
|
|
|
cout put:5 multiply(by:5, add:2) if x > 2.
|
|
|
|
if x > 2 then
|
|
cout put:"Greater"
|
|
else
|
|
cout put:"Less"
|
|
end
|
|
|
|
q = match yz in
|
|
1 => age = age,
|
|
2 => age = age / 12,
|
|
3 => age = age / 365,
|
|
_ => age = 0
|
|
end.
|
|
|
|
while x > 2 do
|
|
cout put:"message"
|
|
end
|
|
|
|
for i in 0 to:100 step:2 do
|
|
cout put:'Count is {i}'
|
|
end
|
|
|
|
cout put:"message" while x > 2.
|
|
cout put:'Count is {i}' for i in 0 to:100 step:2.
|
|
|
|
z = do
|
|
x = 1.
|
|
y = 2.
|
|
^x + y
|
|
end.
|
|
|
|
j = [ cout put:'Hello!' ].
|
|
k = [ :x :y | cout put:'Hello, {x}, {y}!' ].
|
|
|
|
x > 2
|
|
if:[ cout put:'True' ]
|
|
else:[ cout put: 'False' ].
|
|
|
|
0 to:100 step:2 do:[ :i | cout put:'Count: {i}' ].
|
|
|
|
p1 test(param:'Hello' :'World').
|
|
|
|
pkg = {}.
|
|
pkg = { 0 }.
|
|
pkg = { 1, 2, 3, 4, 5 }.
|
|
pkg = { 10, 2 => "Hello", 9, 5 => "World", 14 }.
|
|
pkg = { { 0 }, { 1 }, { y for y in huh } }.
|
|
|
|
pkg = { x multiply-by:2 for x in wow if x > 2 }.
|
|
|
|
pkg->x = 32.
|
|
k = (1 multiply-by:2, 4).
|
|
|
|
for (x, y) in pkg do
|
|
cout put:'{x}: {y}'
|
|
end
|
|
|
|
pkg[0] = 16.
|
|
|
|
/* All of these accesses are equivalent */
|
|
pkg['x'] = 32.
|
|
pkg->x = 32.
|
|
pkg at:'x' put:32.
|
|
|
|
v = pkg['x'].
|
|
v = pkg->x.
|
|
v = pkg at:'x'.
|
|
|
|
pkg2 = {
|
|
on-enter => [
|
|
cout put:'start!'
|
|
],
|
|
|
|
on-exit => [
|
|
cout put:'end!'
|
|
]
|
|
}.
|
|
|
|
index = 'x'.
|
|
pkg[index] = 32.
|
|
pkg at:index put:32
|