Erlang arithmetic operations on ets:select result -
i have ets table can imagine there 2 columns, "key" , value. value integer.
when tried:
ans = ets:select(table_name, ms), ans + 1. where ans equals expected value.
i got error:
** exception error: error occurred when evaluating arithmetic look can not arithmetic operation on ets:select homecoming value?
in ets module spec: select(tab, matchspec) -> [match], reurn value list of match. if match specification define 1 single integer value return, receive list of integer. in case, seems list have length of 1 element, if must case, can write:
[ans] = ets:select(table_name, ms), ans + 1. but beware code crash if returned list empty or have more 1 element.
erlang
No comments:
Post a Comment