[REBOL] Implementing the associative model of data (tm) in Rebol
From: al:bri:xtra at: 29-Jan-2002 18:58
So I had a look at the white paper and implemented the flight example in
Rebol. Here's the contents of %Flight.r:
Flight BA1234
London Heathrow
12/Aug/98
10:25
arrived at
on
at
[1 5 2]
[8 6 3]
[9 7 4]
Concorde
[10 6 11]
Basically a block of Rebol values; string!, date!, time! and block!. The
associations are the three integers in blocks at the end. Then I wrote this
to join up the associations:
Database: load %Flight.r
SVO: function [Database [block!] Item] [Subject Verb Object] [
either block? Item [
Subject: Item/1
Verb: Item/2
Object: Item/3
Subject: SVO Database Database/:Subject
Verb: SVO Database Database/:Verb
Object: SVO Database Database/:Object
reduce [Subject Verb Object]
] [
Item
]
]
foreach Item Database [
print SVO Database Item
]
And running the above script gives the output:
Flight BA1234
London Heathrow
12-Aug-1998
10:25
arrived at
on
at
Flight BA1234 arrived at London Heathrow
Flight BA1234 arrived at London Heathrow on 12-Aug-1998
Flight BA1234 arrived at London Heathrow on 12-Aug-1998 at 10:25
Concorde
Flight BA1234 arrived at London Heathrow on 12-Aug-1998 at 10:25 on Concorde
>>
Note that I've added the "on Concorde" part to the example.
I'll think I'll work up some more magic stuff and thread my HTML dialect
through it, so I can create sentences (SVOs) through a browser
interactively.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/