;; =================================================== ;; Script: refine.r ;; downloaded from: www.REBOL.org ;; on: 28-Mar-2024 ;; at: 10:22:22.928675 UTC ;; owner: romano [script library member who can update ;; this script] ;; =================================================== ;; =================================================== ;; email address(es) have been munged to protect ;; them from spam harvesters. ;; If you were logged on the email addresses would not ;; be munged ;; =================================================== REBOL [ Title: "Refine" Date: 21-Dec-2001 Version: 0.0.1 File: %refine.r Author: "Romano Paolo Tenca" Purpose: {"Add refinement(s) to a word/path" } Email: %rotenca--libero--it Web: http://web.tiscali.it/anarkick/index.r library: [ level: 'intermediate platform: none type: [tool] domain: none tested-under: none support: none license: none see-also: none ] ] refine: func [ "Add refinement(s) to a word/path" path [lit-word! word! path!] "The word/path to refine" refs [word! lit-word! block!] "The word(s) to add" /only "Add the refinement also if its value is none!" ][ refs: append clear [refs] :refs if not only [ refs: head while [not tail? refs] [ refs: either not all[value? first refs get/any first refs] [ remove refs ][ next refs ] ] ] either not empty? refs [ head insert tail to path! :path refs ][ :path ] ] ;this can be removed if not value? 'my_local_user [ help refine ask "See code for examples. Return to Quit - Esc for Shell " ;examples comment [ x: refine/only 'find 'part print x "abcd" "c" 3 x: refine/only :x 'tail print x "abcd" "c" 3 x: refine/only 'find [part tail] print x "abcd" "c" 3 use [part tail][ tail: none part: true x: refine 'find [part tail] print x "abcd" "c" 3 ] halt ] ]