Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Using a Math oper. buried in a variable

From: henrikmk:g:mail at: 3-Apr-2009 15:49

On Fri, Apr 3, 2009 at 2:58 PM, Wall, Scott <Scott.Wall-xwave.com> wrote:
> Gregg wrote: >> As with most things in REBOL, there are a number of ways to do what >> you want. Here's another one: > ... >>>> op: :* > > I'm now trying to use this form in my program. But I'm having trouble > when it comes to dividing. Here is what I tried doing and how it failed: > >>> op: :/ > ** Syntax Error: Invalid word-get -- : > ** Near: (line 1) op: :/ > > Any ideas on how to get this to work?
It will not work, since / can't be directly converted to a word and used as a get-word. The trick would be to write it first as a string and convert it: get to-get-word "/" That is not very pretty, is it? (But keep it in mind, when you need to convert something unwieldy to a word. :-)) So we can do something else: + - * and / are normally infix operators (2 + 3). In REBOL 2 you can use them as prefix operators (+ 2 3), which would work in the examples, but you can't do this in REBOL 3. Instead, use the named functions ADD, SUBTRACT, MULTIPLY and DIVIDE, so: op: :divide should work for you. -- Regards, Henrik Mikael Kristensen