The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Sequencing Data With Lists in Elm

Sequencing Data With Lists in Elm

5:57
Lists are used in Elm to represent sequences of data. The List library comes with a toolbox of useful functions. Here we cover list transformation (map), and getting single values from lists (fold).
Watch this lesson now
Avatar
egghead.io

Lists are used in Elm to represent sequences of data. The List library comes with a toolbox of useful functions. Here we cover list transformation (map), and getting single values from lists (fold).

Avatar
hipertracker

Why for filtering the list you used List.foldl instead of List.filter?

In reply to egghead.io
Avatar
Murphy

In this case, I wanted to get a particular single result from the list, which is what a fold is designed for, taking a list and turning it into just one value. Filter takes a list, and returns a different list, so that wasn't quite what I wanted. If you didn't want to use foldl, you could filter, and then use List.head on the result of the filter to get the first item from the filtered result.

In reply to hipertracker
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?