1,376
edits
| Line 481: | Line 481: | ||
var vector = []; | var vector = []; | ||
debug.dump(pop(vector)); # prints "nil" | debug.dump(pop(vector)); # prints "nil" | ||
}} | |||
=== remove() === | |||
{{Nasal doc | |||
|syntax = remove(vector, value); | |||
|source = {{simgear file|simgear/nasal/lib.c|l=53|t=Source}} | |||
|text = Removes all elements equal to the given value from a vector and returns the modified vector. | |||
|param1 = vector | |||
|param1text = The vector from which elements are to be removed. | |||
|param2 = value | |||
|param2text = A value to remove from the vector. | |||
|example1 = | |||
var vector = [1, 2, 3]; # Initialize the vector. | |||
remove(vector, 2); # Remove the value 2 from the vector. | |||
debug.dump(vector); # Print the contents of the vector: "[1, 3]". | |||
|example2 = | |||
var vector = ["text", "text", "text"]; # Initialize the vector. | |||
remove(vector, "text"); # Remove the value "text" from the vector. | |||
debug.dump(vector); # Print the contents of the vector: "[]". | |||
}} | |||
=== removeat() === | |||
{{Nasal doc | |||
|syntax = removeat(vector, index); | |||
|source = {{simgear file|simgear/nasal/lib.c|l=73|t=Source}} | |||
|text = Removes the element at the specified index from the vector and returns it. | |||
|param1 = vector | |||
|param1text = The vector from which the element will be removed. | |||
|param2 = index | |||
|param2text = Index of the item to be deleted. | |||
|example1 = | |||
var vector = [1, 2, 3]; # Initialize the vector. | |||
removeat(vector, 0); # Remove the index 0 from the vector. | |||
debug.dump(vector); # Print the contents of the vector: "[2, 3]". | |||
}} | }} | ||
edits