Lets say i have an array like such
$artist = array("the roots","michael jackson","billy idol","more","and more","and_YET_MORE");
$count = array(5,3,9,1,1,3);
and i want to generate a tag clound that will have artist with a higher number in count be a H6 tag and the lowest being H1?
any ideas?
...
I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,
foo in iter_attr(array of python objects, attribute name)
I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers...
Is:For i = LBound(arr) To UBound(arr)
The best way?
What is the point in asking for LBound? Surely that is always 0 isn't it?...
I have a perl variable $results that gets returned from a service. The value is supposed to be an array, and $results should be an array reference. However, when the array has only one item in it, $results will be set to that value, and not a referenced array that contains that one item.
I want to do a foreach loop on the expected arr...
If I have a javascript associative array say:
var myArray = new Object();
myArray["firstname"] = "Gareth";
myArray["lastname"] = "Simpson";
myArray["age"] = 21;
Is there a built in or accepted best practice way to get the length of this array?
EDIT: JavaScript does not have associative arrays -- it only has objects.
...
I have an array in Perl:
@my_array = ("one","two","three","two","three")
How do I remove the duplicates from the array?
...
I have been working with a string[] array in C# that gets returned from a function call. I was wondering what the best way to remove duplicates from this array would be? I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array?
...
in php, i often need to map a variable using an array ... but i can not seem to be able to do this in a one liner. c.f. example:
// the following results in an error:
echo array('a','b','c')[$key];
// this works, using an unnecessary variable:
$variable = array('a','b','c');
echo $variable[$key];
this is a minor problem, but it keeps...
I love list comprehensions in Python, because they concisely represent a transformation of a list.
However, in other languages, I frequently find myself writing something along the lines of:
foreach (int x in intArray)
if (x > 3) //generic condition on x
x++
//do other processing
This example is in C#, where I'm under the ...
Hi all, I need to take an array and sort it in c/c++, replacing each value with its' "rank", an integer that corresponds to its position after sort. Heres an example: Input: 1,3,4,9,6. Output: 1, 2, 3, 5, 4. So, I need to replace each value with its position relative to all the other values. I hope that makes sense, but its late, so...
Is it possible to actually make use of placement new in portable code when using it for arrays?
It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm that this is correct), but I don't see how you can allocate a buffer for the array to go in...
Hi everyone, I am trying to build a function in C/c++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but cant get it down. Once again,...
Howdy,
I have a byte array in memory, read from a file. I would like to split the byte array at a certain point(index) without having to just create a new byte array and copy each byte at a time, increasing the in memory foot print of the operation. What I would like is something like this:
byte[] largeBytes = [1,2,3,4,5,6,7,8,9];
...
I have two arrays of System.Data.DataRow objects which I want to compare. The rows have two columns A and B. Column A is a key and I want to find out which rows have had their B column changed and which rows have been added or deleted. How do I do this in PowerShell?
...
Hi all, I am working on a function to establish the entropy of a distribution. It uses a copula, if any are familiar with that. I need to sum up the values in the array based on which dimensions are "cared about."
Example: Consider the following example...
Dimension 0 (across)
_ _ _ _ _ _ _ _ _ _ _ _ _
|_ 0 _|_ 0 _|_ 0 _|_ 2 _| D...
Which is better to use in PHP, a 2D array or a class? I've included an example of what I mean by this.
// Using a class
class someClass
{
public $name;
public $height;
public $weight;
function __construct($name, $height, $weight)
{
$this -> name = $name;
$this -> height = $height;
$this -> weight = $weight;
}
}
$classArra...
I have two arrays of animals (for example).
$array = array(
array(
'id' => 1,
'name' => 'Cat',
),
array(
'id' => 2,
'name' => 'Mouse',
)
);
$array2 = array(
array(
'id' => 2,
'age' => 321,
),
array(
'id' => 1,
'age' => 123,
)
);
How can I merge the two arrays int...
The point of this question is to collect a list of examples of hashtable implementations using arrays in different languages. It would also be nice if someone could throw in a pretty detailed overview of how they work, and what is happening with each example.
Edit:
Why not just use the built in hash functions in your specific languag...
Is there an easy way to iterate over an associative array of this structure in PHP:
The array $searches has a numbered index, with between 4 and 5 associative parts. So I not only need to iterate over $searches[0] through $searches[n], but also $searches[0]["part0"] through $searches[n]["partn"]. The hard part is that different indexes ...
Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:
[0, 0, 0] = 2
[0, 0, 1] = 32
And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a built in function instead?
...