Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hp-pcd!hpcvra.cv.hp.com!billw From: billw@hpcvra.cv.hp.com. (William C Wickes) Newsgroups: comp.sys.handhelds Subject: Re: progamming question Message-ID: <25590133@hpcvra.cv.hp.com.> Date: 11 Apr 91 23:13:31 GMT References: <1991Apr10.191353.18942@bigsur.uucp> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 20 Given x and F on the stack, where x is any argument, and F is a function of one argument (user-defined or built-in), the following program returns 'F(x)': %%HP: T(3)A(R)F(.); @ x F -> 'F(x)' \<< SWAP -> a \<< 'a' SWAP EVAL @ 'F(a)' 'a' a 2 \->LIST \|^MATCH DROP @ 'F(x)' \>> \>> To put a built-in function F on the stack, execute { F } 1 GET. You can also build this logic into the program above, and use { F } as the argument. For user-defined functions, you also can use SWAP 1 \->LIST SWAP APPLY. Bill Wickes HP Corvallis