> For the complete documentation index, see [llms.txt](https://sron.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sron.gitbook.io/docs/functions-in-sron/list-functions.md).

# List Functions

### List functions helps you to manipulate and work on list with great ease, speed and efficiency. These functions are highly optimized and well-tested.

### SRON provides 16 functions for this:

> * at()
> * clear()
> * count()
> * delete()
> * index()
> * insert()
> * len()
> * push()
> * pop()
> * replace()
> * reverse()
> * reverseSort()
> * rindex()
> * sort()
> * subPart()
> * update()

***

### **1. at():**

This function is used to get the 'Char' value at a particular index.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     Any val = at(lst, 1)
     println(val)
}
```

#### **OUTPUT:**

> 2.200

***

### **2. clear():**

This function empties the whole List.

```js
{
    name : Main
     List lst = [1,2.2,true,[11.11, "Wow"]]

     println(lst)
     clear(lst)
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.200000, true, \[11.110000, "Wow"]]\
> \[]

***

### **3. count():**

This function is used to count occurrence of a value in a List.

```js
{
    name : Main
     List lst = [1,2.2,false, 1,[11.11, "Wow"]]

     Int val = count(lst, 1)
     println(val)
}
```

#### **OUTPUT:**

> 2

***

### **4. delete():**

This function is used to delete a value from the List. It takes two arguments: the first argument is of type 'List' from which you have to delete the element and the second argument is of type 'Int' which is for the index from which element is need to be deleted.\
It returns Void.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     delete(lst,3)
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.2, true]

***

### **5. index():**

This function is used to find the index of first occurrence of a value in a List. Returns -1, if value not found.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     Int idx = index(lst,2.2)
     println(idx)
}
```

#### **OUTPUT:**

> 1

***

### **6. insert():**

This function is used to insert a value into 'List'. It takes 3 arguments: first of type 'List', second of type 'Int' to specify at what index you want to insert the value, and third is the value you want to insert.\
It returns Void.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     insert(lst, 2, "SRON")
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.2, "SRON", true, \[11.11, "Wow"]]

***

### **7. len():**

This function is used to get the length of the String.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     Int len = len(lst)
     println(len)
}
```

#### **OUTPUT:**

> 4

***

### **8. push():**

This function is used to append a value to the end of List. It takes two arguments: the List value in which you want to push and another one is a value of any type.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     push(lst," Hi")
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.2, true, \[11.11, "Wow"], "Hi"]

***

### **9. pop():**

This function is used to delete and return the last element of the List. It takes only one argument that is List and returns value of any type.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     Any val = pop(lst)
     println(val)
     println(lst)
}
```

#### **OUTPUT:**

> \[11.11, "Wow"]\
> \[1, 2.2, true]

***

### **10. replace():**

This function is used to replace all the occurence of a particular value with another value. It takes three arguments: first is List value, second one is value which will be replaced and third value which will be replacement of second argument.\
It returns void.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"], true]

     replace(lst, true "SRON")
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.2, "SRON", \[11.11, "Wow"], "SRON"]

***

### **11. reverse():**

This function is used to reverse a String. It takes only String as input and returns Void.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"]]

     reverse(lst)
     println(lst)
}
```

#### **OUTPUT:**

> \[\[11.11, "Wow"], true, 2.2, 1]

***

### **12. rindex():**

This function is used to get the index of a first value occurrence from the end. It takes two arguments: the List value from which you require to find the value and another argument is a value for which you want to find the index.\
It returns -1, if the character is not found.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"], true]

     Int idx = rindex(lst, true)
     println(idx)
}
```

#### **OUTPUT:**

> 4

***

### **13. sort():**

This function is used to sort a String. It returns a Void value.

```js
{
    name : Main
     List lst = [5,4,3,2,1]

     sort(lst)
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2, 3, 4, 5]

***

### **14. subPart():**

This function is used to extract a part of List. It takes 3 arguments: first is the 'List' from which you will extract a certain part from the list, then the 'Int' index by which you need to start extraction, then another 'Int' index by which you want to end the extraction.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"], true]

     lst = subPart(lst,1,3)
     println(lst)
}
```

#### **OUTPUT:**

> \[2.2, true]

***

### **15. update():**

This function is used to update a value at a particular index in a List. It takes 3 arguments: first is the 'List', second is the 'Int' index at which you have to put a new value, and the third argument is the new value at that index.

```js
{
    name : Main
     List lst = [1, 2.2, true, [11.11, "Wow"], true]

     update(lst,3, "SRON")
     println(lst)
}
```

#### **OUTPUT:**

> \[1, 2.2, true, "SRON", true]

***

### **16. reverseSort():**

This function is used to sort a String in reverse order. It returns a Void value.

```js
{
    name : Main
     List lst = [1,2,3,4,5]

     reverseSort(lst)
     println(lst)
}
```

#### **OUTPUT:**

> \[5, 4, 3, 2, 1]

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sron.gitbook.io/docs/functions-in-sron/list-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
