diff options
author | Nicolas Williams <nico@cryptonector.com> | 2013-11-28 22:27:23 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2013-12-04 18:21:39 -0600 |
commit | cf562961b7fa35e13fbe8a4ac9a6d7836a0ecde9 (patch) | |
tree | 0f0d61b2613fddb9aa6a5d57677cd83307609659 /builtin.c | |
parent | 63bed9bdf1919ed9da8a6b46e3fbc25ee4e071be (diff) |
Add string division by string (split on separator)
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -160,6 +160,8 @@ static jv f_divide(jv input, jv a, jv b) { jv_free(input); if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) { return jv_number(jv_number_value(a) / jv_number_value(b)); + } else if (jv_get_kind(a) == JV_KIND_STRING && jv_get_kind(b) == JV_KIND_STRING) { + return jv_string_split(a, b); } else { return type_error2(a, b, "cannot be divided"); } @@ -539,6 +541,7 @@ static const struct cfunction function_list[] = { {(cfunction_ptr)f_keys, "keys", 1}, {(cfunction_ptr)f_startswith, "startswith", 2}, {(cfunction_ptr)f_endswith, "endswith", 2}, + {(cfunction_ptr)jv_string_split, "split", 2}, {(cfunction_ptr)jv_string_explode, "explode", 1}, {(cfunction_ptr)jv_string_implode, "implode", 1}, {(cfunction_ptr)jv_setpath, "setpath", 3}, // FIXME typechecking |