Quick Functional Programming David Matuszek pdf download
Quick Functional Programming David Matuszek pdf download
download
https://ebookbell.com/product/quick-functional-programming-david-
matuszek-49607080
https://ebookbell.com/product/quick-functional-programming-quick-
programming-1st-edition-david-matuszek-49484134
https://ebookbell.com/product/quick-clojure-effective-functional-
programming-1st-ed-mark-mcdonnell-6730354
https://ebookbell.com/product/quick-clojure-effective-functional-
programming-mark-mcdonnell-6778682
https://ebookbell.com/product/quick-functional-exercises-for-
seniors-50-exercises-to-optimize-your-health-1st-edition-cody-
sipe-52674168
Functional Anatomy For Sport And Exercise Quick Reference 1st Edition
Clare Milner
https://ebookbell.com/product/functional-anatomy-for-sport-and-
exercise-quick-reference-1st-edition-clare-milner-1270880
https://ebookbell.com/product/microsoft-excel-functions-quick-
reference-for-highquality-data-analysis-dashboards-and-more-1st-
edition-mandeep-mehta-34873296
https://ebookbell.com/product/microsoft-excel-functions-quick-
reference-for-highquality-data-analysis-dashboards-and-more-1st-
edition-mandeep-mehta-44396112
Excel For Finance Quick Reference Guide Master Formulas Functions And
Analysis Techniques The Finance Toolbox Series Book 1 Schwartz
https://ebookbell.com/product/excel-for-finance-quick-reference-guide-
master-formulas-functions-and-analysis-techniques-the-finance-toolbox-
series-book-1-schwartz-217805110
Windows 11 Quick Guide Tips Learn How To Use Tons Of Windows 11 Hidden
Features Functions And Tricks Cecile Dean Charles J J
https://ebookbell.com/product/windows-11-quick-guide-tips-learn-how-
to-use-tons-of-windows-11-hidden-features-functions-and-tricks-cecile-
dean-charles-j-j-50493072
Quick Functional
Programming
Why learn functional programming? Isn’t that some compli-
cated ivory-tower technique used only in obscure languages like
Haskell?
In this book, we use Python and Java and, as a bonus, Scala. If you
prefer another language, there will be minor differences in syntax,
but the concepts are the same.
David Matuszek
First edition published 2023
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742
and by CRC Press
4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
CRC Press is an imprint of Taylor & Francis Group, LLC
© 2023 David Matuszek
Reasonable efforts have been made to publish reliable data and information, but
the author and publisher cannot assume responsibility for the validity of all
materials or the consequences of their use. The authors and publishers have
attempted to trace the copyright holders of all material reproduced in this
publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged
please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be
reprinted, reproduced, transmitted, or utilized in any form by any electronic,
mechanical, or other means, now known or hereafter invented, including
photocopying, microfilming, and recording, or in any information storage or
retrieval system, without written permission from the publishers.
vii
viii ◾ Contents
Afterword 125
Index, 127
About the Author
xi
xii ◾ About the Author
languages. I’ve also written two science fiction novels, Ice Jockey
and All True Value, and I expect to write more. Check them out!
david.matuszek@gmail.com
Preface
You’re right.
Right again.
Here’s a spoiler: FP will let you replace many of your loops with
shorter, simpler, easier to understand function calls. Yes, there’s
some unfamiliar syntax involved, but it’s just syntax, and you can
get used to it very quickly. The new concepts, the parts you might
think are the most difficult, turn out to be trivially simple.
You may be surprised how much a single power tool can help you
in your day-to-day programming.
Heat.
(347.) The most obvious sources of heat are, the sun, fire,
animal life, fermentations, violent chemical actions of all kinds,
friction, percussion, lightning, or the electric discharge, in whatever
manner produced, the sudden condensation of air, and others, so
numerous, and so varied, as to show the extensive and important
part it has to perform in the economy of nature. The discoveries of
chemists, however, have referred most of these to the general head
of chemical combination. Thus, fire, or the combustion of
inflammable bodies, is nothing more than a violent chemical action
attending the combination of their ingredients with the oxygen of the
air. Animal heat is, in like manner, referable to a process bearing no
remote analogy to a slow combustion, by which a portion of carbon,
an inflammable principle existing in the blood, is united with the
oxygen of the air in respiration; and thus carried off from the
system: fermentation is nothing more than a decomposition of
chemical elements loosely united, and their re-union in a more
permanent state of combination. The analogy between the sun and
terrestrial fire is so natural as to have been chosen by Newton to
exemplify the irresistible force of an inference derived from that
principle. But the nature of the sun and the mode in which its
wonderful supply of light and heat is maintained are involved in a
mystery which every discovery that has been made either in
chemistry or optics, so far from elucidating, seems only to render
more profound. Friction as a source of heat is well known: we rub
our hands to warm them, and we grease the axles of carriage-
wheels to prevent their setting fire to the wood; an accident which,
in spite of this precaution, does sometimes happen. But the effect of
friction, as a means of producing heat with little or no consumption
of materials, was not fully understood till made the subject of direct
experiment by count Rumford, whose results appear to have
established the extraordinary fact, that an unlimited supply of heat
may be derived by friction from the same materials. Condensation,
whether of air by pressure, or of metals by percussion, is another
powerful source of heat. Thus, iron may be so dexterously
hammered as to become red-hot, and the rapid condensation of a
confined portion of air will set tinder on fire.
(348.) The most violent heats known are produced by the
concentration of the solar rays by burning glasses,—by the
combustion of oxygen and hydrogen gases mixed in the exact
proportion in which they combine to produce water,—and by the
discharge of a continued and copious current of electricity through a
small conductor. As these three sources of heat are independent of
each other, and each capable of being brought into action in a very
confined space, there seems no reason why they might not all three
be applied at once at the same point, by which means, probably,
effects would be produced infinitely surpassing any hitherto
witnessed.
(349.) Heat is communicated either by radiation between bodies
at a distance, or by conduction between bodies in contact, or
between the contiguous parts of one and the same body. The laws
of the radiation of heat have been studied with great attention, and
have been found to present strong analogies with that of light in
some points, and singular differences in others. Thus, the heat
which accompanies the sun’s rays comports itself, in all respects, like
light; being subject to similar laws of reflection, refraction, and even
of polarization, as has been shown by Berard. Yet they are not
identical with each other; Sir William Herschel having shown, by
decisive experiments, verified by those of Sir H. Englefield, that
there exist in a solar beam both rays of heat which are not luminous,
and rays of light which have no heating power.
(350.) The heat, radiated by terrestrial fires, and by bodies
obscurely hot, by whatever means they have acquired their heat
(even by exposure to the sun’s rays), differs very materially from
solar heat in their power of penetrating transparent substances. This
singular and important difference was first noticed by Mariotte, and
afterwards made the subject of many curious and interesting
experiments by Scheele, who found that terrestrial heat, or that
radiated from fires or heated bodies, is intercepted and detained by
glass or other transparent bodies, while solar heat is not; and that,
being so detained, it heats them: which the latter, as it passes freely
through them, is incapable of doing. The more recent researches of
Delaroche, however, have shown that this detention is complete only
when the temperature of the source of heat is low; but that, as that
temperature is higher, a portion of the heat radiated acquires a
power of penetrating glass; and that the quantity which does so
bears continually a larger and larger proportion to the whole, as the
heat of the radiant body is more intense. This discovery is very
important, as it establishes a community of nature between solar
and terrestrial heat; while at the same time it leads us to regard the
actual temperature of the sun as far exceeding that of any earthly
flame.
(351.) A variety of theories have been framed to account for
these curious phenomena; but the subject stands rather in need of
further elucidation from experiment, and is one which merits, and
will probably amply repay, the labours of those who may hereafter
devote their attention to it. The theory of the radiation of heat, in
general, which seems to agree best with the known phenomena, is
that of M. Prevost, who considers all bodies as constantly radiating
out heat in all directions, and receiving it by a similar means of
communication from others, and thus tending, in any space filled,
wholly or in part, with bodies at various temperatures, to establish
an equilibrium or equality of heat in all parts. The application of this
idea to the explanation of the phenomenon of dew we have already
seen (see 167.). The laws of such radiation, under various
circumstances, have been lately investigated in a beautiful series of
experiments on the cooling of bodies by their own radiation in
vacuo, by Messrs. Dulong and Petit, which offer some of the best
examples in science of the inductive investigation of quantitative
laws.
(352.) The communication of heat between bodies in contact, or
between the different parts of the same body, is performed by a
process called conduction. It is, in fact, only a particular case of
radiation, as has been explained above (217.); but a case so
particular as to require a separate and independent investigation of
its laws. The most important consideration introduced into the
enquiry by this peculiarity is that of time. The communication of heat
by conduction is performed, for the most part, with extreme
slowness, while that performed by direct radiation is probably not
less rapid than the propagation of light itself. The analysis of the
delicate and difficult points which arise in the investigation of this
subject in its reduction to direct geometrical treatment has been
executed with admirable success by the late Baron Fourrier, whose
recent lamented death has deprived science of an ornament it could
ill spare, thinned as its ranks have been within the last few years.
This acute philosopher and profound mathematician has developed,
in a series of elaborate memoirs presented to the French Institute,
the laws of the communication of heat through the interior of solid
masses, placed under the influence of any external heating and
cooling causes, and has in particular applied his results to the
conditions on which the maintenance of the actual observed
temperature on the earth’s surface depends; to the possible
influence of a supposed central heat on our climates; and to the
determination of the actual amount of the heat, derived to us from
the sun, or at least that portion of it on which the difference of the
seasons depends.
(353.) The principal effects of heat are the sensations of warmth
or cold consequent on its entry or egress into or out of our bodies;
the dilatation it causes in the dimensions of all substances in which it
is accumulated; the changes of state it produces in the melting of
solids, and the conversion of them and of liquids into vapour; and
the chemical changes it performs by actual decompositions effected
in the intimate molecules of various substances, especially those of
which vegetables and animals are composed; to which we may add,
the production of electric phenomena under certain circumstances in
the contact of metals, and the developement of electric polarity in
crystallised substances.
(354.) Cold has been considered by some as a positive quality,
the effect of a cause antagonist to that of heat; but this idea seems
now (with perhaps a single exception) to be universally abandoned.
The sensation of cold is as easily explicable by the passage of heat
outwards through the surface of the body as that of heat by its
ingress from without; and the experiments cited in proof of a
radiation of cold are all perfectly explained by Prevost’s theory of
reciprocal interchange. It is remarkable, however, how very limited
our means of producing intense cold are, compared with those we
possess of effecting the accumulation of heat in bodies. This is one
of the strongest arguments adducible in favour of the doctrines of
those who maintain the possibility of exhausting the heat of a body
altogether, and leaving it in a state absolutely devoid of it. But we
ought to consider, that the known methods of generating heat
chiefly turn on the production of chemical combinations: we may
easily conceive, therefore, that, to obtain equally powerful
corresponding frigorific effects, we ought to possess the means of
effecting a disunion equally extensive and rapid between such
elements, actually combined, as have already produced heat by their
union. This, however, we can only accomplish by engaging them in
combinations still more energetic, that is to say, in which we may
reasonably expect more heat to be produced by the new
combination than would be destroyed or abstracted by the proposed
decomposition. Chemistry, however, (unaided by electric agency,)
affords no means of suddenly breaking the union of two elements,
and presenting both in an uncombined state. A certain analogy to
such disunion, however, and its consequences, may be traced in the
sudden expansion of condensed gases from a liquid state into
vapour, which is the most powerful source of cold known.
(355.) The dilatation of bodies by heat forms the subject of that
branch of science called pyrometry. There is no body but is capable
of being penetrated by heat, though some with greater, others with
less rapidity; and being so penetrated, all bodies (with a very few
exceptions, and those depending on very peculiar circumstances,)
are dilated by it in bulk, though with a great diversity in the amount
of dilatation produced by the same degree of heat. Of the several
forms of natural bodies, gases and vapours are observed to be most
dilatable; liquids next, and solids least of all. The dilatation of solids
has been made a subject of repeated and careful measurement by
several experimenters; among whom, Smeaton, Lavoisier, and
Laplace, are the principal. The remarkable discovery of the unequal
dilatation of crystallised bodies by Mitscherlich has already been
spoken of. (266.) That of gases and vapours was examined about
the same time by Dalton and Gay-Lussac, who both arrived
independently at the conclusion of an equal dilatability subsisting in
them all, which constitutes one of the most remarkable points in
their history.
(356.) The dilatation of air by heat affords, perhaps, the most
unexceptionable means known of measuring degrees of heat. The
thermometer, as originally constructed by Cornelius Drebell, was an
air thermometer. Those now in common use measure accessions of
heat not by the degree of dilatation of air but of mercury. It has
been shown, by the researches of Dulong and Petit, that its
indications coincide exactly with that of the air-thermometer in
moderate temperatures; though at very elevated ones they exhibit a
sensible, and even considerable, deviation. By this instrument, which
owes its present convenience and utility to the happy idea of
Newton, who first thought of fixing determinate points on its scale,
we are enabled to estimate, or at least identify, the degrees of heat;
and thereby to investigate with accuracy the laws of its
communication and its other properties. Were we sure that equal
additions of heat produced equal increments of dimension in any
substance, the indications of a thermometer would afford a true and
secure measure of the quantity present; but this is so far from being
the case, that we are nearly in total ignorance on this important
point; a circumstance which throws the greatest difficulty in the way
of all theoretical reasoning, and even of experimental enquiry. The
laws of the dilatation of liquids, in consequence of this deficiency of
necessary preliminary knowledge, are still involved in great obscurity,
notwithstanding the pains which have been bestowed on them by
the elaborate experiments and calculations of Gilpin, Blagden, Deluc,
Dalton, Gay-Lussac, and Biot.
(357.) The most striking and important of the effects of heat
consist, however, in the liquefaction of solid substances, and the
conversion of the liquids so produced into vapour. There is no solid
substance known which, by a sufficiently intense heat, may not be
melted, and finally dissipated in vapour; and this analogy is so
extensive and cogent, that we cannot but suppose that all those
bodies which are liquid under ordinary circumstances, owe their
liquidity to heat, and would freeze or become solid if their heat could
be sufficiently reduced. In many we see this to be the case in
ordinary winters; for some, severe frosts are requisite; others freeze
only with the most intense artificial colds; and some have hitherto
resisted all our endeavours; yet the number of these last is few, and
they will probably cease to be exceptions as our means of producing
cold become enlarged.
(358.) A similar analogy leads us to conclude that all aëriform
fluids are merely liquids kept in the state of vapour by heat. Many of
them have been actually condensed into the liquid state by cold
accompanied with violent pressure; and as our means of applying
these causes of condensation have improved, more and more
refractory ones have successively yielded. Hence we are fairly
entitled to extend our conclusion to those which we have not yet
been able to succeed with; and thus we are led to regard it as a
general fact, that the liquid and aëriform or vaporous states are
entirely dependent on heat; that were it not for this cause, there
would be nothing but solids in nature; and that, on the other hand,
nothing but a sufficient intensity of heat is requisite to destroy the
cohesion of every substance, and reduce all bodies, first to liquids,
and then into vapour.
(359.) But solids, themselves, by the abstraction of heat shrink
in dimension, and at the same time become harder, and more brittle;
yielding less to pressure, and permitting less separation between
their parts by tension. These facts, coupled with the greater
compressibility of liquids, and the still greater of gases, strongly
induce us to believe that it is heat, and heat alone, which holds the
particles of all bodies at that distance from each other which is
necessary to allow of compression; which in fact gives them their
elasticity, and acts as the antagonist force to their mutual attraction,
which would otherwise draw them into actual contact, and retain
them in a state of absolute immobility and impenetrability. Thus we
learn to regard heat as one of the great maintaining powers of the
universe, and to attach to all its laws and relations a degree of
importance which may justly entitle them to the most assiduous
enquiry.
(360.) It was first ascertained by Dr. Black that when heat
produces the liquefaction of a solid, or the conversion of a liquid into
vapour, the liquid or the vapour resulting is no hotter than the solid
or liquid from which it was produced, though a great deal of heat
has been expended in producing this effect, and has actually entered
into the substance.
(361.) Hence he drew the conclusion that it has become latent,
and continues to exist in the product, maintaining it in its new state,
without increasing its temperature. He further proved, that when the
vapour condenses, or the liquid freezes, this latent heat is again
given out from it. This great discovery, with its natural and hardly
less important concomitant, that of the difference of specific heats in
different bodies, or the different quantities of heat they require to
raise their temperature equally, are the chief reasons for regarding
heat as a material substance in a more decided manner than light,
with which in its radiant state it holds so close an analogy.
(362.) The subject of latent heat has been far less attentively
studied than its great practical importance would appear to demand,
when we consider that it is to this part of physical science that the
theory of the steam-engine is mainly referable, and that material
improvements may not unreasonably be expected in that wonderful
instrument, from a more extended knowledge than we possess of
the latent heats of different vapours. This is not the case, however,
with the subject of specific heat, which was followed up immediately
after its first promulgation with diligence by Irvine; and, after a brief
interval, by Lavoisier and Laplace, as well as by our countryman
Crawfurd, who determined the specific heats of many substances,
both solid and liquid. After a considerable period of inactivity, the
subject was again resumed by Delaroche and Berard, and
subsequently by Dulong and Petit: the result of whose investigations
has been the inductive establishment of one of those simple and
elegant physical laws which carry with them, if not their own
evidence, at least their own recommendation to our belief, as being
in unison with every thing we know of the harmony of nature. The
law to which we allude is this:—that the atoms of all the simple
chemical elements have exactly the same capacity for heat, or are all
equally heated or cooled by equal accessions or abstractions of heat.
It is only among laws like this that we can expect to find a clew
capable of guiding us to a knowledge of the true nature of heat, and
its relations to ponderable matter.
ebookbell.com