Problem 1504. Perl 3: shift
This is part of a series of perl function which were very helpful for many perl programmers. Could you implement it in Matlab?
Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down.
Example:
x=[1 2 3 4 5]
[a, x]=shift(x)
then
x=[2 3 4 5]
a=1
Solution Stats
Problem Comments
-
3 Comments
Jean-Marie Sainthillier
on 13 May 2013
Error in the example (x=[2 3 4 5])
Clemens Giegerich
on 14 May 2013
Typo, thanks!
Dyuman Joshi
on 21 Feb 2023
The test suite has been updated to use isempty instead of isequal, and test cases have been added.
Solution Comments
Show commentsProblem Recent Solvers63
Suggested Problems
-
Select every other element of a vector
33943 Solvers
-
4558 Solvers
-
Increment a number, given its digits
660 Solvers
-
Permute diagonal and antidiagonal
463 Solvers
-
7367 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!