1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/rand/rand.v
Alexander Medvednikov b3b4278f59 rand fixes
2019-06-23 23:25:20 +02:00

23 lines
410 B
Go

// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module rand
#include <time.h>
struct C.time_t{}
fn C.rand() int
fn seed() {
# time_t t;
# srand((unsigned) time(&t));
}
fn next(max int) int {
r := 0
# r = rand(); // TODO parser bug `rand` module name conflict
return r % max
}