Array: Get the length of an array
Tasks: 1.Create an array 2.Print the array length
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create an array 2.Print the array length
Bash | Perl | Python |
---|---|---|
|
|
|
In perl Double dots is called 'range operator',which is useful for writing 'foreach (1..4)' loops and for doing slice operations on arrays for example: @foo = @foo[$#foo-4 .. $#foo]; # slice last 5 items
Tasks: 1.Create an array 2.Print all elements 3.Print elements at index 0~2 respectively 4.Print two consecutive elements start from index 0 5.Print elements starting with index 2 6.Print the last element
Bash | Perl | Python |
---|---|---|
|
|
|
Python normally uses list and tuple as array
Tasks: 1.Create an array with three elements 2.Iterate over the array
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Get the index of the element with value 'duchess'
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Append a element to array
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Insert a element to array
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create an array 2.Remove the 2nd element 3.Alternative ways to remove an element
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Remove all elements with value of "duchess"
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Remove "duchess" with "hare" for all elements
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Sort all the elements
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Reverse all the elements
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create two arrays 2.concatenate the two arrays
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.Create a array 2.Concatenate all elements to a string with '-'
Bash | Perl | Python |
---|---|---|
|
|
|