Skip to content

Instantly share code, notes, and snippets.

@TimeSeriesLord
TimeSeriesLord / greggs-mezz.red
Created September 28, 2016 03:56 — forked from greggirwin/greggs-mezz.red
A bunch of general purpose mezzanine funcs for Red.
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 [
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]
@TimeSeriesLord
TimeSeriesLord / analog-clock.red
Created September 28, 2016 03:52 — forked from greggirwin/analog-clock.red
An analog clock for Red
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]
@TimeSeriesLord
TimeSeriesLord / lc.r
Created September 28, 2016 03:50 — forked from dockimbel/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 []
]
@TimeSeriesLord
TimeSeriesLord / dyn-rule.red
Created September 28, 2016 03:48 — forked from dockimbel/dyn-rule.red
Example of dynamic rule creation in Parse dialect using the Red language. The code can be copy/pasted directly into a Red console.
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.