Skip to content

examples

pannous edited this page Mar 18, 2024 · 7 revisions

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

«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]

lists

[ 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

types

data can be typed as classes or wit schema.

flags virtues={fast, safe}
virtues angle_goal = fast+safe

data selectors

{a:1 b:2}.b == 2

tree data as first class citizen
{a:1 b:2 c:{d:3 e:4}}.c.d == 3

item selection

lists have a 0 based []index and 1 based #number selector:

x='abcde';x[0] == 'a'
x='abcde';x#4 == 'd'

broadcasting

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

folding (left associative)

sum := fold +
sum 1 2 3 == 6

similarity operator

⅓ ≈ .33333

modules

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)

Home

Philosophy

data & code blocks

features

inventions

evaluation

keywords

iteration

tasks

examples

todo : bad ideas and open questions

⚠️ specification and progress are out of sync

Clone this wiki locally