Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created April 23, 2015 19:52
Conditioning bit streams
// get rid of leading Zero's
let rec dropleadingzeros l =
match l with
[] -> []
| (Zero::xs) -> dropleadingzeros xs
| x -> x
// add n leading Zero's
let rec padby n l = if n <= 0 then l else padby (n-1) (Zero::l);;
// pad two lists to the same length
let rec pad (l1, l2) =
let len1 = length l1
let len2 = length l2
if (len1 = len2) then (l1,l2)
else if (len1 < len2) then (padby (len2-len1) l1, l2)
else (l1, padby (len1-len2) l2) ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment