I am looking for a way to easily split a python array in half.
So that if I have an array:
A = [0,1,2,3,4,5]
I would be able to get:
B = [0,1,2]
C = [3,4,5]
I have a object store in Java. My C program stores data (in form of char array) in java. Now I wish to retrieve data from my store. I cannot find any function call that returns me an char array. How can I do this?
Is there a way to initialize an array of primitives, say a integer array, to 0? Without using a for loop? Looking for concise code that doesn't involve a for loop.
:)
Hi,
I have an array of type string that looks like this:
"test1|True,test2|False,test3|False,test4|True".
This is essentially a 2d array like so
[test1][True]
[test2][False]
[test3][False]
[test4][True].
I want to convert this into a dictionary<string,bool> using linq, something like:
Dictionary<string, bool> myResults = results.Split(",".ToCharArray).ToDictionary()
any ideas?
i want to add the current string in a textview view to a string array in arrays.xml.then display the last/previous string of that array in a textview (setText).
I want to copy a string into a char array, and not overrun the buffer.
So if I have a char array of size 5, then I want to copy a maximum of 5 bytes from a string into it.
what's the code to do that?
I am using the DataTables plugin for jQuery and need to get one of the table rows. DataTables has a fnGetNodes function that returns an Array with all of the DOMElements of the table. I would like to use a jQuery selector to find that row (I know the id of the row), but I need to convert the Array to a jQuery Object, is this possible?
Hi ,
I have country table,
i fetch all values and moved into array ,
these value i like to populate into combo/dropdown list ,
here i want to do some magic things,
that is , for my site most of the users coming from uk,us,Australia,Romain and few,
So i like to populate by my preference ,
is there any array will do this magic work, else is it possible mysql query ,
So final question is ,
Populate country name into combo based on my prefernce ,
Thanks
Hi all,
I came cross a question in my interview.
Question:
Array of integers will be given as the input and you should find out the middle element when sorted , but without sorting.
For Example.
Input: 1,3,5,4,2
Output: 3
When you sort the given input array, it will be 1,2,3,4,5 where middle element is 3.
You should find this in one pass without sorting.
Any solutions for this?
I have an array of field names. I would like to use those to populate the keys of another array, which will have empty values as default. Is there a single command I can do this with?
RubyParser.new.parse "1+1"
s(:call, s(:lit, 1), :+, s(:array, s(:lit, 1)))
Above code is from this link
Why there is array after + in the Sexp. I am just trying to learn ruby parser and the whole AST thing. I have been programming for a while but have no formal education in computer science. So do point to good article which explains AST etc. Please no dragon book. I tried couple of times but couldn't understand much of that book
how to search substring from mutable array?
NSMutableArrray names having string values,
searchText is a substring to search from name array values.
for (NSString *sTemp in names)
{
NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
//NSLog(@"sTemp = %@, searchText = %@",sTemp,searchText);
NSLog(@"%@",titleResultsRange.length);
if (titleResultsRange.length > 0)
[Items addObject:sTemp];
}
Hi everyone, I'm trying to find an elegant way in Coffeescript to merge an array of arrays, so that [[1,2,3],[4,5,6],[7,8,9]] == [1,2,3,4,5,6,7,8,9].
As you might imagine, I need this because I'm generating arrays from a function in a "for in" construct and need to concatenate the resulting nested array:
result = (generate_array(x) for x in arr)
Is there an elegant way to handle this? Thanks for any pointers!
I need to pass two array list references to a function and return the reference of merged array list.
how can i do it????
pls help....
public int merge(ArrayList x, ArrayList y)
{
List all = new ArrayList();
all.addAll(x);
all.addAll(y);
System.out.println(all);
return all;
}
is it correct???
Hi,
I have an array of (4) floating point numbers and need to sort the array in descending order. I'm quite new to c++, and was wondering what would be the best way to do this?
Thanks.
How do I show the dates number format next to its name in the array using PHP? So that the number format is saved in the database and the month name is displayed?
Here is the php code.
$month_options = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
I'm looking for a way to define and send a JSON object array. I've figured out how to define a single JSON object, turn it into a string and send it, but what about an array of this type? Probably something simple I'm overlooking...
var myColumnSetting = { "ColumnName": name,
"ColumnIndex": index
}
convert it to a string
var myJSONText = JSON.stringify(myColumnSetting, false);
I have an array $x with nonzero number of elements. I want to create another array ($y) which is equal to $x. Then I want to make some manipulations with $y without causing any changes to $x. Can I create $y in this way:
$y = $x;
In other words, if I modify $y created in the above shown way, will I change value of $x?
Hi,
I was told the array name is a pointer
char a[] = "a"
but when
sizeof(a) = 2
why not it is a size of pointer here?
however when I define it like this
char* a ="a";
we get
sizeof(a) =4;
Well, I think I need more information about how does sizeof work with the array names....
Can anyone elaborate that?
hello.
Is there significant cpu/memory overhead associated with using automatic arrays with g++/Intel on 64-bit x86 linux platform?
int function(int N) {
double array[N];
overhead compared to allocating array before hand (assuming function is called multiple times)
overhead compared to using new
overhead compared to using malloc
range of N maybe from 1kb to 16kb roughly, stack overrun is not a problem
Thank you
Hi,
this is my first question on Stackoverflow, please bear with me.
I'm testing an algorithm for 2d bin packing and I've chosen PHP to mock it up as it's my bread-and-butter language nowadays.
As you can see on http://themworks.com/pack_v0.2/oopack.php?ol=1 it works pretty well, but you need to wait around 10-20 seconds for 100 rectangles to pack. For some hard to handle sets it would hit the php's 30s runtime limit.
I did some profiling and it shows that most of the time my script goes through different parts of a small 2d array with 0's and 1's in it. It either checks if certain cell equals to 0/1 or sets it to 0/1. It can do such operations million times and each times it takes few microseconds.
I guess I could use an array of booleans in a statically typed language and things would be faster. Or even make an array of 1 bit values. I'm thinking of converting the whole thing to some compiled language. Is PHP just not good for it?
If I do need to convert it to let's say C++, how good are the automatic converters? My script is just a lot of for loops with basic arrays and objects manipulations.
Thank you!
Edit. This function gets called more than any other. It reads few properties of a very simple object, and goes through a very small part of a smallish array to check if there's any element not equal to 0.
function fits($bin, $file, $x, $y) {
$flag = true;
$xw = $x + $file->get_width();;
$yh = $y + $file->get_height();
for ($i = $x; $i < $xw; $i++) {
for ($j = $y; $j < $yh; $j++) {
if ($bin[$i][$j] !== 0) {
$flag = false;
break;
}
}
if (!$flag) break;
}
return $flag;
}