Im new to scala and I've been looking everywhere for how to find how to structure my file I write with my function in it. Furthermore how to call that function from cmd. I'm trying to write a simple function like just to understand how to get started writing programs. Anything simple like the below would be useful.
def test (n : Int){
println(n + n)
}
Keep in mind i am writing this in Notepadd ++. my first assignment is the gray code. So my ultimate goal is to figure out how files are run and functions are called. There are tons of solutions to gray code below is 1.
def gray(n: Int) ={
def gray(n: Int, res: List[String]): List[String] = {
val nRes = res.map("0" + _) ::: res.reverse.map("1" + _)
if(n == 1) nRes
else gray(n-1, nRes);
}
gray(n, List(""))
}
Things i've tried were to make an object file and running that and parsing the args to pass to a function.
object test1 {
def main(args: String) {
n = args.toInt
test(n);
}
def test(n: Int){
println( n + n)
}
}