Apply a callback to an array: Difference between revisions

(added hyper form)
Line 1,116:
Applying native function with 'map':
ok [[2 4 6] = map :square-root [4 16 36]]</pre>
 
=={{header|RLaB}}==
RLaB has two type of arrays: 'standard' or 1-dimensional, that can be a row-
or a column-vectory; and, 'associative' which are called lists.
For standard array its entry identifier (index) is an integer in
range 1:N where N is the size of the array.
For associative array its entry identifier is a string consisting of printable
ASCII characters.
 
All scalar mathematical functions are 'matrix-optimized' meaning that if the argument
to a function is a matrix, then the return value of the function is a matrix of the
same size as the input argument, where the function is applied to individual entry
of the matrix.
Consider an example:
 
 
<lang RLaB>
>> x = rand(2,4)
0.707213207 0.275298961 0.396757763 0.232312312
0.215619868 0.207078017 0.565700032 0.666090571
>> sin(x)
0.649717845 0.271834652 0.386430003 0.230228332
0.213952984 0.205601224 0.536006923 0.617916954
</lang>
 
 
=={{header|Ruby}}==
Anonymous user