Hi Ladislav,

This looks really useful.

A more general use of the behaviour than that of my posts.

But two things.

The name. Why not something more accessible like invoke-path, do-path or
whatever?

Can you explain why the emphasis on referential transparency? Or put another
way, what is a non-referentially transparent way to invoke paths and how
does that differ from your functions?


Brett.

----- Original Message -----
From: "Ladislav Mecir" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 05, 2000 5:06 PM
Subject: [REBOL] Re: Accessing nested Blocks + search in blocks


> 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.
>

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

Reply via email to