~~NOTOC~~ * [[ixe:irpl:lists:getlistelement|Get]] * [[ixe:irpl:lists:setlistelement|Set]] ====== GetListElement ====== GetListElement (<-list I) ->element ===== Description ===== Returns the value at the specified index of a list. Lists are indexed from zero. Note: If a list is stored in a variable, this can be abbreviated to <-list[<-index]. ===== Examples ===== Split("1,2,3,4,5,6" ",") ->list 6 0 do Trace (<-list I GetListElement) #functionally equivalent Trace (<-list[I]) #functionally equivalent loop # A 2-line code that gets a random element from a provided list. RandInt(0 GetListCount(<-units)) ->randIndex GetListElement(<-units <-randIndex) ->targetUnit # A function for selecting a random element from a list: 1 2 4 8 16 list ->list <-list @selectRandomElement ->randElement :selectRandomElement Dup Getlistcount 0 swap RandInt Getlistelement