Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.