3 ms·
Erlang has 1-based lists as well.
by davidw 14y ago
Erlang has 1-based lists as well.
- davidw 14y agoI'm not sure who downvoted this, but: > lists:nth(1, [a, b, c]). a > lists:nth(0, [a, b, c]). ** exception error: no function clause matching lists:nth(0,[a,b,c]) (lists.erl, line 117)
- klibertp 14y agoIt's worse in Erlang: "Mainly, Regex and Binary indexes are zero-based, List and Tuple are one-based." I don't remember now but one of the collections in stdlib is zero-based too. It's much worse to be inconsistent than to choose 0 or 1-based indexes for everything.
- davidw 14y ago> one of the collections in stdlib is zero-based too. Yep, array: http://www.erlang.org/doc/man/array.html http://www.erlang.org/doc/man/array.html It's definitely a mess.