首页 > 解决方案 > 使用 Julia 将 in() 与元组数组一起使用时出错

问题描述

我有 2 个元组数组,我有一个循环询问一个元素是否在另一个元素中。在每一步我都会询问坐标数组中包含的元组是否在 Y 数组中。该循环工作正常,除了一个我无法解释原因的元素。这是我所拥有的:

Y[55:65] # This is the array I want to check at each step if my state is in or not.

11 元素数组{Any,1}: (2.0, 1.0) (3.0, 1.0) (4.0, 1.0) (5.0, 1.0) (6.0, 1.0) (7.0, 1.0) (8.0, 1.0) (9.0, 1.0) (10.0, 1.0) (11.0, 1.0) (12.0, 1.0)

coord[i-1]  # this is one element of coord that is in Y

0维数组{Tuple{Float64,Float64},0}: (6.0, 1.0)

coord[i] # this is an other element of coord that is in Y

0维数组{Tuple{Float64,Float64},0}: (7.0, 1.0)

但是当我测试它们在 Y 时:

in(coord[i],Y[55:65]) # testing if coord[i] is in Y

错误的

in(coord[i-1],Y[55:65]) # testing if coord[i-1] is in Y

真的

我不明白:它们在 Y 中都以相同的方式表示,它们具有相同的类型,为什么我从使用 in() 得到一个在而不是另一个?

我使用 Julia 版本 0.6.3。

在此先感谢您的帮助!

标签: julia

解决方案



推荐阅读