guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make an element last element of a list


From: rm
Subject: Re: make an element last element of a list
Date: Tue, 21 Oct 2003 17:50:09 +0200
User-agent: Mutt/1.5.3i

On Tue, Oct 21, 2003 at 05:08:42PM +0200, Laurent Marzullo wrote:
> Hello all,
> 
> I've got a scheme list 
> 
> SCM   scm_game_list;
> 
> and I want to add, with C API, an elements at the end of
> the list.

If you want to destrutively modify your list you can do the
following:
 
 (define my-lst (list 1 2 3 4))
 (define new-last (list 5))
 (set-cdr! (last my-lst) new-last)

using the c functions 
 

 SCM new_last =  scm_cons( new_elem , SCM_EOL );

 scm_set_cdr_x ( scm_last_pair (my_lst),  new_last );

HTH Ralf Mattes


> Is there any function to do this or must I go throw the entire
> list and adding a new scm_cons( new_elem , SCM_EOL ) at the end ?
> 
> Thanks
> -- 
> Laurent Marzullo <address@hidden>
> 
> 
> 
> _______________________________________________
> Guile-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]