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 / opt.red
Created July 10, 2016 19:49
Red `opt` function (optional result based on condition)
opt: func [
"If condition is TRUE, return value, otherwise return empty value of the same type"
condition
value "Some types, e.g., word types, return none if condition is false."
][
either condition [ value ][ attempt [make value 0] ]
]
;opt true 'a
;opt true "A"
@greggirwin
greggirwin / greggs-mezz.red
Last active June 21, 2018 18:54
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
@greggirwin
greggirwin / math-lab.red
Last active October 23, 2017 19:49
Interactive math function laboratory
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.
@greggirwin
greggirwin / trig-lab.red
Last active October 23, 2017 19:53
Interactive trig function laboratory
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.
}
]
@greggirwin
greggirwin / menu.red
Created August 19, 2016 20:44
Basic Red menu demo
Red [
File: %menu.red
Author: "Gregg Irwin"
]
; The menu dialect in Red is easy. When making a face, you use `menu:`
; followed by a block of [string! block!] pairs, where the string is the
; text of the top level menu and the block is a simple dialect that
; defines the drop-down menu items. Each item can be either a string!
; followed by a word!, or the special separator marker of '---. That's it.
@greggirwin
greggirwin / *-while.red
Last active March 27, 2017 23:04
Various <action>-while example funcs for Red.
; A number of languages have `take-while/drop-while` funcs. This is just to show how you
; can build them in Red.
; This model can be applied to any function that has a `/part` refinement, or extended in
; any number of ways. We don't yet have a standard `apply` or `refine` function in Red.
; Once we do, a more general HOF version could take the action as an arg, as well as the
; test to apply.
; Should this return the position, like FIND, rather than an integer?
; No match would then mean a NONE result. REMOVE/TAKE/COPY with /PART
@greggirwin
greggirwin / intuplate.red
Last active December 14, 2016 05:52
Tuple interpolation in Red
; It might seem like just a party trick, out of context. The goal is not "look how
; we can twist the language around!". Think, instead, of how you can use the language
; to most clearly express intent in different domains, or for different users. Quite
; often, when a user wants a different way to express things, we can accommodate them.
; It's also true that we can suggest a form that exists natively in Red, and they will
; be just as happy.
;
; Don't twist the language because you can. But don't be afraid to when it helps.
```
@greggirwin
greggirwin / red-paint-with-time-travel.red
Last active February 8, 2018 18:29
Red Paint with time travel
Red [
title: "Paint"
Author: [REBOL version "Frank Sievertsen" Red port "Gregg Irwin"]
File: %paint-with-time-travel.red
Tabs: 4
Needs: View
version: 0.0.3
Notes: {
The original didn't have time travel.
@greggirwin
greggirwin / REP 101 notes 2016-10-01.md
Last active October 1, 2016 20:49
REP 101 notes 2016-10-01

Setup

First, thanks to everyone for taking time to read the proposal, do their own research, and offer suggestions. I don't know how to export messages from Gitter, so I'm afraid comments there may be lost to time. The REP is a wiki, so you can post your thoughts there. Wiki conversation isn't effective, but if we each have a comment section, we can put our interim and final thoughts there as we move forward. Or Peter can say if we would prefer to have people post things here for him to curate there.

@greggirwin
greggirwin / world-sim-blocks.red
Last active December 14, 2016 05:53
A simple simulator thought experiment, using blocks as the main data structure
Red [
author: "Gregg Irwin"
]
comment {
From Gitter, @this-gavagai asked about modeling in Red compared to modeling
in traditional OOP languages. Here's the concrete example given:
"
Imagine you wanted to simulate economic dynamics in a third world village. You