This file contains 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 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 |
This file contains 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: "Simple GUI livecoding demo" | |
Author: "Nenad Rakocevic / Didier Cadieu" | |
File: %livecode2.red | |
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. | |
} |
This file contains 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
REBOL [] | |
print [] | |
lc: function [block] [lc-state lc-rule input-rule filter-rule i e] [ | |
lc-state: make object! [ | |
do-block: copy [] | |
inputs: copy [] | |
filter-block: none | |
input-state: copy [] | |
res: copy [] | |
] |
This file contains 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 [] | |
find-until: function [series test][ | |
res: copy [] | |
forall series [ | |
either not test first series [ | |
append res first series | |
] [ | |
break/return res | |
] |
This file contains 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: "Bouncing Boxes Connected" | |
Needs: View | |
] | |
Arial: make font! [size: 14 name: "Consolas" style: 'bold] | |
view [ | |
title "Bouncing Boxes Connected" | |
size 400x400 |
This file contains 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 [] L: charset "ABCDEFGHI" D: union N: charset "123456789" charset "0" | |
repeat y 9 [repeat x 9 [col: either x = 1 [#"^(2028)"][#"A" + (x - 2)] | |
append p: [] set ref: (to word! rejoin [col y - 1]) make face! [size: 90x24 | |
type: pick [text field] header?: (y = 1) or (x = 1) | |
offset: -20x10 + as-pair ((x - 1) * size/x + 2) ((y - 1) * size/y + 1) | |
text: form case [y = 1 [col] x = 1 [y - 1] 'else [copy ""]] | |
para: make para! [align: pick [center right] header?] | |
extra: object [name: form ref formula: old: none] | |
actors: context [on-create: on-unfocus: function [f e][f/color: none | |
if rel: f/extra/old [react/unlink rel 'all] |
This file contains 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
;-- Each line is limited to 82 characters. Requires Red build from 07/07/2016 at least. | |
;-- Save it to a file to be able to run it, or type at console's prompt `do [`, paste the code, type `]` and ENTER. | |
Red [] L: charset "ABCDEFGHI" D: union N: charset "123456789" charset "0" repeat | |
y 9 [repeat x 9 [col: either x = 1 [#"^(2028)"][#"A" + (x - 2)] append p: [] set | |
ref:(to word! rejoin [col y - 1]) make face! [size: 90x24 type: pick [text field] | |
header?: (y = 1) or (x = 1) offset: -20x10 + as-pair ((x - 1) * size/x + 2) ((y | |
- 1) * size/y + 1) text: form case [y = 1 [col] x = 1 [y - 1] 'else [copy ""]] | |
para: make para! [align: pick [center right] header?] extra: object [name: form | |
ref formula: old: none] actors: context [on-create: on-unfocus: function [f e][ |
This file contains 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 [] L: charset "ABCDEFGHI" D: union N: charset "123456789" charset "0" | |
repeat y 9 [repeat x 9 [col: either x = 1 [#"^(2028)"][#"A" + (x - 2)] | |
append p: [] set ref: (to word! rejoin [col y - 1]) make face! [size: 90x24 | |
type: pick [text field] header?: (y = 1) or (x = 1) | |
offset: -20x10 + as-pair ((x - 1) * size/x + 2) ((y - 1) * size/y + 1) | |
text: form case [y = 1 [col] x = 1 [y - 1] 'else [copy ""]] | |
para: make para! [align: pick [center right] header?] | |
extra: object [name: form ref formula: old: none] | |
actors: context [on-create: on-unfocus: function [f e][f/color: none | |
if rel: f/extra/old [react/unlink rel 'all] |
This file contains 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 [Needs: View] | |
L: charset "ABCDEFGHI" | |
N: charset "123456789" | |
D: union N charset "0" | |
p: [] | |
repeat y 9 [ | |
repeat x 9 [ | |
col: either x = 1 [#"^(2028)"][#"A" + (x - 2)] |