You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are the various functions OM.integer, OM.float, OM.string, etc,
I would like a function that, given any javascript object (supported by OpenMath), chooses automatically the appropriate function among OM.integer, OM.float, OM.string, etc, and convert the object to OpenMath.
Here is a draft of what I mean:
function to_openmath(obj){
switch(typeof(obj)) {
case number:
if Number.isInteger(obj) return OM.integer(obj) else return OM.float(obj)
break;
case string:
return OM.string(obj)
break;
case boolean:
return OM.symbol(obj,logic1)
break;
case object
if Array.isArray(obj)
return OM.application(OM.symbol(list,list1), elements of the array, with to_openmath applied to each )
break;
case and so on:
return OM.corresponding to that
break;
default:
throw "Not supported"
}
}
The text was updated successfully, but these errors were encountered:
There are the various functions OM.integer, OM.float, OM.string, etc,
I would like a function that, given any javascript object (supported by OpenMath), chooses automatically the appropriate function among OM.integer, OM.float, OM.string, etc, and convert the object to OpenMath.
Here is a draft of what I mean:
The text was updated successfully, but these errors were encountered: