Iteration (map / sum)
There are no loops in Haskell; repetition/transformation is done using map, sum, and ranges (1..n).
Simple enough for a 5-year-old to understand
Ranges and mapM_
[1..5] is a range (inclusive of 5). mapM_ applies an IO action to each element.
main = mapM_ print [1..3]🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)
🎯 Expected output: 1
2
3
4
5