Last active
August 29, 2015 14:04
-
-
Save ncancelliere/8e89871e3956c99f2803 to your computer and use it in GitHub Desktop.
unexpected output from a simple Elixir function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Why does certain input result in weird character output rather than a list? | |
* (from the Exercise: Functions-1 - Pragprog Elixir book) | |
**/ | |
iex> pair_tuple_to_list = fn {a, b} -> [a, b] end | |
#Function<6.90072148/1 in :erl_eval.expr/5> | |
iex> pair_tuple_to_list.({1, 4}) | |
[1, 4] | |
iex> pair_tuple_to_list.({8, 9}) | |
'\b\t' | |
iex> pair_tuple_to_list.({8, 19}) | |
[8, 19] | |
iex> pair_tuple_to_list.({18, 9}) | |
[18, 9] | |
iex> pair_tuple_to_list.({7, 9}) | |
'\a\t' | |
iex> pair_tuple_to_list.({8, 7}) | |
'\b\a' | |
iex> pair_tuple_to_list.({2, 8}) | |
[2, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment