Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// requires jython and jython-engine jars
engine = mgr.getEngineByName("jython")
engine.eval('''
def factorial(n):
    i=fact=1
    while i <= n:
        fact=fact*i
        i=i+1
    return fact

result = factorial(4)
''')
println 'jython: ' + engine.result

Or Jaskell (not quite working as expected):

Code Block
// requires jaskell and jaskell engine and jparsec and jfunutil jars
engine = mgr.getEngineByName("jaskell")
engine.eval('factorial n = if n > 0 then n * factorial (n-1) else 1')
println 'jaskell: ' + engine.eval('factorial 4')

...