| 1 | <h2>Full example</h2> |
| 2 | <pre><code>// Source: https://www.warp10.io/content/04_Tutorials/01_WarpScript/05_Best_Practices |
| 3 | |
| 4 | //factorial macro. take a number on the stack, push its factorial |
| 5 | <% |
| 6 | 'input' STORE |
| 7 | 1 |
| 8 | 1 $input <% * %> FOR |
| 9 | %> 'factorial' STORE |
| 10 | |
| 11 | //build a map with key from 1 to 10 and value = key! |
| 12 | {} 'result' STORE |
| 13 | |
| 14 | 1 10 |
| 15 | <% |
| 16 | 'key' STORE |
| 17 | $result $key @factorial $key PUT |
| 18 | DROP //remove the map let by PUT |
| 19 | %> FOR |
| 20 | |
| 21 | //push the result on the stack |
| 22 | $result</code></pre> |