• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python values.from_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycket.values.from_list函数的典型用法代码示例。如果您正苦于以下问题:Python from_list函数的具体用法?Python from_list怎么用?Python from_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了from_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: from_raw_key

 def from_raw_key(w_key, total_field_cnt=0):
     init_field_cnt = -1
     auto_field_cnt = 0
     auto_v = values.w_false
     super_key = None
     mutables = []
     if isinstance(w_key, values.W_Symbol):
         name = w_key.utf8value
         init_field_cnt = total_field_cnt
     else:
         key = values.from_list(w_key)
         w_name = key[0]
         assert isinstance(w_name, values.W_Symbol)
         name = w_name.utf8value
         idx = 1
         w_init_field_cnt = key[idx]
         if isinstance(w_init_field_cnt, values.W_Fixnum):
             init_field_cnt = w_init_field_cnt.value
             idx += 1
         if len(key) > idx:
             w_auto = key[idx]
             if isinstance(w_auto, values.W_Cons):
                 auto = values.from_list(w_auto)
                 w_auto_field_cnt = auto[0]
                 assert isinstance(w_auto_field_cnt, values.W_Fixnum)
                 auto_field_cnt = w_auto_field_cnt.value
                 auto_v = auto[1]
                 idx += 1
         if len(key) > idx:
             v = key[idx]
             if isinstance(v, values_vector.W_Vector):
                 for i in range(v.len):
                     mutable = v.ref(i)
                     assert isinstance(mutable, values.W_Fixnum)
                     mutables.append(mutable.value)
                 idx += 1
         if len(key) > idx:
             w_super_key = values.to_list(key[idx:])
             super_key = W_PrefabKey.from_raw_key(w_super_key)
     if init_field_cnt == -1:
         init_field_cnt = total_field_cnt
         s_key = super_key
         while s_key:
             super_name, super_init_field_cnt, super_auto_field_cnt,\
                 super_auto_v, super_mutables, s_key = s_key.make_key_tuple()
             init_field_cnt -= super_init_field_cnt
     return W_PrefabKey.make(name, init_field_cnt, auto_field_cnt, auto_v,
         mutables, super_key)
开发者ID:8l,项目名称:pycket,代码行数:48,代码来源:values_struct.py


示例2: is_prefab_key

 def is_prefab_key(v):
     if isinstance(v, values.W_Symbol):
         return values.w_true
     elif isinstance(v, values.W_Cons):
         key = values.from_list(v)
         if not isinstance(key[0], values.W_Symbol):
             return values.w_false
         idx = 1
         if isinstance(key[idx], values.W_Fixnum):
             idx += 1
         else:
             if not isinstance(key[idx], values.W_Cons):
                 return values.w_false
             idx += 1
         if len(key) > idx:
             if not isinstance(key[idx], values.W_Cons):
                 return values.w_false
             idx += 1
         if len(key) > idx:
             if not isinstance(key[idx], values_vector.W_Vector):
                 return values.w_false
             idx += 1
         if len(key) > idx:
             return W_PrefabKey.is_prefab_key(key[idx])
         return values.w_true
     else:
         return values.w_false
开发者ID:antongulenko,项目名称:pycket,代码行数:27,代码来源:values_struct.py


示例3: equal_hash_args

def equal_hash_args(w_prop):
    if isinstance(w_prop, values_vector.W_Vector):
        return w_prop.ref(0), w_prop.ref(1), w_prop.ref(2)
    if isinstance(w_prop, values.W_List):
        lst = values.from_list(w_prop)
        assert len(lst) >= 3
        return lst[0], lst[1], lst[2]
    raise SchemeException("invalid prop:equal+hash arg " + w_prop.tostring())
开发者ID:magnusmorton,项目名称:pycket,代码行数:8,代码来源:equal.py


示例4: append

def append(lists):
    if not lists:
        return values.w_null
    lists, acc = lists[:-1], lists[-1]
    while lists:
        vals = values.from_list(lists.pop())
        acc = values.to_improper(vals, acc)
    return acc
开发者ID:antongulenko,项目名称:pycket,代码行数:8,代码来源:general.py


示例5: from_assocs

def from_assocs(assocs, fname):
    lsts = values.from_list(assocs)
    keys = [None] * len(lsts)
    vals = [None] * len(lsts)
    for i, lst in enumerate(lsts):
        if not isinstance(lst, values.W_Cons):
            raise SchemeException("%s: expected list of pairs" % fname)
        keys[i], vals[i] = lst.car(), lst.cdr()
    return keys, vals
开发者ID:krono,项目名称:pycket,代码行数:9,代码来源:hash.py


示例6: is_struct_info

def is_struct_info(v):
    if isinstance(v, values.W_Cons):
        struct_info = values.from_list(v)
        if len(struct_info) == 6:
            if not isinstance(struct_info[0], values_struct.W_StructType) and\
                struct_info[0] is not values.w_false:
                return False
            if not isinstance(struct_info[1], values_struct.W_StructConstructor) and\
                struct_info[1] is not values.w_false:
                return False
            if not isinstance(struct_info[2], values_struct.W_StructPredicate) and\
                struct_info[2] is not values.w_false:
                return False
            accessors = struct_info[3]
            if isinstance(accessors, values.W_Cons):
                for accessor in values.from_list(accessors):
                    if not isinstance(accessor, values_struct.W_StructFieldAccessor):
                        if accessor is not values.w_false and\
                            accessor is values.from_list(accessors)[-1]:
                            return False
            else:
                return False
            mutators = struct_info[4]
            if isinstance(mutators, values.W_Cons):
                for mutator in values.from_list(mutators):
                    if not isinstance(mutator, values_struct.W_StructFieldAccessor):
                        if mutator is not values.w_false and\
                          mutator is values.from_list(mutators)[-1]:
                          return False
            else:
                return False
            if not isinstance(struct_info[5], values_struct.W_StructType) and\
                not isinstance(struct_info[5], values.W_Bool):
                return False
            return True
        return False
    elif isinstance(v, values.W_Prim):
        if v.name == "make-struct-info":
            return True
    # TODO: it can be also:
    # 1. a structure with the prop:struct-info property
    # 2. a structure type derived from struct:struct-info or
    # with prop:struct-info and wrapped with make-set!-transformer
    return False
开发者ID:rrnewton,项目名称:pycket,代码行数:44,代码来源:struct_structinfo.py


示例7: make_immutable_hasheq

def make_immutable_hasheq(assocs):
    pairs = values.from_list(assocs)
    keys  = [None] * len(pairs)
    vals  = [None] * len(pairs)
    for i, pair in enumerate(pairs):
        if not isinstance(pair, values.W_Cons):
            raise SchemeException("make-immutable-hasheq: expected list of pairs")
        keys[i] = pair.car()
        vals[i] = pair.cdr()
    return make_simple_table(W_EqHashTable, keys, vals, immutable=True)
开发者ID:8l,项目名称:pycket,代码行数:10,代码来源:hash.py


示例8: list_tail

def list_tail(lst, pos):
    start_pos = pos.value
    if start_pos == 0:
        return lst
    else:
        if isinstance(lst, values.W_Cons):
            assert start_pos > 0
            return values.to_list(values.from_list(lst)[start_pos:])
        else:
            return values.w_null
开发者ID:antongulenko,项目名称:pycket,代码行数:10,代码来源:general.py


示例9: make_hasheqv

def make_hasheqv(pairs):
    lsts = values.from_list(pairs)
    keys = []
    vals = []
    for lst in lsts:
        if not isinstance(lst, values.W_Cons):
            raise SchemeException("make-hash: expected list of pairs")
        keys.append(lst.car())
        vals.append(lst.cdr())
    return make_simple_table(W_EqvHashTable, keys, vals)
开发者ID:krono,项目名称:pycket,代码行数:10,代码来源:hash.py


示例10: make_immutable_hash

def make_immutable_hash(assocs):
    # FIXME: Not annotated as immutable
    lsts = values.from_list(assocs)
    keys = []
    vals = []
    for lst in lsts:
        if not isinstance(lst, values.W_Cons):
            raise SchemeException("make-hash: expected list of pairs")
        keys.append(lst.car())
        vals.append(lst.cdr())
    return W_EqualHashTable(keys, vals)
开发者ID:antongulenko,项目名称:pycket,代码行数:11,代码来源:hash.py


示例11: list_to_bytes

def list_to_bytes(w_list):
    l = values.from_list(w_list)
    ll = [' '] * len(l)
    for (i,x) in enumerate(l):
        if not isinstance(x, values.W_Fixnum):
            raise SchemeException("list->bytes: expected fixnum, got %s" % x)
        if x.value < 0 or x.value >= 256:
            raise SchemeException(
                "list->bytes: expected number between 0 and 255, got %s" % x)
        ll[i] = chr(x.value)
    return values.W_MutableBytes(ll)
开发者ID:8l,项目名称:pycket,代码行数:11,代码来源:string.py


示例12: do_is_procedure_arity

def do_is_procedure_arity(n):
    if isinstance(n, values.W_Fixnum):
        if n.value >= 0:
            return values.w_true
    elif isinstance(n, values_struct.W_RootStruct) and\
        n.struct_type().name == "arity-at-least":
        return values.w_true
    elif isinstance(n, values.W_List):
        for item in values.from_list(n):
            if not (isinstance(item, values.W_Fixnum) or\
                (isinstance(item, values_struct.W_RootStruct) and\
                item.struct_type().name == "arity-at-least")):
                return values.w_false
        return values.w_true
    return values.w_false
开发者ID:antongulenko,项目名称:pycket,代码行数:15,代码来源:general.py


示例13: apply

def apply(args, env, cont):
    if not args:
        raise SchemeException("apply expected at least one argument, got 0")
    fn = args[0]
    if not fn.iscallable():
        raise SchemeException("apply expected a procedure, got something else")
    lst = args[-1]
    if not listp_loop(lst):
        raise SchemeException(
            "apply expected a list as the last argument, got something else")
    args_len = len(args)-1
    assert args_len >= 0
    others = args[1:args_len]
    new_args = others + values.from_list(lst)
    return fn.call(new_args, env, cont)
开发者ID:antongulenko,项目名称:pycket,代码行数:15,代码来源:general.py


示例14: is_module_path

def is_module_path(v):
    if isinstance(v, values.W_Symbol):
        # FIXME: not always right
        return True
    if isinstance(v, values.W_Path):
        return True
    if isinstance(v, values_string.W_String):
        return True
    if isinstance(v, values.W_List):
        vs = values.from_list(v)
        for p in vs:
            if not is_module_path(p):
                return False
        return True
    # FIXME
    return False
开发者ID:vishesh,项目名称:pycket,代码行数:16,代码来源:general.py


示例15: apply

def apply(args, env, cont, extra_call_info):
    if not args:
        raise SchemeException("apply expected at least one argument, got 0")
    fn = args[0]
    if not fn.iscallable():
        raise SchemeException("apply expected a procedure, got something else")
    lst = args[-1]
    try:
        rest = values.from_list(lst)
    except SchemeException:
        raise SchemeException(
            "apply expected a list as the last argument, got something else")
    args_len = len(args)-1
    assert args_len >= 0
    others = args[1:args_len]
    new_args = others + rest
    return fn.call_with_extra_info(new_args, env, cont, extra_call_info)
开发者ID:rrnewton,项目名称:pycket,代码行数:17,代码来源:general.py


示例16: from_raw_params

 def from_raw_params(w_name, w_init_field_cnt, w_auto_field_cnt, auto_v,
         w_immutables, super_type):
     assert isinstance(w_name, values.W_Symbol)
     name = w_name.utf8value
     assert isinstance(w_init_field_cnt, values.W_Fixnum)
     init_field_cnt = w_init_field_cnt.value
     assert isinstance(w_auto_field_cnt, values.W_Fixnum)
     auto_field_cnt = w_auto_field_cnt.value
     mutables = []
     prev_idx = 1
     for i in values.from_list(w_immutables):
         assert isinstance(i, values.W_Fixnum)
         for j in range(prev_idx, i.value):
             mutables.append(j)
         prev_idx = i.value + 1
     super_key = W_PrefabKey.from_struct_type(super_type) if\
         super_type is not values.w_false else None
     return W_PrefabKey.make(name, init_field_cnt, auto_field_cnt, auto_v,
         mutables, super_key)
开发者ID:8l,项目名称:pycket,代码行数:19,代码来源:values_struct.py


示例17: initialize_props

 def initialize_props(self, props, proc_spec, env, cont):
     """
     Properties initialization contains few steps:
         1. call initialize_prop for each property from the input list,
            it extracts all super values and stores them into props array
            with a flat structure
         2. recursively call attach_prop for each property from props and
            prepare the value:
            * if the current property has a subproperty, the value is the result
              of calling value procedure with a sub value as an argument
            * if the current property has a guard, the value is the result of
              calling guard with a value and struct type info as arguments
            * in other case, just keep the current value
     """
     proplist = values.from_list(props)
     props = []
     for p in proplist:
         self.initialize_prop(props, p)
     if proc_spec is not values.w_false:
         self.initialize_prop(props, values.W_Cons.make(w_prop_procedure, proc_spec))
     return self.attach_prop(props, 0, False, env, cont)
开发者ID:8l,项目名称:pycket,代码行数:21,代码来源:values_struct.py


示例18: is_prefab_key

 def is_prefab_key(v):
     if isinstance(v, values.W_Symbol):
         return values.w_true
     elif isinstance(v, values.W_Cons):
         key = values.from_list(v)
         if not isinstance(key[0], values.W_Symbol):
             return values.w_false
         idx = 1
         if isinstance(key[idx], values.W_Fixnum):
             idx += 1
         if len(key) > idx:
             if isinstance(key[idx], values.W_Cons):
                 idx += 1
         if len(key) > idx:
             if isinstance(key[idx], values_vector.W_Vector):
                 idx += 1
         if len(key) > idx:
             w_super_key = values.to_list(key[idx:])
             return W_PrefabKey.is_prefab_key(w_super_key)
         return values.W_Bool.make(len(key) == idx)
     else:
         return values.w_false
开发者ID:8l,项目名称:pycket,代码行数:22,代码来源:values_struct.py


示例19: __init__

    def __init__(self, name, super_type, init_field_cnt, auto_field_cnt,
            auto_v, inspector, proc_spec, immutables, guard, constr_name):
        self.name = name.utf8value
        self.super = super_type
        self.init_field_cnt = init_field_cnt.value
        self.auto_field_cnt = auto_field_cnt.value
        self.total_field_cnt = self.init_field_cnt + self.auto_field_cnt + \
            (super_type.total_field_cnt if isinstance(super_type, W_StructType)
            else 0)
        self.auto_v = auto_v
        self.props = []
        self.prop_procedure = None
        self.procedure_source = None
        self.inspector = inspector
        imm = []
        if isinstance(proc_spec, values.W_Fixnum):
            imm.append(proc_spec.value)
        for i in values.from_list(immutables):
            assert isinstance(i, values.W_Fixnum)
            imm.append(i.value)
        self.immutables = imm[:]
        self.guard = guard

        self.auto_values = [self.auto_v] * self.auto_field_cnt
        self.isprefab = inspector is PREFAB
        if self.isprefab:
            self.isopaque = False
        else:
            self.isopaque = self.inspector is not values.w_false

        self.calculate_offsets()

        constr_name = (constr_name.utf8value if
            isinstance(constr_name, values.W_Symbol) else "make-" + self.name)
        self.constr = W_StructConstructor(self, constr_name)
        self.predicate = W_StructPredicate(self)
        self.accessor = W_StructAccessor(self)
        self.mutator = W_StructMutator(self)
开发者ID:8l,项目名称:pycket,代码行数:38,代码来源:values_struct.py


示例20: apply

def apply(args, env, cont, extra_call_info):
    if not args:
        raise SchemeException("apply expected at least one argument, got 0")
    fn = args[0]
    if not fn.iscallable():
        raise SchemeException("apply expected a procedure, got something else")
    lst = args[-1]
    try:
        fn_arity = fn.get_arity()
        if fn_arity is Arity.unknown or fn_arity.at_least == -1:
            unroll_to = 1
        elif fn_arity.arity_list:
            unroll_to = fn_arity.arity_list[-1] - (len(args) - 2)
        else:
            unroll_to = 1
        rest = values.from_list(lst, unroll_to=unroll_to)
    except SchemeException:
        raise SchemeException(
            "apply expected a list as the last argument, got something else")
    args_len = len(args) - 1
    assert args_len >= 0
    others = args[1:args_len]
    new_args = others + rest
    return fn.call_with_extra_info(new_args, env, cont, extra_call_info)
开发者ID:vishesh,项目名称:pycket,代码行数:24,代码来源:general.py



注:本文中的pycket.values.from_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python values.to_list函数代码示例发布时间:2022-05-25
下一篇:
Python testhelper.run_mod_expr函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap