B
Bryan
Hi,
Two questions, which may be related...
1. If I have an array:
@a = (1, 2, 3, 4);
And I want to process each element in the array with some algorithm,
lets say multiply each element by 2, is there a way to do this without
creating a temp array, and -without- looping?
Something along the lines of @a * 2, and @a would then be (2, 4, 6, 8)?
2. If I have two arrays:
@a = (1, 2, 3, 4);
@b = (2, 4, 6, 8);
Is there a way to create a 3rd array of the same size such that @c = @a
+ @b, and after the operation @c = (3, 6, 9, 12). Again, without using
a for or a foreach loop??
Thanks,
Bryan
Two questions, which may be related...
1. If I have an array:
@a = (1, 2, 3, 4);
And I want to process each element in the array with some algorithm,
lets say multiply each element by 2, is there a way to do this without
creating a temp array, and -without- looping?
Something along the lines of @a * 2, and @a would then be (2, 4, 6, 8)?
2. If I have two arrays:
@a = (1, 2, 3, 4);
@b = (2, 4, 6, 8);
Is there a way to create a 3rd array of the same size such that @c = @a
+ @b, and after the operation @c = (3, 6, 9, 12). Again, without using
a for or a foreach loop??
Thanks,
Bryan