From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Gnu Elpa: stream.el: Add some more basic stream operations Date: Thu, 02 Mar 2017 13:58:19 +0100 Message-ID: <87zih3kf84.fsf@petton.fr> References: <87twhbmwbx.fsf@web.de> <878tynl720.fsf@petton.fr> <8737onlapw.fsf@web.de> <87ziqu7ew9.fsf@petton.fr> <87mvmuxuyo.fsf@web.de> <8760tixi99.fsf@web.de> <87twh1kpem.fsf@web.de> <87y42r4d3a.fsf@web.de> <878tug9eh3.fsf@web.de> <87a8es6dcq.fsf@web.de> <87bmz7517d.fsf@web.de> <87shmw76cm.fsf@drachen> <87inns6zos.fsf@drachen> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1488459540 12066 195.159.176.226 (2 Mar 2017 12:59:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 2 Mar 2017 12:59:00 +0000 (UTC) Cc: Emacs developers To: Michael Heerdegen , Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 02 13:58:55 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjQJo-0002CM-5b for ged-emacs-devel@m.gmane.org; Thu, 02 Mar 2017 13:58:52 +0100 Original-Received: from localhost ([::1]:51997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjQJu-0005fW-9W for ged-emacs-devel@m.gmane.org; Thu, 02 Mar 2017 07:58:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjQJL-0005em-Pq for emacs-devel@gnu.org; Thu, 02 Mar 2017 07:58:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjQJK-0000Wx-UV for emacs-devel@gnu.org; Thu, 02 Mar 2017 07:58:23 -0500 Original-Received: from petton.fr ([2a00:5884:8368::1]:34427) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjQJK-0000WK-O3 for emacs-devel@gnu.org; Thu, 02 Mar 2017 07:58:22 -0500 In-Reply-To: <87inns6zos.fsf@drachen> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:5884:8368::1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:212705 Archived-At: --=-=-= Content-Type: text/plain Michael Heerdegen writes: > BTW, with the suggested approach, you can use a counter to specify a > break condition, like here, were I want to calculate the stream of > natural numbers up to a place where two subsequent elements have a > difference that is not less than 2 (which never happens), but where I > say I want to have at most 25 elements: > > #+begin_src emacs-lisp > (seq-into-sequence > (car > (stream-divide > (let (the-naturals) (setq the-naturals (stream-cons 1 (seq-map #'1+ the-naturals)))) > (let ((counter 0)) > (lambda (this next) > (and (< (cl-incf counter) 25) > (< (- next this) 2))))))) > ==> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25) > #+end_src That's really neat! Cheers, Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJYuBbrAAoJECM1h6R8IHkQKgoIAMQlTDEP15kE4yWpXJdH/7Tr F/UNSNFxxLecgQP4345BlMmjQpeaC/dBKgTTi5IxKhUjKoyGa9kMVvGnZE/9zZRw 0s7tY47ESJRnCR7ZtamcQm9eIvC454Gy0rs+O9iAlZNU4hpoJwNHoXJi0Vvsz4O9 OsiDUC4Hof+PPK5xDZtlkZzSMMPz4GaTWdTs4Yyy4DZ3E0o1iS4NsF2sUjSbsLeM 3i46HlH3xY4r9oonsy8ApaW+PNHftvc/XXX7J+GwQhghZKcXqhEQOhCo9WsmcfdQ xmvyRTvJqZf+HD/Tic3AGsyxLc+1NnE7CiKnprI+7I9hCJXNl+ASpkKkjKVm1Nc= =+vTE -----END PGP SIGNATURE----- --=-=-=--