Skip to content

Instantly share code, notes, and snippets.

@themexpride
Created December 16, 2022 07:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Update List of integers with their absolute values
def f(arr:List[Int]):List[Int] = {
arr match {
case Nil => Nil
case h::t => {
if (h < 0) (-1 * h)::f(t)
else h::f(t)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment