What is the purpose of List?

It is possible that this method signature was created as a by-product of some generic class. For example, SwingWorker has two type parameters, one for final result and one for intermediate results. If you just don’t want to use any intermediate results, you pass Void as the type parameter, resulting in some methods returning Void … Read more

How to compare a list of lists/sets in python?

So you want the difference between two lists of items. first_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘3c3c3c’, 3333]] secnd_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘8p8p8p’, 9999], [‘Test4.doc’, ‘4d4d4d’, 4444]] First I’d turn each list of lists into a list of tuples, so as tuples are hashable (lists are not) … Read more

How to chunk a list in Python 3?

In Python 3’s itertools there is a function called zip_longest. It should do the same as izip_longest from Python 2. Why the change in name? You might also notice that itertools.izip is now gone in Python 3 – that’s because in Python 3, the zip built-in function now returns an iterator, whereas in Python 2 … Read more

Kotlin prepend element

I think the easiest would be to write: var list = listOf(2,3) println(list) // [2, 3] list = listOf(1) + list println(list) // [1, 2, 3] There is no specific tail implementation, but you can call .drop(1) to get the same. You can make this head\tail more generic by writing these extension properties: val <T> … Read more