Apply a callback to an array: Difference between revisions

Content added Content deleted
Line 1,159: Line 1,159:
of the function what to do with the list elements. Given a list call it 'x' there is a RLaB
of the function what to do with the list elements. Given a list call it 'x' there is a RLaB
function 'members' which returns a string vector with the names of the elements of the list.
function 'members' which returns a string vector with the names of the elements of the list.

<lang RLaB>
x = <<>>;
for (i in 1:9)
{
x.[i] = rand();
}

y = <<>>;
for (i in members(x))
{
y.[i] = sin( x.[i] );
}
</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==