Swift - Populating array from JSONElemetns

I am using the JSONSerializer to access data from a SQL database. I am managing to get the data to read in with no problems and managing to get each entry and create an temporary object with each entry. I added each object to an array. However, when ...
more »

2017-02-16 13:02 (1) Answers

Cast raw pointer of array to unique_ptr

I am working against a blackbox framework (cdg), which fills an array of uint32_t with values. The call looks like that: std::size_t dataCount = 100; uint32_t* data = new uint32_t[dataCount]; cdg.generate(data); Unfortunately, the framework doesn...
more »

2017-02-16 11:02 (1) Answers

Counting number divisible by 10 in an array

I was given an assignment that made me create 3 methods that created an array, print an array, and count all the numbers divisible by 10 in a array. The part that is giving me the most trouble is counting the numbers divisible by 10. the is the code ...
more »

2017-02-16 05:02 (2) Answers

C - Unusual array initialization

I am working on some legacy C code that has this unusual array initialization: uint32_t defsMB40000[REG40000_SIZE] = { #include "modbusDefs40000.h" }; The header file is a list of comma separated numbers and comments. I have never seen this con...
more »

2017-02-15 21:02 (1) Answers

Fill 1D array from matrix

I have a matrix, my mission is to fill 1D array from my matrix. Example: 1 2 3 1 2 3 1 2 3 I need to sum the columns and fill the sum of every column in a 1D array Here is my code (that doesn't work), (int[,] mat) is the matrix that the functio...
more »

2017-02-15 14:02 (4) Answers

define array with unsure size

As I understand it, when we define an array like const char argv[SIZE]; "SIZE" must be a number which is known at compile time. But recently I read AOSP code, and found this: http://androidxref.com/5.1.1_r6/xref/system/netd/server/NetdConstants.cpp#...
more »

2017-02-15 09:02 (1) Answers

Passing by reference to a template function

I'm having a function of finding max and I want to send static array via reference, Why isn't this possible? template <class T> T findMax(const T &arr, int size){...} int main{ int arr[] = {1,2,3,4,5}; findMax(arr, 5); // I cannot sen...
more »

2017-02-15 06:02 (1) Answers

Matching entries in arrays powershell

I have two data sets one is a data table pulled back from a SQL date base and the other is a data set pulled back from Active directory $HRusers = Invoke-SQL ## this calls a function to get data from SQL $adusers = get-aduser -filter * -Properties s...
more »

2017-02-14 16:02 (0) Answers

Iterating for `setindex!`

I have some specially-defined arrays in Julia which you can think of being just a composition of many arrays. For example: type CompositeArray{T} x::Vector{T} y::Vector{T} end with an indexing scheme getindex(c::CompositeArray,i::Int) = i <...
more »

2017-02-14 14:02 (1) Answers

Combing Array Inline - LINQ

I am initialising and array from items in a list as follows: MyArray[] Arrayitems = SomeOtherList .Select(x => new MyArray[] { ArrayPar1 = x.ListPar1, }).ToArray() I have a secondary List that i would like to add to the same array inline in ...
more »

2017-02-14 10:02 (1) Answers

Sum of array elements as constexpr

I'm trying to get the sum of a const int array as a constexpr so that I can use sum as the size of another array constexpr int arr[] = {1, 2, 3}; constexpr int sum1 = std::accumulate(arr, arr + 3, 0); // not OK int arr1[sum1]; The above does not c...
more »

2017-02-14 07:02 (5) Answers

Why isn't my array saving the results?

My code has a constructor which inputs the position and integer into the selected position as wished by the user up to and including 20 possible entries. Then it returns the result as an array from my constructor.... the only issue is that it is no...
more »

2017-02-14 05:02 (1) Answers

Circular pairs from array?

I can't believe this is nowhere to be found, but: I want all consecutive pairs from an array, including the last element with the first one. I tried: [(a, b) for a, b in zip(list, list[1:])] What is the most pythonic and efficient way to do it? ...
more »

2017-02-13 23:02 (4) Answers

Group similar strings from an array in Node.js

Let's say I have a collection of different URLs in an array: var source = ['www.xyz.com/Product/1', 'www.xyz.com/Product/3', 'www.xyz.com/Category/1', 'somestring'] What would be a good way to iterate over the array and group similar strings into ...
more »

2017-02-13 21:02 (2) Answers

Cast to right generic from array in Swift

I have a Protocol called Composite. This protocol has an array composites: [Composite] I also have a generic subclass GenericSubclass<T>: Composite When iterating over the array the best I can come up with looks like this: for item in compo...
more »

2017-02-13 14:02 (0) Answers

Why PHP loose item value of array?

I have the array with values: $array1 = array('Boss', 'Lentin', 'Endless'); print_r ($array); The result will be: Array ( [0] => Boss [1] => Lentin [2] => Endless It's ok. But, if I add two elements to this array with a keys, the "B...
more »

2017-02-13 13:02 (6) Answers