From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: (*) -> 1 Date: Fri, 20 Jan 2023 10:31:36 +0300 Message-ID: References: <87h6wpkrlq.fsf@web.de> <87zgahj7h3.fsf@web.de> <878rhzvs1h.fsf@web.de> <87ilh28w9u.fsf@web.de> <25545.32808.993869.466435@woitok.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18824"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) Cc: help-gnu-emacs@gnu.org To: Dr Rainer Woitok Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 20 10:35:06 2023 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 1pInnd-0004a6-PB for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 20 Jan 2023 10:35:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pInms-0001sG-Us; Fri, 20 Jan 2023 04:34:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pInmK-0001nO-PO for help-gnu-emacs@gnu.org; Fri, 20 Jan 2023 04:33:46 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pInmI-0000df-LP for help-gnu-emacs@gnu.org; Fri, 20 Jan 2023 04:33:44 -0500 Original-Received: from localhost ([::ffff:197.239.15.2]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000010383A.0000000063CA5FF4.00002EE3; Fri, 20 Jan 2023 02:33:37 -0700 Mail-Followup-To: Dr Rainer Woitok , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <25545.32808.993869.466435@woitok.gmail.com> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142451 Archived-At: * Dr Rainer Woitok [2023-01-19 20:39]: > Sorry, I'm late in this discussion. And to explain why this has not to > do with Gods but rather with simple mathematics, I need to know a little > bit about your math knowledge. Thanks, though it is not related to my question. My question is related to why or how is it useful in Lisp. Apart from "minimizing error handling in some situation" or "sketching of programs" or "shortening of macros", can you demonstrate me how it is useful in Lisp? Let me demonstrate the vague use that was so far discovered: ------------------------------------------------------------ Example of sketching of program: -------------------------------- User thinks of list, but does not place it: (let ((my-factor-1 1) (my-factor-2 2) (my-factor-3 3) (my-factor-4 4)) (+ (*) (* my-factor-3 my-factor-4 ))) then in the next step user does place the elements: (let ((my-factor-1 1) (my-factor-2 2) (my-factor-3 3) (my-factor-4 4)) (+ (* my-factor-1 my-factor-2) (* my-factor-3 my-factor-4 ))) I can't say that above is good usage example, as in fact, programmer may forget that he wrote (*) and may get result without being warned that factors are missing. Example of minimizing errors: ----------------------------- (setq my-list '()) (apply #'* '(2 3 4)) ➜ 24 (apply #'* my-list) ➜ 1 However, in that case programmer could forget to put something in the list, and raising of error is more important for empty list or missing arguments, than just yielding 1. Minimizing errors means neglecting the function and unexpected results. Function `apply' and `reduce' can as well take any kind of functions that require zero or more arguments. When let us say a list has only single element and I wish to `apply' addition on such list, then I can just give that single element as result instead of running function on single list element. So that is matter of programming style and care. It does not really answer my question where is (*) useful. Missing example of macro minimization ------------------------------------- In that example programmer would write shorter macro when function does not require 2 factors and somewhat longer where function require two arguments. Example of fun with (*) ----------------------- (defun m (n) (let ((m)) (dotimes (b n) (setq m (cons "(*)" m))) (concat "(+" (string-join m) ")"))) (let ((first 1)) (insert "\n") (while (<= first 10) (let ((second 1)) (while (<= second 10) (insert "(*" (m first)(m second) ")\n") (setq second (1+ second))) (setq first (1+ first))))) Other example of fun with (*) ----------------------------- (+ (*) (*) (*) (*) (*) (*)) ➜ 6 Or maybe function was made for mathematics lovers? -------------------------------------------------- (*) ➜ 1 Just "because" we love mathematics. The unanswered question: ------------------------ Do you know the actual practical example in any Lisp which will show how (*) ➜ 1 is useful? I do not ask how there are some "laws" outside of Lisp and because of those laws somebody liked them and included in a function. That sounds capricious. To find useful function, we may find which program or function CANNOT be executed (with slight modification) if I would make multiplication to require 2 factors? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/