Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F#:如何获得具有int类型输入的char类型表达式_F#_Char_Int - Fatal编程技术网

F#:如何获得具有int类型输入的char类型表达式

F#:如何获得具有int类型输入的char类型表达式,f#,char,int,F#,Char,Int,我试图编写一个简单的代码,将int-type作为输入变量,并根据输入变量的值为我提供一个char-type输出变量: let control (a : int) (b : int) (c : int) : char = match (a,b,c) with (1,1,1) ->'r' control 1 1 1 它有效,但仅适用于组合1 如果a=b=c,其他组合为“n”,我如何使输出为“t”(例如) 多谢各位 let control a b c = match

我试图编写一个简单的代码,将int-type作为输入变量,并根据输入变量的值为我提供一个char-type输出变量:

    let control (a : int) (b : int) (c : int) : char = match (a,b,c) with (1,1,1) ->'r'

    control 1 1 1
它有效,但仅适用于组合1

如果a=b=c,其他组合为“n”,我如何使输出为“t”(例如)

多谢各位

let control a b c =
    match (a, b, c) with
      | (1, 1, 1)             -> 'r'
      | _ when a = b && b = c -> 't'  // or  when (a, b) = (b, c)
      | _                     -> 'n'
或:

let control a b c =
    if (a, b, c) = (1, 1, 1) then 'r'
    elif a = b && b = c then 't'      // or  elif (a, b) = (b, c) then
    else 'n'