[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: streams are cool, you could stream virtually anything!

From: John Wiegley
Subject: Re: streams are cool, you could stream virtually anything!
Date: Thu, 05 Nov 2015 21:08:32 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

Hi Nicolas,

A rich source of ideas could come from looking at the streaming libraries of
other languages, like SERIES in Common Lisp, or conduit in Haskell. To give
just a few ideas of what might arise from such research:

    stream-take N STR

        Produce a stream composed of up to the first N elements of STR.

    stream-drop N STR

        Produce a stream starting after the first N elements of STR.

        stream-cdr = stream-drop 1

    stream-apply #'FUNC STR1.. STRN

        Given a function, reads its arguments from STR1.. STRN, and #'apply
        the function to those arguments. Its result is the corresponding
        element of the resulting stream. Continue until one of the argument
        streams reaches its end.

        stream-zip = stream-apply #'cons
    stream-apply* #'FUNC STR1.. STRN

        Like stream-apply, but any exhausted argument stream is seen to return
        nil until all are exhausted.

    stream-iterate FUNC VAL

        Produce a stream by funcall'ing FUNC on VAL to determine the first
        element, then funcall FUNC on that result to produce the next element,
        so on until infinity.

    stream-isolate N STR

        Ensure a resulting stream that is exactly N elements long. This is
        like stream-take if STR is longer, otherwise it's like appending N-M
        nil values onto STR, where M is the actual length.

    stream-append STR1 STR2

        Concatenate two streams, producing a longer one.


        This is a macro wrapper around `loop' that adds a new keyword:
        streaming. Like collect, except it collects the results in a stream
        instead of a list.

    stream-list LIST

        Make a list look like a stream (i.e., accessible using the stream

    stream-collect STR

        Drain all the elements of STR into a list.

    stream-repeat N VAL

        A stream consisting of VAL repeated N times.

This list could easily be many times as long... For more inspiration see:


If you'd like me continue, just say. I've written libraries similar to this
before, just not in Emacs Lisp (and it's awesome that it's becoming easy to!).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]