Retrieving an Element of an Array: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 28: | Line 28: | ||
(defun array-value (array index) |
(defun array-value (array index) |
||
(aref array index)) |
(aref array index)) |
||
==[[Perl]]== |
|||
'''Interpreter:''' [[Perl]] 5.8.8 |
|||
#!/usr/bin/perl |
|||
$elem = $array[0]; |
|||
==x86 assembly== |
==x86 assembly== |
Revision as of 19:20, 22 January 2007
Retrieving an Element of an Array
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
In this task, the goal is to retrieve an element of an array.
mIRC
Interpeter: mIRC Script Editor Library: mArray Snippet
alias readmyarray { echo -a $array_read(MyArray, 2, 3) }
C
int array_index(int array[], int index) { return array[index]; }
C++
template <class T> T array_index(T *array, int index) { return array[index]; }
C#
int getArrayValue( int values[], int index ) { return values[index]; }
Common Lisp
(defun array-value (array index) (aref array index))
Perl
Interpreter: Perl 5.8.8
#!/usr/bin/perl
$elem = $array[0];
x86 assembly
Assembler: nasm
mov esi, array_offset mov ebx, 2 mov eax, [esi+ebx*4]