Skip to content

Instantly share code, notes, and snippets.

@toomasv
toomasv / range.red
Last active June 19, 2021 14:41
Range function for multiple datatypes
Red [
Author: "Toomas Vooglaid"
Date: 26-11-2017
]
range: function [val1 val2 /step stp /limit /enbase ebase /debase dbase /unicode][
stp+?: none
stp: any [stp either any [percent? val1 percent? val2] [1%][1]]
if any [all [block? stp zero? stp/3] zero? stp] [return none]
case [
debase [
Red [
Author: "Toomas Vooglaid"
Date: 2017-10-23
]
context [
A: B: C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z: none
numbers: make block! 10
nums: make block! 10
out: make block! 10
letters: make block! 10
@toomasv
toomasv / hanoi.red
Last active October 26, 2017 17:48
Red [
Author: "Toomas Vooglaid"
Date: 2017-10-24
Needs: View
]
context [
system/view/auto-sync?: dragable?: off-the-post?: no
offset: pos-x: post: current-post: post1: post2: post3: disc: disc1: disc2: disc3: disc4: steps: thickness: none
post1-narrow: charset [ 48 - 52]
post2-narrow: charset [148 - 152]
@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 [
@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.
@honix
honix / time.red
Last active August 23, 2017 21:04
Red []
time: func [
do-block
/repeat
n
/local
acc
start
][
@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."
@greggirwin
greggirwin / nsource.red
Last active June 13, 2017 05:27 — forked from rebolek/nsource.red
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"
@meijeru
meijeru / arith.txt
Last active September 6, 2017 15:36
Types of artihmetic operations
Updated to Red for Windows version 0.6.2 built 7-Jun-2017/15:13:57+2:00
The table gives type of first operand, type of second operand, result type
for + (add), - (subtract), * (multiply), / (divide), // (modulo) and % (remainder)
For vectors, the element type is distinguished.
There is one case (time with time) where the result type is not the same
for all allowed operations.
After each type combination, the reverse combination is given.
The fourth column gives the operators for which the combination is forbidden.
If the result type is error, the combination is forbidden for all operators.
@maximvl
maximvl / qf.red
Created May 15, 2017 21:51
quick funcs
Red [
author: {Maxim Velesyuk}
description: {
Quick in-place function definitions without explicit arguments specification.
`_` is next arugment, `_N` is N-th argument
}
]
inc: func ['word] [set word 1 + get word]