Code:
library(stringr)

A:

Code:
library(stringr)

# output

Q:

Why are these two simple python programs not comparable?

I have two very simple code blocks which are not comparable.
One uses a list and the other uses a set.
Why is that?

Code 1:
def reduce(l):
l = list(l)
if l:
r = reduce(l[1:])
print l, r
return r

# Reduced List is much less because items are re-reduced.
>>> reduce([[10, 11], [12, 13], [20, 21]])
[[10, 11], [20, 21]]

Code 2:
>>> reduce([[10, 11], [12, 13], [20, 21]])
Traceback (most recent call last):
File “”, line 1, in
File “”, line 2, in reduce
TypeError: can’t compare offset to list

Edit:
>>> reduce([[10, 11], [12, 13], [20, 21]]) == reduce([[10, 11], [12, 13], [20, 21]])
True

A:

This is because the elements of a set are unique.
>>> reduce([[10,11],[12,13],[20,21]])
[20,21]
>>> reduce([[10,11],[12,13],[20,21]])
[10,11]

In the list case, the duplicates are retained. In order to be comparable you need to define the equivalent of a unique, or you need to not use a set.
For example:
>>> l1 = [1, 2, 3, 3, 3, 4]
>>> l2 = [[1, 2, 3], [2