[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using hash table to apply command sequence with arguments
From: |
Heime |
Subject: |
Using hash table to apply command sequence with arguments |
Date: |
Mon, 25 Nov 2024 12:05:34 +0000 |
How can use a hash table to execute a sequence of commands,
possibly with arguments. Here I am decoupling the action
from the conditions. Would this be a good strategy?
(defun fpln-test (actm-service)
(let ((actm-table (make-hash-table :test 'eq)))
;; Put entry to actm-table
(puthash 'armg (lambda ()
(alkotr-ar ar)
(alkotr-af af)))
actm-table)
;; Put entry to actm-table
(puthash 'go (lambda ()
(require 'alkotr)
(alkotr-ignition gf))
actm-table)
;; Map values from collection with lookup from hash table
(mapc (lambda (actm)
(let ((action (gethash actm actm-table)))
(if action
(funcall action)
(message "[marshal-falkotr]\n%s%s\n"
" └── ACTM Unrecognised:" "'" actm))))
actm-service)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Using hash table to apply command sequence with arguments,
Heime <=