nums = [1, 2, 3, 4, 5] Enum.map(nums, fn n -> n * 2 end) # [2, 4, 6, 8, 10] Enum.filter(nums, fn n -> rem(n, 2) == 1 end) # [1, 3, 5] Enum.filter(nums, fn n -> rem(n, 2) != 1 end) # [2, 4] Enum.reduce(nums, fn a, b -> a + b end) # 15 Enum.each(nums, fn n -> IO.puts n * 100 end) # 100 # 200 # 300 # 400 # 500 # :ok
To embed this project on your website, copy the following code and paste it into your website's HTML: