M
Modular•2w ago
Firas

How to random int ??

I have very simple: results = DTypePointer[type].alloc(batch * cols) how to generate random idex (int) in [0,batch * cols] ??? all the random function in mojo returns SIMD, how to convert simd to regular Int ?
3 Replies
Ryulord
Ryulord•2w ago
var a: UInt32 = 42
var b = int(a)
var a: UInt32 = 42
var b = int(a)
Scalar types like UInt32 are just aliases for simd types like SIMD[DType.uint32, 1]
DobyDabaDu
DobyDabaDu•2w ago
GitHub
Mojo-journey/Samples/Rock Paper Scissors/rps.mojo at main · yetalit...
My journey with Mojo programming language. Contribute to yetalit/Mojo-journey development by creating an account on GitHub.
Firas
Firas•2w ago
ok thanks guys I was so confused and tired after hours of coding, all what I needed is the int() builtin function 🫂
Want results from more Discord servers?
Add your server