Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
divisible?: func [a b] [0 = remainder a b]
; This doesn't work like R3 in how negative widths work.
forskip: func [
"Evaluates a block at regular intervals in a series."
'word [word!] "Word referring to the series to traverse (modified)"
width [integer!] "Interval size (width of each skip)"
body [block!] "Body to evaluate at each position"
/local orig result op
][
@greggirwin
greggirwin / delimit.red
Created May 14, 2016 15:10
A `delimit` function for Red.
; This doesn't work like R3 in how negative widths work.
forskip: func [
"Evaluates a block at regular intervals in a series."
'word [word!] "Word referring to the series to traverse (modified)"
width [integer!] "Interval size (width of each skip)"
body [block!] "Body to evaluate at each position"
/local orig result op
][
either zero? width [none] [
; TBD: assert word refs series
@greggirwin
greggirwin / scheduler.r
Created May 25, 2016 02:58
Rebol scheduler dialect
REBOL [
Title: "Scheduler"
File: %scheduler.r
Purpose: "Dialected task scheduling library"
Author: ["SOFTINNOV / Nenad Rakocevic" "Pointillistic / Gregg Irwin"]
Copyright: ["2009 SOFTINNOV" "2013 SOFTINNOV/POINTILLISTIC"]
Email: [[email protected] [email protected]]
Date: 28-Oct-2013
Version: 0.9.5
License: "BSD - see %LICENCE.txt file"
@greggirwin
greggirwin / What's missing in Red.txt
Last active December 11, 2016 22:29
A quick list of Rebol words not yet in Red
*I tried to eliminate all my local words*
# Most important
abs ; just an alias
apply ; But, PLEASE, a better way to propagate refinements
array ; I rarely use this myself
assert
build-markup ; More general interpolation this is built on
build-tag ; Need tag! first
@greggirwin
greggirwin / split.red
Last active June 2, 2016 03:55
An updated `split` function for Red
map-each: function [
"Evaluates body for each value(s) in a series, returning all results."
'word [word! block!] "Word, or words, to set on each iteration"
data [series! map!]
body [block!]
] [
collect [
foreach :word data [
if not unset? set/any 'tmp do body [keep/only :tmp]
]
;-- In %natives.reds
checksum*: func [
check? [logic!]
_tcp [integer!]
_hash [integer!]
_method [integer!]
_key [integer!]
/local
arg [red-value!]
@greggirwin
greggirwin / entab-detab.red
Last active November 9, 2018 08:04
Red ENTAB/DETAB mezzanines
Red []
; Steeve gets credit for this one
detab: function [
"Converts leading tabs in a string to spaces. (tab size 4)"
string [any-string!] "(modified)"
/size
sz [integer!] "Number of spaces per tab"
/all "Change all, not just leading"
][
@greggirwin
greggirwin / analog-clock.red
Last active September 28, 2016 03:52
An analog clock for Red
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
]
degree-to-xy: func [rad "radius" deg "degrees"] [
as-pair (rad * sine deg) (rad * negate cosine deg)
]
sex-to-degree: func ["Sexagesimal to degrees" n] [n * 6]
@greggirwin
greggirwin / analog-clock-2.red
Last active June 17, 2016 23:24
Analog clock, refined, with informational comments
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
File: %analog-clock.red
Tabs: 4
Needs: View
Purpose: {
- Introduce some basic Red concepts, like functions and datatypes
- Show how the DRAW block and timer events work in the View system
}
@greggirwin
greggirwin / bubbles.red
Last active June 17, 2016 23:23
Animated bubbles
Red [
Title: "Bubbles"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no