In my Scala app, I have a function that calls a function which returns a result of type Future[T]. I need to pass the mapped result in my recursive function call. I want t
Here's a foldLeft solution that calls another function that returns a future.
def factorial(n: Int): Future[Int] = (1 to n).foldLeft(Future.successful(1)) { (f, n) => f.flatMap(a => getFutureNumber(n).map(b => a * b)) } def getFutureNumber(n: Int) : Future[Int] = Future.successful(n)