Questions tagged [append]

To append is to join or add on to the end of something.

Append is an operation usually defined on 1D data structures (e.g., , , , , etc.).
The append operation adds an element to the end of the data structure, consequently, increasing its size by one.

11138 questions
44
votes
3 answers

Remove and adding elements to array in GO lang

I have 2 arrays declared as : var input []string and var output []string . The input array is filled with some IDs initially. Output array is NULL. After every iteration I want to remove a random element from input array and add it to output…
fnaticRC ggwp
  • 955
  • 1
  • 11
  • 20
44
votes
3 answers

python append to array in json object

I have the following json object in python: jsonobj = { "a": { "b": { "c": var1, "d": var2, "e": [], }, }, …
swoosh
  • 639
  • 2
  • 9
  • 17
43
votes
10 answers

Creating a LinkedList class from scratch

We were given an assignment to create a LinkedList from scratch, and there are absolutely no readings given to guide us on this migrane-causing task. Also everything online seems to just use Java's built in LinkedList methods and stuff. Anyway,…
Snowman
  • 31,411
  • 46
  • 180
  • 303
43
votes
4 answers

jQuery: append() object, remove() it with delay()

what's wrong with that? $('body').append("
Upload successful!
"); $('.message').delay(2000).remove(); I want to append a success message to my html document, but only for 2sec. After that the div should be deleted…
matt
  • 42,713
  • 103
  • 264
  • 397
42
votes
7 answers

Possible to append multiple lists at once? (Python)

I have a bunch of lists I want to append to a single list that is sort of the "main" list in a program I'm trying to write. Is there a way to do this in one line of code rather than like 10? I'm a beginner so I have no idea... For a better picture…
anon
  • 1,407
  • 3
  • 14
  • 12
41
votes
7 answers

Appending item to lists within a list comprehension

I have a list, let's say, a = [[1,2],[3,4],[5,6]] I want to add the string 'a' to each item in the list a. When I use: a = [x.append('a') for x in a] it returns [None,None,None]. But if I use: a1 = [x.append('a') for x in a] then it does…
ariel
  • 2,637
  • 4
  • 20
  • 12
41
votes
2 answers

How can I append to a vector in Octave?

When ever I have to append to a vector I am doing this. A = [2 3 4] A = [A; 3 4 5] I was wondering if there are any inbuilt functions for this or more elegant ways of doing this in Octave.
Aditya
  • 1,240
  • 2
  • 14
  • 38
41
votes
5 answers

check if a number already exist in a list in python

I am writing a python program where I will be appending numbers into a list, but I don't want the numbers in the list to repeat. So how do I check if a number is already in the list before I do list.append()?
PhoonOne
  • 2,678
  • 12
  • 48
  • 76
40
votes
12 answers

Idiomatic efficient Haskell append?

List and the cons operator (:) are very common in Haskell. Cons is our friend. But sometimes I want to add to the end of a list instead. xs `append` x = xs ++ [x] This, sadly, is not an efficient way to implement it. I wrote up Pascal's triangle in…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
40
votes
5 answers

ValueError: all the input arrays must have same number of dimensions

I'm having a problem with np.append. I'm trying to duplicate the last column of 20x361 matrix n_list_converted by using the code below: n_last = [] n_last = n_list_converted[:, -1] n_lists = np.append(n_list_converted, n_last, axis=1) But I get…
odo22
  • 590
  • 1
  • 7
  • 16
39
votes
4 answers

C++ std::string append vs push_back()

This really is a question just for my own interest I haven't been able to determine through the documentation. I see on http://www.cplusplus.com/reference/string/string/ that append has complexity: "Unspecified, but generally up to linear in the…
Memento Mori
  • 3,327
  • 2
  • 22
  • 29
38
votes
4 answers

Can I extend list in Python with prepend elements instead of append?

I can perform a = [1,2,3] b = [4,5,6] a.extend(b) # a is now [1,2,3,4,5,6] Is there way to perform an action for extending list and adding new items to the beginning of the list? Like this a = [1,2,3] b = [4,5,6] a.someaction(b) # a is now…
Daniil Grankin
  • 3,841
  • 2
  • 29
  • 39
38
votes
5 answers

remove last append element jquery

I have the following code: $(this).children("a:eq(0)").append('' ); Now I want to remove last appended element (an image). Please give…
Basharat Ali
  • 381
  • 1
  • 3
  • 3
38
votes
3 answers

Appending to the end of a file with NSMutableString

I have a log file that I'm trying to append data to the end of. I have an NSMutableString textToWrite variable, and I am doing the following: [textToWrite writeToFile:filepath atomically:YES encoding:…
Julian Coltea
  • 3,599
  • 10
  • 26
  • 32
37
votes
5 answers

Appending a line break to an output file in a shell script

I have a shell script that I am executing in Cygwin (maybe this is the problem). For this bit of code, I simply want to write the first line, and append a line break: echo "`date` User `whoami` started the script." >> output.log echo >>…
Ode
  • 465
  • 1
  • 5
  • 12