[REBOL] A BUILD dialect
From: lmecir::mbox::vol::cz at: 7-Apr-2003 7:47
Hi all,
comment [
; COMPOSE isn't very comfortable
; Example:
; having
a: [block a]
; to obtain something like
[[[block a] (f: fail) | (f: none)] f]
; we have to write the following description
; for COMPOSE:
probe compose/deep [
[
(reduce [a]) ([(f: fail) | (f: none)])
] f
]
; Example written using BUILD
probe build [
[
only a (f: fail) | (f: none)
] f
]
]
build: function [
{Builds a block. More comfortable, than COMPOSE}
block [block! paren!]
] [result value position] [
result: make block length? :block
parse block [
any [
'insert position: (
set/any [value position] do/next position
insert tail result get/any 'value
) :position |
'only position: (
set/any [value position] do/next position
insert/only tail result get/any 'value
) :position |
set value block! (
insert/only tail result build :value
) |
set value paren! (
insert/only tail result build :value
) |
set value skip (
insert/only tail result get/any 'value
)
]
]
result
]
Regards
-Ladislav