* cons* versus apply
@ 2005-04-20 22:23 Kevin Ryde
0 siblings, 0 replies; only message in thread
From: Kevin Ryde @ 2005-04-20 22:23 UTC (permalink / raw)
cons* seems to mutate a list given to it from apply,
(define x '(1 2 (3 4)))
(apply cons* x)
x
=> (1 2 3 4)
New code not changing the rest arg:
SCM_DEFINE (scm_cons_star, "cons*", 1, 0, 1,
(SCM arg, SCM rest), "...")
#define FUNC_NAME s_scm_cons_star
{
SCM ret = SCM_EOL;
SCM *p = &ret;
SCM_VALIDATE_REST_ARGUMENT (rest);
for ( ; scm_is_pair (rest); rest = SCM_CDR (rest))
{
*p = scm_cons (arg, SCM_EOL);
p = SCM_CDRLOC (*p);
arg = SCM_CAR (rest);
}
*p = arg;
return ret;
}
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-04-20 22:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-20 22:23 cons* versus apply Kevin Ryde
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).