String NetLogo字符串连接?

String NetLogo字符串连接?,string,netlogo,String,Netlogo,我试图将一些字符连接成一个字符串,然后对结果进行一些条件逻辑,但得到的不是预期的“ABC”,而是“[a][B][C]”。我怎样才能避免呢 守则: let first [basetype] of nukleotider-here with [attached] let second [basetype] of nukleotider-on patch-at 1 0 let third [basetype] of nukleotider-on patch-at 2 0 let

我试图将一些字符连接成一个字符串,然后对结果进行一些条件逻辑,但得到的不是预期的“ABC”,而是“[a][B][C]”。我怎样才能避免呢

守则:

  let first [basetype] of nukleotider-here with [attached]
  let second [basetype] of nukleotider-on patch-at 1 0 
  let third [basetype] of nukleotider-on patch-at 2 0 

  let kombination (word first second third)

  if kombination = "ABC" [set looking-for "M"]
谢谢,
Pall

首先,
First
是一个保留的NetLogo原语,但我假设您已经将代码翻译成英语,以便发布在这里(谢谢!)在任何情况下,我都会假设您的变量名为
x1
x2
x3
,而不是
First
第二个
第三个

您的问题源于这样一个事实,即这里的
nukleotider
reporters上的
nukleotider为您提供了一个代理集,而不是一个代理。因此,
将为您提供一个列表,而不是单个值

有很多方法可以解决这个问题,但是你应该首先问问自己,你是否确定在你正在查看的每个补丁上只会有一个nukleotider。如果您确信这一点,您可以选择以下方法之一:

从由
返回的列表中提取第一个项目: 从(可能的)单个代理集中提取代理: 稍微延迟列表提取: 只需将其转换为字符串列表并与之进行比较: 甚至是爱好者:
好吧,最后一个可能太过分了。还有更多的方法可以做到这一点。但希望你能找到一个适合你的…:-)

太棒了,尼古拉斯。当然我完全忽略了代理集问题。是的,我完全肯定,只有一个“nukleotider”(“可能只有一个!”,正如克里斯托弗·兰伯特在80年代所说的那样)——我只是省略了[with]子句以简化问题。是的,我把丹麦语翻译成了“第一”等等。非常感谢!!!:-)
let x1 first [basetype] of nukleotider-here with [attached]
let x2 first [basetype] of nukleotider-on patch-at 1 0 
let x3 first [basetype] of nukleotider-on patch-at 2 0 
let x1 [basetype] of one-of nukleotider-here with [attached]
let x2 [basetype] of one-of nukleotider-on patch-at 1 0 
let x3 [basetype] of one-of nukleotider-on patch-at 2 0 
let x1 [basetype] of nukleotider-here with [attached]
let x2 [basetype] of nukleotider-on patch-at 1 0 
let x3 [basetype] of nukleotider-on patch-at 2 0

let kombination reduce word (sentence x1 x2 x3)
let x1 [basetype] of nukleotider-here with [attached]
let x2 [basetype] of nukleotider-on patch-at 1 0 
let x3 [basetype] of nukleotider-on patch-at 2 0

let kombination (sentence x1 x2 x3)
if kombination = ["A" "B" "C"] [set looking-for "M"]
let kombination reduce word map [ xs -> [basetype] of one-of xs ] (list
  (nukleotider-here with [attached])
  (nukleotider-on patch-at 1 0 )
  (nukleotider-on patch-at 2 0)
)