From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: sequence manipulation functions Date: Wed, 05 Nov 2014 10:26:16 -0500 Message-ID: References: <87oasmmwzt.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415201255 19882 80.91.229.3 (5 Nov 2014 15:27:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 15:27:35 +0000 (UTC) Cc: Emacs developers To: Nicolas Petton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 05 16:27:28 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xm2UZ-0001NQ-Sm for ged-emacs-devel@m.gmane.org; Wed, 05 Nov 2014 16:27:28 +0100 Original-Received: from localhost ([::1]:46998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2UZ-0007IX-Fx for ged-emacs-devel@m.gmane.org; Wed, 05 Nov 2014 10:27:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2TZ-0006IH-QC for emacs-devel@gnu.org; Wed, 05 Nov 2014 10:26:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xm2TS-0001R8-Bd for emacs-devel@gnu.org; Wed, 05 Nov 2014 10:26:25 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:35831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xm2TS-0001Qt-7s for emacs-devel@gnu.org; Wed, 05 Nov 2014 10:26:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4MAOatTlRFpY87/2dsb2JhbABcgw6DYoZ+y1MEAgKBHBcBAXyEAwEBAwFWIwULCzQSFBgNJIhLCctyAQEBAQYBAQEBHpEIB4RLBYtkpjyBb4QWH4J6AQEB X-IPAS-Result: Au4MAOatTlRFpY87/2dsb2JhbABcgw6DYoZ+y1MEAgKBHBcBAXyEAwEBAwFWIwULCzQSFBgNJIhLCctyAQEBAQYBAQEBHpEIB4RLBYtkpjyBb4QWH4J6AQEB X-IronPort-AV: E=Sophos;i="5.04,797,1406606400"; d="scan'208";a="96019270" Original-Received: from 69-165-143-59.dsl.teksavvy.com (HELO pastel.home) ([69.165.143.59]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Nov 2014 10:26:16 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 665E37AB7; Wed, 5 Nov 2014 10:26:16 -0500 (EST) In-Reply-To: <87oasmmwzt.fsf@gmail.com> (Nicolas Petton's message of "Tue, 04 Nov 2014 23:17:26 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:176405 Archived-At: > Here are two files that add some missing sequence-manipulation functions > to Emacs Lisp. I think these should use a "seq-" prefix. This will not only avoid naming conflicts, but also helps discover those functions, since you can type `(seq- TAB' to see all related functions. > ;;; Commentary: > > ;; Sequence manipulation functions No need to repeat the title here. > ;;;###autoload It seems that pretty much all functions in this file are marked as ;;;###autoload. In that case I think it's better to not mark any of them as autoloaded. > (defun rest (seq) > "Return all but the first element of the sequence SEQ. > If SEQ is nil or empty, return nil." The different of cost between "rest of a list" and "rest of an array" is so large that merging the two this way is probably not a good idea. > "Reduce two-argument FUNCTION across SEQ, starting with INITIAL-VALUE if not nil." > (let ((acc (or initial-value (if (empty-p seq) > (funcall function) You start by saying "two-argument FUNCTION" and then you call it here without any argument. > (mapc (lambda (item) > (setq acc (funcall function acc item))) > (if initial-value seq (rest seq))) I don't think using `rest' here is a good idea when`seq' is an array. > "Sort the sequence SEQ comparing elements using PRED." It needs to say that it returns a list rather than a sequence of the same type as SEQ. Stefan