List.map isn't the only way to "loop" in Elm. Recursion is the construct for repeating something in a functional language. If map didn't exist, you could easily write it on your own using recursion -
But in a functional language like Elm, we use recursion and avoid side-effects like variable mutation and reassignment. The result is a program that is much easier to think about -
fibonacci:Int->Intfibonaccin=helpern01helper:Int->Int->Int->Inthelpernab=casenof0->a_->helper(n-1)b(a+b)>fibonacci10-- 55 : Int>fibonacci50-- 12586269025 : Int
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
List.map
isn't the only way to "loop" in Elm. Recursion is the construct for repeating something in a functional language. Ifmap
didn't exist, you could easily write it on your own using recursion -This goes for any program where a "loop" is needed. In some procedural language, you might write the classic
fibonacci
program -But in a functional language like Elm, we use recursion and avoid side-effects like variable mutation and reassignment. The result is a program that is much easier to think about -