本文整理汇总了Python中pycket.values.to_list函数的典型用法代码示例。如果您正苦于以下问题:Python to_list函数的具体用法?Python to_list怎么用?Python to_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: regexp_match
def regexp_match(w_re, w_str, inp_start, inp_end, output_port, prefix):
start = inp_start.value
if inp_end is values.w_false:
end = sys.maxint
elif isinstance(inp_end, values.W_Fixnum):
end = inp_end.value
else:
raise SchemeException("regexp-match: expected fixnum or #f for argument 3")
assert output_port is values.w_false, "output port not supported yet"
result = match(w_re, w_str, start, end)
if result is None:
return values.w_false
elif (isinstance(w_str, values_string.W_String) or \
isinstance(w_str, values.W_StringInputPort)) \
and \
(isinstance(w_re, values_regex.W_PRegexp) or \
isinstance(w_re, values_regex.W_Regexp) or \
isinstance(w_re, values_string.W_String)):
return values.to_list([values_string.W_String.fromstr_utf8(r)
if r else values.w_false
for r in result])
else:
return values.to_list([values.W_Bytes.from_string(r)
if r else values.w_false
for r in result])
开发者ID:uternet,项目名称:pycket,代码行数:25,代码来源:regexp.py
示例2: cms_context
def cms_context(marks):
from pycket.values_string import W_String
# TODO: Pycket does not have a mark to denote context. We need to fix that.
k = marks.cont
n = 0
# find out the length
while isinstance(k, Cont):
if is_ast_cont_with_surrounding_lambda(k):
n += 1
k = k.get_previous_continuation()
# second traversal saves us from reversing it later
ls = [None]*n
k = marks.cont
i = n-1
while isinstance(k, Cont):
if is_ast_cont_with_surrounding_lambda(k):
surrounding_lam = k.get_ast().surrounding_lambda
lam_str = W_String.make(surrounding_lam.tostring())
ls[i] = values.W_Cons.make(lam_str, values.w_false)
i -= 1
k = k.get_previous_continuation()
return values.to_list(ls)
开发者ID:pycket,项目名称:pycket,代码行数:25,代码来源:continuation_marks.py
示例3: attach_prop
def attach_prop(self, props, idx, is_checked, env, cont):
from pycket.interpreter import return_multi_vals
if idx < len(props):
(prop, prop_val, sub_prop) = props[idx]
if sub_prop is not None:
for p in props:
if p[0] is sub_prop:
return prop_val.call([p[1]], env,
self.save_prop_value(props, idx, False, env, cont))
assert isinstance(prop, W_StructProperty)
if not is_checked and prop.guard.iscallable():
return prop.guard.call([prop_val, values.to_list(self.struct_type_info())],
env, self.save_prop_value(props, idx, True, env, cont))
if prop.isinstance(w_prop_procedure):
self.prop_procedure = prop_val
self.props.append((prop, prop_val))
return self.attach_prop(props, idx + 1, False, env, cont)
# at this point all properties are saved, next step is to copy
# propertyes from super types
struct_type = self.super
while isinstance(struct_type, W_StructType):
self.props = self.props + struct_type.props
if not self.prop_procedure and struct_type.prop_procedure:
self.prop_procedure = struct_type.prop_procedure
self.procedure_source = struct_type.procedure_source
struct_type = struct_type.super
struct_tuple = self.make_struct_tuple()
return return_multi_vals(values.Values.make(struct_tuple), env, cont)
开发者ID:8l,项目名称:pycket,代码行数:28,代码来源:values_struct.py
示例4: regexp_match
def regexp_match(w_re, w_str):
result = match(w_re, w_str)
if result is None:
return values.w_false
elif (isinstance(w_str, values_string.W_String) or \
isinstance(w_str, values.W_StringInputPort)) \
and \
(isinstance(w_re, values_regex.W_PRegexp) or \
isinstance(w_re, values_regex.W_Regexp) or \
isinstance(w_re, values_string.W_String)):
return values.to_list([values_string.W_String.fromascii(r)
if r else values.w_false
for r in result])
else:
return values.to_list([values.W_Bytes.from_string(r)
if r else values.w_false
for r in result])
开发者ID:rrnewton,项目名称:pycket,代码行数:17,代码来源:regexp.py
示例5: time_apply_cont
def time_apply_cont(initial, env, cont, vals):
from pycket.interpreter import return_multi_vals
final = time.clock()
ms = values.W_Fixnum(int((final - initial) * 1000))
vals_l = vals._get_full_list()
results = values.Values.make([values.to_list(vals_l),
ms, ms, values.W_Fixnum(0)])
return return_multi_vals(results, env, cont)
开发者ID:antongulenko,项目名称:pycket,代码行数:8,代码来源:general.py
示例6: rmp
def rmp(pat, input):
matches = match_positions(pat, input)
xs = []
for start, end in matches:
s = values.W_Fixnum(start)
e = values.W_Fixnum(end)
xs.append(values.W_Cons.make(s, e))
return values.to_list(xs)
开发者ID:8l,项目名称:pycket,代码行数:8,代码来源:regexp.py
示例7: to_value
def to_value(json):
dbgprint("to_value", json)
if json is pycket_json.json_false:
return values.w_false
elif json is pycket_json.json_true:
return values.w_true
if json.is_object:
# The json-object should only contain one element
obj = json.value_object()
if "vector" in obj:
return vector.W_Vector.fromelements([to_value(v) for v in obj["vector"].value_array()], immutable=True)
if "struct" in obj:
key = to_value(obj["prefab-key"])
fields = [to_value(v) for v in obj["struct"].value_array()]
return values_struct.W_Struct.make_prefab(key, fields)
if "box" in obj:
return values.W_IBox(to_value(obj["box"]))
if "number" in obj:
return _to_num(obj["number"])
if "path" in obj:
return values.W_Path(obj["path"].value_string())
if "char" in obj:
return values.W_Character.make(unichr(int(obj["char"].value_string())))
if "hash-keys" in obj and "hash-vals" in obj:
return W_EqualHashTable(
[to_value(i) for i in obj["hash-keys"].value_array()],
[to_value(i) for i in obj["hash-vals"].value_array()],
immutable=True)
if "regexp" in obj:
return values_regex.W_Regexp(obj["regexp"].value_string())
if "byte-regexp" in obj:
arr = decode_byte_array(obj["byte-regexp"])
return values_regex.W_ByteRegexp("".join(arr))
if "pregexp" in obj:
return values_regex.W_PRegexp(obj["pregexp"].value_string())
if "byte-pregexp" in obj:
arr = decode_byte_array(obj["byte-pregexp"])
return values_regex.W_BytePRegexp("".join(arr))
if "bytes" in obj:
arr = decode_byte_array(obj["bytes"])
return values.W_ImmutableBytes(arr)
if "string" in obj:
return values_string.W_String.make(str(obj["string"].value_string()))
if "keyword" in obj:
return values.W_Keyword.make(str(obj["keyword"].value_string()))
if "improper" in obj:
improper = obj["improper"].value_array()
return values.to_improper([to_value(v) for v in improper[0].value_array()], to_value(improper[1]))
if "void" in obj:
return values.w_void
for i in ["lexical", "module", "source-name", "toplevel"]:
if i in obj:
return values.W_Symbol.make(obj[i].value_string())
if json.is_array:
return values.to_list([to_value(j) for j in json.value_array()])
assert 0, "Unexpected json value: %s" % json.tostring()
开发者ID:magnusmorton,项目名称:pycket,代码行数:56,代码来源:expand.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: do_procedure_arity
def do_procedure_arity(proc):
result = []
(ls, at_least) = proc.get_arity()
for item in ls:
result.append(values.W_Fixnum(item))
if at_least != -1:
result.append(values_struct.W_Struct.make([values.W_Fixnum(at_least)],\
arity_at_least))
if len(result) == 1:
return result[0]
return values.to_list(result[:])
开发者ID:antongulenko,项目名称:pycket,代码行数:11,代码来源:general.py
示例10: do_procedure_arity
def do_procedure_arity(proc, env, cont):
from pycket.interpreter import return_value
result = []
arity = proc.get_arity()
for item in arity.arity_list:
result.append(values.W_Fixnum(item))
if arity.at_least != -1:
val = [values.W_Fixnum(arity.at_least)]
return arity_at_least.constr.call(val, env, proc_arity_cont(result, env, cont))
if len(result) == 1:
return return_value(result[0], env, cont)
return return_value(values.to_list(result[:]), env, cont)
开发者ID:rrnewton,项目名称:pycket,代码行数:12,代码来源:general.py
示例11: struct_type_info
def struct_type_info(self):
name = values.W_Symbol.make(self.name)
init_field_cnt = values.W_Fixnum(self.init_field_cnt)
auto_field_cnt = values.W_Fixnum(self.auto_field_cnt)
immutable_k_list = values.to_list([values.W_Fixnum(i) for i in self.immutables])
# TODO: value of the super variable should be a structure type descriptor
# for the most specific ancestor of the type that is controlled by the current inspector,
# or #f if no ancestor is controlled by the current inspector
super = self.super
# TODO: #f if the seventh result is the most specific ancestor type or
# if the type has no supertype, #t otherwise
skipped = values.w_false
return [name, init_field_cnt, auto_field_cnt, self.acc, self.mut,
immutable_k_list, super, skipped]
开发者ID:antongulenko,项目名称:pycket,代码行数:14,代码来源:values_struct.py
示例12: key
def key(self):
key = []
key.append(values.W_Symbol.make(self.name))
key.append(values.W_Fixnum.make(self.init_field_cnt))
if self.auto_field_cnt > 0:
key.append(values.to_list(
[values.W_Fixnum.make(self.auto_field_cnt), self.auto_v]))
mutables = []
for i in self.mutables:
mutables.append(values.W_Fixnum.make(i))
if mutables:
key.append(values_vector.W_Vector.fromelements(mutables))
if self.super_key:
key.extend(self.super_key.key())
return key
开发者ID:8l,项目名称:pycket,代码行数:15,代码来源:values_struct.py
示例13: 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
示例14: struct_type_info
def struct_type_info(self):
name = values.W_Symbol.make(self.name)
init_field_cnt = values.W_Fixnum.make(self.init_field_cnt)
auto_field_cnt = values.W_Fixnum.make(self.auto_field_cnt)
immutable_k_list = values.to_list(
[values.W_Fixnum.make(i) for i in self.immutables])
super = values.w_false
typ = self.super
while isinstance(typ, W_StructType):
if current_inspector.has_control(typ):
super = typ
typ = typ.super
skipped = values.W_Bool.make(super is values.w_false and
isinstance(self.super, W_StructType))
return [name, init_field_cnt, auto_field_cnt, self.accessor,
self.mutator, immutable_k_list, super, skipped]
开发者ID:8l,项目名称:pycket,代码行数:16,代码来源:values_struct.py
示例15: make_prefab
def make_prefab(prefab_key):
if prefab_key in W_StructType.unbound_prefab_types:
w_struct_type = W_StructType.unbound_prefab_types[prefab_key]
else:
name, init_field_cnt, auto_field_cnt, auto_v, mutables, super_key =\
prefab_key.make_key_tuple()
super_type = W_StructType.make_prefab(super_key) if super_key else\
values.w_false
immutables = []
for i in range(init_field_cnt):
if i not in mutables:
immutables.append(values.W_Fixnum.make(i))
w_struct_type = W_StructType.make_simple(values.W_Symbol.make(name),
super_type, values.W_Fixnum.make(init_field_cnt),
values.W_Fixnum.make(auto_field_cnt), auto_v, values.w_null,
PREFAB, values.w_false, values.to_list(immutables))
W_StructType.unbound_prefab_types[prefab_key] = w_struct_type
return w_struct_type
开发者ID:8l,项目名称:pycket,代码行数:18,代码来源:values_struct.py
示例16: define_struct
def define_struct(name, super=values.w_null, fields=[]):
immutables = []
for i in range(len(fields)):
immutables.append(values.W_Fixnum(i))
struct_type, struct_constr, struct_pred, struct_acc, struct_mut = \
values_struct.W_StructType.make_simple(values.W_Symbol.make(name),
super, values.W_Fixnum(len(fields)), values.W_Fixnum(0),
values.w_false, values.w_null, values.w_false, values.w_false,
values.to_list(immutables)).make_struct_tuple()
expose_val("struct:" + name, struct_type)
expose_val(name, struct_constr)
# this is almost always also provided
expose_val("make-" + name, struct_constr)
expose_val(name + "?", struct_pred)
for field, field_name in enumerate(fields):
w_num = values.W_Fixnum(field)
w_name = values.W_Symbol.make(field_name)
acc = values_struct.W_StructFieldAccessor(struct_acc, w_num, w_name)
expose_val(name + "-" + field_name, acc)
return struct_type
开发者ID:rrnewton,项目名称:pycket,代码行数:20,代码来源:general.py
示例17: 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
示例18: make_known_char_range_list
def make_known_char_range_list(args):
all_known = [None]*LEN_CHAR_RANGES
for i, (start, end, same_props) in enumerate(known_char_ranges):
all_known[i] = to_list([W_Fixnum(start), W_Fixnum(end), W_Bool.make(same_props)])
return to_list(all_known)
开发者ID:pycket,项目名称:pycket,代码行数:5,代码来源:char.py
示例19: string_to_list
def string_to_list(s):
return values.to_list([values.W_Character(i) for i in s.as_unicode()])
开发者ID:8l,项目名称:pycket,代码行数:2,代码来源:string.py
示例20: do_list
def do_list(args):
return values.to_list(args)
开发者ID:antongulenko,项目名称:pycket,代码行数:2,代码来源:general.py
注:本文中的pycket.values.to_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论