9b5212cb45
FossilOrigin-Name: 6efdcd9c4a9455a2f908fa727dae442aee8f7c3e5a5d6c4d09f1ad53960d9d89
24 lines
423 B
Forth
24 lines
423 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 n:put nl
|
|
fetch-next n:put nl
|
|
fetch n:put nl
|
|
```
|
|
|