Functional Programming in Kotlin 1st Edition Marco Vermeulen instant download
Functional Programming in Kotlin 1st Edition Marco Vermeulen instant download
https://ebookmeta.com/product/functional-programming-in-
kotlin-1st-edition-marco-vermeulen/
https://ebookmeta.com/product/from-objects-to-functions-build-
your-software-faster-and-safer-with-functional-programming-and-
kotlin-1st-edition-uberto-barbini/
https://ebookmeta.com/product/functional-programming-in-c-2nd-
edition-enrico-buonanno/
https://ebookmeta.com/product/functional-programming-in-c-second-
edition-enrico-buonanno/
https://ebookmeta.com/product/your-mathematics-standards-
companion-high-school-what-they-mean-and-how-to-teach-them-1st-
edition-frederick-l-dillon/
The Impact Challenge: Reframing Sustainability for
Businesses 1st Edition Alessia Falsarone
https://ebookmeta.com/product/the-impact-challenge-reframing-
sustainability-for-businesses-1st-edition-alessia-falsarone/
https://ebookmeta.com/product/savannah-mafia-1-cruel-prince-1st-
edition-m-a-lee/
https://ebookmeta.com/product/democracy-the-god-that-failed-the-
economics-and-politics-of-monarchy-democracy-and-natural-
order-1st-edition-hans-hermann-hoppe/
https://ebookmeta.com/product/machine-learning-in-2d-materials-
science-1st-edition-parvathi-chundi/
https://ebookmeta.com/product/looking-for-the-good-1st-edition-
neal-j-vanderwaal/
Seafood Mood: Enjoyable and Easy Seafood Recipes (2nd
Edition) Booksumo Press
https://ebookmeta.com/product/seafood-mood-enjoyable-and-easy-
seafood-recipes-2nd-edition-booksumo-press/
Functional Programming in
Marco Vermeulen
Rúnar Bjarnason
Paul Chiusano
Foreword by Raul Raja
MANNING
Functional Programming in Kotlin
Functional
Programming
in Kotlin
MARCO VERMEULEN
RÚNAR BJARNASON
PAUL CHIUSANO
FOREWORD BY RAUL RAJA
MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: orders@manning.com
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning Publications
was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.
The author and publisher have made every effort to ensure that the information in this book
was correct at press time. The author and publisher do not assume and hereby disclaim any
liability to any party for any loss, damage, or disruption caused by errors or omissions, whether
such errors or omissions result from negligence, accident, or any other cause, or from an usage
of the information herein.
ISBN: 9781617297168
Printed in the United States of America
contents
foreword xiii
preface xv
acknowledgments xvii
about this book xix
v
vi CONTENTS
Option 71
4.4 Encoding success and failure conditions with Either 72
For-comprehensions with Either 74
8 Property-based testing
8.1
150
A brief tour of property-based testing 151
8.2 Choosing data types and functions 153
Gathering initial snippets for a possible API 153 Exploring the
■
9 Parser combinators
9.1 Designing an algebra
177
179
A parser to recognize single characters 179 A parser to recognize
■
backtracking 198
9.6 Implementing the algebra 200
Building up the algebra implementation gradually 201
Sequencing parsers after each other 202 Capturing error
■
10 Monoids
10.1
211
What is a monoid? 212
10.2 Folding lists with monoids 217
10.3 Associativity and parallelism 218
10.4 Example: Parallel parsing 221
10.5 Foldable data structures 223
10.6 Composing monoids 227
Assembling more complex monoids 227 ■
Using composed monoids
to fuse traversals 229
interpreters 316
13.5 Non-blocking and asynchronous I/O 319
13.6 A general-purpose IO type 321
The main program at the end of the universe 321
13.7 Why the IO type is insufficient for streaming I/O 322
CONTENTS xi
The mutable array represented as a data type for the ST monad 336
A purely functional in-place quicksort 338
14.3 Purity is contextual 340
Definition by example 340 ■
What counts as a side effect? 341
xiii
xiv FOREWORD
From common scenarios like error handling to more complex cases like streaming,
Functional Programming in Kotlin complements the functional programmer’s learning
journey and provides a foundational approach to learning core functional abstractions
and patterns.
RAUL RAJA
Arrow maintainer
CTO 47 Degrees
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of Remarks on
the Uses of some of the Bazaar Medicines and
Common Medical Plants of India
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
BAZAAR MEDICINES
AND
BY
EDWARD JOHN WARING, C.I.E., M.D.
FELLOW OF THE ROYAL COLLEGE OF PHYSICIANS OF LONDON
SURGEON-MAJOR (RETIRED) HER MAJESTY'S INDIAN ARMY
EDITOR OF THE PHARMACOPŒIA OF INDIA, ETC.
FIFTH EDITION
LONDON
J. & A. C H U R C H I L L
7 GREAT MARLBOROUGH STREET
1897
PREFACE TO THE FIFTH EDITION.
Owing to the favour in which this work is still being held by the public
in India, as proved by the entire sale of the Fourth Edition, I have
taken upon myself to issue this, the Fifth Edition, with the generous
assistance of my late father's friend, J. E. T. Aitchison, M.D., C.I.E.,
to whom I owe a great debt of gratitude for the time and trouble
and valuable special knowledge he has so liberally bestowed on the
work.
The only important changes that occur in this Edition are the
introduction of a couple of diagrams of a clinical thermometer, with a
few notes to guide the non-professional in its use; some alterations
in the text, where subjects that had been issued in the Fourth
Edition as notes to the text are now incorporated in the text itself;
and lastly, Dr. Aitchison has more fully entered upon his treatment of
small-pox with carbolised oil.
C. WARING.
PREFACE TO THE FOURTH EDITION.
That this little work should have reached a Fourth Edition may be
taken as pretty clear indication that it has met a recognised want
amongst our Indian fellow-subjects, for whose instruction and
guidance it was originally issued. To render it worthy of continued
favour, and to make it additionally useful, has been my anxious
endeavour.
Of any merit which this edition may be found to possess over the
preceding one, a very large portion is due to Dr. J. E. T. Aitchison,
C.I.E., Surgeon-Major in H.M. Indian (Bengal) Medical Service, who,
with a liberality that demands my warmest thanks, placed at my
disposal an elaborate MS. commentary on the Third Edition,
embodying his own professional experience in India (extending over
many years), and supplying the vernacular names of the various
drugs in the Punjábí, Kashmírí, and Leh languages. Of this document
it need hardly be said I have availed myself largely, my only regret
being that I could not insert it in extenso, but to have done this
would greatly have exceeded the prescribed limits of the work. As it
is, Dr. Aitchison has laid me under a vast obligation, which I am only
too happy to have this opportunity of acknowledging.
Five new articles have been added to the List of Drugs: two at the
suggestion of Dr. Aitchison; namely, (1) Sugar, and (2) Kerosene Oil,
which latter, owing to its extensive use for lighting purposes during
the past few years, is now obtainable in nearly every bazaar in the
country; the other three being the (3) Cinchona Febrifuge
(Quinetum), (4) Petroleum, and (5) Rock Salt. The various ways in
which these articles may be utilised in the treatment of disease will
be found under their respective headings in the "Addenda," p. 171,
et seq.
In addition to these there have been introduced notices of Indian
Hemp (Gunjah) smoking in the treatment of Tetanus, of the
antiscorbutic properties of Ámchur (dried Mangoes), the lactifuge
powers of Sambac flowers (Jasminum Sambac), the emmenagogue
virtues of Til or Jinjili Seeds (Sesamum Indicum), and other points
unnoticed in previous editions. The therapeutic applications of Water
are enlarged upon; as also are those of Carbolic Acid, especially in
the treatment of Leprosy. The Sick Dietary has likewise been
extended. Amongst the new matter has been introduced a section
(pp. 268-272) detailing the "Precautions to be taken by persons
residing in snake-infested localities."
By these and other additions (occupying upwards of thirty pages
of new matter), and by the revision and modification of other
passages, it is confidently hoped that the practical value of the work
will be found to be materially increased. Indeed, it has been my
earnest endeavour throughout to render this little volume as useful
as possible, and if through its instrumentality suffering humanity be
in any degree benefited my highest aspiration will be attained.
E. J. WARING.
PREFACE TO THE SECOND EDITION.
Fourteen years have elapsed since this work, in an elementary form,
was first issued for the use of the District Vaccinators of Travancore,
whose sphere of action was far removed from regular medical aid. It
was originally published in English and Tamil on opposite pages;
subsequently it was reprinted in Tamil alone by the London
Missionary Society's Press at Nagercoil, for the use of the catechists
and others connected with that Mission. In 1868, a Malyalim
translation, by Dresser Ramswammy Rajoo, was issued by the
Travancore Government. From reports received from various
quarters, there is reason to believe that the work has enjoyed a wide
circulation amongst the people of Travancore and Tinnevelly, and
that it has exercised a considerable influence on the practice of the
native doctors of those districts.
Were I wise, I ought, perhaps, to rest satisfied with these results,
which far exceed what were originally contemplated; but recent
observation has convinced me that there are other classes scattered
through our great Indian possessions to whom a work of the kind
would prove most acceptable, by pointing out to them the agents—
either purchasable in the bazaars at an almost nominal price, or
procurable at the cost of collection, from the road-sides, waste
places, or gardens in the immediate neighbourhood of almost every
out-station—by means of which, with the exercise of ordinary
intelligence, they may often be enabled to relieve the sufferings of
those amongst whom their lot has been cast.
And at the head of these classes stand the Missionaries, whose
stations, for the most part, are too far removed from the busy
haunts of men to allow of their calling in regular medical aid in cases
of sickness, and who are consequently thrown, at such times, very
much on their own resources. Many of the missionaries have under
their charge large establishments of catechists, pupils, &c.; and it
cannot be otherwise than highly desirable that they should be put in
possession of any information regarding the available means of
relieving the sufferings, and treating the diseases, of those placed
under their care. This is not the place to enter into a disquisition on
missionary work, but I cannot refrain from expressing my firm
conviction that the more the principle of Medical Missions—making
Religion and Medicine go hand in hand—is carried out, the greater,
humanly speaking, will be the success of missionary efforts. How
many a door for the admission of Gospel truth, which would
otherwise be shut, would be opened, and that readily, to one who,
with "the glad tidings of great joy" in the one hand, would bring in
the other the means of relieving physical suffering and curing bodily
disease! The highest distinction that I would claim for this little work
is, that it may constitute, as far as India is concerned, a Missionaries'
Medical Vade Mecum.
Next on the rôle comes a large army of European and Anglo-
Indian officials, whether within the magic circle of "the Service" or
beyond its pale, who are attached to the Public Works, Forests,
Railway, Telegraph, or other Departments, or employed in Tea,
Coffee, or Cotton plantations, in commercial pursuits, &c., many of
them married men, with families and a large number of dependants,
the majority at distant "up-country stations," miles away from
medical aid; how important for persons under such circumstances to
possess a knowledge of the means lying (literally so in many
instances) at their very feet, by which pain and suffering may be
alleviated, and, perhaps, a valuable life saved.
Lastly, but by no means least, either in point of numbers or
importance, comes the daily increasing array of educated Natives,
who, as a class, readily avail themselves of every scrap of knowledge
drawn from trustworthy European sources, which tends to throw
light on the products and resources of their native land. Whilst, on
the one hand, I am perfectly prepared to admit that much of the
knowledge I possess of the properties and uses of Indian drugs has
been derived from Native sources, I think I may, on the other hand,
without presumption, claim the credit of repaying the debt with
interest, furnishing in return a considerable amount of information
on the uses of even the same drugs, of which the Natives
themselves had previously no idea. It is to this class that I venture
to think this little work will prove most useful and acceptable.
In addition to the above, I venture to hope that to even duly
qualified Medical Officers, especially at up-country stations, a work
like the present may prove serviceable on emergencies, e.g., a
failure of the supply of European drugs, &c., by showing them what
resources they have at command in the bazaars or in their
immediate neighbourhood, by means of which many a gap may be
stopped till more efficient remedies are available.
In undertaking a Second Edition of this work, I have been further
influenced by a desire to render its scope and contents more
complete. With more extended knowledge on my part, drawn partly
from subsequent personal experience in the use of Indian drugs, and
partly from the Reports received from Medical Officers during the
preparation of the Pharmacopœia of India, I realised how imperfect
the original work was; and feeling myself in a position to add much
information which would tend to increase its usefulness, I
determined upon issuing another edition. The whole work has
accordingly been rewritten and greatly enlarged.
It was evidently quite out of the question, in a small work like the
present, to include the host of medicines included under the general
headings of "Bazaar Medicines" and "Common Medical Plants of
India," but from them I have made a selection of about 80,
comprising—1 Antacid, 8 Astringents, 3 Antispasmodics, 2
Antiscorbutics, 6 Antiperiodics, 5 Demulcents and Emollients, 4
Diaphoretics or Sudorifics, 4 Diuretics, 3 Expectorants, 2
Emmenagogues, 4 Emetics, 6 Purgatives, 3 Narcotics or Sedatives, 5
Refrigerants, 9 Stomachics or Carminatives, 7 Bitter Tonics, 5
Alterative Tonics or Alteratives, 2 Metallic Tonics, 7 Local and 4
General Stimulants, 2 Vesicants, or Blistering Agents, 6 Vermifuges,
and 17 Miscellaneous Articles, not included in the above classes.
In making this selection I have been guided by the following
principles:—1. By the safety of the drug; hence Arsenic, Aconite Root
(Bish), Nux Vomica, Indian Hemp, and some other powerful
medicines have been omitted, as it was felt to be inadvisable, in a
work like the present, to introduce agents which, in the hands of
unprofessional persons, might do more harm than good if employed
in unsuitable cases. Where, however, a powerful drug, e.g., Opium,
has been admitted, minute directions as to its employment have
been given. 2. By the acknowledged utility or efficacy of the drug as
proved by European experience. 3. By the drug possessing a
generally well-known, recognised native name. 4. By its wide
distribution and easy procurability in all parts, and in all the bazaars
of India generally. It is hoped that by the addition of the native
names and descriptions of the drugs (which were omitted in the First
Edition), even a new-comer will have little difficulty in obtaining and
recognising any particular article he may require.
With this native "Apparatus Medicaminum" very much may be
accomplished under ordinary circumstances, in the way of relieving
suffering and curing disease; but it must be admitted that there are
certain articles included under the class "European Medicines" for
which the Indian bazaars supply no adequate substitutes. I have
therefore (in Appendix E) added a list of nine drugs which it appears
desirable should be kept in store. They are—1. Sulphate of Quinine;
2. Ipecacuanha; 3. Smyrna or Turkey Opium; 4. Calomel; 5. Acetate
of Lead; 6. Santonin; 7. Liquor Ammoniæ; 8. Blistering Fluid; and 9.
Carbolic Acid.[1] No attempt has been made in the body of the work
to enter into a description of the properties and uses of these drugs
generally (with the exception of Opium), but in the Synopsis or
Index of Diseases (Part II.) it has been pointed out how these
valuable agents may be utilised in the most efficient manner. It is
believed that, by adopting this course, the practical utility of the
work will be greatly enhanced.
Attention is particularly directed to the Synopsis or Index of
Diseases in Part II.; it is not pretended that the modes of treatment
therein detailed are the best which could be adopted; the object has
rather been to show how much good may be effected by the simple
means at command at almost every "upcountry station" throughout
India; and those who follow the directions may feel assured, that
with the exercise of ordinary prudence, if they fail to do good they
will at any rate do no harm.
London, 1874.
♏︎ = 1 minim
fƷj one fluid-drachm = 60 minims.
f℥j one fluid-ounce = 8 fluid-drachms.
O one pint = 20 fluid-ounces.
21. Alum.
Phitkarí (Hind.), Phitkarí (Beng.), Fatkarí (Punj.), Fatkar, Phatkar
(Kash.), Pati-káram (Tam., Tel.), Chinik-káram (Mal.), Pati-kárá
(Can.), Patikár, Turatí (Mah.), Sina-karam (Cing.), Keo-khin
(Burm.), Twas (Malay).
22. Alum of good quality is generally procurable in all bazaars. It
should be in colourless, transparent, crystalline masses, or pieces of
various sizes, with an acid, sweetish, astringent taste. When mixed
with impurities, as it often is, it may be rendered fit for medicinal
purposes by dissolving it in boiling water, straining the solution, and
evaporating it so as to obtain crystals, which should be preserved for
use. Alum, whether applied externally or given internally, is a
valuable astringent. Dose, from 10 to 20 grains for adults.
23. In that form of Ophthalmia commonly known in India by the
name of Country Sore Eyes, especially when it attacks children, a
solution of Alum is often of great service. For children the strength
of three grains to an ounce of water is sufficient; but for adults, a
solution of double this strength may be used: the eyes should be
freely washed with it four or five times a day, or a cloth wet with it
may be kept constantly applied. If the eyelids are much swollen,
especially in the morning, they should be well bathed with warm
milk, the eyelids should then be carefully separated, and the Alum
lotion dropped in. There is a native plan of treatment of these cases
which proves in many instances effectual, but it has the
disadvantage of being very painful for a short time. It is as follows:
Place some finely powdered alum on a heated plate of iron, and
whilst it is in a state of fusion add a small portion of lemon or lime-
juice, until it forms a black, soft mass. This, whilst hot, is applied
entirely round the orbit, care being taken that none of it gets
beneath the eyelids, as it causes under such circumstances intense
agony. One or two applications, each being allowed to remain on for
twelve hours, suffice ordinarily to effect a cure.
24. After severe Blows on the Eye, when the pain and heat have
subsided, and much discoloration and swelling remain, an Alum
poultice is an effectual application. It is made by rubbing up 30
grains of powdered alum with the white of an egg till it forms a
coagulum. This placed between two pieces of thin rag or muslin,
should be kept applied to the eye for some hours.
25. In Hæmorrhage from the Lungs, Stomach, Kidneys, Uterus,
and other Internal Organs, Alum, in doses of 10 to 12 grains, thrice
daily, with or without opium, may often be given with advantage. It
is, however, inadmissible if much fever is present, and should at
once be discontinued if after the first few doses the symptoms are at
all aggravated. The following, called Alum Whey, is a good form of
administration: Boil for ten minutes two drachms of powdered Alum
in a pint of milk, and strain; of this, the dose is one and a half to two
ounces thrice daily. This may also be given with the view of checking
Excessive Menstrual Discharges (Menorrhagia) and Bleeding from
Piles. In this last case, clothes saturated with a solution of Alum in
decoction of Galls (145) or Babúl bark (9), in the proportion of two
drachms to eight ounces, should be kept constantly applied
externally. This application also proves useful in Prolapsus (descent)
of the Anus, especially in children. In Profuse Bleeding from the
Nose injections of a solution of Alum (20 grains to one ounce of
water) into the nostril is sometimes effectual; care, however, is
required in its use. Powdered Alum, or a very strong saturated
solution, applied locally on a compress, occasionally suffices to arrest
Bleeding from Leech-bites, Cuts, &c.
26. In the Chronic Diarrhœa of Natives, the following mixture has
been found useful: Take of Alum ten grains, infusion of Acorus root
(12), one and a half ounce, Laudanum, five drops; repeat three or
four times daily. In the Diarrhœa which precedes Cholera, and in the
early stages of Cholera, the following powders are worthy of a trial.
Take Alum, Catechu, and Cinnamon, of each, powdered, ten grains,
mix with honey, and give at a dose. It may be repeated every one or
two hours, according to circumstances. It proves useful also in
controlling the Diarrhœa of Phthisis.
27. As a palliative in Diabetes, "Alum Whey," prepared as directed
in paragraph 25, may be tried; under its use the quantity of urine
voided is, in some instances, diminished. In Albuminuria, also, it has
been useful in some instances in reducing the proportion of albumen
in the urine.
28. In Hooping Cough, when the first or acute stage has passed,
no remedy is more generally efficacious than Alum, in doses of three
or four grains, every four or six hours for a child from two to three
years old. It may be given in the form of powder or in solution (Alum
25 grains, Omum Water three ounces) in doses of a dessert-spoonful
every four or six hours for a child from two to four years old.
29. For Relaxed or Ulcerated Sore Throat, for Ulceration and
Sponginess of the Gums, in Salivation, and in Fissures of the Tongue
in Consumption, a very useful gargle or mouth wash is made by
dissolving two drachms of Alum in a pint of the decoction of Galls
(145) or Babúl Bark (9), and sweetening with honey. For the small
white Ulcers (Aphthæ, or Thrush) in the mouths of infants and
young children, a better application is 20 grains of finely powdered
Alum, incorporated with one ounce of honey. This may be applied
twice daily, with the tip of the finger. In the severer Ulcerative forms
of the disease (Ulcerative Stomatitis) Alum in fine powder, or in
strong solution, proves a more effectual application.
30. There is a disease often confounded with Gonorrhœa, where
the discharge does not come, as it does in true gonorrhœa, from the
urethra, but from a sore or excoriated surface between the prepuce
and the head of the penis. For this there is no better application
than a solution of Alum, 20 grains in one ounce of water. It may be
used twice or thrice daily. The strictest cleanliness should be
enforced at the same time. In Gleet, a solution of Alum (three
grains), in water (one ounce), used as an injection twice daily, is
often productive of benefit. In Leucorrhœa and other Vaginal
Discharges, injections of Alum in decoction of Galls or Babúl bark, as
advised in the last paragraph, often prove very useful.
31. In old Chronic spreading and gangrenous Ulcers so common
amongst natives, the following forms an excellent application: Finely
powdered Alum, four drachms; finely powdered Catechu, one
drachm; Opium, half a drachm; Ceromel (167), or Kokum butter, or
Ghee, one ounce. First, rub down the opium with the ceromel till
thoroughly mixed, and then incorporate the other ingredients. A
portion of this, spread on soft rag, should be applied to the ulcer
night and morning. If it occasion much pain, the proportion of
ceromel should be increased. For Bed-Sores or where these are likely
to occur, Dr. Aitchison describes as an excellent remedy—a mixture
of 30 grains of burnt alum and the white of an egg. It should be well
painted over the part.
32. For Enlargement of the Joints, especially that of the Knee, and
for other Swellings resulting from Blows, Bruises, or Sprains, the
following lotion has been found useful; Alum, four drachms, Vinegar
and Arrack, of each a pint; dissolve, and keep cloths wet with this
lotion constantly to the affected part. In Scorpion Bites, Alum
moistened with water and locally applied often affords instantaneous
relief (Dr. Saunders).
33. Asafœtida.
Hing (Hind., Duk., Beng., Pung., Mah., Guz.), Yang (Kash.),
Káyam, Perun-gáyam (Tam.), Inguva (Tel.), Perun-gáyam,
Káyam (Mal.), Perun-káyam (Cing.), Shinkhu or Shingu (Burm.),
Hingu (Malay).
34. Asafœtida of good quality may be obtained in most bazaars.
The moister and most strongly smelling kinds should be chosen for
medical purposes. It may be given in the form of pill, in doses of
from five to ten grains; or in that of mixture, prepared by rubbing
down in a mortar five drachms of Asafœtida in a pint of hot water,
and straining and setting aside to cool. Of this solution, which is
thick and milky, the dose is from one to two table-spoonfuls. Its
nauseous taste is a great objection to its use.
35. In Hysterical Fits and in Fainting, Nervous Palpitations, and
other affections connected with Hysteria, Asafœtida proves most
useful. When the symptoms are urgent, as in fits, &c., it is best
given in the liquid form (ante), but where the object is rather to
combat the tendency to this state, and to make an impression on
the system, the solid form should be preferred. For this purpose it
may be advantageously combined with Aloes, as advised in Sect. 19.
36. In Flatulence, Flatulent Colic, and Spasmodic Affections of the
Bowels, especially when connected with hysteria, it is best given in