Nasal: add isscalar() for Henning

This commit is contained in:
James Turner 2020-04-18 18:06:35 +01:00
parent c82a14c252
commit b72553f6f0

View File

@ -242,6 +242,13 @@ static naRef f_typeof(naContext c, naRef me, int argc, naRef* args)
return NEWCSTR(c, t); return NEWCSTR(c, t);
} }
static naRef f_isscalar(naContext c, naRef me, int argc, naRef* args)
{
naRef r = argc > 0 ? args[0] : naNil();
if(naIsString(r) || naIsNum(r)) return naNum(1);
else return naNum(0);
}
static naRef f_isstr(naContext c, naRef me, int argc, naRef* args) static naRef f_isstr(naContext c, naRef me, int argc, naRef* args)
{ {
naRef r = argc > 0 ? args[0] : naNil(); naRef r = argc > 0 ? args[0] : naNil();
@ -702,6 +709,7 @@ static naCFuncItem funcs[] = {
{ "bind", f_bind }, { "bind", f_bind },
{ "sort", f_sort }, { "sort", f_sort },
{ "id", f_id }, { "id", f_id },
{ "isscalar", f_isscalar },
{ "isint", f_isint }, { "isint", f_isint },
{ "isnum", f_isnum }, { "isnum", f_isnum },
{ "isghost", f_isghost }, { "isghost", f_isghost },