-
-
Notifications
You must be signed in to change notification settings - Fork 5
list
{1 2 3} [1 2 3] (1 2 3) all denote a list with 3 elements.
{a:1 b:2 c:3} [a:1 b:2 c:3] (a:1 b:2 c:3) all denote a map with 3 elements.
The fundamental data type of lisp is a list,
The fundamental data type of wasp is a node.
A node can express different forms of data, it contains a list of other nodes, which might be key-value-pairs, naturally forming maps which can be evaluated as blocks.
lists can have different enclosures '()' '[]' '{}' and grouping symbols ',' ';' '\n' '\t' ' ' '|'. Without special context, all combinations of enclosures and groupings are identical denotations for lists:
a={1 2 3}
b=[x,y,z]
c=("u";"v";"w")
d=1,2,3
e=1;2;3
f={
x=1
y=2
z=3
}// functions as lists of statements/expressions separated by '\n' are still a kind of list
As such, cvs and tsv files are valid data in wasp.
Lists with different enclosures and groupings can be nested to form higher order arrays, maps, matrices, tensors etc:
m=(1 2; 3 4)
within curly braces {} all groupings act as column forming!
otherwise ' ' and ',' act as row forming, whilst ';' and '\n' act as column forming!
x=(1 2) y={3 4}
x*y = 11 // 1*3+2*4
All functions automatically consume lists via auto broadcasting:
square:=it*it
square 1 2 3 == 1 4 9
lists have outer operators, inner operators and element wise operators:
x=(1 2)
x x = (1 2; 1 2) // outer concatenation
x + x = (1 2 1 2) // list concatenation
x \+ x = (2 4) // inner addition
x /+ x = (2 3; 3 4) // outer addition
The following is typical data with implicit lists in wasp:
a=1,2,3
m=(1 2 3, 4 5 6)
t=(1 2, 3 4; 5 6, 7 8)
Because space, comma, semicolon and Newline have decreasing binding, they can be used to form arrays, matrices, tensors of three, four or higher dimension.
The fundamental data type of lisp is a list,
The fundamental data type of wasp is a node
which contains a list of other nodes, a value and or a 'next' node which might form key-value-pairs, naturally forming maps which can be evaluated as blocks:
{a b:c d{e f g}}
When space, comma, semicolon or newline are used purely unmixed, their usage is equivalent, all forming the same list:1 2 3 == 1,2,3 == 1;2;3
In context however their semantics vary (as seen above in case of the tensor, or ubiquitously in programming code blocks). Comma and space bind more closely than assignment so that a=1,2,3 can be written without braces.
All functions can be fed with lists because of auto broadcasting: If a method does not have a signature which takes explicit lists, each parameter will get applied individually: square(1,2,3)==1 4 9