Skip to content

Instantly share code, notes, and snippets.

@giesse
giesse / compiled-rules.red
Created January 22, 2021 15:12
TOPAZ-PARSE compiled rules
make object! [
collection: #[none]
_result: #[none]
_stack: []
_push-state: func [][
append/only _stack collection
]
_pop-state: func [][
collection: take/last _stack
]
prin = function(text) {
sys.print(text);
return text;
};
print = function(text) {
sys.print(text + "\n");
return text;
};
jsProbe = function(value) {
print(sys.inspect(value));
Red []
; [ counter-clockwise marble-number clockwise ]
counter-clockwise: 1
marble-number: 2
clockwise: 3
make-circle: function [marble [integer!]] [
circle: reduce [none marble none]
circle/:counter-clockwise: circle
Red []
export: func [
"Export a value to the global context"
'word [set-word!]
value
/to ctx [any-word! any-object! function!]
] [
set word :value
unless :ctx [ctx: system/words]
@giesse
giesse / profile-gab.red
Last active November 20, 2021 19:13
profile function for Red (two variants)
Red []
e.g.: :comment
; ideally not exported on the global context
delta-time*: function [code count] [
start: now/precise
loop count code
difference now/precise start
]

Keybase proof

I hereby claim:

  • I am giesse on github.
  • I am giesse (https://keybase.io/giesse) on keybase.
  • I have a public key ASD7rJfWzRs0AFSTbGvCKUIb2ogWLAVjNtDKhIi_DDP_bAo

To claim this, I am signing this object: