183c5bae38
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
24 lines
424 B
Forth
24 lines
424 B
Forth
This is an example adding two three element vectors.
|
|
|
|
````
|
|
:vadd (v1v2v3-)
|
|
'abc 'cabcabcab reorder
|
|
[ #2 + ] tri@ [ fetch ] bi@ + swap store
|
|
[ n:inc ] tri@ [ fetch ] bi@ + swap store
|
|
[ fetch ] bi@ + swap store ;
|
|
````
|
|
|
|
A test case:
|
|
|
|
````
|
|
'a d:create #1 , #2 , #3 ,
|
|
'b d:create #2 , #3 , #4 ,
|
|
'c d:create #3 allot
|
|
|
|
&a &b &c vadd
|
|
|
|
&c fetch-next putn nl
|
|
fetch-next putn nl
|
|
fetch putn nl
|
|
````
|
|
|