mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
848ba7303b
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
24 lines
423 B
Text
24 lines
423 B
Text
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
|
|
```
|
|
|