The least we can do is use fromListN machinery to make take linear in the result size, which smells big-O optimal. For stack drop, I imagine we can do something more interesting, to make it linear in the number of elements dropped. For queues, I've implemented take in time linear in the number of elements taken, but I suspect we can do better than that in the case where we take most of the elements—some sort of "drop from the rear" smells better.
The least we can do is use
fromListNmachinery to maketakelinear in the result size, which smells big-O optimal. For stackdrop, I imagine we can do something more interesting, to make it linear in the number of elements dropped. For queues, I've implementedtakein time linear in the number of elements taken, but I suspect we can do better than that in the case where we take most of the elements—some sort of "drop from the rear" smells better.takefor stacks—completed in Implement take for stacks #15takefor queues—implemented in Implement take for queues #17, but I suspect we can improve it.dropfor stacksdropfor queuessplitAtfor stackssplitAtfor queues