[REBOL] Re: Using a Math oper. buried in a variable
From: mumpsoid:gmx at: 2-Apr-2009 14:33
On Thu, 2 Apr 2009, Izkata wrote:
> On Thu, Apr 2, 2009 at 1:46 PM, Gregg Irwin <gregg-pointillistic.com> wrote
> :
> >
> > Hi Duke,
> >
> > DN> I want to do something like:
> > DN> num1: = 6
> > DN> num2: = 5
> > DN> op: "*"
> > DN> print [num1 op num2]
> >
> > DN> and get 30 as the result. How in the %^-#*& do you do this in REBOL?
> >
> > I addition to Tom's answer, this may help explain word usage:
> >
> > =C2=A0http://www.rebol.com/docs/core23/rebolcore-4.html#section-5.2
> >
> > As with most things in REBOL, there are a number of ways to do what
> > you want. Here's another one:
> >
> >>> num1: 6
> > == 6
> >>> num2: 5
> > == 5
> >>> op: :*
> >>> op num1 num2
> > == 30
> >>> print [op num1 num2]
> > 30
>
> Extra explanation for this one. There's an issue in how the
> interpreter sees op! values (anything with infix notation), so the
> infix use of the op is lost here. That's why it's prefix notation
> inside the print block.
>>
>> num1
== 5
>> num2
== 6
>> op
== *
>> print [op num1 num2]
* 5 6
>>
I can't win today..... Must be something wrong with my interpreter.
--
Duke Normandin
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?