Questions tagged [hash-tables]

15 questions
7
votes
1 answer

Accessing JSON data in elisp

JSON: { "name": "xxxxx", "job": "xxxxxx", "projects": [ { "name": "xxxxx", "date": "xxxxx", "about": "xxxxxxxxxx" }, { "name": "xxxxx", "date": "xxxxx", "about": "xxxxxxxxxx" }, { …
I'm Mo
  • 73
  • 1
  • 4
7
votes
2 answers

How to speed up the loading of large hashtables?

As I understand from the manual (last paragraphs of http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Hash.html) and the question https://stackoverflow.com/questions/11745097/ on stackoverflow, one can save a printed version of a…
Name
  • 7,689
  • 4
  • 38
  • 84
4
votes
3 answers

Get a better printed representation of a hash-table

I work with ELisp hash-table and I would like to have a better printed representation of it. I'm on Emacs version 24.5.1. When I create a hash-table (setq table (make-hash-table)) (puthash :name "john" table) (puthash :age 31 table) I get something…
dag
  • 141
  • 2
4
votes
1 answer

Does Elisp replay on hash lookups every time code require access to symbol value?

I go across blog post: http://blog.cdleary.com/2010/09/picing-on-javascript-for-fun-and-profit/ It is about JS performance on accessing object properties and tricks that help reduce that time. Usual access require hash table lookup. Optimized…
gavenkoa
  • 3,352
  • 19
  • 36
3
votes
1 answer

Emacs native database for fast key/value access?

I would like to do a key -> value lookup for data that may not fit into memory (or simply avoid the overhead of having to load it an keep it in memory). Does Emacs natively support any kind of database that can be used for fast lookups (like a…
ideasman42
  • 8,375
  • 1
  • 28
  • 105
2
votes
1 answer

Is there a way to change order of the key in a hashtable?

Say i have following keys in hashtable: "first1" "second2" "third3" "forth4" Is there a way to put key "third3" at the top. So that when i run func hash-table-keys i get following list: ("third3" "first1" "second2" "forth4") I tried running…
Sime1
  • 31
  • 2
2
votes
1 answer

Insert an entry into hash using put

(defvar-local hash-entries nil) (put 'hash-entries "key" "val") (message "%S" hash-entries) I try to add a key-value pair to the hash variable, hash-entries using the function put. But when i print it, it prints nil instead of its contents, (key .…
Madhavan
  • 1,957
  • 12
  • 28
1
vote
1 answer

How to use markers as keys in a hash map?

I'm creating a hash map and I'd like to use markers as keys. I set the hash map equality test to "equal", but the last line from the below code is returning ("bye" "fly") instead of ("bazooka" "joe"). Any idea what I'm doing wrong? (let* ((tmp…
rclark
  • 113
  • 5
1
vote
1 answer

Access hash table by value, not key?

Q: how can I access a hash table by its value, not its key? Association lists can be accessed via either their key or their value: (setq alist '((a .1) (b . 2) (c . 3))) (assoc 'a alist) ; => (a . 1) (rassoc 3 alist) …
Dan
  • 32,584
  • 6
  • 98
  • 168
1
vote
1 answer

how to implement a simple lookup table in lisp

I want to write an elisp function, when a country name is given, it returns the short code for the country. I've been reading about hash tables, but still not sure how to hashify my data set and make the function…
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
1
vote
1 answer

What's the most concise way to make a hash table with data in it?

I'd like to create a hash table with data already in it. I know I can do so as follows: (let ((my-table (make-hash-table))) (puthash 'k1 'v1 my-table) (puthash 'k2 'v2 my-table) (puthash 'k3 'v3 my-table) my-table) But there's a lot of…
zck
  • 8,984
  • 2
  • 31
  • 65
1
vote
3 answers

How to increment several numeric keys of a hash-table

Q: How to programmatically increment several numeric keys of a hash-table. Background: I am working on a modificion of speedbar to support the concept of speedbar-get-marked-files -- speedbar -- mark/unmark directories/files --…
lawlist
  • 18,826
  • 5
  • 37
  • 118
0
votes
1 answer

How to define a singe weak reference in elisp?

Hash tables in elisp supports weak references, however weak references may be useful without the need to use a hash. How can a weak reference to an object be defined without having to use a hash-table containing one item?
ideasman42
  • 8,375
  • 1
  • 28
  • 105
0
votes
1 answer

Helm source from a hash-table

I want to build a helm-source from a large hash-table, is there a smarter/faster way to to this, than the way described below? (setq tab #s(hash-table size 16 test equal data ("asdf" "asdf" …
gdkrmr
  • 175
  • 7
0
votes
2 answers

"Lisp error" when trying to append hash tables to a list

Q:  Is there a way to create one cache that consists of one cons cell and two hash tables? If so, how, please. If not, what is the best way to handle this scenario? Background: I'm working on a new feature for speedbar that creates a cache…
lawlist
  • 18,826
  • 5
  • 37
  • 118