all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [ANN] New library stream.el in ELPA
@ 2015-10-14 11:43 Nicolas Petton
  2015-10-14 12:37 ` Michael Heerdegen
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: Nicolas Petton @ 2015-10-14 11:43 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1632 bytes --]

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 >= 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), unless
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)
      

Cheers,
Nico

[1] https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2015-10-24 20:52 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-14 11:43 [ANN] New library stream.el in ELPA Nicolas Petton
2015-10-14 12:37 ` Michael Heerdegen
2015-10-14 13:20   ` Nicolas Petton
2015-10-14 13:33     ` Michael Heerdegen
2015-10-14 13:30   ` Nicolas Petton
2015-10-14 22:13     ` Michael Heerdegen
2015-10-15  7:38       ` Nicolas Petton
2015-10-14 16:09 ` John Wiegley
2015-10-14 16:20   ` Nicolas Petton
2015-10-14 16:40     ` John Wiegley
2015-10-14 19:31       ` Nicolas Petton
2015-10-14 21:31         ` John Wiegley
2015-10-14 21:51           ` Nicolas Petton
2015-10-15  0:42           ` raman
2015-10-15  0:48             ` John Wiegley
2015-10-18 18:29           ` Daniel Colascione
2015-10-19  4:38             ` Stephen J. Turnbull
2015-10-20  6:55               ` John Wiegley
2015-10-20  7:02                 ` Daniel Colascione
2015-10-20 15:18                   ` John Wiegley
2015-10-20 16:16                   ` Jay Belanger
2015-10-20 10:20                 ` Stephen J. Turnbull
2015-10-20 12:07             ` David Kastrup
2015-10-23 11:30           ` Nicolas Petton
2015-10-23 19:21             ` John Wiegley
2015-10-15 10:08   ` Michael Heerdegen
2015-10-15 18:25     ` John Wiegley
2015-10-15 22:13       ` Nicolas Petton
2015-10-15 20:28 ` John Mastro
2015-10-15 22:02   ` Nicolas Petton
2015-10-24 19:16 ` Michael Heerdegen
2015-10-24 20:52   ` Nicolas Petton

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.