Original JavaScript Unfortunately, stream models of systems with loops may require uses of delay beyond the hidden delay supplied by cons-stream. For instance, figure 3.56 shows a signal-processing system for solving the differential equation $dy/dt=f(y)$ where $f$ is a given function. The figure shows a mapping component, which applies $f$ to its input signal, linked in a feedback loop to an integrator in a manner very similar to that of the analog computer circuits that are actually used to solve such equations. Figure 3.56 An analog computer circuit that solves the equation $dy/dt = f(y)$. Unfortunately, stream models of systems with loops may require uses of a delay beyond the stream programming pattern seen so far. For instance, figure 3.57 shows a signal-processing system for solving the differential equation $dy/dt=f(y)$ where $f$ is a given function. The figure shows a mapping component, which applies $f$ to its input signal, linked in a feedback loop to an integrator in a manner very similar to that of the analog computer circuits that are actually used to solve such equations. Figure 3.57 An analog computer circuit that solves the equation $dy/dt = f(y)$.

 This procedure is not guaranteed to work in all Scheme implementations, although for any implementation there is a simple variation that will work. The problem has to do with subtle differences in the ways that Scheme implementations handle internal definitions. (See section 4.1.6.)
 To complete in reasonable time, this calculation requires the use of the memoization optimization from section 3.5.1 in integral and in the function add_streams used in integral (using the function stream_map_2_optimized as suggested in exercise 3.60).
 This is a small reflection, in Lisp, JavaScript, of the difficulties that conventional strongly early statically typed languages such as Pascal have had in coping with higher-order procedures. functions. In such these languages, the programmer must had to specify the data types of the arguments and the result of each procedure: function: number, logical value, sequence, and so on. Consequently, we could not express an abstraction such as map a given procedure function proc fun over all the elements in a sequence by a single higher-order procedure function such as stream-map. stream_map. Rather, we would need a different mapping procedure function for each different combination of argument and result data types that might be specified for a proc. fun. Maintaining a practical notion of data type in the presence of higher-order procedures functions raises many difficult issues. One way of dealing with this problem is illustrated by the language ML (Gordon, Milner, and Wadsworth 1979), whose polymorphic data types parametrically polymorphic data types include templates for higher-order transformations between data types. Moreover, data types for most procedures functions in ML are never explicitly declared by the programmer. Instead, ML includes a type-inferencing mechanism that uses information in the environment to deduce the data types for newly defined procedures. functions. Today, statically typed programming languages have evolved to typically support some form of type inference as well as parametric polymorphism, with varying degrees of power. Haskell couples an expressive type system with powerful type inference.
3.5.4   Streams and Delayed Evaluation