It's possible, but any real Haskeller will never use length and !! only reluctantly - precisely because linked lists are not arrays.
length
!!
Actually, xs !! (length xs - 2) would still be O(n). That too would go against the essence of the kata though.
xs !! (length xs - 2)
O(n)
Oh never mind. But I'm still not making a JS translation.
Though... I have written a Rust translation that has been approved. I didn't know the original language was Haskell. Though... I am not sure it makes such a difference, it's possible to write a similar solution based on indices in Haskell...
Ah, sorry, the original translation was already approved. I thought you resurrected it. Never mind!
I haven't written the translation, I only made decent tests (look diff ;)).
Was it a good idea to translate this kata to Python?
Linked lists are not arrays and arrays are not linked lists; the essence of the kata seems lost in translation.
Loading collection data...
It's possible, but any real Haskeller will never use
length
and!!
only reluctantly - precisely because linked lists are not arrays.Actually,
xs !! (length xs - 2)
would still beO(n)
. That too would go against the essence of the kata though.Oh never mind. But I'm still not making a JS translation.
Though... I have written a Rust translation that has been approved. I didn't know the original language was Haskell. Though... I am not sure it makes such a difference, it's possible to write a similar solution based on indices in Haskell...
Ah, sorry, the original translation was already approved. I thought you resurrected it. Never mind!
I haven't written the translation, I only made decent tests (look diff ;)).
Was it a good idea to translate this kata to Python?
Linked lists are not arrays and arrays are not linked lists; the essence of the kata seems lost in translation.