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

Add a loop form #1

Open
countvajhula opened this issue Apr 25, 2021 · 0 comments
Open

Add a loop form #1

countvajhula opened this issue Apr 25, 2021 · 0 comments

Comments

@countvajhula
Copy link
Collaborator

countvajhula commented Apr 25, 2021

Add a loop form, which would compile to a lambda expression defined in terms of itself, and would be specified in terms of a set of functions, something like:

(define result (loop ('(1 2 3)) (until empty?) (map first) (combine +) (next rest))

... along with the lambda forms:

(define sum-nums (loop-lambda (nums) (until empty?) (map first) (combine +) (next rest))

and

(define-loop (sum-nums nums) (until empty?) (map first) (combine +) (next rest))

Of course, these examples may be better expressed simply using folds or the built-in for forms. But there may be other cases where this approach is preferable. For instance, it may be that these would be preferable to named lets and handwritten recursive functions in some cases. The idea is simply to provide forms to define loops exclusively in terms of functions with the arguments already implicit (much like the other forms provided by this package), and see where that gets us.

countvajhula pushed a commit that referenced this issue Nov 10, 2023
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