2
3
Fork
You've already forked red-common
1
Red language useful functions library
  • Red 100%
Find a file
2026年03月07日 00:12:47 +07:00
advanced-function.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
assert.md DOC: another note 2025年10月13日 21:00:14 +08:00
assert.red DOC: future note 2025年11月26日 22:53:51 +08:00
bind-only.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
bmatch.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
bulk.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
catchers.red TESTS: more tests on 'following' 2025年02月23日 14:18:36 +08:00
charsets.red FEAT: from-latin-1 converter 2025年11月09日 16:57:06 +08:00
classy-object.red FIX: on-change body override during classify-object call 2026年03月07日 00:12:47 +07:00
clip.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
clock-each.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
clock.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
collect-set-words.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
color-models.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
composite.md DOC: added rawstrings 2021年06月28日 10:05:27 +03:00
composite.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
constructors.red FEAT: as-map / as-object are now in common 2025年11月09日 15:02:15 +08:00
contrast-with.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
count.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
data-store.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
debug.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
do-atomic.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
do-queued-events.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
do-unseen.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
embed-image.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
error-macro.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
everything.red FEAT: high level HTTP client implementation 2025年11月24日 18:33:43 +08:00
expect.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
explore.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
exponent-of.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
extrema.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
for-each.red FEAT: old for-each cleanup 2023年06月08日 00:31:29 +03:00
foreach-design.md DOC: 3rd attempt to fix the table 2024年09月16日 00:09:40 +08:00
format-number.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
format-readable.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
forparse.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
glob-test.red initial commit 2020年05月02日 19:10:03 +03:00
glob.md Update glob.md 2020年07月09日 20:34:49 +00:00
glob.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
hide-macro.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
http-client.md FEAT: request timestamps for latency estimation 2025年12月05日 22:59:43 +08:00
http-client.red FEAT: auto convert float (experimental) 2025年12月06日 15:02:27 +08:00
in-out-func.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
include-once.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
interleave.red DOC: removed extra space from docstring 2025年02月28日 23:02:45 +08:00
is-face.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
join.red FIX: no more delimit in the repo 2026年03月06日 16:58:40 +07:00
keep-type.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
leak-check.red FIX: removed no longer needed workaround 2025年01月12日 01:20:43 +08:00
load-anything.red FEAT: switch to parens similar to new construction syntax 2025年01月04日 21:55:02 +08:00
map-each.red FEAT: old map-each cleanup 2023年06月08日 13:48:27 +03:00
mapparse.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
match.red DOC: some further ideas 2025年05月01日 13:23:09 +08:00
median.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
modulo-plot.red FEAT: added MODULO 2020年07月17日 00:32:41 +03:00
modulo.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
morph.md FEAT: a few more tests 2021年10月31日 19:49:12 +03:00
morph.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
new-apply.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
new-each.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
new-replace-tests.red FEAT: some formatting 2023年05月22日 19:17:27 +03:00
new-replace.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
overload.red FIX: locals/externs were ignored 2025年01月21日 14:22:41 +08:00
parsee-standalone-source.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
parsee-standalone.red FIX: errors escaped from parsee visualization 2025年02月23日 22:19:38 +08:00
parsee.red FIX: errors escaped from parsee visualization 2025年02月23日 22:19:38 +08:00
prettify.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
print-macro.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
profiling.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
pull-react.red FEAT: control over exported words scope 2023年10月22日 22:27:23 +03:00
pull-react2.red FEAT: control over exported words scope 2023年10月22日 22:27:23 +03:00
quantize.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
reactor92.red DOC: comment clarification 2025年08月13日 21:50:29 +08:00
README.md DOC: HTTP client docs 2025年11月25日 00:21:46 +08:00
relativity.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
reshape.md DOC: minor formatting 2023年11月19日 21:20:24 +03:00
reshape.red FIX: more idiomatic failure rule 2025年12月01日 13:57:56 +08:00
scoping.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
scrollpanel-test.red FIX: workaround for #5683 2026年02月12日 19:42:09 +08:00
scrollpanel.md FIX: gif size issues 2020年06月25日 21:50:19 +03:00
scrollpanel.red FIX: missing dependency 2025年03月01日 17:51:53 +08:00
search.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
selective-catch.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
setters.red DOC: returns documented 2025年11月09日 14:37:24 +08:00
shallow-trace.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
show-deep-trace.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
show-trace.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
sift-locate.md DOC: removed the obsolete function mention 2022年11月10日 13:32:20 +03:00
sift-locate.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
smartload.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
split.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
step.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
stepwise-func.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
stepwise-macro.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
tabbing.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
tabs.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
timers.red FIX: automate the initial time skip 2025年01月02日 13:46:20 +08:00
timestamp.red FEAT: better format-date 2025年11月25日 17:01:18 +08:00
trace-deep.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
tree-hopping.red FIX: compilation issues with no view module 2026年01月11日 22:02:36 +08:00
typecheck.red FIX: typechecks were broken with debug=off 2025年11月24日 23:18:00 +08:00
typed-object.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
with.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
without-gc.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00
xyloop.red FEAT: more explicit dependency management 2024年12月31日 15:14:53 +08:00

Table of Contents

Official URL of this project: https://codeberg.org/hiiamboris/red-common

A collection of my Red mezzanines & macros

Some of these are trivial. Some may look simple in code, but are a result long design process. Some are only emerging experiments. See headers of each file for usage, info, design info!

Notes:

  • I try to keep dependencies at minimum for simpler inclusion, until it stops making sense
  • mostly untested for compileability so far; optimized for the interpreted use
  • use #include %everything.red to include all the scripts at once and play

By category

General purpose

Source file Description
setters Contains ONCE, DEFAULT, MAYBE, QUIETLY, ANONYMIZE value assignment wrappers, and GLOBAL/EXPORT to expose some object's words globally
constructors Handy map/object constructors: AS-MAP and AS-OBJECT
with A convenient/readable BIND variant
#hide macro Automatic set-word and loop counter hiding
stepwise-macro and stepwise-func Allows you write long compound expressions as a sequence of steps
trace Step-by-step evaluation of a block of expressions with a callback
trace-deep Step-by-step evaluation of each sub-expression with a callback
selective-catch Catch break/continue/etc. - for use in building custom loops
reshape Advanced code construction dialect to replace compose and build. Read more
without-GC Evaluate code with GC temporarily turned off (brings massive speedup when used wisely)
scoping Primitive experimental support for scope-based resource lifetime management
timers Fast general-purpose timers (independent from View)

Design extensions and fixes

Source file Description
#include macro Smart replacement for #include directive that includes every file only once
## macro Macro for arbitrary load-time evaluation, to be able to save and load any kind of value
bind-only Selectively bind a word or a few only
catchers TRAP - enhanced TRY, FCATCH - Filtered catch, PCATCH - Pattern-matched catch, FOLLOWING - guaranteed cleanup
in-out-func Make functions more readable by allowing lit-arg access as if it was a normal argument
classy object Object 'class' support that adds type checks and per-word on-change functions to objects
typed object Simple per-object type checks support
advanced function Support for value checks and defaults in FUNCTION's spec argument

Math

Source file Description
step Increment & decrement function useful for code readability
clip Contain a value within given range
exponent-of Compute exponent of a number (i.e. how many digits it has)
quantize Quantize a float sequence into rounded bits (e.g. to get an integer vector)
extrema Find minimum and maximum points over a series
median Find median value of a sample
count Count occurences of an item in the series
modulo Working modulo implementation with tests
timestamp Ready-to-use and simple timestamp formatter for naming files
Source file Description
split Generalized series splitter
join Join a list as a string
delimit Insert a delimiter between all list items or interleave two lists
match Mask based pattern matching for strings (used by GLOB)
keep-type Filter list using accepted type or typeset
sift & locate High level dialected series filter and finder Read more
collect-set-words Deeply collect set-words from a block of code
morph Dialect for persistent local series mapping. Read more

Loops

Source file Description
xyloop Iterate over 2D area - image or just size
forparse Leverage parse power to iterate over series
mapparse FORPARSE-based mapping over series
for-each Powerful version of FOREACH, covering most use cases
map-each Map one series into another, leveraging FOR-EACH power
remove-each Extends native REMOVE-EACH with FOR-EACH syntax and fixes its bugs
bulk Bulk evaluation syntax support. Read more
search Find root of a function with better than linear complexity. Supports binary / bisection, interpolation / false position and jump search.
foreach-node Tree visitor pattern support (for building all kinds of tree iterators)

Debugging

These functions mainly help one follow design-by-contract guidelines in one's code.

Source file Description
debug Simple macro to include some debug-mode-only code/data
assert Allow embedding sanity checks into the code, to limit error propagation and simplify debugging. Read more
typecheck Mini-DSL for type checking and constraint validity insurance
expect Test a condition, showing full backtrace when it fails
show-trace Example TRACE wrapper that just prints the evaluation log to console
show-deep-trace Example TRACE-DEEP wrapper that just prints the evaluation log to console
shallow-trace Basic step by step expression evaluator
parsee Parse visual debugger. Read more

Profiling

Source file Description
profiling Inline profiling macros and functions (documented in the header)

Formatting

Source file Description
entab & detab Tabs to spaces conversion and back
format-number Simple number formatter with the ability to control integer & fractional parts size
format-readable Experimental advanced number formatter targeted at human reader (used by the profiler). For a better design see the Format module
prettify Automatically fill some (possibly flat) code with new-line markers for readability

String interpolation

Source file Description
composite macro & mezz String interpolation both at run-time and load-time. Read more
ERROR macro Shortcut for raising an error using string interpolation for the message. Read more
#print macro Shortcut for print #composite
Source file Description
glob Allows you to recursively list files. Read more. Run tests
data-store context Standardized zero-fuss loading and saving of data, config and other state (documented in the header)
http-client Automate everything a typical HTTP API client may require. Read more

Graphics & Reactivity

Source file Description
relativity Face coordinate systems translation mezzanines
color-models Reliable statistically neutral conversion between common color models
contrast-with Pick a color that would contrast with the given one
is-face? Reliable replacement for FACE? which doesn't work on user-defined faces
do-queued-events Flush the View event queue
do-atomic Atomically execute a piece of code that triggers reactions
do-unseen Disable View redraws from triggering during given code evaluation
reactor92 A higher level on-deep-change* replacement based on REP 92
embed-image Macro to compile images into exe
explore & image-explorer style Show UI to explore an image in detail (TODO: support any Red value)
scrollpanel style Automatic scrolling capability to a panel, until such is available out of the box. Read more
tabbing support Simpler and extensible replacement for native tabbing support (extended when using Spaces)

Utilities

Source file Description
leak-check Find words leaking from complex code
bmatch Bracket matching for Red sources (see CLI implementation)

Implementations not yet incorporated into the whole

Source file Description
map, fold, scan, sum, partition (external) Fast FP-like HOFs, as alternative to dialected *each (routines, require compilation)
new replace Based on the new apply, but awaits team consensus on design (see REP 146)