View _5-pane-view.red
Red [] | |
_5-panes-ctx: context [ | |
layout-spec: none ; layout spec we build | |
p-top: p-left: p-center: p-right: p-bottom: none ; area panels | |
def-panel-sizes: [top 50 left 200 right 150 bottom 25] | |
sizes: [] ; panel sizes used in layout | |
win-sizes: compose [ ;!! may be better to separate default |
View load-trap-red
Red [] | |
context [ | |
list: none | |
last-event: none | |
trap: function [ | |
event [word!] ;-- event name | |
input [string! binary!] ;-- input series at current loading position | |
type [datatype! word! none!] ;-- type of token or value currently processed. |
View red-defer-experiment.red
; Go lang style defer experiment | |
deferreds-ctx: context [ | |
stack: [] | |
cur-stack: does [last stack] ; current function's stack | |
push-frame: does [append/only stack copy []] ; new stack frame | |
pop-frame: does [take/last stack] ; drop last stack frame | |
;push-defer: func [blk [block!]] [append/only cur-stack blk] ; LIFO | |
push-defer: func [blk [block!]] [insert/only cur-stack blk] ; FIFO | |
do-deferreds: does [foreach blk cur-stack [attempt [do blk]]] |
View select-case-tests.red
Red [] | |
do %select-case.red | |
test: func [val] [print mold :val] | |
a: 15 | |
test select-case a [15 [OK]] | |
test select-case a [1 [a] 5 [b] 15 [OK]] |
View view-flags-demo.red
Red [] | |
window-flags: [ | |
resize no-title no-border no-min no-max no-buttons modal popup | |
] | |
show-win-using-flags: func [flags [block!]][ | |
view/flags [backdrop sky button "OK" [unview]] flags | |
] | |
spec: [ | |
below |
View sorted.red
Red [ | |
comment: { | |
Minimal sorted series support, allowing fast binary searches. | |
I tinkered with a "dialected" interface, and more support | |
functions, like `[remove take at index?]` but quickly saw | |
that they were of little value, and that using a parameter | |
for the command was downright misleading to read, no matter | |
how clever the implementation. `Find` is not strictly | |
necessary either, but it does make it nicely consistent |
View step.red
Red [] | |
step-ctx: context [ | |
digit=: charset [#"0" - #"9"] | |
alpha=: charset [#"A" - #"Z" #"a" - #"z"] | |
alpha-num=: union alpha= digit= | |
; Could do this with charsets. | |
range-start-char?: func [val] [to logic! find "0Aa" val] |
View refine.red
filter: function [ | |
"Returns two blocks: items that pass the test, and those that don't." | |
series [series!] | |
test [any-function!] "Test (predicate) to perform on each value; must take one arg" | |
/only "Return a single block of values that pass the test" | |
][ | |
result: reduce [copy [] copy []] | |
foreach value series [ | |
append/only pick result make logic! test :value :value | |
] |
View time-marks.red
time-marks: object [ | |
data: #() | |
;!! Watch for [set clear] system word usage in this object! | |
set: func [key] [ | |
either key = /all [ | |
print ["##ERROR time-marks/set reserves /all as an internal key."] | |
none | |
][ |
View load-time-type-tally.red
Red [ | |
file: %load-time-type-tally.red | |
purpose: { | |
Load a Red file, noting how long it takes to do so, | |
then parse it and tally all the values by datatype. | |
It's not a metric that may prove useful, but in | |
aggregate, we could see what types are most commonly | |
used. | |
I'll correct my own thinking. After just a few sample |
NewerOlder