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

[REBOL] Re: Generic Block to Object solution

From: g:santilli:tiscalinet:it at: 8-Dec-2000 11:25

Hello Andrew! On 08-Dic-00, you wrote: AM> Earlier, I wrote: AM>> Deck: make block! divide length? Cards 3 AM>> foreach [Type Value Number] Cards [ AM>> insert tail Deck make object! reduce [ AM>> 'Type: Type AM>> 'Value: Value AM>> 'Number: Number AM>> ] AM>> ] AM> That doesn't work. :-( I should test my code first, before AM> misleading people. What about: foreach [type value number] cards [ insert tail deck make object! compose [ type: (type) value: (value) number: (number) ] ] or: foreach [t v n] cards [ insert tail deck make object! [ type: t value: v number: n ] ] For your Make-Objects: Make-Objects: func [ Table [block!] Prototype! [object!] /local 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 ]
>> print mold Make-Objects Cards Prototype
[ make object! [ Type: 'Gold Value: 0 Number: 2 Something-else: 10 ] make object! [ Type: 'Gold Value: 11 Number: 1 Something-else: 10 ] make object! [ Type: 'Cups Value: 2 Number: 4 Something-else: 10 ]] Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila --