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 functional programming #6

Open
zero-plusplus opened this issue Sep 5, 2021 · 0 comments
Open

Support functional programming #6

zero-plusplus opened this issue Sep 5, 2021 · 0 comments
Labels
draft Draft of new features

Comments

@zero-plusplus
Copy link
Owner

Functional programming may be able to solve the issue of fat-arrow functions in v2.

The issue with the fat-arrow function is that it can only process one statement.

One suggestion to solve this issue is to run multiple expressions with commas, as follows.

f := () => (
  a(),
  b(),
  c()
)

However, this method is a bit inconvenient because you cannot use if statements, and if you forget to remove the comma at the end of the expression, an error will occur.

The following is the current solution with reference to functional programming.

; 2.0-beta.1
f := bee.from()
  .pipe(() => a())
  .pipe(() => b())
  .pipe(() => c())
)

If you want to use an if or loop statement, do the following

; 2.0-beta.1
f := bee.from(0)
  .loop(Random(1, 10), (data) => data + 1)
  .if((data) => 5< data, (data) => data, () => bee.null)
%f%() ; => 6, 7, 8, 9, 10 or bee.null

Functional programming can be useful not only for solving fat-arrow function issue, but also for general data processing.

@zero-plusplus zero-plusplus added the draft Draft of new features label Sep 5, 2021
@zero-plusplus zero-plusplus changed the title Research on functional programming Support functional programming Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft Draft of new features
Projects
None yet
Development

No branches or pull requests

1 participant