为什么编译的时候会得到"Cannot unify 't₂' with type 'f32'",如何解决?
Why do I get "Cannot unify 't₂' with type 'f32'" when compiling and how do I solve it?
我正在尝试检查一个点是否在原点为 1,1 的圆内。
但是,当我尝试简单地从坐标中减去“1.0”时,出现错误:
Error at exercise3.fut:2:6-14:
Cannot unify 't₂' with type f32' ('t₂' must be one of i8, i16, i32, i64, u8, u16, u32, u64 due to use at exercise3.fut:2:6-30).
When matching type
t₂
with
f32
我需要做什么才能使编译器适应 "x-1.0"(其中 x 的类型为 f32)?
我试过将输入类型更改为 't' 并写入 x-(1.0f32) 等,但仍然出现相同或相似的错误。
这是给出问题的代码:
let hit_register (x : f32) (y : f32) : bool =
((x - 1.0)^2.0 + (y - 1.0)^2.0) <= 1.0
看起来很简单 function/problem,但我找不到任何在线可用的帮助。
^
运算符代表整数类型参数的按位xor。
求幂运算符是**
。它是为所有数字类型定义的。
参考:https://futhark.readthedocs.io/en/latest/language-reference.html
我正在尝试检查一个点是否在原点为 1,1 的圆内。 但是,当我尝试简单地从坐标中减去“1.0”时,出现错误:
Error at exercise3.fut:2:6-14:
Cannot unify 't₂' with type f32' ('t₂' must be one of i8, i16, i32, i64, u8, u16, u32, u64 due to use at exercise3.fut:2:6-30).
When matching type
t₂
with
f32
我需要做什么才能使编译器适应 "x-1.0"(其中 x 的类型为 f32)?
我试过将输入类型更改为 't' 并写入 x-(1.0f32) 等,但仍然出现相同或相似的错误。
这是给出问题的代码:
let hit_register (x : f32) (y : f32) : bool =
((x - 1.0)^2.0 + (y - 1.0)^2.0) <= 1.0
看起来很简单 function/problem,但我找不到任何在线可用的帮助。
^
运算符代表整数类型参数的按位xor。
求幂运算符是**
。它是为所有数字类型定义的。
参考:https://futhark.readthedocs.io/en/latest/language-reference.html