unlikearrays,length is relatively expensive operation.
It needs to traversethewhole list to find its end and therefore takes time proportional to the number of elements in the list.
Do xs.isEmpty
Don’t use xs.length == 0.
unlikearrays,length is relatively expensive operation.
It needs to traversethewhole list to find its end and therefore takes time proportional to the number of elements in the list.
Do xs.isEmpty
Don’t use xs.length == 0.