diff options
| author | stainer_t <thomas.stainer@oecd-nea.org> | 2025-09-08 13:48:49 +0200 |
|---|---|---|
| committer | stainer_t <thomas.stainer@oecd-nea.org> | 2025-09-08 13:48:49 +0200 |
| commit | 7dfcc480ba1e19bd3232349fc733caef94034292 (patch) | |
| tree | 03ee104eb8846d5cc1a981d267687a729185d3f3 /Yacs++/data/fact.c2m | |
Initial commit from Polytechnique Montreal
Diffstat (limited to 'Yacs++/data/fact.c2m')
| -rwxr-xr-x | Yacs++/data/fact.c2m | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Yacs++/data/fact.c2m b/Yacs++/data/fact.c2m new file mode 100755 index 0000000..45a6dfd --- /dev/null +++ b/Yacs++/data/fact.c2m @@ -0,0 +1,19 @@ + ! + ! Example of a recursive procedure. + ! + ! input to "fact": *n* + ! output from "fact": *n_fact* + ! + INTEGER n n_fact prev_fact ; + :: >>n<< ; + IF n 1 = THEN + EVALUATE n_fact := 1 ; + ELSE + EVALUATE n := n 1 - ; + ! Here, "fact" calls itself + PROCEDURE fact ; + fact :: <<n>> >>prev_fact<< ; + EVALUATE n_fact := n 1 + prev_fact * ; + ENDIF ; + :: <<n_fact>> ; + QUIT " Recursive procedure *fact* XREF " . |
