You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that I wanted to compare two lists of cstructs if they each combined contained the same bytes. It can easily but inefficiently be implemented using Cstruct.equal (Cstruct.concat xs) (Cstruct.concat ys). Implementing it more efficiently is less straight forward.
letcstruct_equalvab=letrec loopab=match a, b with|[], [] -> true|[], _|_, [] -> false|a :: a', b :: b' ->
let l = min (Cstruct.length a) (Cstruct.length b) inletremainderxxs=ifCstruct.length x > l thenCstruct.sub x l (Cstruct.length x - l) :: xs
else
xs
inCstruct.equal (Cstruct.sub a 0 l) (Cstruct.sub b 0 l) &&
loop (remainder a a') (remainder b b')
inCstruct.lenv a =Cstruct.lenv b &&
loop a b
It may be a slippery slope to add more and more *v functions.
The text was updated successfully, but these errors were encountered:
I found that I wanted to compare two lists of cstructs if they each combined contained the same bytes. It can easily but inefficiently be implemented using
Cstruct.equal (Cstruct.concat xs) (Cstruct.concat ys)
. Implementing it more efficiently is less straight forward.It may be a slippery slope to add more and more *v functions.
The text was updated successfully, but these errors were encountered: