I used a "global variable" named tally to handle this tutorial assignment, but I think there must be a way to avoid the use of such a variable in solving this problem. Any help is appreciated:
\ Assignment: Write a definition vsum ( addr u -- n ) that computes the sum of u cells, with the first of these cells at addr, the next one at addr cell+ etc. ( Usage: create vx 2 , 2 , 2 , 2 , 2 , vx 5 vsum ) : loop-range ( number-of-cells -- number-of-cells zero ) 0 ; : get-value-at-address-offset ( address offset -- v ) cells + @ ; : increase-value ( n addr -- v+n ) TUCK @ + SWAP ! ; VARIABLE tally : vsum { address u } u loop-range U+DO address i get-value-at-address-offset tally increase-value LOOP tally @ ;