A buch of sequence functions
This commit is contained in:
12
src/lisp.c
12
src/lisp.c
@ -2443,6 +2443,17 @@ DEFUN(hash_table_count, "hash-table-count", (LispVal * table)) {
|
||||
return make_lisp_integer(((LispHashtable *) table)->count);
|
||||
}
|
||||
|
||||
DEFUN(maphash, "maphash", (LispVal * func, LispVal *table)) {
|
||||
HT_FOREACH_VALID_INDEX(table, i) {
|
||||
LispVal *args =
|
||||
const_list(true, 2, HASH_KEY(table, i), HASH_VALUE(table, i));
|
||||
WITH_CLEANUP(args, {
|
||||
refcount_unref(Ffuncall(func, args)); //
|
||||
});
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
DEFUN(puthash, "puthash", (LispVal * table, LispVal *key, LispVal *value)) {
|
||||
return refcount_ref(puthash(table, key, value));
|
||||
}
|
||||
@ -3522,4 +3533,5 @@ static void register_symbols_and_functions(void) {
|
||||
REGISTER_FUNCTION(string, "(val)", "");
|
||||
REGISTER_FUNCTION(subvector, "(seq &opt start end)", "");
|
||||
REGISTER_FUNCTION(string_to_vector, "(str)", "");
|
||||
REGISTER_FUNCTION(maphash, "(func table)", "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user