unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* take! 0==1?
@ 2013-07-12  7:14 Jan Nieuwenhuizen
  2013-07-12  7:42 ` William ML Leslie
  2013-07-12  7:57 ` William ML Leslie
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2013-07-12  7:14 UTC (permalink / raw)
  To: guile-devel

Hi,

Reading the documentation of take!

    -- Scheme Procedure: take lst i
    -- Scheme Procedure: take! lst i
        Return a list containing the first I elements of LST.

        `take!' may modify the structure of the argument list LST in order
        to produce the result.

its behaviour surpsises me.

For list LST, (take! lst 0) leaves LST in the same state
as (take! lst 1) does.  Worse, the return value suggests
that it worked

    scheme@(guile-user)> (use-modules (srfi srfi-1))
    scheme@(guile-user)> (define lst '(a))
    scheme@(guile-user)> (take! lst 0)
    $4 = ()
    scheme@(guile-user)> lst
    $5 = (a)
    scheme@(guile-user)> (take! lst 1)
    $6 = (a)
    scheme@(guile-user)> lst
    $7 = (a)
    scheme@(guile-user)>

How are you doing such things?  Is anyone using take! at all to reduce a
list to n elements?  Using list-cdr-set! and set!/list-set! also seems a bit
clumsy.

Greetings, Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-12 16:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-12  7:14 take! 0==1? Jan Nieuwenhuizen
2013-07-12  7:42 ` William ML Leslie
2013-07-12  7:57 ` William ML Leslie
2013-07-12 16:57   ` Resolved: ! often means may, not will [WAS: Re: take! 0==1?] Jan Nieuwenhuizen

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).