F# 中的 if /then 语句函数

首页 / F#入门教程 / F# 中的 if /then 语句函数

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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

左耳听风 -〔陈皓〕

Python核心技术与实战 -〔景霄〕

数据中台实战课 -〔郭忆〕

系统性能调优必知必会 -〔陶辉〕

Vim 实用技巧必知必会 -〔吴咏炜〕

数据分析思维课 -〔郭炜〕

手把手带你写一门编程语言 -〔宫文学〕

PyTorch深度学习实战 -〔方远〕

云原生架构与GitOps实战 -〔王炜〕

好记忆不如烂笔头。留下您的足迹吧 :)