guile-devel
[Top][All Lists]
Advanced

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

take! 0==1?


From: Jan Nieuwenhuizen
Subject: take! 0==1?
Date: Fri, 12 Jul 2013 09:14:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

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



reply via email to

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