How make a list of cumulative sum in netlogo

前端 未结 4 1006
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 06:43

How can i make a list of cumulative sum of a other list?

i tried it that way:

;;all temperatrue-values around the turtle saved in list 
set tempera         


        
4条回答
  •  余生分开走
    2021-01-07 07:05

    Similar to Alan's solution (Just an update for the recent version of NetLogo that replaces ? with -> for anonymous procedures.)

    to-report partial-sums [lst]
    report butfirst reduce [[result-so-far next-item] -> lput (next-item + last 
    result-so-far) result-so-far] fput [0] lst
    end
    

提交回复
热议问题