Skip to content

[CH4] A more concise implementation of fibTailRec. #452

Description

@sandeep-datta

Hi,

What do you think of the following implementation of fibTailRec from CH4?

fibTailRec :: Int -> Int
fibTailRec n = fibtr n 0 1 where
  fibtr :: Int -> Int -> Int -> Int
  fibtr n a b =
    if n == 0 then a
    else fibtr (n-1) b (a+b)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions