diff options
author | Lex Spoon <lex@lexspoon.org> | 2006-05-26 12:23:50 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2006-05-26 12:23:50 +0000 |
commit | fa80c56a42832ed9b3b778266fb0da5cd0a4a18a (patch) | |
tree | 26395564ab58ed96d91702651123cc818144b47b /test/files/script/fact.scala | |
parent | e3b1cc9130d7046905cc86f0f25e25c1010c5900 (diff) | |
download | scala-fa80c56a42832ed9b3b778266fb0da5cd0a4a18a.tar.gz scala-fa80c56a42832ed9b3b778266fb0da5cd0a4a18a.tar.bz2 scala-fa80c56a42832ed9b3b778266fb0da5cd0a4a18a.zip |
added a test case for scalascript
Diffstat (limited to 'test/files/script/fact.scala')
-rwxr-xr-x | test/files/script/fact.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/script/fact.scala b/test/files/script/fact.scala new file mode 100755 index 0000000000..a15c93452c --- /dev/null +++ b/test/files/script/fact.scala @@ -0,0 +1,15 @@ +#!/bin/sh +# fact - A simple Scala script that prints out the factorial of +# the argument specified on the command line. + +exec scalascript "$0" "$@" +!# + + +val x = Integer.parseInt(argv(0)) + +def fact(x: Int):Int = + if(x==0) 1 + else x*fact(x-1) + +Console.println("fact(" + x + ") = " + fact(x)) |