Created
April 23, 2015 19:52
Conditioning bit streams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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