ProgrammingElixir1.6-MyTurns/ModulesAndFunctions-7.exs

26 lines
No EOL
1.3 KiB
Elixir
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Find the library functions to do the following, and then use each in IEx.
# (If the word Elixir or Erlang appears at the end of the challenge, then youll find the answer in that set of libraries.)
# - Convert a float to a string with two decimal digits. (Erlang)
# - Get the value of an operating-system environment variable. (Elixir)
# - Return the extension component of a file name (so return .exs if given "dave/test.exs"). (Elixir)
# - Return the processs current working directory. (Elixir)
# - Convert a string containing JSON into Elixir data structures. (Just find; dont install.)
# - Execute a command in your operating systems shell.
# https://erldocs.com/current/erts/erlang.html?i=4&search=float%20to#float_to_list/2
IO.puts :erlang.float_to_list(1234.5678, [decimals: 2])
# https://erldocs.com/current/kernel/os.html?i=1&search=os:get#getenv/1
IO.inspect :os.getenv('HOME')
# https://hexdocs.pm/elixir/Path.html#extname/1
IO.puts Path.extname('dave/test.exs')
# https://hexdocs.pm/elixir/System.html#cwd/0
IO.puts System.cwd()
# https://github.com/devinus/poison
# Poison.Parser.parse!(~s({"name": "Devin Torres", "age": 27}), %{})
# https://hexdocs.pm/elixir/System.html#cmd/3
IO.inspect System.cmd("echo", ["hello world"], into: IO.stream(:stdio, :line))