-
-
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)