Move 'iterable' module
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from smnp.module import system, mic, note
|
||||
from smnp.module import system, mic, note, iterable
|
||||
|
||||
functions = [ *system.functions, *mic.functions, *note.functions ]
|
||||
methods = [ *system.methods, *mic.methods, *note.methods ]
|
||||
functions = [ *system.functions, *mic.functions, *note.functions, *iterable.functions ]
|
||||
methods = [ *system.methods, *mic.methods, *note.methods, *iterable.methods ]
|
||||
4
smnp/module/iterable/__init__.py
Normal file
4
smnp/module/iterable/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from smnp.module.iterable.function import combine, flat, map, range, get
|
||||
|
||||
functions = [ combine.function, flat.function, map.function, range.function ]
|
||||
methods = [ get.function ]
|
||||
0
smnp/module/iterable/function/__init__.py
Normal file
0
smnp/module/iterable/function/__init__.py
Normal file
@@ -2,6 +2,7 @@ from smnp.library.model import Function
|
||||
from smnp.library.signature import varargSignature, allTypes
|
||||
from smnp.type.model import Type
|
||||
|
||||
|
||||
_signature = varargSignature(allTypes())
|
||||
def _function(env, vararg):
|
||||
return Type.list(doFlat(vararg, [])).decompose()
|
||||
@@ -3,10 +3,11 @@ from smnp.library.model import CombinedFunction, Function
|
||||
from smnp.library.signature import signature, ofType, ofTypes
|
||||
from smnp.type.model import Type
|
||||
|
||||
|
||||
_signature1 = signature(ofType(Type.LIST), ofType(Type.INTEGER))
|
||||
def _function1(env, list, index):
|
||||
try:
|
||||
return list.value[index]
|
||||
return list.value[index.value]
|
||||
except KeyError:
|
||||
raise RuntimeException(f"Attempt to access item which is outside the list", None)
|
||||
|
||||
@@ -18,6 +19,7 @@ def _function2(env, map, key):
|
||||
except KeyError:
|
||||
raise RuntimeException(f"Attempt to access unknown key in map", None)
|
||||
|
||||
|
||||
function = CombinedFunction(
|
||||
'get',
|
||||
Function(_signature1, _function1),
|
||||
@@ -2,6 +2,7 @@ from smnp.library.model import Function, CombinedFunction
|
||||
from smnp.library.signature import varargSignature, listMatches, ofTypes, allTypes, signature, listOfMatchers
|
||||
from smnp.type.model import Type
|
||||
|
||||
|
||||
_signature1 = varargSignature(listMatches(ofTypes(Type.INTEGER, Type.STRING, Type.NOTE), allTypes()))
|
||||
def _function1(env, vararg):
|
||||
map = {}
|
||||
@@ -1,4 +1,4 @@
|
||||
from smnp.module.note.function import tuplet, transpose, semitones, pause, octave, duration
|
||||
from smnp.module.note.function import tuplet, transpose, semitones, pause, octave, duration, interval
|
||||
|
||||
functions = [ pause.function, semitones.function, transpose.function, tuplet.function ]
|
||||
functions = [ pause.function, semitones.function, interval.function, transpose.function, tuplet.function ]
|
||||
methods = [ duration.function, octave.function ]
|
||||
Reference in New Issue
Block a user