The array tag has no wiki summary.
0
votes
0answers
29 views
PHP: How can I let 2 functions come together in 1 function and then divide the 2 arrays that come along with it [migrated]
Currently I am making a bidding algorythm. I have been struggling to make 2 functions(which do work seperately) into one and then mathematically divide them by each other.
It has to be calculated ...
0
votes
2answers
120 views
Quick algorithm to find matches between two arrays
I'm faced with the following problem:
I have an array which is produced by the parsing of a yaml file which contains patterns in the following structure.
"Programming books"
Title:
a ...
3
votes
3answers
424 views
How do you read this line of code?
Forgive me for my poor English, me and my friend were doing school homework, suddenly he asked me to read this line of code ptr = &array[1][1][1] (ptr is a pointer to an integer).
He said
...
-3
votes
0answers
34 views
separating strings from an array of pointers [migrated]
I am having two arrays of pointers i.e.
char *a[3]= {"man","dog","cat"};
char *b[3]= {"job","rain","sleep"};
and I want to separate the three strings of both above ...
3
votes
2answers
633 views
Should I use a list or an array?
I'm working on a windows form to calculate UPC for item numbers.
I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item ...
0
votes
1answer
60 views
What is a cross-platform way to expose an Array[][] over a webservice? Any JSON nuances to be aware of?
I need to expose an Array[][] to many different clients (iPhone, Android, PC, Unix, etc), and need to make it available over HTTP/s
This brings me to JSON, and makes me wonder how do all the other ...
0
votes
2answers
150 views
PHP SplFixedArray How To Deal With billions of indexes?
I've built a flatfile db system that will work like mini-noSQL system
and it split db to smaller files, and I did a SplFixedArray wrapper for it
with a method for searching usage built on preg_grep.
...
1
vote
3answers
170 views
Arrays vs Objects in view template
I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays
{{$user->zip_code}} vs {{$user['zip_code']}}
I'm ...
1
vote
5answers
208 views
Is it considered bad practice to access a returned array by a key straight away?
I couldn't think of a good way to word the title, sorry. But what I mean is, is it considered bad practice to do:
print get_array()[2]
over:
output=get_array()
print output[2]
(where get_array() ...
-1
votes
3answers
140 views
Find all lines segments intersections
I have a collection of lines segments, represented by an array.
Ex: [3,7,13,6,9] is 4 line segments: [(3,7)(7,13)] , [(7,13)(13,6)] , [(13,6)(6,9)] , ([6,9)(9,3)]
I want to find all the lines ...
0
votes
5answers
697 views
Reverse subarray of an array with O(1)
I have an idea how to implement sub array reverse with O(1), not including precalculation such as reading the input. I will have many reverse operations, and I can't use the trivial solution of O(N).
...
3
votes
2answers
163 views
What would be the optimal way to solve a problem like this?
I have a problem where I have to change all the Xs in a 2D array into 0s, and I have to calculate the minimum steps (where a single step consists of changing an entire row or column) required to do ...
2
votes
3answers
223 views
What language has integrated “list insertion” as part of code *syntax*?
Many programming languages permit natural manipulation of strings, and some languages permit the manipulations of lists too.
More often then not (always?), these operations are done as procedure ...
2
votes
6answers
320 views
Settle an Argument: String vs. Array?
True or False: A string is the same thing as an array.
I had an interview the other day and the above question was asked. I said false, but the interviewer said it was actually true. I explained to ...
0
votes
1answer
115 views
Use ruby's array sort() method, or add items in correct place with a binary lookup?
If I am loading a whole load of items (un-ordered words from a file or something) would it be more efficient to load them all to a Ruby array, and then use the built in sort! method or to do a binary ...
0
votes
1answer
202 views
Sort rectangles in a grid based on a comparison of the center point of each
If I have a grid of rectangles and I move one of the rectangles, say above and to the left of another rectangle, how would I resort the rectangles?
Note the rectangles are in an array, so each ...
3
votes
2answers
407 views
CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why?
I have a question about CA1819 msdn performance warning.
The rule is: Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the ...
2
votes
3answers
614 views
Specific reasons to create own array class over using std::array?
What specific conditions or requirements should you create your own array over using std::array?
Here is my background:
I'm developing a small simple library that a small group of people will use ...
2
votes
3answers
234 views
Best way to choose random element from weighted list
I want to create a simple game. Every so often, a power up should appear. Right now the different kinds of power ups are stored in an array.
However, not every power up should appear equally often: ...
1
vote
2answers
90 views
Efficient way of evaluating an array of strings then add to an array in Ruby
I am looking for an efficient way of evaluating an array of strings against a series of rules and then adding them to another array.
For example I have an array of strings:
something
a
1234
#gohere
...
-3
votes
2answers
935 views
Java: The best way to learn it when MOOCs and books are not enough? [closed]
This topic was taken from Stack Overflow, but it was put on-hold due to Opinion-based question. So I moved it to here.
I've had some great troubles with my homework exercises and I've used ...
1
vote
1answer
164 views
ruby-idiomatic hashes vs arrays
So I am still fairly new to ruby, though I have noticed that it is very hard to create 2d-array and that hashes seem to be more of the go to data structure than arrays.
I was wondering why the Ruby ...
1
vote
1answer
133 views
What is the name of this array transformation?
Start with an array of arrays; in this case, they are different lengths in order to demonstrate the technique, but they do not have to be.
[[1,2,3,4], [5,6,7], [8,9,10], [11,12,13,14,15]]
At the ...
4
votes
2answers
261 views
Array Multiplication and Division
I came across a question that (eventually) landed me wondering about array arithmetic. I'm thinking specifically in Ruby, but I think the concepts are language independent.
So, addition and ...
2
votes
1answer
85 views
Handling Dynamic amount of Strings for persistent and runtime storage in an IOS App
Background
I am dynamically building an FQL query statement and because of the nature of the app, I exclude FB family members, this is the base portion of the query and remains fairly static. The ...
0
votes
1answer
733 views
Sorting an ArrayList by a Split Value [closed]
I am attempting to create an list which should be sorted by a particular field in a colon separated string. I have an array of strings with the following values:
name1:535
name2:697
After sorting ...
3
votes
2answers
340 views
Implementing non-fixed length array support in a compiler
I'm thinking of building a language for PIC microcontrollers. I want to be able to use non-fixed size arrays, like this:
Declare the variable as int[]
Wait for input from serial connection
Make the ...
3
votes
4answers
639 views
Retrieving maximum value from a range in unsorted array
I have an unsorted array. I have queries in which I give a range and then the maximum value from that range has to returned.
For example:
array[]={23,17,9,45,78,2,4,6,90,1};
query(both inclusive): 2 ...
2
votes
4answers
697 views
How do you find the first common element in two arrays
The way I did it was to loop through each at the same time and add the current value to a separate set for each of the lists. Also, check if the current element is already in the other list's set. I ...
-4
votes
1answer
694 views
Program to verify all words in a crossword puzzle are valid
I have my own solution and wanted to check it against something online but couldn't find any examples. How would you solve this one. (I can post my code if necessary). I just want to see if someone ...
5
votes
2answers
296 views
Which design pattern is illustrated by inheriting IStructuralComparable interface?
We know that some design patterns are found so useful that they become features of the language itself.
For instance, the interface IEnumerator which is implemented by Array object.
This helps in ...
0
votes
3answers
427 views
A simple algorithm for finding duplicate floats [closed]
We have N numbers(real numbers(float)).They can be positive or negative or anything we do not know except the fact that there is exactly one number which has a duplicate and the rest all are distinct. ...
3
votes
1answer
577 views
The array class in C# - Implementation questions
I am studying the Array class in C#. The following is the implementation of System.Array class:
[SerializableAttribute]
[ComVisibleAttribute(true)]
public abstract class Array : ICloneable, IList, ...
0
votes
3answers
250 views
Count true array elements
In my code (Python+numpy or Matlab, but issue can apply to any array programming language), I often need to count the number of elements in an array where the elements are true. Usually, I implement ...
5
votes
5answers
561 views
What's the effect of this assignment (whatever the language)?
I think my book (Programming Languages: Principles and Paradigms) is wrong. a is a vector, assume a C-like language:
b = 0;
a[f(3)] = a[f(3)] + 1;
int f(int n) {
if(b == 0) {
b = 1;
...
4
votes
4answers
14k views
Initializing char array with string
I don't remember how I got to the thread, but I was reading its replies and one of them states that you should never initialize a char[] with a string literal.
My question: Is initializing a ...
0
votes
6answers
636 views
Visualization of N>2-D array? [closed]
I have an array of dimension 5. But, I can't figure out how to visualize that array?
int[][][][][] array = new int[4][4][4][6][2].
Is there a good way to visualize arrays with dimension counts of 3 ...
0
votes
3answers
554 views
How to efficiently store IP addresses? [closed]
Background
I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its ...
3
votes
2answers
680 views
Should the 12-String be in its own class and why?
This question is regarding a homework project in my first Java programming class (online program).
The assignment is to create a "stringed instrument" class using (among other things) an array of ...
5
votes
3answers
314 views
Generating Deep Arrays: Shallow to Deep, Deep to Shallow or Bad idea?
I'm working on an array structure that will be used as the data source for a report template in a web app.
The data comes from relatively complex SQL queries that return one or many rows as one ...
0
votes
1answer
349 views
Java Dynamic Binding
I am having trouble understanding the OOP Polymorphic principl of Dynamic Binding ( Late Binding ) in Java. I looked for question pertaining to java, and wasn't sure if a overall answer to how dynamic ...
-2
votes
4answers
702 views
C simple arrays and pointers question
So here's the confusion, let's say I declare an array of characters
char name[3] = "Sam";
and then I declare another array but this time using pointers
char * name = "Sam";
What's the ...
3
votes
3answers
457 views
Is there a way to add unique items to an array without doing a ton of comparisons?
Please bare with me, I want this to be as language agnostic as possible becuase of the languages I am working with (One of which is a language called PowerOn). However, most languanges support for ...
0
votes
4answers
10k views
2 Dimensional Arrays in C++
I started learning arrays in C++ and came over a little side note in the book talking about 2D arrays in breif.
I tested it out and i was amazed that it could give the programmer the ability to store ...
1
vote
2answers
516 views
Should I create specific classes for JSON Objects or only use the container(Array/Dictionary) for accessing Data?
I'm using Foursquare to get a List of Restaurants nearby inside an iOS app. The Result is stored in an Array which consists of Dictionaries and regarding how deep the Data is, each Dictionary contains ...
3
votes
3answers
1k views
C Flexible Arrays: When did they become part of the standard?
I learned to program in C many years ago, and used C steadily for about 10 years.
These days, I occasionally have to look at C code, because our Informix 4GL RDS customized runners also contain C ...
0
votes
2answers
286 views
arrays format (Javascript)
I have a list of users, with minions, something like this:
User52:
minion10
minion12
User32:
minion13
minion11
I've been keeping in an array where the "location" is the ...
6
votes
8answers
7k views
What is the difference between an Array and a Stack?
According to Wikipedia, a stack:
is a last in, first out (LIFO) abstract data type and linear data structure.
While an array:
is a data structure consisting of a collection of elements ...
4
votes
6answers
744 views
why are both index[array] and array[index] valid in C?
For example consider:
int index = 3;
int array[4] = {0, 1, 2, 3};
then both index[array] and array[index] are valid expressions, much like *(index + array) and *(array + index).
In C arrays why is ...
6
votes
2answers
519 views
How to remove the boundary effects arising due to zero padding in scipy/numpy fft?
I have made a python code to smoothen a given signal using the Weierstrass transform, which is basically the convolution of a normalised gaussian with a signal.
The code is as follows:
#Importing ...