Skip to Content
Learn Red ? Fundamentals of Red
book

Learn Red ? Fundamentals of Red

by Ivo Balbaert
May 2018
Beginner content levelBeginner
252 pages
6h 19m
English
Packt Publishing
Content preview from Learn Red ? Fundamentals of Red

Evaluation with do and reduce

In the previous chapter, we saw how to use do to evaluate a script in the console with do %script.red.

In fact, do is more general in that it accepts any expression, function, or block, such as here:

;-- see Chapter03/evaluating.red:do 9 * 9                         ;== 81do square-root 25                ;== 5.0do [print [tab uppercase "Red"]] ; == "RED"

You can even use do %script.red from inside a Red program, that's how powerful it is. Let's make script.red containing—Red[] print "This is executed in a script". Now edit an evaluating.red program containing—Red[] do %script.red.

Then red evaluating.red will print the text, This is executed in a script in the console. To see the same output in a terminal compile it with red -r evaluating.red and then ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How I Built a Personal Board of Directors With GenAI

How I Built a Personal Board of Directors With GenAI

Vipin Gupta
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
Why AI Demands a New Breed of Leaders

Why AI Demands a New Breed of Leaders

Faisal Hoque, Thomas Davenport, Erik Nelson

Publisher Resources

ISBN: 9781789130706Supplemental Content