Skip to content

Instantly share code, notes, and snippets.

; proof of concept (but usable!) implementation of immutable persistent 'blocks' in Red
; author: Jay G. Porcasi (@numberjay)
; the exported API is at the bottom, starting with: set '<function name> ...
; free to use without any warranty of any kind: use at your own leisure and risk
; for bugs, suggestions, questions... comment here below or reach me on Gitter (@numberjay)
; copyright Jay G. Porcasi 2017
context [
; all functions ending with ' are helper functions working on 'immutable' blocks only
@greggirwin
greggirwin / requesters.red
Last active February 6, 2020 21:41
Red requesters (alert, confirm, prompt, etc.)
Red [
author: ["Gregg Irwin"]
notes: {
Experimental requesters, for design discussion. Not just about the
implementation, but about modal vs modeless dialogs. I think there's
value in the simple, modal approach, but we probably want to provide
more advanced options. e.g. document/sheet modal, and mobile standard
approaches.
TBD: Determine if we want to build everything on inner funcs that are
@greggirwin
greggirwin / profile.red
Last active December 28, 2020 06:17
Basic profiling for Red code comparisons
Red []
e.g.: :comment
delta-time: function [
"Return the time it takes to evaluate a block"
code [block! word! function!] "Code to evaluate"
/count ct "Eval the code this many times, rather than once"
][
ct: any [ct 1]
@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 [
@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
@greggirwin
greggirwin / compare-times.red
Last active October 28, 2017 22:23
compare-times perf test idea for Red
; Stats added by @toomasv
compare-times: func [
blocks "Block of code blocks to performance compare"
/count ct
/local t n baseline res blk stats1 memory time code template
][
ct: any [ct 1]
t: now/time/precise
loop ct [do []]
baseline: now/time/precise - t
@greggirwin
greggirwin / red-object-browser.red
Last active October 16, 2020 17:48
Red Object Browser
Red [
title: "Red Object Browser"
author: "Gregg Irwin"
needs: 'View
]
e.g.: :comment
map-ex: func [
"Evaluates a function for all values in a series and returns the results."
@rebolek
rebolek / nsource.red
Last active June 19, 2019 20:11
Provides source of Red native functions
Red [
Title: "Nsource - native source"
Purpose: "Print source for native functions"
Author: "Boleslav Březovský"
Date: "8-6-2017"
]
indent: func [
"(Un)indent text by tab"
string [string!] "Text to (un)indent"
@rebolek
rebolek / incredidle.red
Created May 15, 2017 17:12
Simple tool to show how faces work
Red []
inc-value: func [
face
color-id
dest-face
/local value rate
] [
unless face/extra [face/font/color: 255.255.255]
overflow?: false
@toomasv
toomasv / regex.red
Last active November 20, 2017 18:22
Regex to parse translator
Red [
Author: "Toomas Vooglaid"
file: "%regex.red"
Purpose: {Regex to parse converter}
History: {Started: 2017-05-09
v.0.1: 2017-05-12 -- first working version with:
start `^^` and end `$` anchors,
non-capturing groups (one level) with alterns,
quantifiers (possessive),
some character-classes.