This file contains hidden or 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 [] | |
| load-any: function [input [string!]][ | |
| out: make block! 100 | |
| junk: none | |
| until [ | |
| result: load/trap/next input 'pos | |
| either error? result/3 [ | |
| append any [junk junk: make string! 20] result/2/1 |
This file contains hidden or 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 [] | |
| form-all: func [blk][ | |
| forall blk [blk/1: form blk/1] | |
| blk | |
| ] | |
| types-of: function [value [typeset!]][ | |
| ; typesets don't support reflection | |
| third load mold value |
This file contains hidden or 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 [ | |
| Author: "Toomas Vooglaid" | |
| file: "%regex.red" | |
| Purpose: {Regex to parse converter} | |
| History: {Started: 2017-05-09 | |
| v.0.1: 2017-05-12 -- first working version with: | |
| start `^^` and end `$` anchors, | |
| non-capturing groups (one level) with alterns, | |
| quantifiers (possessive), | |
| some character-classes. |
This file contains hidden or 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 [] | |
| inc-value: func [ | |
| face | |
| color-id | |
| dest-face | |
| /local value rate | |
| ] [ | |
| unless face/extra [face/font/color: 255.255.255] | |
| overflow?: false |
This file contains hidden or 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 [ | |
| Title: "Nsource - native source" | |
| Purpose: "Print source for native functions" | |
| Author: "Boleslav Březovský" | |
| Date: "8-6-2017" | |
| ] | |
| indent: func [ | |
| "(Un)indent text by tab" | |
| string [string!] "Text to (un)indent" |
This file contains hidden or 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 [ | |
| title: "Red Object Browser" | |
| author: "Gregg Irwin" | |
| needs: 'View | |
| ] | |
| e.g.: :comment | |
| map-ex: func [ | |
| "Evaluates a function for all values in a series and returns the results." |
This file contains hidden or 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
| ; Stats added by @toomasv | |
| compare-times: func [ | |
| blocks "Block of code blocks to performance compare" | |
| /count ct | |
| /local t n baseline res blk stats1 memory time code template | |
| ][ | |
| ct: any [ct 1] | |
| t: now/time/precise | |
| loop ct [do []] | |
| baseline: now/time/precise - t |
This file contains hidden or 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 [ | |
| Purpose: {Implementation of a "capture-by-value" closure generator} | |
| Date: 4-Oct-2017 | |
| ] | |
| collect-words: function [ | |
| spec [any-list!] | |
| /deep | |
| /set | |
| /to-set |
This file contains hidden or 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 [ | |
| Title: "Parse Info" | |
| Purpose: { | |
| Provides some stats about internal parse states usage for a given parsing job. | |
| Could be used as a way to compare efficiency of different parsing strategies. | |
| } | |
| Date: 06-Oct-2017 | |
| ] | |
| context [ |
This file contains hidden or 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 [] | |
| e.g.: :comment | |
| delta-time: function [ | |
| "Return the time it takes to evaluate a block" | |
| code [block! word! function!] "Code to evaluate" | |
| /count ct "Eval the code this many times, rather than once" | |
| ][ | |
| ct: any [ct 1] |