diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-06-27 01:59:59 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-06-27 01:59:59 -0500 |
| commit | 29bdd10ee3621ed875bfa34a0faa42c35a1e39ed (patch) | |
| tree | 97f7605b53fc77277d98d5ea8127391edefc4ab5 /std | |
| parent | 9c2d8f5a10b8affd604cec6e394d43514ef93ca1 (diff) | |
| download | sloth-29bdd10ee3621ed875bfa34a0faa42c35a1e39ed.tar.gz | |
Standard library methinks
Diffstat (limited to 'std')
| -rw-r--r-- | std/stdlib.c | 2 | ||||
| -rw-r--r-- | std/stdlib.sloth | 2 | ||||
| -rw-r--r-- | std/stdmath.c | 6 |
3 files changed, 7 insertions, 3 deletions
diff --git a/std/stdlib.c b/std/stdlib.c index 11ae42f..f405b6f 100644 --- a/std/stdlib.c +++ b/std/stdlib.c @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> -void wait(int x) { +void wait(float x) { sleep(x); } diff --git a/std/stdlib.sloth b/std/stdlib.sloth index cc404f6..e15d4dc 100644 --- a/std/stdlib.sloth +++ b/std/stdlib.sloth @@ -1,4 +1,4 @@ -foreign fn wait(x: Int) Void; +foreign fn wait(x: Float) Void; foreign fn print(str: String) Void; foreign fn slen(str: String) Int; # foreign fn charAt(str: String) Char; diff --git a/std/stdmath.c b/std/stdmath.c index 37c81b0..f7f79c6 100644 --- a/std/stdmath.c +++ b/std/stdmath.c @@ -2,8 +2,12 @@ #include <stdlib.h> #include <time.h> +bool random_setup = false; int randGen(int min, int max) { - srandom((unsigned) time(NULL)); + if random_setup == false { + srandom(time(NULL)); + random_setup = true; + } return random() % (max - min + 1) + min; } |
