[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping lists through mapcar
From: |
uzibalqa |
Subject: |
Re: Looping lists through mapcar |
Date: |
Wed, 24 Aug 2022 11:49:25 +0000 |
Sent with Proton Mail secure email.
------- Original Message -------
On Wednesday, August 24th, 2022 at 11:02 AM, uzibalqa <uzibalqa@proton.me>
wrote:
> ------- Original Message -------
> On Wednesday, August 24th, 2022 at 10:52 AM, Jean Louis bugs@gnu.support
> wrote:
>
>
>
> > * uzibalqa uzibalqa@proton.me [2022-08-24 12:04]:
> >
> > > ------- Original Message -------
> > > On Wednesday, August 24th, 2022 at 6:24 AM, Jean Louis bugs@gnu.support
> > > wrote:
> > >
> > > > I cannot understand. Provide exactly what you mean.
> > >
> > > Here is what I mean. When I have many alists (`andromeda-assoc-table-N'
> > > where` N' is a numeric value
> > > with say `N' being from 1 to 57), I want to avoid having to write them
> > > all down inside the function` andromeda-translate'.
> >
> > I got it now.
> >
> > (defvar nscrip '())
> >
> > (defconst andromeda-assoc-table-1
> > '( ("OrycteropusAfer" . "Aardvark")
> > ("VicugnaPacos" . "Alpaca")
> > ("MyrmecophagaTridactyla" . "Anteater") ))
> >
> > (defconst andromeda-assoc-table-2
> > '( ("Dasypodidae" . "Armadillo")
> > ("TaxideaTaxus" . "Badger")
> > ("Beaver" . "Beaver") ))
> >
> > (defconst andromeda-assoc-table-3
> > '( ("LynxRufus" . "Bobcat")
> > ("LepomisMacrochirus" . "Bluegill")
> > ("RangiferTarandus" . "Caribou") ))
> >
> > (defun my-assoc-lists ()
> > (let* ((name "andromeda-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))
> >
> > ;; Testing
> >
> > (my-assoc-lists) ⇒ (("OrycteropusAfer" . "Aardvark") ("VicugnaPacos" .
> > "Alpaca") ("MyrmecophagaTridactyla" . "Anteater") ("Dasypodidae" .
> > "Armadillo") ("TaxideaTaxus" . "Badger") ("Beaver" . "Beaver") ("LynxRufus"
> > . "Bobcat") ("LepomisMacrochirus" . "Bluegill") ("RangiferTarandus" .
> > "Caribou"))
> >
> > (defun andromeda-translate ()
> > "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))
> > (add-to-list 'nscrip word)
> >
> > (dolist (aggr (my-assoc-lists))
> > (setq rplc (cdr (assoc word aggr)))
> > (unless (null rplc)
> > (add-to-list 'nscrip
> > (replace-regexp-in-string word rplc word)))) ))
> >
> > ;; I did not test your function.
> >
> > --
> > Jean
>
>
> I hope your new function does not actually make an additional list, because I
> want to save
> memory.
Testing your function I am getting
Lisp error: (wrong-type-argument listp ("OrycteropusAfer" . "Aardvark")
- Looping lists through mapcar, uzibalqa, 2022/08/23
- Re: Looping lists through mapcar, Jean Louis, 2022/08/24
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24
- Re: Looping lists through mapcar, Jean Louis, 2022/08/24
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24
- Re: Looping lists through mapcar, Emanuel Berg, 2022/08/24
- Re: Looping lists through mapcar, Jean Louis, 2022/08/24
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24
- Re: Looping lists through mapcar,
uzibalqa <=
- Re: Looping lists through mapcar, Jean Louis, 2022/08/25
- Re: Looping lists through mapcar, Jean Louis, 2022/08/25
- Re: Looping lists through mapcar, Emanuel Berg, 2022/08/24
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24
- Re: Looping lists through mapcar, Jean Louis, 2022/08/25
- Re: Looping lists through mapcar, uzibalqa, 2022/08/25
- Re: Looping lists through mapcar, Jean Louis, 2022/08/25
- Re: Looping lists through mapcar, uzibalqa, 2022/08/25
- Re: Looping lists through mapcar, uzibalqa, 2022/08/24