Move 'flat' function definition to standard library
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from smnp.module.iterable.function import combine, flat, map, range, get
|
||||
from smnp.module.iterable.function import combine, map, range, get
|
||||
|
||||
functions = [ combine.function, flat.function, map.function, range.function ]
|
||||
functions = [ combine.function, map.function, range.function ]
|
||||
methods = [ get.function ]
|
||||
@@ -1,23 +0,0 @@
|
||||
from smnp.function.model import Function
|
||||
from smnp.function.signature import varargSignature
|
||||
from smnp.type.model import Type
|
||||
from smnp.type.signature.matcher.type import allTypes
|
||||
|
||||
_signature = varargSignature(allTypes())
|
||||
def _function(env, vararg):
|
||||
return Type.list(doFlat(vararg, [])).decompose()
|
||||
|
||||
|
||||
def doFlat(input, output=None):
|
||||
if output is None:
|
||||
output = []
|
||||
|
||||
for item in input:
|
||||
if item.type == Type.LIST:
|
||||
doFlat(item.value, output)
|
||||
else:
|
||||
output.append(item)
|
||||
return output
|
||||
|
||||
|
||||
function = Function(_signature, _function, 'flat')
|
||||
@@ -7,5 +7,5 @@ class ImportEvaluator(Evaluator):
|
||||
@classmethod
|
||||
def evaluator(cls, node, environment):
|
||||
source = node.source
|
||||
newEnvironment = Interpreter.interpretFile(source.value)
|
||||
newEnvironment = Interpreter.interpretFile(source.value, baseEnvironment=environment)
|
||||
environment.extend(newEnvironment)
|
||||
Reference in New Issue
Block a user