public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Philippe de Rochambeau <phiroc@free.fr>
To: kawa mailing list <kawa@sourceware.org>
Subject: Re: values
Date: Sun, 26 Sep 2021 15:37:26 +0200	[thread overview]
Message-ID: <11BE00BD-0D11-4F6A-9314-A7C4FFEF33D6@free.fr> (raw)
In-Reply-To: <52C1790E-E668-4FA0-B0B0-F27AB68D6B14@free.fr>

I found a solution:

(define (halve n)
	(let-values (((a b) (div-and-mod n 2)))
	a))


> Le 26 sept. 2021 à 15:25, Philippe de Rochambeau <phiroc@free.fr> a écrit :
> 
> Hi Arvydas,
> thanks you for your feedback.
> I’ve managed to retrieve the 19 from div-and-mod using let-values.
> Now, how do I add a procedure called « (halve n) » which when passed a value such as 39, returns 19?
> Many thanks.
> Philippe
> 
> (display (let-values (((a b) (div-and-mod 39 2)))
> a))
> 
> 
> 
>> Le 26 sept. 2021 à 14:33, Arvydas Silanskas <nma.arvydas.silanskas@gmail.com <mailto:nma.arvydas.silanskas@gmail.com>> a écrit :
>> 
>> Hi
>> 
>> generally you would use constructs like define-values or let-values to declare multiple variables which will be bound to the received multiple values. There is also a more primitive call-with-values construct for piping those values as arguments to some procedure. To get a list, you could use `(call-with-values (lambda () (values 1 3)) list)`.
>> 
>> Arvydas
>> 
>> 2021-09-26, sk, 14:57 Philippe de Rochambeau via Kawa <kawa@sourceware.org <mailto:kawa@sourceware.org>> rašė:
>> Hello,
>> how do you retrieve the first item returned by the values procedure?
>> I’ve tried (first (values 1 3)), but to no avail, because values doesn’t return a list.
>> Many thanks.
>> Philippe
> 


  reply	other threads:[~2021-09-26 13:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 11:56 values Philippe de Rochambeau
2021-09-26 12:33 ` values Arvydas Silanskas
2021-09-26 13:25   ` values Philippe de Rochambeau
2021-09-26 13:37     ` Philippe de Rochambeau [this message]
2021-09-26 16:19       ` values Philippe de Rochambeau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11BE00BD-0D11-4F6A-9314-A7C4FFEF33D6@free.fr \
    --to=phiroc@free.fr \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).