decision tables Re: Another stab at a "switch/case" construct (new proposal):

Roman Suzi rnd at onego.ru
Sat Mar 30 08:30:46 EST 2002


On Sat, 30 Mar 2002, Gerson Kurz wrote:

>On Sat, 30 Mar 2002 08:33:13 +0300 (MSK), Roman Suzi <rnd at onego.ru>
>wrote:
>
>>However, I'd liked to see a good paradigm for expressing
>>decision tables like this one:
>>
>>F1 F2 F3 R
>>0  0  *  do1
>>0  1  0  do2
>>0  1  1  do3
>>1  *  *  do4
>
>just an idea: subclass dict, implement pattern matching in the lookup
>func?
>
>derived_dict(
>  (0,0,2) : do1,
>  (0,1,0) : do2,
>  (0,1,1) : do3,
>  (1,2,2) : do4
>)
>
>with lookup
>
>d[F1,F2,F3](args)

Well, that is if do1-4 are functions. But if they are just some short
pieces of code? Making them functions will clutter the code...

However, I like the idea, thanks!

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, March 30, 2002 _/ Powered by Linux RedHat 6.2 _/
_/ "Answers: $1 * Correct answers: $5 * Dumb looks: Free! *" _/





More information about the Python-list mailing list