Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:09:20+00:00 2026-06-12T02:09:20+00:00

open System let random_number_generator = System.Random(int System.DateTime.Now.Ticks) in let random_number_below n = random_number_generator.Next(n) in

  • 0
open System

let random_number_generator = System.Random(int System.DateTime.Now.Ticks) in
let random_number_below n = random_number_generator.Next(n) in
match random_number_below 3 with
| 0 -> "Zero!"
| 1 -> "One!"
| 2 -> "Two!"
;;

The above match statement is not exhaustive, according to the compiler. This is totally legitimate, as F# has no syntactical information that would guarantee the bounds of the random number.

Incomplete pattern matches on this expression. For example, the value '3' may indicate a case not covered by the pattern(s).

What were the idiomatic F# way of matching (or is it simply if-else’ing) against a random number?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:09:21+00:00Added an answer on June 12, 2026 at 2:09 am

    As in the comments, solving this in general requires solving the halting problem. As a result the best thing to do is probably

    |_ -> failwith "broken RNG"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code in the next example, open System.Drawing let testColor c = match c
Here is my code: open System let rec gcd a b = match b
When I tried the console programming, I received unexpected result. open System let printSomeMessage
The example from this post has an example open System.IO let lines = File.ReadAllLines(tclscript.do)
I've tried the following code in VS2010: open System.Security.Cryptography let rsaTest1 = let ecKey
This works open System let f = Action(fun () -> Unchecked.defaultof<_>) But this let
Small part of a code to highlight the problem: open System.IO let do_smth i
The code I'm playing with is: open System open System.Windows.Forms open System.Drawing let tehform
I'm reading Expert F# book and I found this code open System.Collections.Generic let divideIntoEquivalenceClasses
I'm working on replacing a window.open() notification system and think to implement this with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.