hash-keys and hash-values
This commit is contained in:
parent
544cab5f17
commit
588ff1644b
compiler
js-assembler/runtime-src
lang
|
@ -111,6 +111,8 @@
|
|||
'hash-remove
|
||||
'equal-hash-code
|
||||
'hash-count
|
||||
'hash-keys
|
||||
'hash-values
|
||||
|
||||
'string-copy
|
||||
))
|
||||
|
|
|
@ -163,6 +163,15 @@
|
|||
return ('#' + this.type + '(' + ret.join(' ') + ')');
|
||||
};
|
||||
|
||||
WhalesongHashtable.prototype.keys = function() {
|
||||
return this.hash.keys();
|
||||
};
|
||||
|
||||
WhalesongHashtable.prototype.values = function() {
|
||||
return this.hash.values();
|
||||
};
|
||||
|
||||
|
||||
WhalesongHashtable.prototype.equals = function (other, aUnionFind) {
|
||||
if (!(other instanceof WhalesongHashtable)) {
|
||||
return false;
|
||||
|
@ -282,6 +291,14 @@
|
|||
return ('#' + this.type + '(' + ret.join(' ') + ')');
|
||||
};
|
||||
|
||||
WhalesongImmutableHashtable.prototype.keys = function() {
|
||||
return this.map.keys();
|
||||
};
|
||||
|
||||
WhalesongImmutableHashtable.prototype.values = function() {
|
||||
return this.map.values();
|
||||
};
|
||||
|
||||
WhalesongImmutableHashtable.prototype.equals = function (other, aUnionFind) {
|
||||
if (!(other instanceof WhalesongImmutableHashtable)) {
|
||||
return false;
|
||||
|
|
|
@ -238,6 +238,15 @@
|
|||
};
|
||||
|
||||
|
||||
var arrayToList = function (arr) {
|
||||
var result = EMPTY, i;
|
||||
for (i = arr.length -1; i >= 0; i--) {
|
||||
result = makePair(arr[i], result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
// Coerse a list back into a JavaScript array.
|
||||
var listToArray = function (lst) {
|
||||
var result = [];
|
||||
|
@ -311,5 +320,6 @@
|
|||
exports.length = length;
|
||||
exports.listRef = listRef;
|
||||
exports.listToArray = listToArray;
|
||||
exports.arrayToList = arrayToList;
|
||||
|
||||
}(this.plt.baselib));
|
|
@ -2767,6 +2767,21 @@
|
|||
return hash.functionalRemove(key);
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-keys',
|
||||
1,
|
||||
function(M) {
|
||||
var hash = checkHash(M, 'hash-keys', 0);
|
||||
return baselib.lists.arrayToList(hash.keys());
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-values',
|
||||
1,
|
||||
function(M) {
|
||||
var hash = checkHash(M, 'hash-keys', 0);
|
||||
return baselib.lists.arrayToList(hash.values());
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-has-key?',
|
||||
|
|
|
@ -170,7 +170,8 @@
|
|||
hash-remove
|
||||
equal-hash-code
|
||||
hash-count
|
||||
|
||||
hash-keys
|
||||
hash-values
|
||||
|
||||
|
||||
;; Kernel inlinable
|
||||
|
|
Loading…
Reference in New Issue
Block a user