Skip to content

Cross platform random number generation #2

@tpanetti

Description

@tpanetti

Vim script has no native support for random numbers, so we need a cross platform (Linux, Mac OS, Windows) solution for generating them.

This is my current implementation of a random function, although it is based on time so it's not giving great results.

function! Randnum(max) abort
    return str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:]) % a:max
endfunction

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions