Last active
January 17, 2021 06:17
-
-
Save GiuseppeChillemi/93febe44dffd5dfae764b3cd6ad86988 to your computer and use it in GitHub Desktop.
Show how relative paths works on containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Name: "Power Selector" | |
Purpose: "Demostrate the working scenario of relative paths" | |
Notes: { | |
Idea: Giuseppe Chillemi | |
Path operator: Toomas Vooglaid | |
} | |
] | |
;---- Create the new "///" operator | |
path: function [a b][to path! append to block! a to block! b] | |
///: make op! :path | |
;------------ | |
;The list of relative accessors | |
mystruct: [ | |
name: heading/name | |
size: heading/size | |
body: body | |
extra: extra | |
authors: extra/authors | |
] | |
;Now we create 2 contaniers having the same structure | |
; the second one is the previous version of the first one | |
software-list: [ | |
[ | |
heading [name "Red" size 1200] | |
body ["The new merging Full-stack language"] | |
extra [ | |
authors [ | |
"Nenad Rakočević" | |
"Quingtian" | |
"Greg Irvin" | |
"Valdimir Valiliev" | |
"Boleslav Březovský" | |
"Hiiamboris" | |
] | |
] | |
] | |
[ | |
heading [name "Rebol" size 900] | |
body ["The Ancestor of our language"] | |
extra [ | |
authors [ | |
"Carl Sassenrath" | |
] | |
] | |
] | |
[ | |
heading [name "REN-C" size 650] | |
body ["Experimental Rebol derived language" ] | |
extra [ | |
authors [ | |
"Hostile Fork" | |
] | |
] | |
] | |
] | |
software-list-Previous: [ | |
[ | |
heading [name "Red" size 1200] | |
body ["The new merging Full-stack language"] | |
extra [ | |
Authors [ | |
"Nenad Irvin" | |
] | |
] | |
] | |
] | |
; Here we print some elements of the strcuture of the following containers. | |
containers-to-print: [software-list software-list-Previous] | |
;The code loops the containers | |
foreach series containers-to-print [ | |
print ["------- Container name: -------" series] | |
;All the records | |
repeat idx length? get series [ | |
Print [ | |
"Software name:" get series /// idx /// mystruct/name lf | |
"Size is:" get series /// idx /// mystruct/size | |
] | |
;And sub records | |
auth-temp: get series /// idx /// mystruct/authors | |
forall auth-temp [ | |
print [" Author:" first auth-temp] | |
] | |
Print lf | |
] | |
Print lf | |
] | |
;--- Output: ------ | |
comment { | |
------- Container name: ------- software-list | |
Software name: Red | |
Size is: 1200 | |
Author: Nenad Rakočević | |
Author: Quingtian | |
Author: Greg Irvin | |
Author: Valdimir Valiliev | |
Author: Boleslav Březovský | |
Author: Hiiamboris | |
Software name: Rebol | |
Size is: 900 | |
Author: Carl Sassenrath | |
Software name: REN-C | |
Size is: 650 | |
Author: Hostile Fork | |
------- Container name: ------- software-list-Previous | |
Software name: Red | |
Size is: 1200 | |
Author: Nenad Irvin | |
} | |
Ah, sorry, resolve2 doesn't work this way.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:)
Oldes'
resolve
can be restructured in a somewhat similar way toget-path
:And main procedure reformulated as
with similar results: