# Can't Understand Pseudocode in Wikipedia

Im trying to read this wikipedia article, and im struggling with understanding what some of these symbols are supposed to mean: In Place Alhorithm

`````` function reverse(a[0..n - 1])
allocate b[0..n - 1]
for i from 0 to n - 1
b[n − 1 − i] := a[i]
return b
``````
1. I dont know what it means by ‘allocate’?
2. No idea what := would imply.

Lastly, is there a standard syntax for this type of ‘pseudo code’, or is it just randomly up to the author? Are there any online materials that cover this concept?

Maybe this resource could help.

For me, personally, this is crap pseudocode. I am way too informal. That said, what they mean by ‘allocate’ is ‘allow a space in the memory for’ or ‘declare a variable’. In js, that would be `let b = []` or `let b = new Array(a.length)`. As to what := means, it’s the cute way of saying ‘set this equal to that’. In js, that would be `b[a.length-i] = a[i];`

That said, were I to pseudocode that, it seems to me that the whole point of me pseudocoding is so I can understand what it is I’m about to write. If I don’t understand my artificial language, I need to drop it and use a different one. Here’s how I’d pseudocode it:

``````function reverse(arr1){
create a second array, empty but of the same length as arr1 (we'll call it arr2)
loop from zero to the length of arr1, and {
set the arr2 member, indexed from the end, to the value of arr1 at this index
(so the last index of arr2 gets the first index of arr1, the second-to-last of arr2 = second of arr1...)
}
}
``````

of course, in javascript, it would be TRULY complicated:

``````function reverse(arr1){
return arr1.reverse();
}
``````

in languages that have a push/pop syntax, the easiest way to do this would be like this:

``````function reverse(arr1=[]){
let tempArr = [...arr1]; // or whatever mechanism you prefer to clone the array
let arr2 = [];
while (tempArr.length>0){
arr2.push( tempArr.pop() );
}
return arr2;
}
``````

This is functional, in that the array passed in is cloned rather than modified. And it removes the first element from that array and crams it onto the beginning of our new array, and repeats that, pushing the elements on the front and reversing the whole thing.