FP in Niue

Started adding Backus' FP primitives to Niue. Progress is slow, sleep is overtaking me :–). A stack language is an apt vehicle for FP as you get function composition and implicit argument passing for free. Here is the famous inner-product example in Niue:

[ transpose '* apply-to-all '+ reduce ] 'inner-product ;

1 2 3 6 5 4 inner-product .
=> 28

This is how the call to inner-product got expanded:

1 2 3 6 5 4
transpose ( => 1 6 2 5 3 4 )
'* apply-to-all ( => (1 * 6) (2 * 5) (3 * 4) => 6 10 12 )
'+ reduce ( => (6 + 10 + 12) => 28 )

An interesting “language implementation exercise”!