From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Bruno =?utf-8?Q?F=C3=A9lix?= Rezende Ribeiro Newsgroups: gmane.emacs.help Subject: Re: str-to-int Date: Tue, 07 Apr 2020 20:04:04 -0300 Message-ID: <87blo2lwyj.fsf@oitofelix.com> References: <87k13xdl2m.fsf@ebih.ebihd> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="94526"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 08 01:04:50 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 1jLxGz-000OTm-G9 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 08 Apr 2020 01:04:49 +0200 Original-Received: from localhost ([::1]:54284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLxGy-0002gM-G8 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 07 Apr 2020 19:04:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLxGK-0002g8-3b for help-gnu-emacs@gnu.org; Tue, 07 Apr 2020 19:04:12 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jLxGJ-0007FO-V8 for help-gnu-emacs@gnu.org; Tue, 07 Apr 2020 19:04:08 -0400 Original-Received: from [189.15.96.129] (port=58642 helo=felix-laptop) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1jLxGJ-0007l8-Dd for help-gnu-emacs@gnu.org; Tue, 07 Apr 2020 19:04:07 -0400 In-Reply-To: <87k13xdl2m.fsf@ebih.ebihd> (Emanuel Berg via Users list for the's message of "Sat, 07 Mar 2020 02:12:49 +0100") X-Face: %,T7Hsg=SK$Zh)wiU4Qdv9-fZ26Pf5*+}Ld,{LeV'Cq-1?=kA"hc,'i""S85]g; _W+{nZfx 2GnAMS1K\E_E&:{h[wQd+Tqj5#PtH:W&8^crA0>i?nmD7hOL$K".`@An_8.7gaObQLlMy0\%%I0Jp. Lue$J0B Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACcElEQVRYw93YzXHCQAwF4G0h Fw4caYEW0oJbSAtuwa1AldGg8PKQtP+GMHkHxkDG/qLVrtek6x65UCZPleYdH485HA4zrHHQ4R5F cPSTl4L0qigJDoxpoFRpUmMGKzR1sbpB3DTLsnzd83nL+XyeNHWDoBHEeg9YQlQWCtZrSmOa1YVN ktDkiz0FwmDJVbd7CizTUhcXLByDINXIiGyUQqnkL8Nm8iCY5CD1lkf+9UYQFykEhb7UqEGFeLwK Q6YgnXTovEtDZkHGZFpbR21nkLlhlUFqWig63XYGyevxeGSQXFjXG4lclSnyyekW/Ur+jFfzWRD6 31RoeQxAnxQB6cErQBKsywDpW6Yo93UgFAMg3DqgMaCqaRzEc4pBPh50fdxk9oF4zvPCCBDml6fo sIagnClVNTmQn/BAmOXxn4LMXQan45vrJCg07QPC/JI8BeT3BjidLNkGpOu1anSNbgd5U6qWx4Ak DOL1RotkTLMV8ouEWYc8yNzezcBNVchv5MIK8VKEHjKrM0D+malvyFoqxG2kLBHIMCmo3EAjFfLl MSAeNSzZoeZZIH/SHAim3I1MMwvC7syAeBuEyV++s3aA2suDHkI7nyi6UUTCHwLGKxSCsFjzzpV3 ZNUihc+s9QqF7YwtEW88zAMQt5Ec7AkKx4uvWjChwaujFoAay+PLUHhQ5LQXKeVu7y2a0GRY/LZq +gG1jBROap4Sy0XyX1VNyf8Ekav8lom5dqFyocn0k62QOenWkBC05uNNDyCv2fpj2mUtxve7vGZB 21CqI1X1BaBhTfiz1QDL9tAMaN70C8L8ei/Q32rYlN6hgdj0DS+u5+J4AqFYAAAAAElFTkSuQmCC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:122762 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Emanuel, Emanuel Berg via Users list for the GNU Emacs text editor writes: > ;; better than string-to-number > (defun str-to-int (str) > (if (string=3D str "0") 0 > (let ((res (string-to-number str))) > (if (=3D res 0) nil (round res)) ))) > ;; (string-to-number "love and pain / it never stays the same") ; 0 > ;; ... ??? > ;; > ;; (string-to-number "0") ; 0 ... well, correct! by all means > ;; (str-to-int "give me all the storybook told me") ; nil > ;; (str-to-int "the power and the glory till thy kingdom come") ; nil > ;; (str-to-int "0") ; 0 > ;; (str-to-int "1337") ; 1337 > ;; (str-to-int "1.337") ; 1 > ;; (str-to-int "1.9") ; 2 > ;; (str-to-int "0.1") ; 0 How about (str-to-int "00") =3D> nil? =2D-=20 Bruno F=C3=A9lix Rezende Ribeiro (oitofelix) [0x28D618AF] --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJejQbkAAoJECe5xv0o1hivZkoIAKU160Zx8PGvjpr17McpONTt sMwvcTWJMDtkQHWs+vsjkNXFbZz9xVIhji6KKzkMMyUpRVSa8MwUYv0mqJtzKT3Z UJH8J1n/vTPb1bD+ChgeJvzwVp0aata3w0RabuSWCds926qOqULQgEu5MmlK95u3 H6UQO18fu1R8W7Bg6mYPEEdLCmdmpRlzgFJt8/2qWMUUUVi/a3MS3TMIIIBGq588 CfXYmCFeL28XELGKzznDgtrU0FrfpKpT3dGcDoQ3EDGTvClFD33teeHEuj4xjWik atSqe6MyQLA8UVdvwYcOCgQJqOLdPhYjy1TTb6dHaSUhN/i6Swxm6jjPFTx9w24= =6sT2 -----END PGP SIGNATURE----- --=-=-=--