本文整理汇总了Golang中code/google/com/p/gelo.List.Copy方法的典型用法代码示例。如果您正苦于以下问题:Golang List.Copy方法的具体用法?Golang List.Copy怎么用?Golang List.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/gelo.List
的用法示例。
在下文中一共展示了List.Copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Partial
func Partial(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
//TODO all of the argument errors in this function could be more informative
if ac < 2 {
gelo.ArgumentError(vm, "partial", "command [args*|'*|'X]+", args)
}
cmd, args := vm.API.InvokableOrElse(args.Value), args.Next
a_star := false
var val gelo.Word
var kind _partial_kind
var ph, pt *_partial
for ; args != nil; args = args.Next {
kind, val = _pk_fill, nil
if sym, ok := args.Value.(gelo.Symbol); ok {
if gelo.StrEqualsSym("X", sym) {
if a_star {
gelo.ArgumentError(vm, "partial",
"there will be no arguments left after *", args)
}
kind = _pk_hole
} else if gelo.StrEqualsSym("*", sym) {
if a_star {
gelo.ArgumentError(vm, "partial",
"only one * can be specfied", args)
}
kind, a_star = _pk_slurp, true
} else {
val = sym
}
} else {
val = args.Value
}
if ph != nil {
pt.next = &_partial{kind, val, nil}
pt = pt.next
} else {
ph = &_partial{kind, val, nil}
pt = ph
}
}
pt = nil
return gelo.Alien(func(vm *gelo.VM, args *gelo.List, ac uint) gelo.Word {
real_args := extensions.ListBuilder(cmd)
for pls := ph; pls != nil; pls = pls.next {
switch pls.kind {
case _pk_fill:
real_args.Push(pls.item)
case _pk_hole:
if args == nil {
gelo.ArgumentError(vm, "partial function",
"requires at least one more argument", args)
}
real_args.Push(args.Value)
args = args.Next
case _pk_slurp:
real_args.Extend(args.Copy().(*gelo.List))
args = nil
}
}
if args != nil {
gelo.ArgumentError(vm, "partial function", "got too many arguments",
args)
}
return vm.API.InvokeOrElse(real_args.List())
})
}