From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help,gmane.emacs.devel Subject: str-to-int Date: Sat, 07 Mar 2020 02:12:49 +0100 Message-ID: <87k13xdl2m.fsf@ebih.ebihd> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="65521"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: emacs-devel@gnu.org To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:vQ6xebszjS/A2gvQeExtEB5giw0= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 07 02:13:22 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 1jAO1p-000Gxh-Rc for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 07 Mar 2020 02:13:21 +0100 Original-Received: from localhost ([::1]:44100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAO1o-0004pf-UC for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 06 Mar 2020 20:13:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40727) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAO1R-0004pY-JF for help-gnu-emacs@gnu.org; Fri, 06 Mar 2020 20:12:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAO1Q-0002hr-HK for help-gnu-emacs@gnu.org; Fri, 06 Mar 2020 20:12:57 -0500 Original-Received: from ciao.gmane.io ([159.69.161.202]:41832) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAO1Q-0002gr-BK for help-gnu-emacs@gnu.org; Fri, 06 Mar 2020 20:12:56 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jAO1P-000GQ4-3L for help-gnu-emacs@gnu.org; Sat, 07 Mar 2020 02:12:55 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Followup-To: gmane.emacs.help Mail-Copies-To: never X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 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:122538 gmane.emacs.devel:245302 Archived-At: ;; better than string-to-number (defun str-to-int (str) (if (string= str "0") 0 (let ((res (string-to-number str))) (if (= 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 -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal