无涯教程-F# - if /then 语句函数

61 阅读1分钟

if/then语句由一个布尔表达式后跟一个或多个语句组成。

if /then - 语法

F#中的if/then构造具有以下语法-

(* simple if *)
if expr then
   expr

if /then - 流程图

If then Statement

if /then - 示例

let a : int32=10

(* check the boolean condition using if statement *)
if (a < 20) then
   printfn "a is less than 20\n"
   printfn "Value of a is: %d" a

当您编译并执行程序时,它会生成以下输出-

a is less than 20

Value of a is: 10

参考链接

www.learnfk.com/fsharp/fsha…