Yard/test.erpn

64 lines
727 B
Plaintext
Raw Normal View History

2023-01-02 11:06:24 +00:00
extern function say_hello
extern function print
extern function println
2023-01-02 11:56:53 +00:00
extern function to_rat
2023-01-02 11:06:24 +00:00
2023-01-02 11:56:53 +00:00
extern function to_int
extern function parse_int
extern function parse_rat
2023-01-02 11:06:24 +00:00
fac:
Load Arg x
Load Int 1
NotEq Int
Unless
Load Int 1
Yield
Load Arg x
Load Int 1
Sub Int
Call fac
Load Arg x
Mul Int
Yield
2023-01-02 11:56:53 +00:00
number:
Load Rat 12.0
2022-12-06 14:02:03 +00:00
main:
2023-01-02 11:56:53 +00:00
Call number
Call to_int
Call fac
Store Int result
Load String "The Factorial of "
Call number
Load String " is: "
Load Var result
Cat Str
Cat Str
Cat Str
Call println
2022-12-06 14:02:03 +00:00
Load Int 0
2022-12-06 21:48:52 +00:00
Store Int x
2023-01-02 11:56:53 +00:00
Loopstart
Load Var x
Load Int 9
Gt Int
While
Load String ""
2022-12-06 21:48:52 +00:00
Load Var x
2023-01-02 11:56:53 +00:00
Cat Str
Call println
Load Var x
Load Int 1
Add Int
Store Int x
2023-01-02 11:06:24 +00:00
Load Int 0
2022-11-14 16:50:34 +00:00
Yield
2022-12-06 14:02:03 +00:00