PICO-8 Wiki
Tag: Visual edit
Tag: Visual edit
Line 20: Line 20:
 
*[https://pico-8.fandom.com/wiki/Tables Tables]
 
*[https://pico-8.fandom.com/wiki/Tables Tables]
 
*[https://pico-8.fandom.com/wiki/Add add()]
 
*[https://pico-8.fandom.com/wiki/Add add()]
  +
*[https://pico-8.fandom.com/wiki/Del del()]
 
*[https://pico-8.fandom.com/wiki/All all()]
 
*[https://pico-8.fandom.com/wiki/All all()]
 
*[https://pico-8.fandom.com/wiki/Foreach foreach()]
 
*[https://pico-8.fandom.com/wiki/Foreach foreach()]

Revision as of 22:30, 9 July 2020

deli( tbl, i )

Deletes the first occurrence of a value from a sequence in a table.
tbl
The table.
i
The value to match and remove.

The deli() function removes the value at the given index of a sequence. All subsequent values in the sequence shift down by one slot to keep the sequence contiguous.

The deli() function returns the object being removed. This can be ignored, tested it to see if the removal was successful, or used as needed.

Example

t = {1, 2, 4, 3, 4}
deli(t, 5)  -- t = {1, 2, 4, 3}
deli(t, 3)  -- t = {1, 2, 3}

See also