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 [] | |
clock: func [code /local t1 t2] [ | |
t1: now/precise/time | |
loop 100 code | |
t2: now/precise/time | |
print [(t2 - t1) mold/flat code] | |
] | |
m1: make hash! [] |
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 [] | |
clock: func [code /local t1 t2] [ | |
t1: now/precise/time | |
loop 100 code | |
t2: now/precise/time | |
print [(t2 - t1) mold/flat code] | |
] | |
m1: #() |
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 [] | |
clock: func [code /local t1 t2] [ | |
t1: now/precise/time | |
loop 100 code | |
t2: now/precise/time | |
print [(t2 - t1) mold/flat code] | |
] | |
m1: make hash! [] |
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 [] | |
; WOW! chain expressions with a dot to make them more readable! | |
; an inline transformation of a chain of function applications into a lisp-like pyramid of braces ;) | |
; (expr) . func args... => (func (expr) args...) | |
; e.g. [1 2 3 4 5] . skip 1 . change/part '- 3 . head => (head (change/part (skip ([1 2 3 4 5]) 1) '- 3)) | |
#macro [skip '. [word! | path!]] func [[manual] s e /local a r p p2] [ | |
p: s/3 | |
a: either word? p [ |
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 [] | |
; WOW! dialectic version of function piping! | |
; . with a cutest dot! | |
; . to make expressions more readable! | |
; . can be invoked recursively (pipe [ pipe [...] . ... ]) | |
; e.g. [1 2 3 4 5] . skip 1 . change/part '- 3 . head | |
; => head change/part skip [1 2 3 4 5] 1 '- 3 |
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
arity?: func [p [word! path!] /local p2] [ | |
either word? p [ | |
preprocessor/func-arity? spec-of get :p | |
][ | |
; path format: obj1/obj2.../func/ref1/ref2... | |
; have to find a point where in that path a function starts | |
; i.e. p2: obj1/obj2.../func | |
; and the call itself is: func/ref1/ref2... | |
p2: as path! clear [] ; reuse the same block over and over again | |
until [ |
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 [] | |
; outright improvement of collect mezzanine's performance and RAM footprint | |
; the compiled default "collect" | |
collect1: :collect | |
; the interpreted default "collect" | |
collect2: func spec-of :collect body-of :collect |
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 [title: "glob func test script"] | |
#include %glob.red | |
unless value? 'input [input: none] | |
root: %globtest-temp-dir.$$$ | |
if exists? root [print ["please remove the" root "from" what-dir "first"] input quit] | |
change-dir make-dir root |
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 [ | |
Author: [@greggirwin @endo @toomasv] | |
Purpose: "COMPOSE for strings" | |
Notes: { | |
TBD: Security model for eval'ing expressions | |
TBD: Decide if support for custom marker and eval contexts are worthwhile | |
TBD: Finalize refinement names | |
} | |
] |
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 [] | |
idiom: [ [a (x: b) | reset (x: c)] x | reset d ] ; 1 | |
impl: [ a then b | reset c | reset d ] ; 2 | |
;impl: [ a b | reset c | reset d ] ; 2 | |
;impl: [ (f: yes) a (f: no) b | reset if (f) c | reset d ] ; 1 | |
;impl: [ a b | reset not a c | reset d ] ; 3 | |
;impl: [ not a c | reset a b | reset d ] ; 3 | |
;impl: [ [a fail b] | reset c | reset d ] ; 2, nightly build only | |
;impl: [ p: a [b | :p reset d |] | reset c | reset d ] ; 1 |
OlderNewer