By default index of every javascript array starts from 0. I want to create an array whose index starts from 1.
I know, must be very trivial...thnx for ur help
Hi,
I am using C#.
I have an array of size 10. I want to pass it to a function, but only from the second element. In C, this is how I would implement it
myfunc( myarray + 1 )
Effectively I am virtually shifting the array / deleting the first element.
How do I implement this in C# ?
Hello,
I have an array of string, like:
char **strings = {"str1", "str2"};
And i would like to know if there is a function in the glib to find the position of a string in this array.
I guess i could just do g_strcmp0 in a for() loop, but there may be a better way to do it.
Thanks
I assume arguments to my shell scripts willbe ./x.sh subject N file1 file2 fileN
So I am splicing argv from 3 till end candidates=${@:3}
now I want to check whether length of candidates is same as given N I am trying with echo $((${#candidates[@]})) which is always returning 1.
I can do echo "$#-2" | bc but, I shouldn't I be able to get array size ?
I can use bc to do integer comparison. but I've to know the size of `candidates array which I am not getting properly.
how can I eliminate duplicate elements from an array of ruby objects using an attribute of the object to match identical objects.
with an array of basic types I can use a set..
eg.
array_list = [1, 3, 4 5, 6, 6]
array_list.to_set
=> [1, 2, 3, 4, 5, 6]
can I adapt this technique to work with object attributes?
thanks
Hi,
I have a C array that contains binary x86_64 machine code, which I need to convert to assembly code on a Linux machine. I have no problem in converting the C array to a binary executable, but can't find the utility to convert it to asm code.
Any ideas?
Thanks!
In javascript is there a good(i mean built in) way that i can find whether element if array of not ? one simple i can see is as follows but i don't like it
if(ele.push){//its array it has push method}
I mean i would like know if something like below exists
function x(ele){ if(isArray(ele)){//dosomething} }
I manage to pass the following array from MessagesTableViewController.m to arraySelectedCategory in another class called MessageDetailViewController.m:
self.messageDetailViewController.arraySelectedCategory =
[[NSMutableArray alloc] initWithObjects:@"Value 1",@"Value 2", @"Value 3", nil];
but how do I hand over an array stored in: NSMutableArray *categories;
self.messageDetailViewController.arraySelectedCategory = ?????
Thanks!
Here's what I' trying to do:
Currently I am using this to create an array of all elements matching the class name of '.cookie'. Right now I am getting the text value of that element, which is not what I need:
var getAllCookies = $('.cookie').text();
var cookiesArray = jQuery.makeArray(getAllCookies);
alert(cookiesArray[0]);
What I need is to find all elements of a certain class (.cookie), get that elements ID value and store that ID value inside of array.
I'm frequently using the following to get the second to last value in an array:
$z=array_pop(array_slice($array,-2,1));
Am I missing a php function to do that in one go or is that the best I have?
I have 2 dimensional table in file, which look like this:
11, 12, 13, 14, 15
21, 22, 23, 24, 25
I want it to be imported in 2 dimensional array. I wrote this code:
INTEGER :: SMALL(10)
DO I = 1, 3
READ(UNIT=10, FMT='(5I4)') SMALL
WRITE(UNIT=*, FMT='(6X,5I4)') SMALL
ENDDO
But it imports everything in one dimensional array.
Here is the code:
$arraya = array('a','b','c');
foreach($arraya as $key=>$value)
{
if($value == 'b')
{
$arraya[] = 'd';
//print_r($arraya); //$arraya now becomes array('a','b','c','d')
}
echo $key.' is '.$value."\n";
}
and it will get:
0 is a
1 is b
2 is c
And I wonder why 3 is d doesn't show up??
Hello,
I have a field in my DB that holds value separated by commas like;
$tmp_list = "COB,ISJ,NSJ,"
Now when I fetch that the row, I would like to have them in an array.
I have used array($tmp_list) but I get the values in one line only like:
[0] => 'COB,ISJ,NSJ,'
instead of
[0] => 'COB',
[1] => 'ISJ',
[2] => 'NSJ'
All help is appriciated.
I have a simple one level deep vocabulary taxonomy. Something like Vocabulary-Term-Node. What I want to know is if there's a built in function to get an array of nodes related to a single term, something like taxonomy_select_nodes() but that would return an array of nodes instead of a string.
The CakePHP Cookbook states that a Model can use a file (csv for example) instead of an actual database table but I couldn't find any implementation for it.
I was wondering if it is possible to use an Array of data as a model in CakePHP since I have a fairly static set of data which is important to me in a relationship with another table but it doesn't make a whole lot of sense to create a complete table for it.
Is it possible to implement a CakePHP Model using an Array?
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
The range of N may be from 1kb to 16kb roughly, stack overrun is not a problem.
Hi chaps, I have an array of nsdictionaries and one key is ID (which is unique) I simply want to see if the the array of dictionaries contains a specific ID.
Really simple but its friday and after statiny up watching the election i think my brain is melting. Any help would be great.
Thanks
HI. This is maybe simple question but I want to create two dimensional array and add it string like in java
string str = "text" ;
string [][] array = new [][] string ;
array[i][j] = str ;
But in C there is no string .I tried like this but here strcpy() gives error.It returns to assembly code. I am trying to read line by line from text and split line by space and add them to structure.But first I think that I must add each line and row in array and then making iteration and adding to structures fields.
static const char filename[] = "student.txt";
FILE *file = fopen ( filename, "r" );
char line [ 128 ]; /* or other suitable maximum line size */
char delims [ ]=" ";
char *result =NULL;
char list[15];
char arra[128][128];
int i=0;
int j=0;
struct {
char gruppa[10];
char familiya[20];
int uchaste;
struct {
int firsth;
int second;
int third;
int fourht;
int fifth;
} exam;
}student;
for(i=0; i<128; i++)
for(j=0; j<128; j++)
arra[i][j] = '\0';
for(i=0; i<15; i++)
list[i] = '\0';
if ( file != NULL )
{
while ( fgets ( line, sizeof line, file ) != NULL )
{
result = strtok(line,delims);
while (result !=NULL) {
strcpy(list,("%s",result));
strcpy(arra[i][j],list); // Here it gives errror
j++;
result = strtok(NULL,delims);
}
j=0;
i++;
}
fclose ( file );
}
else
{
perror ( filename );
}
getchar();
return 0;
}
All,
I have an array with hyphens in the key name. How do I extract the value of it in PHP? It returns a 0 to me, if I access like this:
print $testarray->test-key;
This is how the array looks like
testarray[] = {["test-key"]=2,["hotlink"]=1}
Thanks
for example i have array
int a[]=new int[]{3,4,6,2,1};
I need list of all permutation such that if one is like this, {3,2,1,4,6}, others must not be the same i know that if length of array=n then there is n! possible combination please help me to write this algortihm what to do?
Hello,
I have some difficulties for using Ruby block, passing in a method.
As in the following case, I would like to display each element of @array, from Box instance (using .each method):
class Box
def initialize
@array = [:foo, :bar]
end
def each(&block)
# well, hm..
end
end
a = Box.new
a.each { |element| puts element }
Thanks for any help.
I am trying to index a numpy.array with varying dimensions during runtime. To retrieve e.g. the first row of a n*m array a, you can simply do
a[0,:]
However, in case a happens to be a 1xn vector, this code above returns an index error:
IndexError: too many indices
As the code needs to be executed as efficiently as possible I don't want to introduce an if statement. Does anybody have a convenient solution that ideally doesn't involve changing any data structure types?