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

[REBOL] Re: Problem with paren

From: joel:neely:fedex at: 2-Feb-2003 0:37

Hi, Patrick, Here's one way... pat665 wrote:
> Hi List, > > I am trying to build a block including some parenthesis and I am > surely missing something. > > values: [ 7 "/" "(" 1 "+" 2 ")"]
...
> Any clue? >
bos2bov: make object! [ myblock: none _run: func [/local result front] [ result: copy [] while [0 < length? myblock] [ front: first myblock remove myblock if front = ")" [return result] append/only result either number? front [ front ][ either front = "(" [ to-paren _run ][ to-word front ] ] ] result ] run: func [b [block!]] [ myblock: copy/deep b _run ] ] ...which behaves as...
>> values: [ 7 "/" "(" 1 "+" 2 ")"]
== [7 "/" "(" 1 "+" 2 ")"]
>> foo: bos2bov/run values
== [7 / (1 + 2)]
>> length? foo
== 3
>> do foo
== 2.33333333333333 Hope this helps! -jn-