Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: for us beginners? Help Message-ID: <2104.UUL1.3#5129@willett.pgh.pa.us> Date: 13 Dec 90 12:34:41 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 35 Category 2, Topic 5 Message 172 Wed Dec 12, 1990 J.SANFORD1 at 20:32 MST The included code is submitted as if it were a homework assignment; " On one screen or less show a usefull calculation & try to find a happy ballance between 'stack pumping' & 'too many variables'" \ Inflation Calculator : R% 10 */ 5 + 10 / ; (S n1 n2 -- n3) ( rounded percent ) variable amount variable rate : calc cr - 0 do amount @ rate @ R% amount +! loop amount @ . ; : ask cr ." inflation rate ? i.e. 5 rate ! " cr ." amount ? i.e. 100 amount ! " cr ." stack -- date2 date1 i.e. 1990 1940 later first " cr ( the original amount is from earlyer date1 ) ( the result is the inflation adjusted equivalent for date2 ) This is the result of reading "Beginners use too many variables" in FD & then picking up the concept of "excessive stack pumping" I had been trying to put All the numbers on the stack. I couldn't because amount changes in the loop and rate dosen't. The word [ ask ] is a crude way to avoid real numeric input words, which I haven't studied yet. If it isn't obvious, you type ask to remind yourself where to put which numbers. Then type calc. There is 1 cute little bug that I know of. I am putting this here to be picked apart and put back in different ways. One of the amusing features of Forth is that that there are so many ways to do something that never occure to me, yet seem perfectly obvious when someone else shows me. thanks later - jon - *S E******* B*s C C E*S ----- This message came from GEnie via willett through a semi-automated process. Report problems to: dwp@willett.pgh.pa.us or uunet!willett!dwp