Skip to content

Instantly share code, notes, and snippets.

@tlehman
Created October 3, 2012 04:43
Show Gist options
  • Select an option

  • Save tlehman/3825044 to your computer and use it in GitHub Desktop.

Select an option

Save tlehman/3825044 to your computer and use it in GitHub Desktop.
reduce in scala
def reduce(f:(Int,Int)=>Int, xo:Int, lst: List[Int]): Int = {
if (lst.length == 1) f(xo, lst.head)
else f(reduce(f, xo, lst.tail), lst.head)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment