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

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

Re: complicated code to do trivial (?) thing


From: Emanuel Berg
Subject: Re: complicated code to do trivial (?) thing
Date: Fri, 14 Jun 2019 21:41:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Anders Dalskov wrote:

> It can be simplified somewhat, I think.
> My take is below. Instead of `cl-remove' you
> can use `split-string', and instead of
> `mapcar' + `format' + `substring' you can use
> `mapconcat'.
>
> (defun alphabet (&optional as-list)
>   (let ((abc "a b c d e f g h i j k l m n o p q r s t u v w x y z"))
>     (if as-list
>       (split-string abc)
>       abc)))
>
> (defun echo-alphabet (&optional number)
>   (interactive "P")
>   (let* ((abc-as-list (alphabet t))
>        (number (or number (length abc-as-list))))
>     (mapconcat 'identity (subseq abc-as-list 0 number) " ")))

That looks much better, yes. Thank you, will
try it out, examine the code, and if it works
as well as mine ;) I will replace it, and put
your initials next it it.

Mange tak!

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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