Ignore:
Timestamp:
Sep 16, 2010, 3:31:33 PM (11 years ago)
Author:
mulligan
Message:

Lots of work done on tidying up code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/Byte.ml

    r67 r83  
    44(*              operations on them.                                          *)
    55(* CREATED:     10/09/2010, Dominic Mulligan                                 *)
    6 (* BUGS:                                                                     *)
     6(* BUGS:        `from_int' not yet implemented.                              *)
    77(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
    88
     
    2020  val from_nibbles: nibble -> nibble -> byte
    2121  val from_nibble: nibble -> byte
    22 (*
    23   val from_int: int -> byte
    24 *)
     22  (* val from_int: int -> byte *)
     23
    2524  val to_bit: byte -> bit option
    2625  val to_nibble: byte -> nibble option
     
    4847  val zip_bit: (bit -> bit -> bit) -> byte -> byte -> byte
    4948  val to_string: byte -> string
     49
     50  val zero: byte
     51  val half_add: byte -> byte -> (byte * bit)
     52  val full_add: (byte * bit) -> byte -> (byte * bit)
    5053end
    5154
     
    7477                              (Bit.from_bool false) (Bit.from_bool false) in
    7578      (n1, n2)
     79  (* let from_int = assert false                                 DPM: finish! *)
    7680
    7781  let get_nibble_at index (n1, n2) =
     
    197201      (new_n1, new_n2)
    198202  let to_string = iter_nibble Nibble.to_string
     203
     204  let zero = (Nibble.zero, Nibble.zero)
     205  let half_add (l1, l2) (r1, r2) =
     206    let (a2, c2) = Nibble.half_add l2 r2 in
     207    let (a1, c1) = Nibble.full_add (l1, c2) r2 in
     208      ((a1, a2), c1)
     209  let full_add ((l1, l2), c) (r1, r2) =
     210    let (a2, c2) = Nibble.full_add (l2, c) r2 in
     211    let (a1, c1) = Nibble.full_add (l1, c2) r2 in
     212      ((a1, a2), c1)
    199213end;;
    200214
Note: See TracChangeset for help on using the changeset viewer.