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 <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ®  http://AvatarAcademy.nl  

Reply via email to