-
-
Notifications
You must be signed in to change notification settings - Fork 4
examples
Hello World in Angle is
"Hello World"
The deep formal reason why this is a valid program is that the last object in a block is its return value and the last result in the root block of the main file is printed.
Β«Data is Code and Code is DataΒ»
Everything in Wasp is a node, when it has children it is a list, when the children are of type key it's a map:
1 == [1] β [a:1]
[ 1 2 3 ] == ( 1 2 3 ) == { 1 2 3 } == γ 1 2 3 γ== 1 2 3 β¦
All unicode brackets are parsed as listsγβ¦γγβ¦γγβ¦γγβ¦γ β¦
[ 1 2 3 ] + ( 4 5 ) = 1 2 3 4 5
data can be typed as classes or wit schema.
flags virtues={fast, safe}
virtues angle_goal = fast+safe
{a:1 b:2}.b == 2
tree data as first class citizen
{a:1 b:2 c:{d:3 e:4}}.c.d == 3
lists have a 0 based []index and 1 based #number selector:
x='abcde';x[0] == 'a'
x='abcde';x#4 == 'd'
Functions operating on single elements are automatically applicable to lists
square x:=xΒ²
square 1 2 3 == 1 4 9
Behavior can be refined via overloading
sum := fold +
sum 1 2 3 == 6
β
β .33333
use math sin Ο/2 == 1
Fibonacci in Angle is
fibonacci number = if number<2 : 1 else fibonacci(number - 1) + fibonacci it - 2
for more complete list of examples see syntax
https://github.com/pannous/wasp/tree/master/samples
https://github.com/pannous/wasp/blob/master/source/tests.cpp
https://github.com/pannous/wasp/blob/master/source/test_wasm.cpp
https://github.com/pannous/wasp/blob/master/source/test_angle.cpp
https://github.com/pannous/english-script-samples/tree/master
https://github.com/pannous/angle/tree/master/tests (old python tests)