M: string tutorial-line <label> ;\r
\r
: example-theme\r
- dup roll-button-theme\r
- dup "Monospaced" font set-paint-prop\r
- italic font-style set-paint-prop ;\r
+ dup button-theme\r
+ "Monospaced" font set-paint-prop ;\r
\r
M: general-list tutorial-line\r
car dup <label> dup rot [ pane get pane-input set-editor-text drop ] cons\r
""\r
"Prefixing a word with \\ pushes it on the stack, instead of"\r
"executing it. So the see word has stack effect ( word -- )."\r
- ] [\r
- "Booleans"\r
- "In Factor, any object can be used as a truth value."\r
- "- The f object is false."\r
- "- Anything else is true."\r
- ""\r
- "Here is a word that outputs a boolean:"\r
- ""\r
- [ ": negative? ( n -- ? ) 0 < ;" ]\r
] [\r
"Branches"\r
"Now suppose we want to write a word that computes the"\r
""\r
[ ": absolute ( x -- |x| ) dup 0 < [ negate ] when ;" ]\r
""\r
- "It duplicates the top of the stack, since negative? pops it."\r
- "Then if the top of the stack was found to be negative,"\r
- "it is negated, yielding a postive result."\r
+ "If the top of the stack is negative, the word negates it"\r
+ "again, making it positive."\r
+ ""\r
+ "The < ( x y -- x<y ) word outputs a boolean."\r
+ "In Factor, any object can be used as a truth value."\r
+ "- The f object is false."\r
+ "- Anything else is true."\r
] [\r
"More branches"\r
"On the previous slide, you saw the 'when' conditional:"\r
""\r
- [ " ... condition ... [ ... code to run if true ... ] when" ]\r
+ [ " ... condition ... [ ... true case ... ] when" ]\r
""\r
"Another commonly-used form is 'unless':"\r
""\r
- [ " ... condition ... [ ... code to run if true ... ] unless" ]\r
+ [ " ... condition ... [ ... false case ... ] unless" ]\r
""\r
"The 'ifte' conditional takes action on both branches:"\r
""\r