Re:Julia Language Co-Creators Win James H. Wilkinson Prize f...
by yellowapple on Wednesday January 23, 2019 @04:48PM
(#18983421)
Are they, though? The relevant functions in Enum all seem to be zero-based, for example:
iex> [:foo, :bar, :baz] |> Enum.at(1)
:bar
Not that it really matters anyway. Like with Erlang, in the vast majority of cases where I'd normally reach for querying a list element by index, pattern matching is the better / more idiomatic option. Compare: foo = list |> Enum.at(0)
bar = list |> Enum.at(1)
baz = list |> Enum.at(2)
rem = list |> Enum.slice(3..-1)
with: [foo, bar, baz | rem] = list
Both give you the exact same values of foo/bar/baz/rem, but the latter is arguably more readable and concise, and entirely avoids the 0 v. 1 debate.
Regex and Binary indexes are zero-based, List and Tuple are one-based