---
# System prepended metadata

title: Untitled

---

As part of a data processing pipeline, complete the implementation of the _makePipeline_ function:

-   The function should accept a sequence of functions, and it should return a new function that accepts one parameter _arg_.
-   The returned function should call the first function in the _makePipeline _with the parameter _arg_, and call the second function with the result of the first function.
-   The returned function should continue calling each function in the _makePipeline _in order, following the same pattern, and return the value from the last function.

For example, 

```scala
val functions = List((x: Int) => x * 3, (x: Int) => x + 1, (x: Int) => x / 2)

makePipeline(functions)(3)
```

and then calling the returned function with 3 should return 5.


```scala
// implement here

def makePipeline[T](functions: List[T => T]): T => T = (x: T) => {
    functions.foldLeft(x)((acc: T, z: T => T) => z(acc))
    }

  //def makePipieLine[T](functions: List[T => T]): T => T = (x:T) => {

    //def recurvPipeLine(f: List[T=>T], a:T): T = {
     // f match {
      //  case Nil => a
      //  case rest:List[T => T] => recurvPipeLine(rest.tail,rest.head(a))
     // }
   // }
   // recurvPipeLine(functions,x)
 // }

  val functions = List( (x: Int) => x * 3, (x: Int) => x + 1, (x: Int) => x / 2)


  makePipieLine(functions)(3)

```

def foldLeft[B](z: B)(op: (B, A) ⇒ B): B
val l: List[Int] = List()

val result: Int = l.foldLeft(0)()


def sum(values: List[Int]): Int = {}
    
}
```
