Share on Facebook Share on Twitter Email
Answers.com

append

 
(ə-pĕnd') pronunciation
tr.v., -pend·ed, -pend·ing, -pends.
  1. To add as a supplement or appendix: appended a list of errors to the report.
  2. To fix to; attach: append a charm to the bracelet.

[Latin appendere, to hang upon : ad-, ad- + pendere, to hang.]


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
TechEncyclopedia:

append

Top

To add to the end of an existing structure.

Download Computer Desktop Encyclopedia to your PC, iPhone or Android.

Roget's Thesaurus:

append

Top

verb

    To add as a supplement or an appendix: affix, annex, attach, subjoin. See increase/decrease.


v

Definition: add, join
Antonyms: disjoin, subtract, take away

  See crossword solutions for the clue Append.

In general, to append is to join or add on to the end of something. For example, an appendix is a section appended (added to the end) of a document.

In computer programming, append is the name of a procedure for concatenating (linked) lists or arrays in some high-level programming languages.

Contents

Lisp

Append originates in the Lisp programming language. The append procedure takes zero or more (linked) lists as arguments, and returns the concatenation of these lists.

(append '(1 2 3) '(a b) '() '(6))
;Output: (1 2 3 a b 6)

Since the append procedure must completely copy all of its arguments except the last, both its time and space complexity are O(n) for a list of n elements. It may thus be a source of inefficiency if used injudiciously in code.

The nconc procedure (called append! in Scheme) performs the same function as append, but destructively: it alters the cdr of each argument (save the last), pointing it to the next list.

Implementation

Append can easily be defined recursively in terms of cons. The following is a simple implementation in Scheme, for two arguments only:

(define append
  (lambda (ls1 ls2)
    (if (null? ls1)
      ls2
      (cons (car ls1) (append (cdr ls1) ls2)))))

Append can also be implemented using fold-right:

(define append
   (lambda (a b)
      (fold-right cons b a)))

Other languages

Following Lisp, other high-level languages which feature linked lists as primitive data structures have adopted an append. Haskell uses the ++ operator to append lists. OCaml uses the @ operator to append lists.

Other languages use the + or ++ symbols for nondestructive string/list/array concatenation.

Prolog

The logic programming language Prolog features a built-in append predicate, which can be implemented as follows:

append([],Ys,Ys).
append([X|Xs],Ys,[X|Zs]) :-
    append(Xs,Ys,Zs).

This predicate can be used for appending, but also for picking lists apart. Calling

 ?- append(L,R,[1,2,3]).

yields the solutions:

L = [], R = [1, 2, 3] ;
L = [1], R = [2, 3] ;
L = [1, 2], R = [3] ;
L = [1, 2, 3], R = []

Miranda

This right-fold, from Hughes (1989:5-6), has the same semantics (by example) as the Scheme implementation above, for two arguments.

append a b = reduce cons b a

Where reduce is Miranda's name for fold, and cons constructs a list from two values or lists.

For example,

append [1,2] [3,4] = reduce cons [3,4] [1,2]
    = (reduce cons [3,4]) (cons 1 (cons 2 nil))
    = cons 1 (cons 2 [3,4]))
        (replacing cons by cons and nil by [3,4])
    = [1,2,3,4]

Haskell

This right-fold has the same effect as the Scheme implementation above:

append :: [a] -> [a] -> [a]
append xs ys = foldr (:) ys xs

This is essentially a reimplementation of Haskell's ++ operator.

Perl

In Perl, the push function is equivalent to the append method, and can be used in the following way.

my @list;
push @list, 1;
push @list, 2, 3;

The end result is a list containing [1, 2, 3]

The unshift function appends to the front of a list, rather than the end

my @list;
unshift @list, 1;
unshift @list, 2, 3;

The end result is a list containing [2, 3, 1]

When opening a file, use the ">>" mode to append rather than over write.

open(my $fh, '>>', "/some/file.txt");
print $fh "Some new text\n";
close $fh;

Note that when opening and closing file handles, one should always check the return value.

Python

In Python, the list append method can be used in the following way.

list = [1, 2]
list.append(3)

The end result is a list containing [1, 2, 3]

Bash

In Bash the append redirect is the usage of ">>" for adding a stream to something, like in the following series of shell commands:

echo Hello world! >text; echo Goodbye world! >>text; cat text

The stream "Goodbye world!" is added to the text file written in the first command. The ";" implies the execution of the given commands in order not simultaneously. So, the final content of the text file is:

Hello world!

Goodbye world!

DOS command

append is a DOS command that allows programs to open data files in specified directories as if they were in the current directory. It appends the directories to the search path list.

References


Translations:

Append

Top

Dansk (Danish)
v. tr. - vedhæfte, vedføje, vedlægge

Nederlands (Dutch)
bijvoegen (aan document etc.)

Français (French)
v. tr. - ajouter, joindre, annexer, apposer (une signature), (Comput) ajouter (à la fin d'un fichier)

Deutsch (German)
v. - anhängen, beifügen

Ελληνική (Greek)
v. - επισυνάπτω, προσθέτω, προσαρτώ, θέτω/βάζω υπογραφή, σφραγίδα κτλ.

Italiano (Italian)
aggiungere, sospendere

Português (Portuguese)
v. - juntar, anexar, suplementar

Русский (Russian)
прибавлять, прилагать

Español (Spanish)
v. tr. - añadir, adjuntar

Svenska (Swedish)
v. - bifoga, tillägga

中文(简体)(Chinese (Simplified))
悬挂, 添加, 附加

中文(繁體)(Chinese (Traditional))
v. tr. - 懸掛, 添加, 附加

한국어 (Korean)
v. tr. - 을 부가하다, 을 붙이다

日本語 (Japanese)
v. - 添える, 追加する

العربيه (Arabic)
‏(فعل) يلحق, يذيل, يضيف‏

עברית (Hebrew)
v. tr. - ‮צירף, הוסיף‬


 
 
Related topics:
appendicate
DOS Append (technology)
prepend (computer jargon)

Related answers:
What is the past tense of append? Read answer...
What does the word \'append mean? Read answer...
How do you append a output of a program to a program? Read answer...

Help us answer these:
What is append querry?
How do you append a message?
What is the append function?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

American Heritage Dictionary. The American Heritage® Dictionary of the English Language, Fourth Edition Copyright © 2007, 2000 by Houghton Mifflin Company. Updated in 2009. Published by Houghton Mifflin Company. All rights reserved.  Read more
TechEncyclopedia. THIS DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2012 The Computer Language Company Inc.  All rights reserved.  Read more
Roget's Thesaurus. Roget's II: The New Thesaurus, Third Edition by the Editors of the American Heritage® Dictionary Copyright © 1995 byHoughton Mifflin Company. Published by Houghton Mifflin Company. All rights reserved.  Read more
Answers Corporation Antonyms by Answers.com. © 1999-present by Answers Corporation. All rights reserved.  Read more
 Rhymes. Oxford University Press. © 2006, 2007 All rights reserved.  Read more
Bradford's Crossword Solver's Dictionary. Collins Bradford's Crossword Solver's Dictionary © Anne Bradford, 1986, 1993, 1997, 2000, 2003, 2005, 2008 HarperCollins Publishers All rights reserved.  Read more
Wikipedia on Answers.com. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article Append Read more
Translations. Copyright © 2007, WizCom Technologies Ltd. All rights reserved.  Read more

Follow us
Facebook Twitter
YouTube

Mentioned in

» More» More