Adding an element to the head of an alist (Associative list) is simple enough:
> (cons '(ding . 53) '((foo . 42) (bar . 27)))
((ding . 53) (foo . 42) (bar . 27))
Appending to the tail of an alist is a bit trickier though. After some experimenting, I produced this:
> (define (alist-append alist pair) `(,@alist ,pair))
> (alist-append ...
I need to get just the first item (actually, just the first key) off a rather large associative array in JavaScript. Here's how I'm doing it currently (using jQuery):
getKey = function (data) {
var firstKey;
$.each(data, function (key, val) {
firstKey = key;
return false;
});
return firstKey;
};
Just gu...
Can someone explain how PHP implements associative arrays? What underlying data structure does PHP use? Does PHP hash the key and store it in some kind of hash map? I am curious because I was wondering what the performance of associative arrays where when inserting and searching for keys.
...
var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
Now if I wanted to remove "lastname"?....is there some equivalent of myArray["lastname"].remove()?
(I need the element gone because the number of elements is important and I want to keep things clean).
Thanks in advance to eve...
Hi All,
If 'Associative Array variable' is declared globally, able to use that in OPEN CURSOR USING statement.
If 'Associative Array variable' is declared within package, while use in OPEN CURSOR USING statement, getting compilation error.
More details provided below
I am storing some values in one Associative Array variable. Late...
Hi out there in Stackland. I was wondering if there was either a function or an easy way to change an associative array into an indexed array.
To elaborate, I'm using the Zend framework, and I've got a point in my site where I take out a row of an SQL table as an associative array. I've passed it to javascript via an echoed in JSON. ...
can an array in JS be associative AND indexed?
I'd like to be able to lookup an item in the array by its position or a key value..
possible?
...
Hi, I have searched on here for a quality method to compare associative arrays in javascript. The only decent solution I have found is the PHP.JS project which has some comparative array functions. The only problem is that these functions consider the first array as the key to the second. In my situation at least both arrays do not alway...
Hi all, I would like to print out the data, for debugging purpose.
Data format would be like this
cntryCode = resArray("COUNTRYCODE")
business = resArray("BUSINESS") ' Payer's business name.
shipToName = resArray("SHIPTONAME")
the resArray consist of more than 10 records itself.
I tried to print out, but fail.
version 1 not w...
I know there are a lot of smart people, so prove me right!
I want to combine arrays where similar named keys merge together to form a single array. See example:
[Bob] => Array
(
[BobsDetails] => Array
(
[Title] => Mr
)
)
[Bob] => Array
(
[BobsDetails] => Array
(
[Surname] => Smith
)
)
How do ...
I want to convert the arguments to a function into an associative array with keys equal to the parameter variable names, and values equal to the parameter values.
PHP:
function my_function($a, $b, $c) {
// <--- magic goes here to create the $params array
var_dump($params['a'] === $a); // Should result in bool(true)
var_d...
I’m working in SQL Server with the following sample problem. Brandon prefers PC’s and Macs, Sue prefers PC’s only, and Alan Prefers Macs. The data would be represented something like this. I've had to make some compromises here but hopefully you get the picture:
TABLE 1: User
uID (INT PK), uName (VARCHAR)
1 'Brandon'
2 ...
The thing is I have to create a 2D matrix in php where each row and column must have a key. I tried to do this but what happens is that a 2-D array is created which does not resemble a matrix. I used the following code:
$x=$row['start_id'];
$y=$row['dest_id'];
$d=$row['distance'];
$this->map[$x][$y]=$d;
Here map is the intended matri...
Is there library usable from c++ for sharing fairly simple data (integers,floating point numbers, strings) between cooperative processes?
Must be :
high-speed (SQL-based methods too slow due to parsing)
able to get,set,update,delete both fixed and variable data types (e.g. int and string)
ACID (atomic,consistent,isolated,durable)
us...
How can I copy an array that has other associative arrays in it?
I am talking about a result set returned from a mysql_fetch_assoc.
So say I have a structure like this...
connect
$result = query;
while ($row = mysql_fetch_assoc($result)) {
array_push($static_row, $row); // here lies the problem
}
I would like to get that $stat...
Hi,
is there in VB.NET something like this in php?:
$var["a1"]['name']="Mike";
$var["a1"]['nick']="MMM";
I tried hashtables, dictionary, lists and arrays in .net, all I could get is a simple key=>value array
Is there a simple solution if not, is there a class or something for this?
Thanks.
...
In the documentation for preg_replace is says you can use indexed arrays to replace multiple strings. I would like to do this with associative arrays, but it seems to not work.
Does anyone know if this indeed does not work?
...
Hi erveryone,
I have 2 assoc. Arrays which have the same structure, but only one ID is identical. I need to add content to the MainArray from the IncludeArray everytime the specific ID is identical.
Here are a sample of the Arrays (MainArray could hold up to 100 or more items, the sample contains only a portion of the real content):
$...
Its just a question out of curiosity. Suppose we have an associative array A. How is A["hello"] actually evaluated , as in how does system map to a memory location using index "hello"?
...
Lately we have been testing QlikView in the office. The first impression is good: it has an attractive interface and performs very fast. We want to use it as a database frontend for our customers. We are also trying to determine whether it can take over parts of our relational database structure. However, we are in doubt whether its data...