racket / racket/racket

allow for/fold #:results to reference sequence identifiers

Open
#2,240 0 comments 0 reactions 1 assignee View on GitHub

@pnwamk is already working on this.

Since Aug 21, 2018.

api design feature request
Dominant language
Racket
Stars
5.2k
Forks
698
Avg merge
18h 34m
Merged PRs (30d)
5

Description

Someone in the Racket Slack channel requested being able to reference the sequencing identifiers in the #:results clause of a for/fold. I think this would be a straightforward addition; I plan on looking into it in the near future.

I think the below two examples illustrate how this feature should behave:

#lang racket

(require rackunit)

;; the #:result clause can reference identifiers
;; bound by the sequencing clauses
(check-equal? (for/fold ([sum 0]
                         #:result (list sum n))
                        ([n (in-range 3)])
                (+ sum n))
              (list 3 2))

;; the accumulators bindings shadow the bindings
;; of identifiers bound by sequencing clauses
(check-equal? (for/fold ([n 0]
                         #:result n)
                        ([n (in-range 3)])
                (number->string n))
              "2")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.