Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EffectSeq = createSeqFunction(func(v core.Value) core.Value { return core.EvalImpure(v) })
EffectSeq runs arguments of effects sequentially and returns the last one.
var Greater = createCompareFunction(func(n core.NumberType) bool { return n == 1 })
Greater checks if arguments are aligned in ascending order or not.
var GreaterEq = createCompareFunction(func(n core.NumberType) bool { return n == 1 || n == 0 })
GreaterEq checks if arguments are aligned in ascending order or not.
var Less = createCompareFunction(func(n core.NumberType) bool { return n == -1 })
Less checks if arguments are aligned in ascending order or not.
var LessEq = createCompareFunction(func(n core.NumberType) bool { return n == -1 || n == 0 })
LessEq checks if arguments are aligned in ascending order or not.
var Par = core.NewLazyFunction( core.NewSignature(nil, "args", nil, ""), func(ts ...core.Value) core.Value { l := ts[0] for { v := core.PApp(core.First, l) l = core.PApp(core.Rest, l) if v := core.ReturnIfEmptyList(l, v); v != nil { return v } systemt.Daemonize(func() { core.EvalPure(v) }) } })
Par evaluates arguments in parallel and returns the last one.
var Print = core.NewEffectFunction( core.NewSignature( nil, "args", []core.OptionalParameter{ core.NewOptionalParameter("sep", core.NewString(" ")), core.NewOptionalParameter("end", core.NewString("\n")), core.NewOptionalParameter("file", core.NewNumber(1)), core.NewOptionalParameter("mode", core.NewNumber(0664)), }, "", ), func(ts ...core.Value) core.Value { sep, err := evalGoString(ts[1]) if err != nil { return err } f, err := evalFileArguments(ts[3], ts[4]) if err != nil { return err } l, err := core.EvalList(ts[0]) if err != nil { return err } ss := []string{} for !l.Empty() { s, err := evalGoString(core.PApp(core.ToString, l.First())) if err != nil { return err } ss = append(ss, s) l, err = core.EvalList(l.Rest()) if err != nil { return err } } end, err := evalGoString(ts[2]) if err != nil { return err } if _, err := fmt.Fprint(f, strings.Join(ss, sep)+end); err != nil { return fileError(err) } return core.Nil })
Print prints string representation of arguments to stdout.
var Rally = core.NewLazyFunction( core.NewSignature(nil, "args", nil, ""), func(vs ...core.Value) core.Value { c := make(chan core.Value, valueChannelCapacity) systemt.Daemonize(func() { l, err := core.EvalList(vs[0]) if err != nil { c <- err return } sem := make(chan bool, maxConcurrency) for !l.Empty() { sem <- true go func(v core.Value) { c <- core.EvalPure(v) <-sem }(l.First()) l, err = core.EvalList(l.Rest()) if err != nil { c <- err break } } time.Sleep(channelCloseDuration) c <- nil }) return core.PApp(core.PApp(Y, core.NewLazyFunction( core.NewSignature([]string{"me"}, "", nil, ""), func(vs ...core.Value) core.Value { v := <-c if v == nil { return core.EmptyList } else if err, ok := v.(*core.ErrorType); ok { return err } return core.StrictPrepend([]core.Value{v}, core.PApp(vs[0])) }))) })
Rally sorts arguments by time.
var Read = createReadFunction(os.Stdin)
Read reads a string from stdin or a file.
Seq runs arguments of pure values sequentially and returns the last one.
var Y = core.NewLazyFunction( core.NewSignature([]string{"function"}, "", nil, ""), func(ts ...core.Value) core.Value { return y(ts[0]) })
Y is Y combinator which takes a function whose first argument is itself applied to the combinator.
THE COMMENT BELOW MAY BE OUTDATED because we moved from a lambda calculus based combinator to an implementation based on a recursive function in Go.
Using Y combinator to define built-in functions in Go source is dangerous because top-level recursive functions generate infinitely nested closures. (i.e. closure{f, x} where x will also be evaluated as closure{f, x}.)
var Ys = core.NewLazyFunction( core.NewSignature(nil, "functions", nil, ""), func(ts ...core.Value) core.Value { t := ts[0] return core.PApp(xx, core.NewLazyFunction( core.NewSignature([]string{"x"}, "", nil, ""), func(ts ...core.Value) core.Value { s := ts[0] applyF := core.NewLazyFunction( core.NewSignature([]string{"f"}, "args", nil, "kwargs"), func(ts ...core.Value) core.Value { return core.App(ts[0], core.NewArguments( []core.PositionalArgument{ core.NewPositionalArgument(core.PApp(s, s), false), core.NewPositionalArgument(ts[1], true), }, []core.KeywordArgument{core.NewKeywordArgument("", ts[2])})) }) return createNewFuncs(t, applyF) })) })
Ys is Y* combinator which takes functions whose first arguments are a list of themselves applied to the combinator.
Functions ¶
This section is empty.
Types ¶
This section is empty.