concatenate words in netlogo

荒凉一梦 提交于 2019-12-25 05:18:17

问题


NetLogo users

I want to make a list which concatenates lists, for example

Here is list 1 : [ 0 1 4 6 8]

and here is list2 : (word "turtle")

then I'd like to make list which ["turtle 0" "turtle 1" "turtle 4" turtle 8"]

How could I possibily make this?

Thank you in advance


回答1:


Note that (word "turtle") is just "turtle", so I'm not quite sure what you want. But this should cover it.

to-report append-word [w xs]
  report map [[x] -> (word w " " x)] xs
end

to-report append-words [ws xs]
  report map [[w] -> append-word w xs] ws
end

to test
  let ws ["turtle" "rabbit"]
  let xs [0 1 4 8]
  print append-word item 0 ws xs
  print append-words ws xs
end


来源:https://stackoverflow.com/questions/43889591/concatenate-words-in-netlogo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!