Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created July 19, 2011 02:09
Show Gist options
  • Save davidgrenier/1091168 to your computer and use it in GitHub Desktop.
Save davidgrenier/1091168 to your computer and use it in GitHub Desktop.
toVarint for a would-be implementation of proto-buf in F#
let toVarint v =
let rec loop n s =
match n >>> 7, n &&& 127 with
| (0, c) -> byte c :: s
| (r, c) -> loop r (byte (128 ||| c) :: s)
loop v []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment