Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@greggirwin
greggirwin / bmr-calc.red
Last active July 14, 2023 19:14
Reactive BMR calculator in Red
Red [
Title: "BMR (Basal Metabolic Rate) Calculator"
Author: "Gregg Irwin"
File: %bmr-calc.red
Needs: View
Comment: {
An experiment in reactivity and data modeling.
TBD: Caloric calcs based on activity level.
@greggirwin
greggirwin / bmr-calc-code-only.red
Last active July 14, 2023 19:17
The BMR Calculator without all the prose
Red [
Title: "BMR (Basal Metabolic Rate) Calculator"
Author: "Gregg Irwin"
File: %bmr-calc.red
Needs: View
Comment: {
An experiment in reactivity and data modeling.
TBD: Caloric calcs based on activity level.
@greggirwin
greggirwin / like.r
Created November 25, 2016 18:04
VB Like Operator Module for Rebol2
REBOL [
Title: "VB Like Operator Module"
Date: 10-Sep-2003
Version: 0.0.3
File: %like.r
Author: "Gregg Irwin"
Purpose: {
The LIKE? function is a first crack at something like
VB's Like operator. i.e. a *very* simple RegEx engine. The
real purpose was to help me get acquainted with parse.
@greggirwin
greggirwin / pretty-print.red
Created March 2, 2017 00:46
Red Pretty Printer
Red [
title: "Red Pretty Printer"
notes: "Derived from http://www.rebol.net/cookbook/recipes/0042.html"
]
output: none ; output text
indent: copy "" ; indentation chars
emit-val: func [val] [append output val]
@greggirwin
greggirwin / cycler.red
Last active March 21, 2017 15:41
Round-robin cycling through a series
Red []
cycler: context [
_data: none
_key: none
set-data: func [data [block!]][
_data: copy data
; Should we make sure the data conforms to our needs?
;if (last data) <> (first data) [
append/only _data first _data
@greggirwin
greggirwin / closure-cycler.red
Last active August 15, 2017 15:33
A different approach to a cycle generator, using a closure.
Red []
closure: func [
vars [block!] "Values to close over, in spec block format"
spec [block!] "Function spec for closure func"
body [block!] "Body of closure func; vars will be available"
][
func spec bind body context vars
]
cycler: func [block [block!]][
@greggirwin
greggirwin / load-any.red
Created March 23, 2017 17:53 — forked from dockimbel/load-any.red
Experimental generic loader for non-Red input text.
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
@greggirwin
greggirwin / typeset-list.red
Created March 24, 2017 17:59
Interactive typeset list viewer
Red []
form-all: func [blk][forall blk [blk/1: form blk/1] blk]
types-of: function [value [typeset!]][
; typesets don't support reflection
third load mold value
]
get-sys-words: func [test [function!]][
@greggirwin
greggirwin / datatype-help.red
Created March 25, 2017 21:57
Small GUI experiment for showing datatype information.
Red []
form-all: func [blk][
forall blk [blk/1: form blk/1]
blk
]
types-of: function [value [typeset!]][
; typesets don't support reflection
third load mold value
@greggirwin
greggirwin / a-or-b-op.red
Last active March 27, 2017 17:31
Infix operator you can use like ANY for two args.
Red []
a-or-b: function [a b][any reduce [a b]]
|: make op! :a-or-b
example: {
>> a-or-b: function [a b][any reduce [a b]]
== func [a b][any reduce [a b]]
>> |: make op! :a-or-b
== make op! [[a b]]