I confess that I am falling in love with Haskell, I am giving hard to the lists and the functions that can be applied:
Prelude> let list = [1,2,3,4,5]
Prelude> head list
1
Prelude> tail list
[2,3,4,5]
Prelude> init list
[1,2,3,4]
Prelude> last list
5
Prelude> take 2 list
[1,2]
Prelude> drop 3 list
[4,5]
Prelude> reverse list
[5,4,3,2,1]
Wonder, I understand that the functions that return a list (such as tail
, init
, reverse
, etc.) do not affect the list used as a parameter, that is, the original list list
has not been modified and a copy (?) of that list is returned:
Prelude> list
[1,2,3,4,5]
What I tried to do is something very simple:
Prelude> let list = reverse list
In my head I expected it to now list
contain [5,4,3,2,1]
, but trying to see what it contains just crashes the interpreter:
Prelude> list
(el cursor se queda acá y no hace nada)
Why is this happening?