Al Dente examples

Examples of Al Dente code.

Value conditional example
BitStream {  zero; one; BitStream tail; zero excludes one; tail.zero or tail.one requires zero or one; }

BitStreamConditional {  pickFirst; pickSecond; BitStream inputFirst; BitStream inputSecond; BitStream output; BitStreamConditional tail; pickFirst excludes pickSecond; output.zero requires pickFirst and inputFirst.zero or pickSecond and inputSecond.zero; output.one requires pickFirst and inputFirst.one or pickSecond and inputSecond.one; tail.pickFirst requires pickFirst; tail.pickSecond requires pickSecond; tail.inputFirst matches inputFirst.tail; tail.inputSecond matches inputSecond.tail; tail.output matches output.tail; }

These classes demonstrate how a choice can be made between two s. Another class can state that a     each of the two input streams of a , and also set one or the other (but not both) of   and. The values of  and   will cascade down the   via the   chains. The elements of the input streams will be immediately mirrored into the. The appropriate events will then be copied into  and mirrored in the output stream.

Natural numbers and arithmetic
Number { zero; succ; Number tail; zero excludes succ; tail.zero or tail.succ requires succ; } Copier { copy; Number in; Number out; Copier copier; copy requires ((in.zero and out.zero) or (in.succ and out.succ)); copier.in matches in.tail; copier.out matches out.tail; copier.copy requires copy; copy requires copier.copy or in.zero; } Add { Number in1; Number in2; Number out; Copier copier; Copier in2copier; Copier outcopier; Add next; copier.copy matches in1.zero; copier.in matches in2; copier.out matches out; outcopier.copy matches in1.succ; outcopier.in matches next.out; outcopier.out matches out; next.in1 matches in1.tail; in2copier.copy matches in1.succ; in2copier.in matches in2; in2copier.out matches next.in2.tail; }

There you have it.

Hopefully multiplication won't be too complicated.