title: Subtracting element of ith position from element at (i + 1)th position of any list in netlogo
body: <p>I want to create a list of count values of some variable (tot-turtles) increasing with each tick. I tried the below code but all time list is having single element  of length 1. neither i is getting incremented. please correct me.</p>
  
  <pre><code>set tot-turtles count turtles 
  
  to go
    let mylist [ ]
    set mylist lput tot-turtles mylist  ;    show mylist 
  
    set i 1
    foreach mylist [       ; print ?        ;show i
       set x ? - i         ; print x
       set i (i + 1)        ;show i
    ]
   end
  </code></pre>
  
  <p>I want to subtract elements of list in the following fashion where the length of list depends on the number of simulation run or till simulation ends, then
  i need subtraction of element as element at (i + 1)th - element at ith position till the end of the list.</p>
  
  <p>In the above code i is 1 then increments by 1 ie 2 and then continue to 1 2 1 2 1 2. mylsit always shows single element. Confused with "?" , it gives element of current position if i am not wrong, but how we know the current position? </p>
  
  <p>Please help me out of these doubts and code. thanks a lot.</p>
  
  <p>Thank you sir, yes i was doing mistake with local and global variable i checkd it later. and the thing i wanted is as below.</p>
  
  <pre><code>  to setup 
            set mylist [ 0] 
            set item-difference 0
    end  
  
    to go 
       set tot-turtles count tutles set 
  
       mylist lput tot-turtles mylist 
       let _n (length mylist) 
       set item-difference (( item ( _n - 1 ) mylist - item ( _n - 2 ) mylist )         
   end
  </code></pre>
  
  <p>I hope you got Allan sir.</p>