The “assignment” inside the for loop has no effect, it creates a new variable on each loop iteration. I think you might be looking for Enum.reduce:
Enum.reduce(0..9, %{sensor1: 0}, fn n, sensor_data ->
Map.update!(sensor_data, :sensor1, &(&1 ||| (1 <<< n)))
end)






















