moduleFstarList(* Don't use Fstar as module name *)(* If used in type refinements, you must specify return effects, Ex: "Tot".
But always use the most precise type as it possible *)vallength:xs:list'a->Tot(r:int{r>=0})letreclengthxs=matchxswith|[]->0|x::xs->1+lengthxs(* Only two branches in pattern matching are needed. _,[] and [],_
are not neccesary *)valzip:xs:list'a->ys:list'b{lengthxs=lengthys}->Tot(r:list('a*'b){lengthr=lengthxs&&lengthr=lengthys})letreczipxsys=matchxs,yswith|[],[]->[]|x::xs,y::ys->(x,y)::zipxsys
F* Code output:
F# Code Snippet
1
2
3
4
5
6
7
8
9
letreczipxsys=(xs,ys)|>function|[],[]->[]|_____,[]->failwith"xs and ys aren't of same length"|[],_____->failwith"xs and ys aren't of same length"|x::xs,y::ys->(x,y)::zipxsys(* Note: | _____,[ ] | [ ],_____ -> failwith "..." isn't supported *)letr=zip[1..10]['a'..'z']