[英]Meaning of “==>” syntax in F#
考虑以下F#代码
let rec ordered xs =
match xs with
| [] | [_] -> true
| x1 :: x2 :: xs' -> x1 <= x2 && ordered (x2 :: xs')
接着
let rec insert x xs =
match xs with
| [] -> [x]
| y :: ys -> if x <= y then x :: y :: ys
else y :: insert x ys
最后
let insertKeepsOrder (x : int) xs = ordered xs ==> ordered (insert x xs)
我不明白的是最后一行中的==>
!!!
它是什么?
==>
运算符是FsCheck的一部分。 它用于表示仅在某些条件为true时才应保留的属性。
因此,在您的示例中:
let insertKeepsOrder (x : int) xs = ordered xs ==> ordered (insert x xs)
这意味着仅当ordered xs
为true时, ordered (insert x xs)
应该为true。
您可以在FsCheck文档的“条件属性”部分中了解有关此内容的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.