summaryrefslogtreecommitdiff
path: root/stdlib/listLabels.mli
diff options
context:
space:
mode:
authorCraig Ferguson <me@craigfe.io>2022-10-31 10:40:38 +0000
committerGitHub <noreply@github.com>2022-10-31 11:40:38 +0100
commitfc06c7df6392b1054efbf99217290dc9bc28ec34 (patch)
treee46256bb3c70358596c96b7ac86d4eb624ab2aae /stdlib/listLabels.mli
parentcc3d9cb9bbe594b89e0339c6ef8b1da74a537972 (diff)
downloadocaml-fc06c7df6392b1054efbf99217290dc9bc28ec34.tar.gz
stdlib: add `List.is_empty` (#10464)
As of #10681, the native compiler is able to simplify this pattern-matching to use bitwise operations rather than an explicit branch (as was previously the case) or an integer comparison (as is the case for the implementation using `( = )`). Co-authored-by: David Allsopp <david.allsopp@metastack.com>
Diffstat (limited to 'stdlib/listLabels.mli')
-rw-r--r--stdlib/listLabels.mli6
1 files changed, 6 insertions, 0 deletions
diff --git a/stdlib/listLabels.mli b/stdlib/listLabels.mli
index 832d7de753..5669bf80d4 100644
--- a/stdlib/listLabels.mli
+++ b/stdlib/listLabels.mli
@@ -57,6 +57,12 @@ val compare_length_with : 'a list -> len:int -> int
@since 4.05.0
*)
+val is_empty : 'a list -> bool
+(** [is_empty l] is true if and only if [l] has no elements. It is equivalent to
+ [compare_length_with l 0 = 0].
+ @since 5.1
+ *)
+
val cons : 'a -> 'a list -> 'a list
(** [cons x xs] is [x :: xs]
@since 4.03.0 (4.05.0 in ListLabels)