Lists:sublist oddity

Heinrich Venter heinrich@REDACTED
Mon Jan 30 10:16:28 CET 2006

I just discovered the following strange behaviour

32> lists:sublist([a,b,c],1,2).
33> lists:sublist([a,b,c],2,2).
34> lists:sublist([a,b,c],3,2).
35> lists:sublist([a,b,c],4,2).
36> lists:sublist([a,b,c],5,2).
=ERROR REPORT==== 30-Jan-2006::10:59:47 ===
Error in process <0.72.0> with exit value:

** exited: {function_clause,[{lists,nthtail,[1,[]]},
                             {shell,eval_loop,3}]} **

It would appear that sublist works according to the docs when
(Start-length(List1)) = 1 but fails when (Start-length(List1)) > 1

>From the source it would appear that the documentation is wrong :(
sublist WILL in fact fail if Start > length(List1)+1.


More information about the erlang-questions mailing list