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!
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 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???
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?
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);
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?
Hi,
Just playing around with some of the APIs in .NET and I can't seem to find a way to cause Array.ConstrainedCopy() fail.
According to MSDN, it's treated as an atomic operation. If it fails during the copy, the entire call fails resulting in no elements being copied as opposed to its Array.Copy() counterpart.
Can someone demonstrate this or tell me how to do this?
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;
}
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
I'm trying to represent the port number 9876 (or 0x2694 in hex) in a two byte array:
class foo {
public static void main (String args[]) {
byte[] sendData = new byte[1];
sendData[0] = 0x26;
sendData[1] = 0x94;
}
}
But I get a warning about possible loss of precision:
foo.java:5: possible loss of precision
found : int
required: byte
sendData[1] = 0x94;
^
1 error
How can I represent the number 9876 in a two byte array without losing precision?
I am writing a program that is declaring an array of 100 integer numbers
and filling the array with random numbers using rand().
All I have so far is:
#include <iostream>
using namespace std;
int main()
{
int random_integer = rand();
hi,
what does this construct mean in PHP ? It is storing a variable called "function" with his String value in an array ?
array('function' => 'theme_select_as_checkboxes')
thanks
Hi, I need to know how to put bits into a character array.
for example,
I want to put 0001 bits into a character array using C or C++.
Need your help guys. Thanks.
Hello people!
I'm a bit confused here.
I have a php array like this Array(2010,2009,2008 ...1992) and i want to create a loop to print a menu with a four year range counting down like this
2010-2006
2005-2001
2000-1996 etc..
How can i do this Everything i tried end up in an endless loop.
THnx in advance.
J.
Given a 2D array that has been converted to binary, for some index values of the binary array how do you find the corresponding values in the original?
Maybe something using ind2sub?
hi,
i am having 10 check boxes.if i click the value of the check box has to push to the array,if i unchecked the check box then the corresponding check box value has to be deleted from the array?
pls...anyone give reply for this
I have a HP DL360 server with 4x 146GB SAS disks and a Smart Array P400i RAID controller with 256MB cache. The disks are in RAID 5 (3 disks + 1 hot spare).
The server is running VMware ESX 3i.
The disk write performance is really bad. Here are some numbers:
ns1:~# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 3364 MB in 2.00 seconds = 1685.69 MB/sec
Timing buffered disk reads: 18 MB in 3.79 seconds = 4.75 MB/sec
ns1:~# time sh -c "dd if=/dev/zero of=ddfile bs=8k count=125000 && sync"
125000+0 records in
125000+0 records out
1024000000 bytes (1.0 GB) copied, 282.307 s, 3.6 MB/s
real 4m52.003s
user 0m2.160s
sys 3m10.796s
Compared to another server those number are terrible: Dell R200, 2x 500GB SATA disks, PERC raid controller (disks are mirrored).
web4:~# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 6584 MB in 2.00 seconds = 3297.79 MB/sec
Timing buffered disk reads: 316 MB in 3.02 seconds = 104.79 MB/sec
web4:~# time sh -c "dd if=/dev/zero of=ddfile bs=8k count=125000 && sync"
125000+0 records in
125000+0 records out
1024000000 bytes (1.0 GB) copied, 35.2919 s, 29.0 MB/s
real 0m36.570s
user 0m0.476s
sys 0m32.298s
The server isn't very loaded and the VMware Infrastructure Client performance monitor is showing 550KBps average read and 1208KBps average write for the last 30 minutes (highest write rate: 6.6MBps).
This has been a problem from the start. Any ideas?
I'm in need of some fast (15+ GB/s write) and somewhat large (50 TB+) storage subsystem with a standard storage interface. I'd prefer something other than Fibre Channel, which admittedly appears to be the most standard interface. RAID 5 is sufficient. What are the cheapest / smallest products from vendors to look at for building this subsystem? I've looked at DDN and TMS so far.
Small: Under 20U
Cheap: Under a million
Edit: I'd really like to cut back costs as much as possible at the expense of capacity. How cheap can these bandwidth requirements be met?
Hi,
We are moving to the dataceneter and planning to have tiered storage on EVA4400 - FC RAID 10 for SQL databases and RAID5 across 24 FATA 1TB disks form VMware ESX guests.HP is describing FATA disks as suitable for near online storage, however I am not convinced that 24 spindles will not be enough for running VMWare for 3 ESX servers.
Does anyone has opinion on why this could be a such a bad idea?
Hi I am having major problems setting up a Hyper-V 2012 cluster on a P2000 SAS SAN.
Running System Center VMM 2012 SP1 I am unable to see any storage to create my cluster. Has anyone had experienced anything similar? Under fabric and storage I can't add the P2000, all I can do is use storage spaces in server manager to create a storage pool and virtual disk. This allows me to create a file share which I can add to VMM but I still can't see any disk to create a cluster. I am just about at the point where I want to tear my hair out wipe the servers and stick VMware on them because I know it works as I have set several systems up like this in the past.
The Hyper-V servers can see the storage and in server manager on my management machine it seems to know both servers can see the same disk. VMM is running on the same machine and it can't see any disk.
Help.....
Thanks
Mike
I am using MS2003 EXCEL. I have a cell in Sheet 1 with a color value and totals, with sub-totals. On sheet 2, I have a data set with 3 columns (colors, dress, type). On Sheet 1, I will need a tabulation showing Totals for Colors, with totals at sub-group of dress (shirt,pants) split by type totals (Full, Half, Tee)
Below table represents my Data set in Sheet 2
Colors Make Dress Type
--------------------------------
Red Arrow shirt full
Red Levi shirt half
blue Rugger Pant full
yellow Wrangler shirt tee
yellow Rugger Pant half
yellow Arrow shirt tee
yellow Wrangler Pant half
Green Rugger Pant full
Red Levi shirt tee
blue Rugger Pant full
blue Arrow shirt full
blue Wrangler Pant half
Green Levi shirt full
I will need a formula showing counts, totals and sub-totals on Sheet 1 for data set from Sheet 2.
Refer my table below which represent my expected data on Sheet 1,
total Shirt Full Half Tees Pants Full Shorts
Red 10 8 4 3 1 2 1 1
Blue
Green
Yellow
Please note I am not looking for a Pivot table solution.