Skip to content

proposal: add support for ?0 to generate a random float between 0 and 1 #167

Closed
@fzipp

Description

Some APL dialects (including Dyalog APL and J) feature a unary roll operator that generates a random floating-point number between 0 and 1 when the operand is zero. See https://aplwiki.com/wiki/Roll

Example:

?0
	0.945196149294

The revised doc text could be:

Roll              ?B    ?       One integer selected randomly from the first B integers
                                If B=0, random floating-point number between 0 and 1

The implementation would return

BigFloat{big.NewFloat(c.Config().Random().Float64())}

Is this something you could imagine for Ivy as well? If so, I can create a pull request.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions