An opportunity for improvement

Thomas Charles CONWAY conway at cs.mu.oz.au
Tue Jul 22 16:04:46 AEST 1997


Hi.

Consider the following predicate (most clauses deleted for clarity...):
(full source available in ~conway/src/misc/z.m)

:- module z.

:- interface.

:- import_module int, bool.

:- pred bits(bool, bool, bool, bool, bool, bool, bool, bool, int).
:- mode bits(in, in, in, in, in, in, in, in, out) is det.
:- mode bits(out, out, out, out, out, out, out, out, in) is semidet.

:- implementation.

bits( no,  no,  no,  no,  no,  no,  no,  no, 0x00).
bits( no,  no,  no,  no,  no,  no,  no, yes, 0x01).
bits( no,  no,  no,  no,  no,  no, yes,  no, 0x02).
bits( no,  no,  no,  no,  no,  no, yes, yes, 0x03).
bits( no,  no,  no,  no,  no, yes,  no,  no, 0x04).
bits( no,  no,  no,  no,  no, yes,  no, yes, 0x05).
bits( no,  no,  no,  no,  no, yes, yes,  no, 0x06).
....
bits(yes, yes, yes, yes, yes,  no,  no,  no, 0xf8).
bits(yes, yes, yes, yes, yes,  no,  no, yes, 0xf9).
bits(yes, yes, yes, yes, yes,  no, yes,  no, 0xfa).
bits(yes, yes, yes, yes, yes,  no, yes, yes, 0xfb).
bits(yes, yes, yes, yes, yes, yes,  no,  no, 0xfc).
bits(yes, yes, yes, yes, yes, yes,  no, yes, 0xfd).
bits(yes, yes, yes, yes, yes, yes, yes,  no, 0xfe).
bits(yes, yes, yes, yes, yes, yes, yes, yes, 0xff).

Currently, the code we generate for the first mode is a decision tree
where every path has 8 branches.

We could do better....

-- 
ZZ:wq!
^X^C
Thomas Conway               				      conway at cs.mu.oz.au
AD DEUM ET VINUM	  			      Every sword has two edges.



More information about the developers mailing list