sumList head for List + flip function + call function

Too many questions at once…

For the next time, I personally would recommend you to rather use gitter and ask one by one.

In any case, let me try to answer all of them, forgive me if I miss one.


The head takes always the first element or not?

Yes, head always returns the first element of a non-empty list.
But again, not sure what you expected ls.head ::: ls.tail to do. Also not exactly sure what you mean with “I tried to do it with head and tail”.
Not sure if you believe you are pattern matching or what; it may be good to (re)check the docs and follow your lectures / tutorial.

Again, maybe you wanted to do something like this?

def sumList(ls: List[Int]): Int = ls match {
  case head :: tail => // do something with head and tail.
  case Nil => // do something when the list is empty.
}

Is my flip method correct how Implemented?

Yes.

Do I have to call it like this?
flip(f(2,1)

No.
Again, flip is a higher-order function, so it is a function that receives another function as an argument; I already explained that to you.

So once again, you only need to pass a function directly: flip(f)
And that will return another function.


Yes, it is correct; although I would remove the :Int at the end, it shouldn’t be needed.

And again, you call it by passing two functions and it will return a new function; e.g.

val myComposedFunction = compose(_ + 10, _ * 2)
val result = myComposedFunction(5)
// result: Int = 20 === ((5 * 2) + 10)

How do I have to call curry2?

Again, passing a function.

I would recommend you to take a look to this, this & this.