DEV Community

Discussion on: AoC Day 1: Chronal Calibration

 
ryanwilldev profile image
Ryan Will

It does, but because Elixir is immutable it returns a new list with the first element from repeated_numbers instead of mutating (changing in place) repeating_numbers

Also, this line hd(Enum.take(repeated_numbers, 1)) could be rewritten as hd(repeated_numbers) to get the same functionality. The more "Elixir way to write that would be to use pattern matching. Something like [head | tail] = repeated_numbers Here is some more info on pattern matching, if you're interested. I think it is super cool!

Thread Thread
 
rhymes profile image
rhymes

Thank you! :-)

I have to get used again to immutability and transformation instead of mutability and assignment :D