Hi,

I hope, that somebody can find some use for the following :

Rebol []

rtp: function [
    {A referentially transparent way to invoke paths}
    [catch]
    block [block!]
] [head path stop] [
    path: either stop: find block first [/] [
        copy/part block stop
    ] [
        stop: [none]
        block
    ]
    if not empty? path [
        path: reduce path
        if not word? set/any 'head first path [change/only path 'head]
        if error? path: try [to-path! path] [
            throw make error! {Invalid path representation}
        ]
    ]
    do compose [(:path) (next stop)]
]

to-path!: function [
    [catch]
    path-block [block!]
] [path] [
    path: make path! length? path-block
    foreach element path-block [
        throw-on-error [
            if :element [insert/only tail :path :element]
        ]
    ]
    :path
]

{
    Example:
    
rtp [now 'time 'second]
a: [1 2 3]
rtp [a 1 + 1]
only: false
head rtp ['insert if only ['only] / tail a [4]]
only: true
head rtp ['insert if only ['only] / tail a [4]]

}


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to