From: Nicolas C. <war...@fr...> - 2004-04-09 12:25:48
|
> Hi list, > > Here's another IO update : > - added "pos_in" and "pos_out" that enable to know the current > reading/writing pos. > - the return of the pipe() function - this time working correctly. > > Regards > Nicolas Cannasse Just added to IO : val input_bits : (char,'a) input -> (bool,int) input val output_bits : (char,'a,'b) output -> (bool,(int * int),'b) output This enables you to read/write on bits-packed channels : let data = "....." in let i = IO.input_bits (IO.input_string data) in let b = IO.read i in (* read one bit as boolean *) let n = IO.nread i 7 in (* read the 7 other bits as a int value *= ... let o = IO.output_bits (IO.output_channel ch) in IO.write o true; IO.write o false; IO.nwrite o (6,63); (* write 63 as a 6-bits integer *) IO.nwrite o (3,0); (* write 3 bits *) IO.flush o; (* flush the current accumulator : this will pad current unwritten bits with 0's *) Regards, Nicolas Cannasse |