summaryrefslogtreecommitdiff
path: root/random_choice.pl
diff options
context:
space:
mode:
Diffstat (limited to 'random_choice.pl')
-rw-r--r--random_choice.pl4
1 files changed, 4 insertions, 0 deletions
diff --git a/random_choice.pl b/random_choice.pl
new file mode 100644
index 0000000..3a2dfe3
--- /dev/null
+++ b/random_choice.pl
@@ -0,0 +1,4 @@
+random_choice_do(c,Number):-Number < 0.5,!.
+random_choice_do(d,_).
+
+random_choice(_, Choice) :- random(Number), random_choice_do(Choice, Number).