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

[REBOL] Re: Accessing nested Blocks + search in blocks

From: lmecir:geocities at: 5-Nov-2000 7:06

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]] }