Changeset 64 for Deliverables/D4.1/Byte.ml
- Timestamp:
- Sep 13, 2010, 12:59:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D4.1/Byte.ml
r63 r64 30 30 val get_bit_at: int -> byte -> bit 31 31 val set_bit_at: int -> bit -> byte -> byte option 32 *) 32 33 33 34 val (-&-): byte -> byte -> byte 34 35 val (-|-): byte -> byte -> byte 35 36 val (-^-): byte -> byte -> byte 37 (* 38 val rotate_right: byte -> byte 39 val rotate_left: byte -> byte 40 val shift_right: byte -> byte 41 val shift_left: byte -> byte 42 *) 36 43 val not: byte -> byte 37 44 45 (* 38 46 val map_nibble: (nibble -> nibble) -> byte -> byte 39 47 val map_bit: (bit -> bit) -> byte -> byte … … 42 50 val zip_nibble: (nibble -> nibble -> nibble) -> byte -> byte -> byte 43 51 val zip_bit: (bit -> bit -> bit) -> byte -> byte -> byte 44 val pretty: byte -> string52 val to_string: byte -> string 45 53 *) 46 54 end 47 55 48 module Byte(Nibble: NIBBLE): BYTE 49 with type bit = Nibble.bit and type nibble = Nibble.nibble = 56 module Byte(Bit: BIT) (Nibble: NIBBLE): BYTE 57 with type Nibble.bit = Bit.bit 58 and type nibble = Nibble.nibble = 50 59 struct 51 type bit = Nibble.bit60 type bit = Bit.bit 52 61 type nibble = Nibble.nibble 53 62 type byte = nibble * nibble 54 63 55 let from_bits b1 b2 b3 b4 b5 b6 b7 b8 = 56 let nibble 64 let (-&-) (l1, l2) (r1, r2) = (Nibble.(-&-) l1 r1, Nibble.(-&-) l2 r2) 65 let (-|-) (l1, l2) (r1, r2) = (Nibble.(-|-) l1 r1, Nibble.(-|-) l2 r2) 66 let (-^-) (l1, l2) (r1, r2) = (Nibble.(-^-) l1 r1, Nibble.(-^-) l2 r2) 67 (* 68 let shift_right (n1, n2) = 69 let (b1, b2, b3, b4) = Nibble.to_bits n1 in 70 let (b5, b6, b7, b8) = Nibble.to_bits n2 in 71 let new_n1 = Nibble.from_bits (Bit.from_bool false) b1 b2 b3 in 72 let new_n2 = Nibble.from_bits b4 b5 b6 b7 in 73 (new_n1, new_n2) 74 let shift_left (n1, n2) = 75 let (b1, b2, b3, b4) = Nibble.to_bits n1 in 76 let (b5, b6, b7, b8) = Nibble.to_bits n2 in 77 let new_n1 = Nibble.from_bits b1 b2 b3 b4 in 78 let new_n2 = Nibble.from_bits b5 b6 b7 (Bit.from_bool false) in 79 (new_n1, new_n2) 80 let rotate_right (n1, n2) = 81 let (b1, b2, b3, b4) = Nibble.to_bits n1 in 82 let (b5, b6, b7, b8) = Nibble.to_bits n2 in 83 let new_n1 = Nibble.from_bits b8 b1 b2 b3 in 84 let new_n2 = Nibble.from_bits b4 b5 b6 b7 in 85 (new_n1, new_n2) 86 let rotate_left (n1, n2) = 87 let (b1, b2, b3, b4) = Nibble.to_bits n1 in 88 let (b5, b6, b7, b8) = Nibble.to_bits n2 in 89 let new_n1 = Nibble.from_bits b2 b3 b4 b5 in 90 let new_n2 = Nibble.from_bits b5 b6 b7 b1 in 91 (new_n1, new_n2) 92 *) 93 let not (n1, n2) = (Nibble.not n1, Nibble.not n2) 57 94 end
Note: See TracChangeset
for help on using the changeset viewer.