Skip to main content

list

Lists in Soul are ordered collections of elements that can hold values of any type. They are created using square brackets [] and provide dynamic resizing and various methods for manipulation.

Basic List Creation

Create lists with square bracket notation:

List with Different Data Types

Lists can contain mixed data types:

Accessing List Elements

Use index notation to access elements:

Modifying List Elements

Change elements using index assignment:

List Methods

Common list operations:

List Concatenation

Combine lists together:

List Slicing

Extract portions of lists:

Nested Lists

Lists can contain other lists:

List Iteration

Iterate through list elements:

List Searching

Find elements in lists:

List Filtering

Filter elements based on conditions:

List Mapping

Transform list elements:

List Reduction

Reduce list to a single value:

List Sorting

Sort list elements:

List of Objects

Work with lists containing objects:

List Validation

Validate list contents:

List Utilities

Common list utility functions:

List Performance

Optimize list operations:

Best Practices

  1. Check for null/empty: Always validate lists before use
  2. Use appropriate methods: Choose the right operation for your needs
  3. Cache length: Store list length in variables for performance
  4. Handle bounds: Check indices before accessing elements
  5. Use meaningful names: Make list purpose clear
Lists are fundamental data structures in Soul, providing flexible and powerful ways to store and manipulate collections of data.