tiny beautification

This commit is contained in:
VaclavT 2021-02-17 00:10:39 +01:00
parent fb23b20473
commit 4a867d3c22
2 changed files with 10 additions and 10 deletions

View File

@ -14,14 +14,14 @@
|`(while cond ...)`|`while` evaluates only its cond argument.|`while` evaluates its condition expression every iteration before running. If it is true, it continues to evaluate every expression in the `while` body. It then returns the last value evaluated.| |`(while cond ...)`|`while` evaluates only its cond argument.|`while` evaluates its condition expression every iteration before running. If it is true, it continues to evaluate every expression in the `while` body. It then returns the last value evaluated.|
## Examples ## Library
#### Using the binary #### Using the binary
Run wisp in interactive mode: Run ml in interactive mode:
```bash ```bash
$ ./wisp $ ./ml
>>> (print "Hello world!") >>> (print "Hello world!")
Hello world! Hello world!
=> "Hello world!" => "Hello world!"
@ -30,13 +30,13 @@ Hello world!
Interpret a file: Interpret a file:
```bash ```bash
$ ./wisp -f "examples/hello_world.lisp" $ ./ml -f "examples/hello_world.lisp"
Hello world! Hello world!
``` ```
Interpret from command line argument: Interpret from command line argument:
```bash ```bash
$ ./wisp -c '(print "Hello world!")' $ ./ml -c '(print "Hello world!")'
Hello world! Hello world!
``` ```

10
ml.cpp
View File

@ -15,7 +15,6 @@
#include <sstream> #include <sstream>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <fstream>
#include <ctime> #include <ctime>
@ -47,7 +46,7 @@
// Convert an object to a string using a stringstream conveniently // Convert an object to a string using a string stream conveniently
#define to_string(x) static_cast<std::ostringstream>((std::ostringstream() << std::dec << x )).str() #define to_string(x) static_cast<std::ostringstream>((std::ostringstream() << std::dec << x )).str()
// Replace a substring with a replacement string in a source string // Replace a substring with a replacement string in a source string
@ -1350,8 +1349,8 @@ namespace builtin {
eval_args(args, env); eval_args(args, env);
if (args.size() != 1) if (args.size() != 1)
throw MlError(MlValue(FLOAT_TYPE, cast_to_float), env, throw MlError(MlValue(FLOAT_TYPE, cast_to_float), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
return args[0].cast_to_float(); return args[0].cast_to_float();
} }
@ -1360,7 +1359,8 @@ namespace builtin {
eval_args(args, env); eval_args(args, env);
if (args.size() != 1) if (args.size() != 1)
throw MlError(MlValue(INT_TYPE, cast_to_int), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS); throw MlError(MlValue(INT_TYPE, cast_to_int), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
return args[0].cast_to_int(); return args[0].cast_to_int();
} }