: show20fib cr 20 0 u+do i dup dup . ." : " fibit . ." , " fibrec . cr loop ;
-\ TODO
\ ============================== 3.22 ========================================
+\ Assignment: Can you rewrite any of the definitions you wrote until now in a
+\ better way using the return stack?
+: min ( n1 n2 -- n)
+ 2dup < >r r@ ( n1 n2 v )
+ invert and swap r> and or ;
+
\ ============================== 3.23 ========================================
+\ Assignment: Write a definition sum ( addr u -- n ) that computes the sum of u
+\ cells, with the first of these calls at addr, the next one at addr cell+ etc.
+: sum ( addr u -- n )
+ >r
+ 1 cells - 0 ( addr-4 0)
+ r> 0 ( addr-4 0 u 0 )
+ u+do
+ swap cell+ dup ( 0 addr addr )
+ @ ( 0 addr val )
+ rot ( addr val 0 )
+ + ( addr sum )
+ loop swap drop ;
+
+create v3
+ 5 , 4 , 3 , 2 , 1 ,
+: sumexample v3 5 sum ;