emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Scala problem in Babel


From: Jarmo Hurri
Subject: Re: [O] Scala problem in Babel
Date: Mon, 03 Apr 2017 11:10:28 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Jarmo Hurri <address@hidden> writes:

> When I look at the temporary file I see that the code has been
> embedded in a wrapper defined in ob-scala.el. I guess it's the wrapper
> that messes up the execution of the code.

> What is the wrapper for? How am I supposed to use it?

Ok, got it by taking a closer look at ob-scala.el. In Babel scala code
isn't compiled and executed, it is run in interactive mode (shell). The
following works as expected (just as an example; you can also do this
without the Fibonacci class).

  #+BEGIN_SRC scala :exports both :results output
    object Fibonacci
    {
      def fib (n : Int) : Int =
      {
        if (n == 1 || n == 2)
          n - 1
        else
          fib (n - 1) + fib (n - 2)
      }
    }
    println (Fibonacci.fib (7))
  #+END_SRC

  #+RESULTS:
  : 8

Jarmo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]