Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Created September 30, 2015 20:06
Show Gist options
  • Select an option

  • Save binarytemple/10c6af405d590dbd035f to your computer and use it in GitHub Desktop.

Select an option

Save binarytemple/10c6af405d590dbd035f to your computer and use it in GitHub Desktop.
Flatmap in Erlang, substitute characters in a list
X = fun(Bin) ->
list_to_binary(
lists:flatmap( fun($&) -> "\\&"; ($\\) -> "\\\\"; (Chr) -> [Chr] end, binary_to_list(Bin))
)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment