dirty lang supports currying:
$ arr = import("arr")
$ lst = [1 5 3 6 4]
lst : arr.insert(1, 8)
lst
: arr.map(~ (i) i + 10)
: arr.sort()
: arr.each(print)
:
basically treats the left operand as the first argument of the following function call
but you can also do
$ arr = import("arr")
$ lst (arr) = [1 5 3 6 4]
lst : insert(1, 8)
lst
: map(~ (i) i + 10)
: sort()
: each(print)
to declare lst
is* a arr
, and everytime :
will know the left operand is a arr
and can use all its functions
this allows some flexible behavior composition like
$ pos = {
move: ~ () {}
}
$ scale = {
shrink: ~ () {}
}
$ sprite = {
render: ~ () {}
}
$ froggy (pos + scale + sprite) = {
x: 10
y: 30
name: "froggy"
}
froggy
: move(10, 20)
: shrink
: render()