From 29bdd10ee3621ed875bfa34a0faa42c35a1e39ed Mon Sep 17 00:00:00 2001 From: nic-gaffney Date: Tue, 27 Jun 2023 01:59:59 -0500 Subject: Standard library methinks --- std/stdlib.c | 2 +- std/stdlib.sloth | 2 +- std/stdmath.c | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'std') 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 #include -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 #include +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; } -- cgit v1.2.3