Anonymous user
Four bit adder: Difference between revisions
→{{header|OCaml}}
(Improved D code) |
|||
Line 1,603:
let n = Array.length v in
let w = Array.make (n*nbits) false in
Array.iteri (fun i x ->
Array.blit (bits_of_int nbits
w;;
Line 1,612:
let r = nv mod nbits and n = nv/nbits in
if r <> 0 then failwith "bad output size" else
▲ w.(i) <- int_of_bits nbits (Array.sub v (i*nbits) nbits)
▲ w;;
(* We have a type for blocks, so we need operations on blocks.
Line 1,656 ⟶ 1,654:
map: map n input lines on length(v) output lines, using the links out(k)=v(in(k))
pass: n wires not connected (out(k) = in(k))
fork: a wire is
perm: permutation of wires
forget: n wires going nowhere
|