From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Newsgroups: gmane.lisp.guile.user Subject: Re: help : call function with args Date: Wed, 4 Apr 2018 16:39:56 +0200 Message-ID: <20180404143956.GC3431@tuxteam.de> References: <3b59deec-179a-00d3-2957-9a460e3bbc2b@disroot.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1522852754 28923 195.159.176.226 (4 Apr 2018 14:39:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Apr 2018 14:39:14 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Apr 04 16:39:10 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3jZ4-0007N3-0t for guile-user@m.gmane.org; Wed, 04 Apr 2018 16:39:06 +0200 Original-Received: from localhost ([::1]:34931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3jb9-0006El-FF for guile-user@m.gmane.org; Wed, 04 Apr 2018 10:41:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3jZz-0005WC-JT for guile-user@gnu.org; Wed, 04 Apr 2018 10:40:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3jZu-0002kx-NA for guile-user@gnu.org; Wed, 04 Apr 2018 10:40:03 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:40409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f3jZu-0002kU-D3 for guile-user@gnu.org; Wed, 04 Apr 2018 10:39:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=20171004; h=From:In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=1kKndCBBQRjMe3uXYz56dXVDQ7auovIhcxn5jMzTWDU=; b=N9OPSn9S9BKFOvZL0g/VDY5lEzUQ2Vf0DnKKyAUfXvoHKFkOCogIV2SW57AJAvSB3j8e//mdECsrn5jgE4SIMtyxnxpJ6G4Xg6Ie5gfT6s7rWkozWufCkPk5EWxqtfp1dku/grRJ96nj9o0AfSN+msHckpESl60WbkFvONJnp3LOf+26EySAbJ/sZNn8YAU5UE+ZJBgp3Shf2TA/SfvV/zeqWydV9pVxSBv/Iwl0GqHd4CRWJJhC918LOAPv0d3zHNUXyl9HmAJ1effbli6teMZx4FxXtN8RMdnVLNdCwmlmAz8848kjPcEJWos8m7L0U99961fxKowgZgsKdIH3Xg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1f3jZs-0001Jw-QZ for guile-user@gnu.org; Wed, 04 Apr 2018 16:39:56 +0200 In-Reply-To: <3b59deec-179a-00d3-2957-9a460e3bbc2b@disroot.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 5.199.139.25 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14527 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, Apr 04, 2018 at 09:43:18AM +0200, calcium wrote: > Sorry, I tried to use a disposable email web service, but it didn’t > work, so I just created a email account. No problem. And despite your second mail, this one does arrive as plain text: all seems well :-) > The question was how to do what I intended with this code (sorry I don’t > know how to express this with words) : > > > (define (f a b c d) > > (+ a b c d)) > > > (f 1 (values 2 3) 4) Hm. I don't think "values" does what you expect it to do. (Please, more seasoned Schemers help out if I'm talking nonsense) Thing is that the "slot" (which I'll represent as "#") in (f 1 # 4) just expects *one* value. And multiple value returns (as returned by "values" are built to only yield one value when expected to do so (the first one), so your code will "see" (f 1 2 4) and complain that you're "holding" f "wrong". If you want to build a function taking multiple values you'll have to use "call-with-values". I think you'll find it easier to reason first about an f which takes as many args as your conditionals produce, so you won't be struggling to splice your "bunch of values" into a bigger argument list. For example (using list here, but could use multiple values too): (define weather 'fine) (define (mood) (if (eq weather 'fine) (list "very" "good") (list "pretty" "bad"))) (apply string-append (mood)) => "verygood" (set! weather 'so-so) (apply string-append (mood)) => "prettybad" Is that the direction you are trying to take? Cheers - -- t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlrE47wACgkQBcgs9XrR2kYPBwCfTxPUCELmJz67+luFK4e0s2il ExsAnjdUCxW1atS5ojsv+Rqm9XkBO+aI =sWuA -----END PGP SIGNATURE-----