Skip to content

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

@sandeep-datta

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)

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