0

TL;DR: How to define a procedure foobar which can be used as (let-values ((foo bar) (foobar)) ...).


R7RS defines two procedures floor/ and truncate, which computes the quotient and remainder of two numbers divided. I find this really tricky because I can only use these procedures with let-values (or let*-values). A more important issue is that I cannot find a way to define my own procedures that returns multiple values.

Does someone have any ideas?

Note:

  • The definitions of floor/ and truncate/ are on the top of page 37 of the report.
  • I'm not lucky enough to successfully install any R7RS-compliant interpreters or compilers, so I haven't tested any of the above ideas yet. When I had the opportunity I would update this question, if needed.
Vursc
  • 21
  • 4
  • This feature hasn't changed since it got introduced in R5RS. Thus you will not find it under language changes in the R7RS. – Sylwester Aug 15 '21 at 21:11

1 Answers1

2

Did you try values? The report mentions it on page 53.

(define (foobar)
  (values 1 2))

(let-values (((foo bar) (foobar)))
  (cons foo bar))
Martin Půda
  • 7,353
  • 2
  • 6
  • 13
  • I did not notice this possible use of `values` when I first read it... That's what I want. Thanks a lot. – Vursc Aug 15 '21 at 00:56