Re: Decision Tables



"Bartc" <bc@xxxxxxxxxx> writes:

kwikius wrote:
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):
<snip>

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.
.



Relevant Pages

  • Re: Macro Question: Paraphrasing
    ... why not use keywords for everything? ... which is the language used by the human reader to map symbols to ... It's the basic building block of the Lisp language. ...
    (comp.lang.lisp)
  • Re: Macro Question: Paraphrasing
    ... why not use keywords for everything? ... that keywords can distort the meaning of a symbol on the surface level, ... which is the language used by the human reader to map symbols to ... language is by convention read right to left. ...
    (comp.lang.lisp)
  • Re: Cheap tricks for map data structure
    ... Is C++ a slow, high-level language? ... So it's not exactly a "map square object" anti-pattern that ... same coordinates for various arrays in the Map class? ... The fast language lets you get away with bad programming practices. ...
    (rec.games.roguelike.development)
  • Re: Decision Tables
    ... encoding is as function pointers: ... void match_and ... if the OP can use an appropriate language then the code given below ... if Match (A,B, Map) then ...
    (comp.programming)
  • Re: [OT] Guess the country.
    ... # Fewer than three in 10 think it important to know the locations of countries in the news and just 14 percent believe speaking another language is a necessary skill. ... # Forty-seven percent could not find the Indian subcontinent on a map of Asia. ... I'm certain the data would be just as frightful. ... It isn't a de facto ignorance, but it is a willful and apathetic ignorance. ...
    (rec.autos.sport.f1)