Skip to content

Instantly share code, notes, and snippets.

@rgchris
rgchris / iterate.md
Last active November 28, 2025 15:10

Iterators, Part I

In this article, I will introduce iterators and discuss how they offer an intuitive interface for addressing a diverse set of programming problems. Specifically, I'll explore the potential application of iterators in Rebol, highlighting how they complement Rebol's elegant and expressive approach to problem-solving.

What are Iterators?

Iterators are mechanisms used to traverse complex data structures without exposing their internal composition. They provide a standard interface for accessing the component parts of those structures sequentially, significantly simplifying the code built around them. Iterators typically share the following characteristics:

  • Encapsulation: They encapsulate the domain logic of a given data structure, meaning you do not need to learn that structure to use it.
  • Sequential Access: Each call presents the next logical component from that domain.
@gurzgri
gurzgri / mutator-object.red
Created November 10, 2024 22:27
mutator-object
Red [
title: 'mutator-object
author: "Christian Ensel"
usage: [
>> do %../mutator-object.red
>> circle: mutator-object [
#set area: does [if number? new [set-quiet in self 'radius square-root divide new pi]]
#get area: does [multiply pi power radius 2]
radius: 10
]
@luce80
luce80 / Red-vid-styles.red
Last active April 23, 2024 17:30
Some useful Red View/VID styles
Red []
;%numeric-spinner.red
;%area-plus.red
;%splitter.red
;%scrollable-panel.red
;%%multi-text-list.red
;%area-rt.red
;%spinner-panel.red
;%tipped-button.red
@Oldes
Oldes / html-entities.red
Last active May 13, 2020 10:05
HTML entities
Red [
Title: "HTML entities"
Purpose: "To decode HTML entities in a text"
Author: "Oldes"
Date: 12-May-2020
Version: 1.0.2
License: MIT
Usage: [
"Test: ♠ & ¢ <a> and Δδ ¾" =
decode-html-entities {Test: &spades; & &#162; &lt;a&gt;&#32;and &Delta;&delta; &frac34;}
@jemmanuel
jemmanuel / reallocation.md
Created April 10, 2020 14:26
Optimal memory reallocation and the golden ratio

This is based on a neat little post that I saw on Simon Frankau‘s blog that I thought I’d provide a few more details on, as well as bringing it to a wider audience. Some higher-level data structures in object-oriented programming languages have dynamic memory allocation. This is used to create objects (usually things that behave like lists) that can grow and shrink as the program executes. When initializing a regular array in C or Java, you have to specify the size of the array on creation, for example with

int myArray[] = new int[10];
Rebol [
Title: "Build"
Author: ["Ladislav Mecir" "Brian Hawley"]
File: %build.r
Date: 2-May-2006/13:36:38+2:00
History: [
7/apr/2003/19:02 {using INSERT and ONLY keywords}
30/Oct/2004/12:55 {intermediate version - alpha}
31/Oct/2004/9:49 {intermediate - word - insert/only, :word - insert}
4/Nov/2004/6:55 {word - insert and evaluate, :word - insert/only}
@zeux
zeux / murmur.h
Last active March 20, 2021 23:05
MurMurHash finalizers as 32-bit integer/pointer hashers
uint32_t murmur2(uint32_t h)
{
h ^= h >> 13;
h *= 0x5bd1e995;
h ^= h >> 15;
return h;
}
uint32_t murmur3(uint32_t h)
@meijeru
meijeru / word-finder.red
Last active April 6, 2020 09:06
Word-finder: find occurrences of any word in the toolchain source files
Red [
Title: "Word finder"
Purpose: {Find occurrences of words in the source files
of the Red toolchain and display them}
Author: "Rudolf W. MEIJER"
File: %word-finder.red
Needs: 'View
Rights: "Copyright (c) 2019 Rudolf W. MEIJER"
History: [
[0.0 23-Jan-2019 {Start of project}]
@luce80
luce80 / add-script.red
Created July 1, 2018 18:34
Help update red scripts collection list
Red [
title: "Update red scripts collection list"
file: %add-script.red
author: "Marco Antoniazzi"
license: "Do with this code whatever you want, giving credit to me is NOT required"
email: [luce80 AT alice DOT it]
date: 01-07-2018
version: 1.0.1
Purpose: "Help update red scripts collection list"
Needs: 'View
@DideC
DideC / animate.red
Created February 26, 2018 08:32
First try of an animation dialect for Red VID. Computation is not precise enough, but just a proof of concept ;-)
Red [
Purpose: "Animation system for VID"
Needs: 'View
Notes: {
Simplyfied Ease in/out formulas : http://gizma.com/easing/#l
See at the end of page source for javascripts formulas (included elastic) : http://easings.net/en
}
]