This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
][ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
view [ | |
style chk: check "Option" data yes | |
style vline: base 2x60 red | |
across top vline button "Ok" text "Text" field chk return | |
across middle vline button "Ok" text "Text" field chk return | |
across bottom vline button "Ok" text "Text" field chk | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
;!! This is very much a work in progress, with many things untested. It needs | |
; to be clear what is functional and break out R&D bits into a working script | |
; for that purpose. | |
;------------------------------------------------------------------------------- | |
Arcsin: func [X [decimal!]] [ | |
;'Arcsin(X) = Atn(X / Sqr(-X * X + 1)) [from MS Help - VB4, 1995] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Re: WRT: func ['name content][] | |
WRT incr { | |
The most common case will be to change state, but incr does add meaning, and has | |
benefits, in my mind, when used with scalars. | |
- By default, there is no step value, so you can't get the + 1 part wrong. | |
- Incr is often used when looping, making loop variables stand out from other add | |
ops that might be in expressions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
do %url-parser.red | |
test-urls: reduce [ | |
foo:// ; no path | |
object [ | |
scheme: 'foo | |
user-info: none | |
host: "" ; none ; this is tricky, the // means we'll always have a host, even if empty. |