This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; 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" | |
| ][ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| load-any: function [input [string!]][ | |
| out: make block! 100 | |
| junk: none | |
| until [ | |
| result: load/trap/next input 'pos | |
| either error? result/3 [ | |
| append any [junk junk: make string! 20] result/2/1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| Author: "ifgem" | |
| ] | |
| #do [ | |
| macro: context [ | |
| make-object-spec: function [words] [ | |
| spec: copy [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| title: "Heart animation" | |
| author: "Didier Cadieu" | |
| notes: { | |
| Traduction in Red/Rebol of Terebus Volodymyr javascript demo : http://codepen.io/tvolodimir/pen/wqKuJ | |
| } | |
| Needs: View | |
| ] | |
| ;*** Settings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| description: { | |
| Attempt to copy Haiku Editor | |
| (http://forthsalon.appspot.com/haiku-editor) | |
| } | |
| ] | |
| map: func [s 'word body] [ | |
| bind body 'word | |
| forall s [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| Title: "BMR (Basal Metabolic Rate) Calculator" | |
| Author: "Gregg Irwin" | |
| File: %bmr-calc.red | |
| Needs: View | |
| Comment: { | |
| An experiment in reactivity and data modeling. | |
| 145 lines with blanks and comments removed. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| #system [ | |
| #import [ | |
| "shell32.dll" stdcall [ | |
| ShellExecute: "ShellExecuteW" [ | |
| hwnd [integer!] | |
| lpOperation [c-string!] | |
| lpFile [c-string!] | |
| lpParameters [integer!] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red[ | |
| Title: "Raytracer" | |
| Needs: 'View | |
| Notes: "Simple raytracer based on 'Ray Tracing in One Weekend' by Peter Shirley" | |
| ] | |
| vec3_dot: function [a[vector!] b[vector!]] [ | |
| reduce (a/1 * b/1) + (a/2 * b/2) + (a/3 * b/3) | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| Title: "Conway's Game of Life" | |
| Needs: 'View | |
| ] | |
| grid: collect [repeat i 10 [keep/only collect [repeat j 10 [keep random true]]]] | |
| scratchgrid: collect [repeat i 10 [keep/only collect [repeat j 10 [keep false]]]] | |
| a: copy grid/1 | |
| b: copy grid/10 |