11 Jun 2013, 07:52
Avatar_pragsmall

Javier Acero (2 posts)

I am doing the exercises on section 6.1 (the @Times@ module). Here is my solution:

defmodule Times do
  def double(n),    do: ( n * 2 )
  def triple(n),    do: ( n * 3 )
  def quadruple(n), do: ( double(double(n)) )
end

When I run it doing:

⌘ ~/Dev/elixir ❯ iex times.ex
Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (0.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Times.quadruple(4)
16

It works like a charm. But, when I start @iex@ and then try to compile I get this error:

⌘ ~/Dev/elixir ❯ iex
Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (0.9.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> c('times.ex')
== Compilation error on file 116 ==
** (FunctionClauseError) no function clause matching in :elixir_compiler.file_to_path/2
    src/elixir_compiler.erl:47: :elixir_compiler.file_to_path(116, ".")
    /private/tmp/elixir-5Yng/elixir-0.9.1/lib/elixir/lib/kernel/parallel_compiler.ex:56: Kernel.ParallelCompiler."-spawn_compilers/7-fun-0-"/3

Any idea why? I am running elixir 0.9.1 in case it helps. Thanks!

11 Jun 2013, 20:32
Generic-user-small

David Simmons (3 posts)

Hi Javier

I think your problem is that you are using single quotes - the file needs to be surrounded by double quotes.

So

c(“times.ex”) nto c(‘times.ex’)

cheers

Dave

12 Jun 2013, 06:47
Avatar_pragsmall

Javier Acero (2 posts)

Thank you Dave.

It was just that. Too much time single quoting Ruby :)

  You must be logged in to comment