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

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

Re: Passing a list to an interactive function


From: pietru
Subject: Re: Passing a list to an interactive function
Date: Sat, 19 Dec 2020 04:34:01 +0100

I decided towards a simpler strategy by passing a string with numbers
separated by spaces.  But inside the function, I got to convert from
string to a list containing numbers.

How  could I convert to a list containing numbers.

Example of string: "3 5 13"

> Sent: Saturday, December 19, 2020 at 4:25 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: pietru@caramail.com
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: Passing a list to an interactive function
>
> * pietru@caramail.com <pietru@caramail.com> [2020-12-19 05:06]:
> > Still very unsure what to do.  I want to call "M-x thermoluminescence"
> > but pass six numbers to the function.
> >
> > (defun thermoluminesce (ta tb tlab tc td tlcd te tf tlef)
> >    (interactive) )
> >
> > Could I simply pass six numbers separated by spaces
>
> To make it less error prone, just do this:
>
> (defun thermoluminesce ()
>   (interactive)
>   (let* ((list '()) ;; here you prepare empty list
>        (list (dotimes (n 6 (reverse list))
>                (push (read-number (format "Enter number %s: " (1+ n))) list)))
>        (ta (elt list 0))
>        (tb (elt list 1))
>        (tlab (elt list 2))
>        (tc (elt list 3))
>        (td (elt list 4))
>        (tlcd (elt list 5))
>        (te (elt list 6)))
>     ;; continue here using variables
>     ))
>



reply via email to

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