unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Thomas Morley <thomasmorley65@gmail.com>
To: calcium <calcium@disroot.org>
Cc: guile-user@gnu.org
Subject: Re: help : call function with args
Date: Thu, 5 Apr 2018 10:54:16 +0200	[thread overview]
Message-ID: <CABsfGyVV6g1T3FvdjM8y-AfmnKkvSXO0YK0SMHeeA7VqdzD_fA@mail.gmail.com> (raw)
In-Reply-To: <531867ae-fc67-35dc-e480-968678eed296@disroot.org>

2018-04-05 10:16 GMT+02:00 calcium <calcium@disroot.org>:
>> 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.
>
> yes, thank you tomas,
> i stopped trying to return multiples values, and instead call the
> functions with the right numbers of args, and using the cond statement
> to change the values of args.
>
> (define (f a b c d)
>   (+ a b c d))
>
> (let ((a 1)
>       (b #f)
>       (c #f)
>       (d 10))
>   (cond (#t (set! b 2)
>             (set! c 3))
>         (else
>          (set! b 6)
>          (set! c 10)))
>   (f a b c d))
>

Not sure what you aim at.
Though, above seems to be easier with:

(define (f . rest) (apply + rest))

(f)
-> 0
(f 1 2 3)
-> 6
(f 1 2 3 4 5 6 7 8 9 10)
-> 55

Cheers,
  Harm



  reply	other threads:[~2018-04-05  8:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  8:16 help : call function with args calcium
2018-04-05  8:54 ` Thomas Morley [this message]
2018-04-05  9:42   ` calcium
     [not found] <1f5de71a-c5aa-b850-023e-96fdd471dab5@disroot.org>
2018-04-04  8:01 ` calcium
  -- strict thread matches above, loose matches on Subject: below --
2018-04-04  7:43 calcium
2018-04-04 14:39 ` tomas
2018-04-03 20:43 amnesia
2018-04-03 22:40 ` Mark H Weaver
2018-04-04  7:27 ` tomas

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=CABsfGyVV6g1T3FvdjM8y-AfmnKkvSXO0YK0SMHeeA7VqdzD_fA@mail.gmail.com \
    --to=thomasmorley65@gmail.com \
    --cc=calcium@disroot.org \
    --cc=guile-user@gnu.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).