FIND YOUR NEXT FEW LINES

Results for “Array operations”

Small, practical examples. Search by task or narrow things down below.

298 snippets foundClear filters
PowerShellArray operations

Read the last array element

PowerShell: A negative array index counts backward from the end.

PowerShell✓ Tested
Bash ScriptsArray operations

Remove an indexed element and compact the array

Bash Scripts: Unsetting an element leaves a gap; reassigning the values creates consecutive indices.

Bash Scripts✓ Tested
Bash ScriptsArray operations

Select a range of array elements

Bash Scripts: Quote a sliced at-sign expansion to keep each selected element separate.

Bash Scripts✓ Tested
PowerShellArray operations

Split an array into fixed-size batches

PowerShell: Bound the final index so the last batch can contain fewer elements.

PowerShell✓ Tested
PowerShellArray operations

Test whether an array contains a value

PowerShell: The contains operator compares complete items rather than matching substrings.

PowerShell✓ Tested
Bash ScriptsArray operations

Visit associative-array keys in a stable order

Bash Scripts: Associative arrays have no defined iteration order, so sort their keys explicitly.

Bash Scripts✓ Tested
PowerShellArray operations

Build a mutable generic list

PowerShell: A generic list supports repeated additions without copying an entire array each time.

PowerShell✓ Tested
PowerShellArray operations

Count a result even when it is empty or has one item

PowerShell: Wrap pipeline results in an array subexpression for consistent Count behavior.

PowerShell✓ Tested
PowerShellArray operations

Reverse a copy while preserving the source

PowerShell: Clone the array before using Array.Reverse because Reverse mutates its argument.

PowerShell✓ Tested
PowerShellArray operations

Select elements by an index range

PowerShell: An index range selects the requested array positions in order.

PowerShell✓ Tested
JavaQueues & collection operations

Use a deque as a FIFO queue

Java: Add at the tail and remove at the head using ArrayDeque.

Java✓ Tested
CNumbers & memory

Allocate a zeroed array

Check calloc, use the allocation, and release it in C.

C✓ Tested