dave@bgtys6.uucp (Dave Hubert) (04/11/91)
Does anyone know how to force symbolic notation on a numerical value? ie. 1: '5' The idea being that I can build a numerical equation from this number... ie. 1: '\v/5' @ square root of 5. I would not mind doing '\v/a' and then substitute the value of a, but I don't know of a way to do this. Maybe MATCH?? ....Never used it before, and there's gotta be a simpler solution. All suggestions are appreciated. I hope this isn't a dumb question... I hate asking dumb things...On the other hand, maybe there's a stupid solution... Thanks in advance, -Dave.
TDSTRONG%MTUS5.BITNET@VM1.NoDak.EDU (Tim Strong) (04/12/91)
> >Does anyone know how to force symbolic notation on a numerical value? > ie. 1: '5' >The idea being that I can build a numerical equation from this number... > ie. 1: '\v/5' @ square root of 5. > >I would not mind doing '\v/a' and then substitute the value of a, but >I don't know of a way to do this. > Maybe MATCH?? ....Never used it before, and there's gotta be a > simpler solution. > >All suggestions are appreciated. I hope this isn't a dumb question... >I hate asking dumb things...On the other hand, maybe there's a stupid >solution... > >Thanks in advance, >-Dave. Here's a possibilty however, since I don't know what you're using this for I'm not sure how well it fits your needs. The SYSEVAL #5B15h takes a string from the stack and returns it as a name. WARNING!!!! this code does not check to see if the string is a valid name. The last time I saw this posting that warning was placed prominently at the begining. However I haven't figured out how an invalid name can be dangerous since even if it is used as a variable name one can just recreate the name again to purge it. Maybe someone can enlighten me. Anyway if you were to place the following code somewhere useful perhaps in the middle of the program you're working on or assign it to a key it should work for you: ...->STR #5B15h SYSEVAL... I hope thats what you needed. The last time I tried to answer a question I found out I didn't really understand what the guy wanted. ====================================================================== ___ I__) _ _I _ _ TIM STRONG <TDSTRONG%MTUS5.BITNET@CUNYVM.EDU> I \ (_I (_I (_I I MICHIGAN TECH. HOUGHTON, MICHIGAN ======================================================================
billw@hpcvra.cv.hp.com. (William C Wickes) (04/12/91)
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
robert@longs.LANCE.ColoState.Edu (04/12/91)
*> Does anyone know how to force symbolic notation on a numerical value? *> ie. 1: '5' *> The idea being that I can build a numerical equation from this number... *> ie. 1: '\v/5' @ square root of 5. *> *> I would not mind doing '\v/a' and then substitute the value of a, but *> I don't know of a way to do this. *> Maybe MATCH?? ....Never used it before, and there's gotta be a *> simpler solution. *> *> All suggestions are appreciated. I hope this isn't a dumb question... *> I hate asking dumb things...On the other hand, maybe there's a stupid *> solution... *> *> Thanks in advance, *> -Dave. There is no such thing as a dumb question. :-) How about doing this in your program: 2: "\v/" 1: "5" + gives: 1: "\v/5" then STR-> to get: 1: 2.2360679775 While this may be slow for what you are doing, I beleive it does what you want it to do. -Robert