Re: Decision Tables
- From: "Leslie Sanford" <jabberdabber@xxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Jan 2008 06:55:42 -0600
"Ben Bacarisse" <ben.usenet@xxxxxxxxx> wrote in message
<snip>
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):
void match_first_name(rM, cM) { push(rM.FirstName == cM.FirstName); }
void match_last_name(rM, cM) { push(rM.LastName == cM.LastName); }
void match_country(rM, cM) { push(rM.Country == cM.Country); }
void match_and(rM, cM) { push(pop() & pop()); }
void match_or(rM, cM) { push(pop() | pop()); }
void match_not(rM, cM) { push(!pop()); }
Your complex matches then become short NULL terminated arrays for
these:
complex_match[] = { match_contry, match_not, match_first_name,
match_or, NULL };
Very cool. I hadn't thought of using a stack. I'll have to add this to my
bag of tricks. Thanks.
.
- References:
- Decision Tables
- From: Leslie Sanford
- Re: Decision Tables
- From: Ben Bacarisse
- Decision Tables
- Prev by Date: Re: Where do two linked lists merge?
- Next by Date: Re: crossword project works
- Previous by thread: Re: Decision Tables
- Next by thread: Re: Decision Tables
- Index(es):
Relevant Pages
|