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

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

Re: Composing words from acronyms


From: Tassilo Horn
Subject: Re: Composing words from acronyms
Date: Tue, 25 Jul 2023 20:50:16 +0200
User-agent: mu4e 1.11.10; emacs 30.0.50

uzibalqa <uzibalqa@proton.me> writes:

> I would like to compose words from acronyms (e.g. 5-letter words,
> 4-letter words, etc).  For instance, from the acronym 'Emacs' I can
> compose 'maces'.
>
> Is this difficult to de in eamcs, and how may I approach this task ?

It's a bit cheating but the dash package has a -permutations function
which does the job.

(defun acronyms (word)
  (seq-filter
   (lambda (acronym)
     ;; TODO: check if acronym is actually a sensible word.
     t)
   (mapcar (lambda (lst)
             (mapconcat #'char-to-string lst))
           (-permutations (string-to-list word)))))

For the TODO, you could probably use some dictionary file.

Bye,
Tassilo



reply via email to

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