为什么我得到“无法统一't?' 编译时输入'f32'"类型,我该如何解决?

Jac*_*son 4 functional-programming compiler-errors type-mismatch futhark

我试图检查一个点是否在原点为 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
Run Code Online (Sandbox Code Playgroud)

似乎是一个足够简单的功能/问题,但我在网上找不到任何有关此功能的帮助。

Wil*_*ess 5

^运营商表示按位异或的整型参数。

求幂运算符是**。它是为所有数字类型定义的。

参考:https : //futhark.readthedocs.io/en/latest/language-reference.html