Skip to content

Chapter 8: Fibonacci to PTC form? #173

Description

@mulongjiangliu

Loved the in-depth coverage and explanations of this series . And it's easy to understand for newcomers who are fresh to FP.

In Continuation Passing Style (CPS) of Chapter 8, it is said that Fibonacci recursion cannot practically be refactored to pure PTC. It confuses me there. As I find below code, though it lost some readability.

function fib(x, res = 1, pre = 1) { if (x <= 1) return res; return fib(x - 1, pre, pre + res) }

Is above fib a pure PTC form?
Any Comments are welcome and appreciated.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions