erlang/otp — pull request #27 by ttmrichter (2012-08-23 12:26:43+00:00)
Title: Added automagic step-down case to lists:seq/2.

If I do lists:seq(1,100) I get, as expected, [1,2,3,...,99,100]. The increment is automatically assumed to be +1 and everybody is happy. If, however, I do lists:seq(100,1) I'm told that no function clause matches lists:seq(100,1) at line 177 of lists.erl.

This doesn't seem sensible to me. If an assumed +1 can be baked in for First < Last, surely an assumed -1 can be baked in for First > Last.

I've made the necessary change in lists.erl (line 180 in this pull request) to add this logic. The code will not break any existing code because currently First > Last crashes with a bad match so no existing code can have this kind of use of lists:seq/2.