What are lists in ELM?

Overview

ELM is a functional programming language used to develop the front end of a website. Evan Czaplicki designed ELM in 2012.

Some practical applications of ELM in programming platforms are as follows:

  • Game development
  • Graphics
  • SPA (single page applications)

List in ELM

Lists are data structures that store data like other data structures, such as Linked-list, Arrays, Trees, and more.

  • Lists are the collection of homogeneous values.
  • Lists do not contain values of different data types.
ELM List

Syntax

Let's discuss the syntax of the list:

  • To create a list:
List_name = [value 1 ,value 2 ,value 3…nth value].
  • To search an element of the list:
List.member <Value to search> [ value 1, value 2,.....,nth value ]
  • Another way to search for an element:
List.member <Value to search> ListName

If the searched key is present in the list then it will return true. Otherwise, it will return false.

  • To append two lists:
List.append first_list second_list
  • To append values in a list:
List.append ListName [5] // there may be more than one element in it.
  • To sort a list:
List.sort list_name

Code example

The following code shows how to create, search, and append a list in ELM:

// Create your first list
myList = [1,3,2,6,5]
// search an element from a list
List.member 2 myList
// instead of writting list name you can also write list
// Appending two lists
List.append myList [7,8,9]
// Sorting a list in ELM
List.sort myList

You can try this example in the terminal given below. Copy and paste the code one by one in the terminal and press ENTER.

Terminal 1
Terminal
Loading...

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved