Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let bool_bin = function
- |true -> 1
- |false -> 0
- let rec binList xs ys = match xs with
- |[] -> ys
- |x::xs -> binList xs ((bool_bin x)::ys)
- let rec pow a = function
- | 0 -> 1
- | 1 -> a
- | n ->
- let b = pow a (n / 2) in
- b * b * (if n mod 2 = 0 then 1 else a)
- let rec bin_dec xs ys position= match xs with
- |[] -> ys
- |x::xs when position = 0 -> bin_dec xs (x+ys) (position+1)
- |x::xs when position <> 0 -> bin_dec xs (x* (pow 2 position) 0)+ys) (position+1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement