Skip to content

Instantly share code, notes, and snippets.

@9214

9214/streams.red Secret

Created May 19, 2020 12:13
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 9214/e0410184b76d9e6e339bd5d8e0000218 to your computer and use it in GitHub Desktop.
Save 9214/e0410184b76d9e6e339bd5d8e0000218 to your computer and use it in GitHub Desktop.
Red [
Title: "Ad-hoc streams"
Author: @9214
Date: ..?
]
freeze: func [seed [block!] growth [function!]][
insert seed :growth
]
thaw: func [stream [block!]][
next append/only stream stream/-1 stream
]
fibonacci: function [stream [block!]][
tip: tail stream
tip/-1 + tip/-2
]
harmony: freeze [0 1] :fibonacci
probe loop 20 [thaw harmony]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment