Evaluating a recursive definition by substitution

A pure Haskell function is defined recursively as follows, where function application binds more tightly than multiplication, and multiplication more tightly than addition.


haskell
f :: Int -> Int
f 0 = 1
f n = 2 * f (n - 1) + n


Evaluate f 4 by substitution. Give the result as an integer.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Functional Languages and Programs Questions: