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: "Nenad Rakocevic" | |
Date: 06/12/2013 | |
Note: { | |
This short Red program demonstrates the use of dynamically built Parse rules. | |
It parses an imaginary external DSL with variables, and detects if a variable has | |
been used before been properly declared and initialized. | |
The detection works by comparing found variables against a list of declared | |
variables. The list starts empty, and it grows as new variables are collected. |
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
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 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: "Red O'clock" | |
Author: "Gregg Irwin" | |
] | |
degree-to-xy: func [rad "radius" deg "degrees"] [ | |
as-pair (rad * sine deg) (rad * negate cosine deg) | |
] | |
sex-to-degree: func ["Sexagesimal to degrees" n] [n * 6] |
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 [ | |
Needs: 'View | |
] | |
R: G: B: box: value: none | |
to-color: function [r g b][ | |
color: 0.0.0 | |
if r [color/1: to integer! 256 * r] | |
if g [color/2: to integer! 256 * g] |
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 [ | |
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 |
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: "math-lab.red" | |
Author: "Gregg Irwin" | |
File: %math-lab.red | |
Needs: 'View | |
Purpose: { | |
Experiment, to see what an interactive "Lab" tool might look | |
like, for general language functions. i.e., take the idea of | |
font-lab, effect-lab, gradient-lab, etc., and apply it to | |
functions to aid in language discovery and learning. |
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: "trig-lab.red" | |
Author: "Gregg Irwin" | |
File: %trig-lab.red | |
Needs: 'View | |
Purpose: { | |
See %math-lab comments for details. This script focuses | |
on trigonometric functions. | |
} | |
] |
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
invalid-utf?: function [ | |
; https://robots.thoughtbot.com/fight-back-utf-8-invalid-byte-sequences | |
"Checks UTF encoding; if correct, returns none else position of error." | |
binary [binary!] | |
][ | |
bad: [ | |
#{C0} | #{C1} | #{F5} | #{F6} | #{F7} | #{F8} | #{F9} | #{FA} | |
| #{FB} | #{FC} | #{FD} | #{FE} | #{FF} | |
] | |
if parse binary [any [[mark: bad (return mark)] | skip]] [none] |
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 [] | |
; Steeve gets credit for this one | |
detab: function [ | |
"Converts leading tabs in a string to spaces. (tab size 4)" | |
string [any-string!] "(modified)" | |
/size | |
sz [integer!] "Number of spaces per tab" | |
/all "Change all, not just leading" | |
][ |
OlderNewer