When there was no iterators (e.g. C) or not that popular in the past. It is 
usually done by keeping two index and scan. This keeps the elements' order 
(stable).
    
    
    var xs = @[1,2,3,4]
    
    var i,j = 0
    while j < xs.len:
      # check xs[j]
      if xs[j] mod 2 == 0:
        # to keep
        xs[i] = xs[j]
        i.inc
      j.inc
    xs.setLen(i)
    
    assert xs == @[2,4]
    
    
    Run

Reply via email to