help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning a single alist


From: wilnerthomas
Subject: Re: Returning a single alist
Date: Thu, 25 Aug 2022 02:28:39 +0200 (CEST)

Aug 24, 2022, 23:48 by help-gnu-emacs@gnu.org:

>
> Aug 24, 2022, 23:23 by help-gnu-emacs@gnu.org:
>
>> The function `translate' ends up returning a list of alists.  What can I do 
>> to return just a single alist? 
>>
>> (defconst assoc-table-1  '( ("gigantic" . "jgN") ("graphology" . "Gol")  
>> ("phrenology" . "fnol") ))
>>
>>
>> (defconst assoc-table-2  '( ("psychology" . "skol")  ("physiology" . "fsol") 
>> ("minerology" . "Mnol") ))
>>
>>
>> (defun translate () 
>>
>> "TODO" 
>>
>> (let* ( (name "assoc-table-")      (list '())      (counter 1) ) 
>>
>> (while (boundp (intern (concat name (number-to-string counter)))) 
>>
>>      (setq list         (append list 
>>
>>           (symbol-value (intern (concat name (number-to-string counter)))))) 
>>
>>      (setq counter (1+ counter))) 
>>
>> list))
>>
Does not look like the problem is with the function above, but with this one

Particularly the call to  (dolist (aggr (translate))

(defun shorten ()
  "Shorten word at point according to specific rules."

  (interactive)

  (let* ( (bounds  (bounds-of-thing-at-point 'word))
  
             (word  (downcase  (buffer-substring (car bounds) (cdr bounds))))

            (rplc "") )

    (goto-char (car bounds))
    
    (dolist (aggr (translate))
    
        (setq rplc (cdr (assoc word aggr)))
    
        (unless (null rplc)

             (add-to-list 'nscrip  (replace-regexp-in-string word rplc word)))) 
))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]