From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: What about seq-slice? (Was: Would seq-range and seq-mapcat be useful?) Date: Fri, 30 Jan 2015 03:20:04 -0500 Message-ID: <87iofoof2j.fsf@udel.edu> References: <878uglwmra.fsf@petton.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1422609071 4863 80.91.229.3 (30 Jan 2015 09:11:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Jan 2015 09:11:11 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 30 10:11:10 2015 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 1YH7bY-0004by-Ny for ged-emacs-devel@m.gmane.org; Fri, 30 Jan 2015 10:11:08 +0100 Original-Received: from localhost ([::1]:35614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH7bY-0007ZY-5d for ged-emacs-devel@m.gmane.org; Fri, 30 Jan 2015 04:11:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH6oD-0005db-NI for emacs-devel@gnu.org; Fri, 30 Jan 2015 03:20:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH6oA-00038j-Ii for emacs-devel@gnu.org; Fri, 30 Jan 2015 03:20:09 -0500 Original-Received: from mail-qa0-f51.google.com ([209.85.216.51]:64528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH6oA-00036T-FS for emacs-devel@gnu.org; Fri, 30 Jan 2015 03:20:06 -0500 Original-Received: by mail-qa0-f51.google.com with SMTP id f12so18881690qad.10 for ; Fri, 30 Jan 2015 00:20:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=AjQDLiQp2QAh4fuwv1QJh1WdXe/I8RYBiHBOfKWkA+4=; b=Ups/hyGsBoVtth7r6nyzOkK5G4q1sVXtcuC9lvkcT6DVr/5ckp+wx0JQQN94Llkf+j SXuz9W0YSJo3K0kE+MFGGd/iHKw+bGJ9REOzcg/nRy079VEu2eduX8D3PnDYjb7eYsFY d8Gy+zi0/OK6SY6eOAsYnSvEoXyVzYPXoNC4444Xg4UjxGpyuIpRx9Lkak28ehLstEke hOxDiK0P9us4b6Z7/u4Gn3w1l8PMYPar1r0zG4AnKbCAj/TXMkFtJS/PjbBxXaABmA/J i2QYb0ZKuUv0WsBrjUaaduWS6wR5oNCR/naYRTTNAdqWzfAL0iA347JESBejw2iADnC3 rUIA== X-Gm-Message-State: ALoCoQnT7KaVnwsCnvakvG8RakjXTJDtIYHRpmA2enbBF5fVgQE2im/R148KoQVG1RUjrwka21OM X-Received: by 10.140.101.119 with SMTP id t110mr9600281qge.9.1422606005520; Fri, 30 Jan 2015 00:20:05 -0800 (PST) Original-Received: from holos (c-73-163-124-41.hsd1.md.comcast.net. [73.163.124.41]) by mx.google.com with ESMTPSA id m74sm9409811qgd.17.2015.01.30.00.20.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jan 2015 00:20:05 -0800 (PST) In-Reply-To: <878uglwmra.fsf@petton.fr> (Nicolas Petton's message of "Thu, 29 Jan 2015 17:54:33 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.216.51 X-Mailman-Approved-At: Fri, 30 Jan 2015 04:11:05 -0500 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:182032 Archived-At: Nicolas Petton writes: > While using seq.el, I often miss functions like seq-mapcat and > seq-range. Do you think adding such functions would be a good addition > to seq.el? Coincidentally, I had been thinking about additions to seq.el. I'm interested in having a function like Ruby's each_slice[0] method. For example, (defun seq-slice (seq n) "Return a list of subsequences of SEQ, each a sequence of length N. The last subsequence may have less than N elements. If N is a negative integer or zero, a list containing SEQ is returned." (if (or (<= n 0) (>= n (seq-length seq))) (list seq) (let ((copy (seq-copy seq)) (result '())) (while (not (seq-empty-p copy)) (push (seq-take copy n) result) (setq copy (seq-drop copy n))) (nreverse result)))) I didn't think dash.el had it until I realized it is named something else: -partition-all[1]. [0]: http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-each_slice [1]: https://github.com/magnars/dash.el/blob/master/dash.el#L730