home *** CD-ROM | disk | FTP | other *** search
- \ Balraj Sidhu Set: 14D4
- \ Comp 462 - Forth
- \ Date: April 16, 1990
- \ Problem 4.17
-
-
- create data 20 allot
-
-
- \ leaves the number of non zero items k in the array data on the stack.
- : count-data ( -- k )
- 0 20 0 do i data + c@
- if 1+
- then loop ;
-
- \ sums the non zero data values
- : sum-data ( -- sum )
- 0 20 0 do i data + c@ + loop ;
-
- \ prints the average of the non 0 values.
- : average-data ( -- )
- cr ." The average is: " sum-data count-data / . cr ;
-
-
-