+
+ (* Call function g on the top bits, then f on each full byte
+ * (little endian - so start at root).
+ *)
+ let rec map_bytes_le g f v bits =
+ if bits >= 8 then (
+ let lsb = v land ff in
+ f (to_int lsb);
+ map_bytes_le g f (v >> 8) (bits-8)
+ ) else if bits > 0 then (
+ let lsb = v land (mask bits) in
+ g (to_int lsb) bits
+ )