This question already has answers here:
How does one declare an array in VBScript?
(2 answers)
Closed 5 years ago.
how to create array and display required array value. For example:
Arr[0]="anand" Arr[1]="bala".print Arr optin:2, Bala .
i need the required array output
Queat seems a bit unclear.
May be below piece of code can be relevent to your Question.
'Initializing & Filling up array
Dim testArr(3)
testArr(0)="First"
testArr(1)="Second"
testArr(2)="Third"
Dim Iterator,userInput
'If you Need ro validate the User input you need to use Err Object.
'Like if it's number or not/Is teh User Provided value is positive or not/ etc. etc. which i'm not doing now)
userInput=Cint(inputbox("Please enter a Positive number between 1-" & Ubound(testArr)))
If userInput<=Ubound(testArr) Then
MsgBox(testArr(userInput-1))
Else
MsgBox("Wrong Value Provided. Not Applicable Array Index Number !!!")
End If
This question already has answers here:
Ruby method to sum all values in a multidimensional array
(5 answers)
Closed 6 years ago.
I've been looking for the answer to this. Maybe I haven't looked hard enough. This question has stumped me.
stairs = [[sunday],[monday],[tuesday],[wednesday],[thursday],[friday],[saturday]]
sunday = [6737, 7244, 5776, 9826, 7057, 9247, 5842, 5484, 6543, 5153, 6832, 8274, 7148, 6152, 5940, 8040, 9174, 7555, 7682, 5252, 8793, 8837, 7320, 8478, 6063, 5751, 9716, 5085, 7315, 7859, 6628, 5425, 6331, 7097, 6249, 8381, 5936, 8496, 6934, 8347, 7036, 6421, 6510, 5821, 8602, 5312, 7836, 8032, 9871, 5990, 6309, 7825]
each day has their own set of values. How do I find the sum of all the values within the array? I apologize if this has already been asked. I am a beginner and I'm finding it difficult just searching for answers to my questions.
Could be as simple as this:
stairs.flatten.inject(0, &:+)
This question already has answers here:
Convert cell to array in matlab
(3 answers)
Closed 6 years ago.
I am using Matlab and I have the following data:
a = {'3' '11' '7'}; % This is what I have.
My goal is to use a function to convert such cell into a vector having the following shape:
b = [3 11 7]; % What I need to get!
If I try to use the b = cell2mat(a) function the result that I get is this number: b = 3117; which is not what I want.
What function should I use to reach my goal? If possible please do not use for loops but just Matlab functions.
You're looking for str2double:
b = str2double(a);
This question already has answers here:
Word frequency count Java 8
(11 answers)
Closed 7 years ago.
I have an Object[] array
I need to create map Map<Obejct, Integer>, where Integer value contains frequency of key Object in array.
How can i do it in java 8 style, using Collectors?
You can do (I hope I don't have any typos) :
Map<Object,Long> map = Stream.of(array)
.collect(Collectors.groupingBy(o -> o,
Collectors.counting()));
This should group the elements of the array by equality and count the number of Objects in each group.
This question already has answers here:
Concatenate two cell arrays of strings with a space in between?
(3 answers)
Closed 8 years ago.
Say I have a cell arrays like
a = {'abcde', 'fghi'};
b = {'jkl', 'mn'};
ab = strcat(a, b)
ab =
'abcdejkl' 'fghimn'
But I do not want 'abcdejk', I need 'abcde jkl' and also ' fghi mn'
with that little space there
Add a space cell by using ab = strcat(a,{' '},b)