Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = module.NewBuiltin(). Func("int() (v int)", rand.Int63). Func("float() (v float)", rand.Float64). Func("intn(n int) (v int)", rand.Int63n). Func("exp_float() (v float)", rand.ExpFloat64). Func("norm_float() (v float)", rand.NormFloat64). Func("perm(n int) (v []int)", rand.Perm). Func("read(b bytes) (n int, err error)", func(ctx context.Context, args ...vm.Object) (ret vm.Object, err error) { if len(args) != 1 { return nil, vm.ErrWrongNumArguments } y1, ok := args[0].(*vm.Bytes) if !ok { return nil, vm.ErrInvalidArgumentType{ Name: "first", Expected: "bytes", Found: args[0].TypeName(), } } res, err := rand.Read(y1.Value) if err != nil { ret = module.WrapError(err) return } return &vm.Int{Value: int64(res)}, nil }). Func("rand(seed int) (rand *Rand)", func(ctx context.Context, args ...vm.Object) (vm.Object, error) { if len(args) != 1 { return nil, vm.ErrWrongNumArguments } i1, ok := vm.ToInt64(args[0]) if !ok { return nil, vm.ErrInvalidArgumentType{ Name: "first", Expected: "int(compatible)", Found: args[0].TypeName(), } } src := rand.NewSource(i1) return randRand(rand.New(src)), nil })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.