From the reference of berkeley's version of sicp text, It is mentioned that:
Expressing programs as sequence operations helps us design programs that are modular. That is, our designs are constructed by combining relatively independent pieces, each of which transforms a sequence. In general, we can encourage modular design by providing a library of standard components together with a conventional interface for connecting the components in flexible ways.
For instance, In python, <class 'list'>
and <class 'tuple'>
are some of the types of mostly used sequential data models for storage.
For instance, In python <class 'dict'>
is one popular type of non-sequential data model.
Text reference gives below solutions written in python to two different problems and mentions as similar solution, which is not convincing, because these two problems could not be the representative sample to take this decision.
>>> def sum_even_fibs(n):
"""Sum the even members of the first n Fibonacci numbers."""
return sum(filter(iseven, map(fib, range(1, n+1))))
>>> sum_even_fibs(20)
3382
>>> def acronym(name):
"""Return a tuple of the letters that form the acronym for name."""
return tuple(map(first, filter(iscap, name.split())))
>>> acronym('University of California Berkeley Undergraduate Graphics Group')
('U', 'C', 'B', 'U', 'G', 'G')
I am still not clear on the decision to make "sequences as conventional interfaces" despite these given examples.
So, Amidst designing a library or component, Why sequential type data models are recommended to be chosen as conventional interfaces?Is this something to do with closure property of these sequential data models(provided by python/scheme/lisp)?
Note: Same recommendation is given in SICP text from MIT press