Memory layout of a data structure: Difference between revisions

Line 354:
:- interface.
 
:- import_module bitmap, bool, list, string.
 
:- type rs232_pin
Line 367:
; ring_indicator.
 
:- type rs232 == bitmap.
 
:- func rs232_bits = rs232.
Line 377:
:- func rs232_set_bits(rs232, list(rs232_pin)) = rs232.
:- func rs232_clear_bits(rs232, list(rs232_pin)) = rs232.
 
:- func to_string(rs232) = string.
 
:- implementation.
 
:- import_module bitmap.
 
:- type rs232 == bitmap.
 
rs232_bits = rs232_bits(no).
Line 388 ⟶ 394:
rs232_set_bits(A, Pins) = foldl((func(Pin, B) = rs232_set(B, Pin)), Pins, A).
rs232_clear_bits(A, Pins) = foldl((func(Pin, B) = rs232_clear(B, Pin)), Pins, A).
 
to_string(A) = bitmap.to_string(A).
 
:- func to_index(rs232_pin) = bit_index.