aboutsummaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'builtins')
-rw-r--r--builtins/bool.c5
-rw-r--r--builtins/bool.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/builtins/bool.c b/builtins/bool.c
index 1e741be1..af2f0ac7 100644
--- a/builtins/bool.c
+++ b/builtins/bool.c
@@ -40,6 +40,11 @@ public Bool_t Bool$from_text(CORD text, bool *success)
}
}
+public Bool_t Bool$random(double p)
+{
+ return (drand48() < p);
+}
+
public const TypeInfo $Bool = {
.size=sizeof(bool),
.align=__alignof__(bool),
diff --git a/builtins/bool.h b/builtins/bool.h
index 356889d1..716ddd5b 100644
--- a/builtins/bool.h
+++ b/builtins/bool.h
@@ -14,6 +14,7 @@
CORD Bool$as_text(const bool *b, bool colorize, const TypeInfo *type);
bool Bool$from_text(CORD text, bool *success);
+Bool_t Bool$random(double p);
extern const TypeInfo $Bool;