Skip to content

Instantly share code, notes, and snippets.

@rares
Created December 6, 2011 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rares/1439502 to your computer and use it in GitHub Desktop.
Save rares/1439502 to your computer and use it in GitHub Desktop.
-module(stream).
-export([take/2, build/2]).
build(K, C) ->
[K|fun() -> build(K + C, C) end].
take(S, N) ->
take(S, [], N).
take([_|_], Out, 0) -> Out;
take([K|C], Out, N) ->
take(C(), Out ++ [K], N - 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment