I hereby claim:
- I am dander on github.
- I am zentrog (https://keybase.io/zentrog) on keybase.
- I have a public key ASCuqh1j3qQKj19_LB0DsfA2IVRSuZt1j3MjMElSu5dYUQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Red [ | |
Title: "Find pattern" | |
Description: "Searches Red source files for a parse pattern" | |
] | |
allow: func [any][yes] | |
get-files: function [ | |
"recursively collects the full file paths for all the files in the given directory" | |
dir [file!] /filter "only collect files where the predicate evaluates to true" pred [function!] |
Red [ | |
Title: "solarized colors" | |
Source: https://ethanschoonover.com/solarized | |
Values: { | |
SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB | |
--------- ------- ---- ------- ----------- ---------- ----------- ----------- | |
base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 | |
base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26 | |
base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46 | |
base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51 |
Red [ | |
Title: "Diceword passphrase generator" | |
Needs: 'View | |
] | |
word-list: https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt | |
words: parse load-thru word-list [collect some [keep word! | skip]] | |
random/seed now/precise | |
view [ |
Words form the grammar of the Red programming language. For people familiar with more mainstream languages, word!
replaces keywords, variables, and operators. However, unlike other programming languages where those constructs have fixed definitions hard-wired in the compiler, in Red words are just a basic type of data. This makes the structure of a program extremely flexible.
A word!
is made of up of 3 basic parts.
Macros(SPEL:-semantic-programming-enhancement-logic).md First of all, I advocate we call macros SPELs in order to get rid of the confusion when people come from other languages. This will also allow people who want to write tutorials about such a feature to easily(or more easily) google the word SPEL over macro. My recommendation of SPEL is not my own idea it comes from Conrad Barski: http://www.lisperati.com/no_macros.html
Shen, a dialect of lisp, will be what is used for spel examples. I will try to explain the syntax in order for readers of this wiki to be able to absorb the idea of spels. Come to this channel for questions, comments, approvals, disapprovals, or whatever else: https://gitter.im/red/red/lisp
We will begin(and end) by discussing two examples: max and thread.
In Shen, one defines a function at the repl like so...
Red [] | |
e.g.: :comment | |
delta-time: function [ | |
"Return the time it takes to evaluate a block" | |
block [block! word! function!] "Block to evaluate" | |
/count ct "Eval the block this many times, rather than once" | |
][ | |
ct: any [ct 1] |
Red [ | |
Title: "generator function experiments" | |
Author: "Dave Andersen" | |
Date: 27-Sep-2017 | |
] | |
reload: does [do system/options/script] | |
; @JacobGood's closure func | |
closure1: func [ |
Red [ | |
Title: "range generator attempt (4?)" | |
] | |
; @JacobGood's closure func | |
closure: func [ | |
vars [block!] | |
spec [block!] | |
body [block!] | |
][ |
<Query Kind="Program"> | |
<Reference><RuntimeDirectory>\System.Runtime.InteropServices.dll</Reference> | |
<Namespace>System.Runtime.InteropServices</Namespace> | |
</Query> | |
void Main() | |
{ | |
redOpen(); | |
redDo("view [text {hello, libRed!}]"); | |
} |