F#If-Elif梯子

F#if-elif梯形图仅从多个布尔表达式中执行一个布尔表达式。

if boolean-expression then expression1 elif boolean-expression thenexpression2 elif Boolean-expression thenexpression3

F#If-Elif梯子

文章图片
示例:if- then elif梯子
open System// System is a package, and this is the way to import package in F#Console.Write("Enter integer number to check whether it is even or not : ")let input = Console.ReadLine()let number = input |> Int32.Parse// casting input to integer valueif(number< 0 & & number> 100) thenprintfn "wrong number"elif(number> =0 & & number< 50) thenprintfn "fail"elif(number> =50 & & number< 60)thenprintfn "D Grade"elif(number> =60 & & number< 70) thenprintfn "C Grade"elif(number> =70 & & number< 80)thenprintfn "B Grade"elif(number> =80 & & number< 90)thenprintfn "A Grade"elif(number> =90 & & number< =100)thenprintfn "A+ Grade"

【F#If-Elif梯子】输出:
Enter a number to check grade: 85A Grade

    推荐阅读