From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: pietru@caramail.com Newsgroups: gmane.emacs.help Subject: Re: Passing a list to an interactive function Date: Sat, 19 Dec 2020 05:29:50 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33806"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 19 05:31:36 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kqTu4-0008iH-5b for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 19 Dec 2020 05:31:36 +0100 Original-Received: from localhost ([::1]:53188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqTu3-0001xT-8T for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 18 Dec 2020 23:31:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqTsw-0001x4-Qe for help-gnu-emacs@gnu.org; Fri, 18 Dec 2020 23:30:27 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:35811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqTsu-0004Og-0u for help-gnu-emacs@gnu.org; Fri, 18 Dec 2020 23:30:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608352190; bh=GSJAX8iOKygcwN3VbYHpthkxKp4UtEVTA7xEEbssqn8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=h36ZYEB6O30qyX4A3Up/hq8bqw/mSAavBqhGmLl7WILyl+d4UOtOWQMXvTu1ugXbJ NIOPoTfr4QtNlWZTWWP6J2QGj0q6gSD63eOZLQrKabaKE1/pxLspm+/LVeEmDeH0au Wc6apHnpHjwoRoSeK4TG+TFVkAy1dKm7qknMvCcQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs02.server.lan [172.19.170.129]) (via HTTP); Sat, 19 Dec 2020 05:29:50 +0100 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:yiKiKONLHi4h+JVi700IFmaU03vXD2sM0qMtjNq3J4s4VvaO7ldzQEhOcOPQHfkTBlASd hSgBUR03bn0N4vU4s64ErDW9W4ByPrDLKaQE2K4bGOoNomLAcHeZGr9LIWCOMNCZOF2mTwIhKWeD 3Had//+A9QCcitNtn7WHaVlvaDy2aEfuMVuJn6IqOLo3KX7iDyLlNPAkt85ob5fp1FWIvkc94Icz DpL6T2OCnHarJMib4er+2O/sUYJezHWMop040dHNM6pzgzcvcfKIg/iOk9nM6cHinNuf6JKG8px9 9s= X-UI-Out-Filterresults: notjunk:1;V03:K0:w3tRhG2xlX8=:z3xvV1bwhT8xzPjVzyP8BM Tx7VPsaxBQNr4vgrt8WNdzHI6WHAIqcmnLlqIl5XEb4O9i5k6FtdeBk/Hx90RNAMhVPO6ZdN1 eEAoP2Aajf3Am7CEQjCdBIuwFkkWBJp+KPnVFBgqrcHxZzxGWRjRtRHKjIXGONrwyXaNIEBaG F7ItYpWyCIXwazYfu5iowsAgKZnXhmJXMkiECEz1BGKP5Nqr/2avYtLaraD7AS1e1AW9wRoCS K762xb3NpVamHozRwcgZ2NC2gVcYagVVInsxOheu8mWO2wb0qZiHW5PS+D+iIvvxNiJk1hgii 51lNnEsvcxRKrzn2sSkw9z2tqECDp45sWShZfYq7ZMqC+kfjaMsyJSsKqB+/fYQJ5jHvohe9m 9NFLOTp4CbinyWbI0Xgbv1AfAT+U0veklHYN4zafhpVGLq6myAMieLw4udyVt1lvL0XjjcZh0 7z4RWA14xgC5+kXG48kQjIkvOguEOgJp9os5wyUrlou4nY0zfH6f2HwWIaeRLbYbDgVsIV2Fs 5rM313+WKdoDr5Dj6GK9spaogmW3iXjqo70cUNob22u3OsUFWBd7IP6C/BCpGurT2K0c2WZLN GXtuqUwtKRfws= Received-SPF: pass client-ip=212.227.15.19; envelope-from=pietru@caramail.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126555 Archived-At: Am trying to fill variables "ta tb tc" with the numbers from "tlist" (defun thermoluminesce (tseq) "Sets thermoluminesce." (interactive "stseq: ") (message "stseq: %s " tseq) (let ((slist (split-string tseq)) tlist ta tb tpab) (message "slist: %s" slist) (message "tlist: %s" tlist) (message "tlen: %d" (length tlist)) (setq tlist (mapcar #'string-to-number slist)) ;;(setq ta (nth 1 tlist)) ;;(setq tb (nth 2 tlist)) ;;(setq tc (nth 3 tlist)) (message "ta tb tc: %d %d %d" ta tb tc) )) > Sent: Saturday, December 19, 2020 at 4:49 AM > From: "Jean Louis" > To: pietru@caramail.com > Cc: "Help Gnu Emacs" > Subject: Re: Passing a list to an interactive function > > * pietru@caramail.com [2020-12-19 06:34]: > > 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" > > Function `read-number' ensured you get the number. If function is for > you it is fine, if it is for others you risk not getting a number. If > data goes to database which also accepts string you risk losing > data as you maybe did not get a number. > > If user writes spaces before numbers or after numbers or multiple > spaces between you need to remove such. > > (setq my-worse-string " 1 2 3 4 5 6 ") > > (setq my-string (split-string my-worse-string) ;; it will convert to num= bers > > my-string becomes =3D> ("1" "2" "3" "4" "5" "6") > > Inspect `split-string' as it can omit nulls and trim > strings automatically. But I did not here include those > switches, as it does so by default. > > Then you need to convert list of strings to list of numbers: > > (mapcar #'string-to-number my-string) > > >