Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@dockimbel
dockimbel / to-Roman.red
Last active October 12, 2016 20:16
Arabic to Roman numbers converter in Red
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 [
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
@dockimbel
dockimbel / Livecode enhanced
Created September 10, 2016 06:05 — forked from DideC/Livecode enhanced
Based on Dockimbel VID livecode, this is a little more advanced version where you can define Red's values used by the VID code. And the window is resizable.
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.
}
@dockimbel
dockimbel / lc.r
Created August 6, 2016 11:11 — forked from maximvl/lc.r
List comprehension dialect for Rebol
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 []
]
Red []
find-until: function [series test][
res: copy []
forall series [
either not test first series [
append res first series
] [
break/return res
]
Red [
Title: "Bouncing Boxes Connected"
Needs: View
]
Arial: make font! [size: 14 name: "Consolas" style: 'bold]
view [
title "Bouncing Boxes Connected"
size 400x400
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]
@dockimbel
dockimbel / picosheet-packed.red
Last active May 12, 2020 14:35
Native reactive spreadsheet demo in 14 LOC
;-- 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][
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]
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)]