Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@toomasv
toomasv / info.red
Last active April 20, 2021 06:13
To get info about any function
Red []
context [
get-function: function [path] [
if path? path [
path: copy path
while [
not any [
tail? path
any-function? attempt [get/any either last? path [path/1] [path]]
]
@toomasv
toomasv / matrix.red
Last active October 6, 2017 10:52
Little matrix DSL
Red [
Author: "Toomas Vooglaid"
Date: 7-9-2017
Last-update: 4-10-2017
]
mx: context [
ctx: self
mtx: object [
rows: cols: data: none
get-col: func [col][extract at data col cols]
@toomasv
toomasv / chatbot.red
Last active September 12, 2017 08:39
Red [
Original: "Gregg Irwin"
Source: https://gitter.im/red/help?at=59b3040566c1c7c4772d4172
Purpose: "Toy chatbot about Red functions"
Needs: "info.red (https://gist.github.com/toomasv/eaac3829ac5e745f43121aa60b555d68)"
]
; See: http://www.red-lang.org/2016/03/060-red-gui-system.html blog entry
; Lots of name choices to consider.
@maximvl
maximvl / abc-score.red
Last active September 27, 2017 03:59
abc score for Red code
Red [
author: {Maxim Velesyuk}
usage: {
abc-score? <block of code>
abc-score? %file.red
abc-score? :some-function
}
description: {
The ABC software metric defines an ABC score as a triplet of values that represent the size of a set of source code statements.
An ABC score is calculated by counting the number of assignments (A), number of branches (B), and number of conditionals (C) in a program.
@toomasv
toomasv / l-system.red
Last active February 21, 2019 12:11
Experiments with L-System
Red [
Author: "Toomas Vooglaid"
Date: 25-9-2017
Description: {Experiments with L-System}
Last-update: 26-9-2017
Uses: {%models.red https://gist.github.com/toomasv/313e1d8583fb159428222651b76926cd}
Repo: https://github.com/toomasv/l-system
]
context [
ctx: self
@dander
dander / generators.red
Last active August 27, 2020 07:29
An experiment to make a general purpose generator-creating function
Red [
Title: "generator function experiments"
Author: "Dave Andersen"
Date: 27-Sep-2017
]
reload: does [do system/options/script]
; @JacobGood's closure func
closure1: func [
Red [
Note: "https://gitter.im/red/red?at=59d0e788f7299e8f539496d3"
]
time-it: func [block /count ct /local t baseline][
ct: any [ct 1]
t: now/time/precise
loop ct [do []]
baseline: now/time/precise - t
t: now/time/precise
@dockimbel
dockimbel / closure-by-value.red
Last active October 4, 2017 16:19
"Capture by value" closure generator
Red [
Purpose: {Implementation of a "capture-by-value" closure generator}
Date: 4-Oct-2017
]
collect-words: function [
spec [any-list!]
/deep
/set
/to-set
@dockimbel
dockimbel / parse-info.red
Last active October 24, 2017 08:46
Function to get stats about internal parse states usage for a given parsing job.
Red [
Title: "Parse Info"
Purpose: {
Provides some stats about internal parse states usage for a given parsing job.
Could be used as a way to compare efficiency of different parsing strategies.
}
Date: 06-Oct-2017
]
context [
Red []
context [
cases: copy []
x: sum: probabilities: none
set 'pick-random func [items /size num /init probs /local out][
x: random 100%
if init [
probabilities: probs
cases: copy []
sum: 0%