0

From this list [23,23,35,46] I want to exclude 23 and get [35,46] So I tried

Enum.filter([23,23,35,46],fn x -> x != 23 end)

I get '#.' as output why this is not working x != 23 is a valid boolean

when this is working

Enum.filter([23,23,35,46],fn x -> x == 23 end)
#[23,23]

What is the meaning of '#.'

Yugandhar Chaudhari
  • 3,831
  • 3
  • 24
  • 40

1 Answers1

1

You can this because the output you expect in the first example is 35 and 46 but since these are inside the ASCII range they are interpreted as letters. So basically if a list with all integers in it are in the ASCII range its interpreted as charlist. In the second example you get 23 because its not in the ASCII range. You can check that simply by putting only 23 in a list. But if you try to put 35 or 46 it will be "read" as a letter. Under the hood both of the examples are just list of integers but when we output this to the terminal its interpreted differently. Anyway if you want to interpret them as integers anyway check this out https://hexdocs.pm/elixir/Inspect.Opts.html#content

Tano
  • 1,285
  • 1
  • 18
  • 38