[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `append' vs. `nconc'
From: |
Emanuel Berg |
Subject: |
Re: `append' vs. `nconc' |
Date: |
Thu, 31 Dec 2015 04:37:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Teemu Likonen <tlikonen@iki.fi> writes:
> Given the following:
>
> (append list1 list2 list3 last)
>
> (nconc list1 list2 list3 last)
>
> APPEND copies LIST1, LIST2 and LIST3 but not LAST.
> All original lists remain untouched but LAST becomes
> part of the new list returned by APPEND.
I think I always used `append' as if it were
(append list1 ... listn '())
probably the reason it never bit me was I never did
much with the lists returned.
> NCONC doesn't copy lists but modifies LIST1's,
> LIST2's and LIST3's last cons's CDR to point to the
> next list. NCONC returnes the joined list. Only LAST
> remains untouched.
OK, so for example this:
(setq completion-ignored-extensions
(append completion-ignored-extensions '(".bcf" ".run.xml")) )
Is better as:
(nconc completion-ignored-extensions (list ".bcf" ".run.xml"))
?
>> I have several appends in my source, is there
>> a rule-of-thumb when to use `append' and when to
>> use `nconc'?
>
> You can use NCONC if it's safe to modify the lists,
> that is, you know where the lists come from and know
> how they are used. Don't modify a list created with
> '(...). Use (list ...) instead.
OK.
--
underground experts united
http://user.it.uu.se/~embe8573
- Error: Setting the shell in sh-mode via a local variable does not work, Johannes Kastl, 2015/12/28
- Re: Error: Setting the shell in sh-mode via a local variable does not work, Teemu Likonen, 2015/12/30
- `append' vs. `nconc' (was: Re: Error: Setting the shell in sh-mode via a local variable does not work), Emanuel Berg, 2015/12/30
- Re: `append' vs. `nconc', Teemu Likonen, 2015/12/30
- Re: `append' vs. `nconc',
Emanuel Berg <=
- Message not available
- Re: `append' vs. `nconc', Pascal J. Bourguignon, 2015/12/30
- Re: `append' vs. `nconc', Emanuel Berg, 2015/12/30
- Re: `append' vs. `nconc', tomas, 2015/12/31
- Re: `append' vs. `nconc', Emanuel Berg, 2015/12/31
- Message not available
- Re: `append' vs. `nconc', Pascal J. Bourguignon, 2015/12/31
- Re: `append' vs. `nconc', Emanuel Berg, 2015/12/30
- Message not available
- Re: `append' vs. `nconc', Pascal J. Bourguignon, 2015/12/31
- Re: `append' vs. `nconc', Emanuel Berg, 2015/12/31
- Re: `append' vs. `nconc', tomas, 2015/12/31
- side effects, list sharing [was: `append' vs. `nconc'], Drew Adams, 2015/12/31