(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| <!-- | |
| Sign .exe files using signtool.exe. | |
| (c) 2014 Greg MacLellan, Licensed under MIT http://opensource.org/licenses/MIT | |
| Features: | |
| * Hides password from being displayed in build output | |
| * Retries against multiple timestamp servers if the server returns an invalid response (fairly common) | |
| Usage: |
| Red [ | |
| Title: "Tile game" | |
| Purpose: {An implementation in Red of the 4x4 sliding tile puzzle} | |
| Author: "Rudolf W. MEIJER (meijeru)" | |
| File: %tile-game.red | |
| Needs: 'View | |
| Usage: { | |
| Click on any tile that is adjacent to the empty space | |
| and it will shift to that space. | |
| Try to obtain a given configuration, e.g. 1 to 15 in order. |
| ; We have other reflective functions (words-of, body-of, etc.), but | |
| ; this is a little higher level, sounded fun to do, and may prove | |
| ; useful as we write more Red tools. It also shows how to make your | |
| ; own typesets and use them when parsing. | |
| arity-of: function [ | |
| "Returns the fixed-part arity of a function spec" | |
| spec [any-function! block!] | |
| /with refs [refinement! block!] "Count one or more refinements, and add their arity" | |
| ][ |
| Red [ | |
| File: %greggs-mezz.red | |
| Author: "Gregg Irwin" | |
| Purpose: "An interim mezzanine dump, while Red is still moving fast." | |
| Tabs: 4 | |
| Comment: { | |
| Not everything here has been well-tested or, well, tested. Most | |
| of the functions are ports from R2, with many more to come. I'm | |
| combining everything in one file for ease of experimentation, so | |
| you don't have to worry about includes or dependencies with the |
| Red [ | |
| Title: "Simple GUI livecoding demo" | |
| Author: "Nenad Rakocevic / Didier Cadieu" | |
| File: %livecode.red | |
| Version: 1.2.1 | |
| Needs: 'View | |
| Usage: { | |
| Type VID code in the bottom right area, you will see the resulting GUI components | |
| rendered live on the left side and fully functional (events/actors/reactors working live). | |
| The top right area let you define Red's values to be used in your VID code, even functions or anything. |
| ; A number of languages have `take-while/drop-while` funcs. This is just to show how you | |
| ; can build them in Red. | |
| ; This model can be applied to any function that has a `/part` refinement, or extended in | |
| ; any number of ways. We don't yet have a standard `apply` or `refine` function in Red. | |
| ; Once we do, a more general HOF version could take the action as an arg, as well as the | |
| ; test to apply. | |
| ; Should this return the position, like FIND, rather than an integer? | |
| ; No match would then mean a NONE result. REMOVE/TAKE/COPY with /PART |
| Red [ | |
| Purpose: "Arabic to Roman numbers converter" | |
| Date: "06-Oct-2016" | |
| ] | |
| table: [1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I] | |
| to-Roman: function [n [integer!]] reduce [ | |
| 'case collect [ | |
| foreach [a r] table [ |
| Red [ | |
| author: "Gregg Irwin" | |
| ] | |
| comment { | |
| From Gitter, @this-gavagai asked about modeling in Red compared to modeling | |
| in traditional OOP languages. Here's the concrete example given: | |
| " | |
| Imagine you wanted to simulate economic dynamics in a third world village. You |
| Red [] | |
| #system [ | |
| chr: 1 | |
| handle: 0 | |
| KEYDOWN: 0 | |
| KEYUP: 2 | |
| minus-one: -1 | |
| pointer-to-minus-one: :minus-one | |
| rs-phrase: "" |