From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: [ANN] New library stream.el in ELPA Date: Wed, 14 Oct 2015 13:43:06 +0200 Message-ID: <87d1whk75h.fsf@petton.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1444823111 26148 80.91.229.3 (14 Oct 2015 11:45:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Oct 2015 11:45:11 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 14 13:45:01 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 1ZmKUN-0008R9-Qp for ged-emacs-devel@m.gmane.org; Wed, 14 Oct 2015 13:45:00 +0200 Original-Received: from localhost ([::1]:41794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmKUI-0006MM-2x for ged-emacs-devel@m.gmane.org; Wed, 14 Oct 2015 07:44:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmKSg-0006D8-29 for emacs-devel@gnu.org; Wed, 14 Oct 2015 07:43:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmKSc-0005r7-L9 for emacs-devel@gnu.org; Wed, 14 Oct 2015 07:43:13 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:40119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmKSc-0005qM-F4 for emacs-devel@gnu.org; Wed, 14 Oct 2015 07:43:10 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id EEEF7200CD for ; Wed, 14 Oct 2015 07:43:08 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 14 Oct 2015 07:43:08 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=9S iI/m0+bMaFFv2vYAVPsXnkfLI=; b=qS6KAGukr05ey82UHCQCNnoCgQBEHV6w01 sh+HH623nk9dCTMyqQO2uANG2HxMxShZuzurfWfPZzqN8nPbK8ZG+bFKU1CKmmPv QyM1weCNh70kWdX2Qy0+BvR7Gfq7+hj00RDc+cCt7h6gO887aUH2pnKqU7MUCaAX 46mLqD3Wc= X-Sasl-enc: XUmmnI8FXPDsnMlLYzOT5UL0WIAkUPREbAZSTg3Cks8h 1444822988 Original-Received: from blueberry (brc29-2-88-162-37-238.fbx.proxad.net [88.162.37.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 67488C00014 for ; Wed, 14 Oct 2015 07:43:08 -0400 (EDT) User-Agent: Notmuch/0.19 (http://notmuchmail.org) Emacs/25.0.50.7 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 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:191547 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, I just pushed to ELPA the first version of `stream', a new library that provides an implementation of streams. Streams are implemented as delayed evaluation of cons cells, and are immutable. In that sense they are similar to streams in the SICP book[1] or to Clojure's lazy sequences. `stream' requires Emacs >=3D 25.1, as it leverages the extensibility of seq.el (the version currently in master, not the one in ELPA): all functions defined in seq.el will work on streams, meaning that it's possible to consume a stream using `seq-take', map and filter it using `seq-map` and `seq-filter`, and so forth. Streams could be created from any sequential input data: - sequences, making operation on them lazy - a set of 2 forms (first and rest), making it easy to represent infinite = sequences - buffers (by character) - buffers (by line) - buffers (by page) - IO streams - orgmode table cells - ... The generic `stream' function currently accepts lists, strings, arrays and buffers as input, but it can be cleanly extended to support pretty much any= kind of data. All operations on streams are lazy (including the functions from seq.el), u= nless data is actually needed. Here is an example implementation of the Fibonacci numbers implemented as in infinite stream: (defun fib (a b) (stream-cons a (fib b (+ a b)))) (fib 0 1) The following example returns a stream of the first 50 characters of the current buffer: (seq-take (stream (current-buffer)) 50) =20=20=20=20=20=20 Cheers, Nico [1] https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: GPGTools - http://gpgtools.org iQEcBAEBCAAGBQJWHj/KAAoJECM1h6R8IHkQ1jIH/RA7gOn84xxsMlJuJjvd9iD+ NteLk5m2nqFfOUpqJn+oKQSbFX1p91sd+R2YtHKdaboeQpfVRGBIZJjkHPxcbEDH qbXkZ84S2wVNFz8mXRPSELtJTaIcDUNpsV0HSv2zC8UAZKN1N3b/pxl52ItAb1NB 86ivhqreO44tK0LF3qMRmJrBVZZBOIhSWfi96f/6gFWnoa0IQClIAThqcpwTAV29 9mDXpAEKadyDPEJp+SkmxGLdMrtNZWxS9+3gJc19paCBvmdrNWcga20/kN95NN8n y7bv/r9uWpPn5WjlKAR2NjN2HjM42R1gSryQJHpeSdfO22GMDbH+E8VXvGx+jTc= =KqoH -----END PGP SIGNATURE----- --=-=-=--