Add Float function to convert strings and integers to floats
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from smnp.module import system, mic, note, iterable, sound, synth, string, util, integer
|
||||
from smnp.module import system, mic, note, iterable, sound, synth, string, util, integer, float
|
||||
|
||||
functions = [ *system.functions, *mic.functions, *note.functions, *iterable.functions, *sound.functions, *synth.functions, *string.functions, *util.functions, *integer.functions ]
|
||||
methods = [ *system.methods, *mic.methods, *note.methods, *iterable.methods, *sound.methods, *synth.methods, *string.methods, *util.methods, *integer.methods ]
|
||||
functions = [ *system.functions, *mic.functions, *note.functions, *iterable.functions, *sound.functions, *synth.functions, *string.functions, *util.functions, *integer.functions, *float.functions ]
|
||||
methods = [ *system.methods, *mic.methods, *note.methods, *iterable.methods, *sound.methods, *synth.methods, *string.methods, *util.methods, *integer.methods, *float.methods ]
|
||||
4
smnp/module/float/__init__.py
Normal file
4
smnp/module/float/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from smnp.module.float.function import float
|
||||
|
||||
functions = [ float.function ]
|
||||
methods = []
|
||||
0
smnp/module/float/function/__init__.py
Normal file
0
smnp/module/float/function/__init__.py
Normal file
26
smnp/module/float/function/float.py
Normal file
26
smnp/module/float/function/float.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from smnp.function.model import CombinedFunction, Function
|
||||
from smnp.function.signature import signature
|
||||
from smnp.type.model import Type
|
||||
from smnp.type.signature.matcher.type import ofType
|
||||
|
||||
_signature1 = signature(ofType(Type.INTEGER))
|
||||
def _function1(env, value):
|
||||
return Type.float(float(value.value))
|
||||
|
||||
|
||||
_signature2 = signature(ofType(Type.STRING))
|
||||
def _function2(env, value):
|
||||
return Type.float(float(value.value))
|
||||
|
||||
|
||||
_signature3 = signature(ofType(Type.FLOAT))
|
||||
def _function3(env, value):
|
||||
return value
|
||||
|
||||
|
||||
function = CombinedFunction(
|
||||
'Float',
|
||||
Function(_signature1, _function1),
|
||||
Function(_signature2, _function2),
|
||||
Function(_signature3, _function3),
|
||||
)
|
||||
Reference in New Issue
Block a user