From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [IPv6:2a01:e0c:1:1599::15]) by sourceware.org (Postfix) with ESMTPS id A50733858C60 for ; Sun, 26 Sep 2021 16:19:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A50733858C60 Received: from smtpclient.apple (unknown [78.196.108.109]) (Authenticated sender: phiroc@free.fr) by smtp6-g21.free.fr (Postfix) with ESMTPSA id 7EF59780310 for ; Sun, 26 Sep 2021 18:19:51 +0200 (CEST) From: Philippe de Rochambeau Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Subject: Re: values Date: Sun, 26 Sep 2021 18:19:51 +0200 References: <9C7CF706-65C5-40E5-8949-EB836F398DDD@free.fr> <52C1790E-E668-4FA0-B0B0-F27AB68D6B14@free.fr> <11BE00BD-0D11-4F6A-9314-A7C4FFEF33D6@free.fr> To: kawa mailing list In-Reply-To: <11BE00BD-0D11-4F6A-9314-A7C4FFEF33D6@free.fr> Message-Id: <5EC715FC-1C6F-4DF5-9AAB-B7B513E08C2E@free.fr> X-Mailer: Apple Mail (2.3654.80.0.2.43) X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, FREEMAIL_REPLY, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Sep 2021 16:19:56 -0000 =E2=80=A6 and here=E2=80=99s a solution with a local halve procedure: (let* ((n0 39) (halve (lambda (n) (div-and-mod n 2)))) (let-values (((a b) (halve n0))) (display a))) >=20 > I found a solution: >=20 > (define (halve n) > (let-values (((a b) (div-and-mod n 2))) > a)) >=20 >>=20 >>=20 >> Hi Arvydas, >> thanks you for your feedback. >> I=E2=80=99ve managed to retrieve the 19 from div-and-mod using = let-values. >> Now, how do I add a procedure called =C2=AB (halve n) =C2=BB which = when passed a value such as 39, returns 19? >> Many thanks. >> Philippe >>=20 >> (display (let-values (((a b) (div-and-mod 39 2))) >> a)) >>=20 >>=20 >>=20 >>> Le 26 sept. 2021 =C3=A0 14:33, Arvydas Silanskas = > a =C3=A9crit : >>>=20 >>> Hi >>>=20 >>> 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)`. >>>=20 >>> Arvydas >>>=20 >>>=20 >>> Hello, >>> how do you retrieve the first item returned by the values procedure? >>> I=E2=80=99ve tried (first (values 1 3)), but to no avail, because = values doesn=E2=80=99t return a list. >>> Many thanks. >>> Philippe