[REBOL] Re: Path with integers
From: al:bri:xtra at: 13-Dec-2000 6:37
Sascha wrote:
> i wonder if it worked for you,
I didn't try it out, that's why it's got errors. Eventually we (Gabriele and
I) came up with:
[
Rebol []
Cards: [
[Type Value Number]
Gold 0 2
Gold 11 1
Cups 2 4
]
Make-Objects: function [
Table [block!]
Prototype! [object!]
][
Specification Result Object
][
Specification: first Table
Result: make block! to-integer divide length? next Table length?
Specification
foreach :Specification next Table compose/deep [
Object: make Prototype! []
set bind [(Specification)] in Object 'self reduce [(Specification)]
insert tail Result Object
]
Result
]
Prototype: make object! [
f: function [test] [block] [
block: [] ; Don't do this at home!
append block test
probe block
]
Type: lit-word!
Value: integer!
Number: integer!
]
probe Deck: Make-Objects Cards Prototype
halt
]
Which is a generic solution to the problem. Reversing the problem is left as
an exercise for the reader. ;-)
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/