May 2018
Beginner
252 pages
6h 19m
English
Lines of code in Red are just data structures. Let's start with some very basic code, such as an arithmetic expression—for example, 3.14 ** 2 , calculating the square of 3.14, which is 9.8596. You write your code in an editor, so it's basically a string, right?
;-- see Chapter06/code-data.red:calc: "3.14 ** 2"type? calc ;== string!calc ;== "3.14 ** 2"
Here, :calc or get 'calc return the same result as calc.
Now we must transform this string expression into something Red can work with—namely, a series in a block. This can be done with the load word, which loads the string into memory, parses it, and turns it into Red values:
code: load calc ;== [3.14 ** 2]code ;== [3.14 ** 2]type? code ;== block!length? code ;== ...