-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
questionFurther information is requestedFurther information is requested
Description
etuplize
currently transforms a Python list to an expression tuple that contains the elements of the list:
from etuples import etuplize
from etuples.core import InvalidExpression
et = etuplize([1, 2])
print(et)
# e(1, 2)
This expression tuple is invalid and cannot be evaluated:
try:
et.evaled_obj
except InvalidExpression as e:
print(e)
# ExpressionTuple does not have a callable operator.
I thus suggest that etuplize
returns the following expression that uses cons
, which can be emulated by registering _car
and _cdr
from cons.core
for lists:
from cons.core import _car, _cdr, cons
from etuples import etuple
@_car.register(list)
def car_list(x):
return cons
@_cdr.register(list)
def cdr_list(x):
return etuple(*x, [])
et = etuplize([1, 2])
print(et)
# e(<class 'cons.core.ConsPair'>, 1, 2, [])
brandonwillard
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested