如何在netlogo中列出累计金额 [英] How make a list of cumulative sum in netlogo
本文介绍了如何在netlogo中列出累计金额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何列出另一个列表的累加总和?
我尝试过这种方式:
;;all temperatrue-values around the turtle saved in list
set temperature_values (list [(output-heat + 1)^ Freedom] of neighbors)
;;build cumulative value of temperatures and put each value in list
let tempsum 0
set tempsum_list []
foreach temperature_values
[set tempsum (tempsum + ? )
set tempsum_list fput tempsum tempsum_list
]
但是它不起作用.谁能解决这个问题?它说"+排除了输入,但获得了列表".
解决方案
your code for a cumulative sum works (except that I think you need lput
rather than fput
. You can see it with this:
to test
let ll [1 2 3 4]
let tempsum 0
let tempsum_list []
foreach ll
[ set tempsum (tempsum + ? )
set tempsum_list lput tempsum tempsum_list
]
print tempsum_list
end
Did the error highlight the line set temperature_values (list [(output-heat + 1)^ Freedom] of neighbors)
? Try putting a space after between ) and ^. NetLogo is picky about space around mathematical operators.
这篇关于如何在netlogo中列出累计金额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文