Re: Decision Tables
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 00:21:20 +0000
"Bartc" <bc@xxxxxxxxxx> writes:
kwikius wrote:<snip>
On Jan 28, 5:20 pm, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
Another way to go about this (when you don't have closures) is to
encode the actions that match into a stack machine. One simple
encoding is as function pointers (invented language):
...
FWIW heres a C++ variant, which seems to work...
Some quite elaborate and advanced ideas have been proposed.
But, if the OP can use an appropriate language then the code given below
will do pretty much what he requested. (This is in my own 'toy' language,
but I doubt this code has anything that Python, Perl etc cannot do. The code
actually works)
The business part is the half-dozen lines of Match(), which I'd imagine
would not be impossible in C, depending on the actual types of the fields
being tested.
It would not be that hard in C (though a little messy) but see below.
/--------------------------------------------------------------------
Type testrec = Record (var firstname, lastname, address, country)
Proc Start=
A := testrec( "John", "Smith", "London", "UK")
B := testrec( "John", "Brown", "Manchester", "UK")
Map := (1,4)
if Match (A,B, Map) then
println A," and ",B, " MATCH on fields ",Map
else
println A," and ",B, " DON'T MATCH on fields ",Map
fi
End
Function Match(A, B, map)=
forall i in map do
if A.[i]<>B.[I] then return 0 fi
end
return 1
End
What you a showing, I think, is a language that can index record
(or structure) members. In the posted C++, this is done by using
pointers to member functions. Both are key to one part of the OP's
problem but neither really gets to the heart of the OP's question --
how to represent (or denote) compound match predicates.
At least, that was what I took out of the posting and was the part I
addressed in my rather lax outline pseudo-code.
--
Ben.
.
- Follow-Ups:
- Re: Decision Tables
- From: Bartc
- Re: Decision Tables
- References:
- Decision Tables
- From: Leslie Sanford
- Re: Decision Tables
- From: Ben Bacarisse
- Re: Decision Tables
- From: kwikius
- Re: Decision Tables
- From: Bartc
- Decision Tables
- Prev by Date: Re: Decision Tables
- Next by Date: What makes a CD-ROM bootable?
- Previous by thread: Re: Decision Tables
- Next by thread: Re: Decision Tables
- Index(es):
Relevant Pages
|