Lazy and eager¶
FlpIt is a deferred, streaming query over any iterable. FlpList is a materialized list that also has the
whole LINQ API.
Deferred execution¶
numbers = [1, 2]
doubled: FlpIt[int] = flp.it(numbers).select(lambda x: x * 2)
numbers.append(3) # the query has not run yet, so it sees the change
assert doubled.to_list() == [2, 4, 6]
Materialized results¶
snapshot: FlpList[int] = flp.it([1, 2, 3]).select(lambda x: x * 2).to_list()
assert snapshot[0] == 2 # a FlpList is a normal indexable collection
assert snapshot[1:] == [4, 6] # ... that also speaks LINQ
assert snapshot.where(lambda x: x > 2).to_list() == [4, 6]
count()¶
FlpList.count() is LINQ's Count(). Use the built-in list.count(value) on a plain list if you want
Python's meaning.