Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support statements #73

Closed
davidchambers opened this issue Dec 29, 2016 · 0 comments
Closed

support statements #73

davidchambers opened this issue Dec 29, 2016 · 0 comments

Comments

@davidchambers
Copy link
Owner

Currently all > lines must be expressions. This is awkward when one wishes to define a function for use in doctests, as in sanctuary-js/sanctuary#316:

  //. > global.fib = function fib(n) {
  //. .   return n <= 1 ? n : fib(n - 2) + fib(n - 1);
  //. . }
  //. fib
  //.
  //. > S.fromMaybe_(() => fib(30), S.Just(1000000))
  //. 1000000
  //.
  //. > S.fromMaybe_(() => fib(30), S.Nothing)
  //. 832040

It would be nice to be able to use a function declaration (a statement) instead:

  //. > function fib(n) { return n <= 1 ? n : fib(n - 2) + fib(n - 1); }
  //.
  //. > S.fromMaybe_(() => fib(30), S.Just(1000000))
  //. 1000000
  //.
  //. > S.fromMaybe_(() => fib(30), S.Nothing)
  //. 832040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant