Julia - Bit by Bit: Programming For Beginners (Undergraduate Topics in Computer Science) Noel Kalicharan PDF Download
Julia - Bit by Bit: Programming For Beginners (Undergraduate Topics in Computer Science) Noel Kalicharan PDF Download
https://ebookmeta.com/product/julia-bit-by-bit-programming-for-
beginners-undergraduate-topics-in-computer-science-noel-
kalicharan/
https://ebookmeta.com/product/doing-her-bit-erin-hagar/
https://ebookmeta.com/product/mathematics-for-computer-graphics-
undergraduate-topics-in-computer-science-6th-edition-2022-john-
vince/
https://ebookmeta.com/product/micro-bit-iot-in-c-2nd-edition-
harry-fairhead/
https://ebookmeta.com/product/algorithms-in-bioinformatics-
theory-and-implementation-1st-edition-gagniuc-paul-a/
Philosophical Foundations of Neuroscience Second
Edition M R Bennett P M S Hacker
https://ebookmeta.com/product/philosophical-foundations-of-
neuroscience-second-edition-m-r-bennett-p-m-s-hacker/
https://ebookmeta.com/product/higher-education-and-china-s-
global-rise-a-neo-tributary-perspective-1st-edition-su-yan-pan/
https://ebookmeta.com/product/digital-logic-design-using-verilog-
coding-and-rtl-synthesis-2nd-edition-taraate/
https://ebookmeta.com/product/envy-the-love-is-cure-vol-1-vices-
virtues-4-1st-edition-brookelyn-mosley/
https://ebookmeta.com/product/public-higher-education-in-
california-neil-j-smelser-editor/
Human Microbiome in Health Disease and Therapy 1st
Edition Pallaval Veera Bramhachari
https://ebookmeta.com/product/human-microbiome-in-health-disease-
and-therapy-1st-edition-pallaval-veera-bramhachari/
Undergraduate Topics in Computer Science
Noel Kalicharan
Julia –
Bit by Bit
Programming for Beginners
Undergraduate Topics in Computer
Science
Series Editor
Ian Mackie, University of Sussex, Brighton, UK
Advisory Editors
Samson Abramsky , Department of Computer Science, University of Oxford,
Oxford, UK
Chris Hankin , Department of Computing, Imperial College London, London, UK
Mike Hinchey , Lero – The Irish Software Research Centre, University of
Limerick, Limerick, Ireland
Dexter C. Kozen, Department of Computer Science, Cornell University, Ithaca,
NY, USA
Andrew Pitts , Department of Computer Science and Technology, University of
Cambridge, Cambridge, UK
Hanne Riis Nielson , Department of Applied Mathematics and Computer Science,
Technical University of Denmark, Kongens Lyngby, Denmark
Steven S. Skiena, Department of Computer Science, Stony Brook University, Stony
Brook, NY, USA
Iain Stewart , Department of Computer Science, Durham University, Durham, UK
‘Undergraduate Topics in Computer Science’ (UTiCS) delivers high-quality
instructional content for undergraduates studying in all areas of computing and
information science. From core foundational and theoretical material to final-year
topics and applications, UTiCS books take a fresh, concise, and modern approach
and are ideal for self-study or for a one- or two-semester course. The texts are all
authored by established experts in their fields, reviewed by an international advisory
board, and contain numerous examples and problems, many of which include fully
worked solutions.
The UTiCS concept relies on high-quality, concise books in softback format, and
generally a maximum of 275–300 pages. For undergraduate textbooks that are likely
to be longer, more expository, Springer continues to offer the highly regarded Texts
in Computer Science series, to which we refer potential authors.
123
Noel Kalicharan
Department of Computing and IT
University of the West Indies
St. Augustine, Trinidad and Tobago
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2021
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter
developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply,
even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations
and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to
be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty,
expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been
made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Dedication
James & Clara
Claudette & Samuel
Jeff & Jenny
Margaret & Stephen
Kenrick & Debbie
Jennifer & Andrew
Anushka & Michael
Saskia & Vaishnavi
Special Thanks
Hubert Dupont
Shellyann Sooklal
Julia—Bit by Bit attempts to teach computer programming to the complete beginner using
Julia—a relatively new programming language. Created in 2009 by Jeff Bezanson, Stefan
Karpinski, Viral B. Shah and Alan Edelman, Julia was launched in 2012. Their goal? "To create
a free language that was both high-level and fast." Since its launch, Julia has undergone several
version changes. As of November 9, 2020, it had matured to Version 1.5.3.
The book assumes you have no knowledge whatsoever about programming. And if you are
worried that you are not good at high-school mathematics, don’t be. It is a myth that you must
be good at mathematics to learn programming. In this book, a knowledge of primary school
mathematics is all that is required—basic addition, subtraction, multiplication, division, finding
the percentage of some quantity, finding an average or the larger of two quantities.
Some of our most outstanding students over the last forty years have been people with little
mathematics background from all walks of life—politicians, civil servants, sports people,
housewives, secretaries, clerical assistants, artists, musicians and teachers. On the other hand,
we’ve had professionals like engineers and scientists who didn’t do as well as might be
expected. So it's not about how "qualified" you are.
What will be an asset is the ability to think logically or to follow a logical argument. If you are
good at presenting convincing arguments, you will probably be a good programmer. Even if
you aren’t, programming is the perfect vehicle for learning logical thinking skills. You should
learn it for these skills even if you never intend to become a serious programmer.
The main goal of this book is to teach fundamental programming principles using Julia, one of
the fastest growing programming languages in the world today. Julia can be classified as a
"modern" language, possessing many features not available in more popular languages like C
and Java.
Best of all, Julia is easy to learn. In fact, I would go so far as to say that, of all the many
languages I have learnt and taught over the last forty years, Julia is the easiest to learn. This is
particularly important for someone learning programming for the first time. You can concentrate
on acquiring problem-solving skills without being overwhelmed by the language. I've known
many students who got turned off learning programming because they found the basics of the
language too difficult to grasp.
Julia strips away the "fluff" of most languages, the "overhead" you need to write even the
simplest programs. It's not fussy about things like semi-colons or having to "declare" the type
of every variable you need to use. You just use it the way you want—Julia will figure out the
type for you. But if you really want Julia to enforce "typing", it can do that as well.
Nevertheless, this book is as much about teaching basic problem-solving principles as it is about
teaching Julia. Remember, a language is useless if you can't use it to solve a problem. But once
you learn the principles well, they can be applied to any language.
Chapter 1 gives an overview of the programming process. It shows you how to write your first
Julia program and introduces some of the basic building blocks needed to write programs.
Chapter 2 is all about numbers—integers, floating-point, operators, expressions—how to work
with them and how to print them. It also explains how to write programs that use sequence
logic—statements are executed one after the other, from first to last.
Chapter 3 shows how to write programs which can make decisions. It explains how to use if
and if…else statements.
vii
viii Preface
Chapter 4 explains the notion of ‘looping’ and how to use this powerful programming idea to
solve more interesting problems. Looping is implemented using for and while statements. We
also explain how to read data from a file and write results to a file.
Chapter 5 formally treats with functions. These enable a (large) program to be broken up into
smaller manageable units but which work together to solve a given problem.
Chapter 6 is devoted to Characters and Strings. These present some difficulty in other languages
but, in Julia, we can work with them as seamlessly as we do numbers.
Chapter 7 tackles the nemesis of many would-be programmers—array processing. However,
this is significantly easier in Julia than other languages. Master array processing and you would
add to your repertoire a tool that will significantly increase the range of problems you can solve.
Chapter 8 is mainly about sorting and searching techniques. Sorting puts data in an order that
can be searched more quickly/easily, and makes it more palatable for human consumption.
Chapter 9 introduces structures. These enable us to group data in a form that can be manipulated
more easily an a unit.
Chapter 10 deals with two useful data structures—dictionaries and sets. These enable us to solve
certain kinds of problems more easily and conveniently than we can without them.
The first step in becoming a good programmer is learning the syntax rules of the programming
language. This is the easy part and many people mistakenly believe that this makes them a
programmer. They get carried away by the cosmetics— they learn the features of a language
without learning how to use them to solve problems. Of course, you must learn some features.
But it is far better to learn a few features and be able to use them to solve many problems rather
than learn many features but can’t use them to solve anything. For this reason, this book
emphasizes solving many problems from just a few features.
This book is intended for anyone who is learning programming for the first time, regardless of
age or institution. The presentation is based on our experience that many people (though not all)
have difficulty learning programming. To try and overcome this, we use an approach which
provides clear examples, detailed explanations of very basic concepts and numerous interesting
problems (not just artificial exercises whose only purpose is to illustrate some language feature).
While computer programming is essentially a mental activity and you can learn a fair amount
of programming from just reading the book, it is important that you “get your hands dirty” by
writing and running programs. One of life’s thrills is to write your first program and get it to run
successfully on a computer. Don’t miss out on it.
But do not stop there. The only way to learn programming well is to write programs to solve
new problems. The end-of-chapter exercises are a very rich source of problems, a result of the
author’s more than 40 years in the teaching of programming.
Thank you for taking the time to read this book. I hope your venture into programming is a
successful and enjoyable one.
Noel Kalicharan
Contents
Index 286
CHAPTER 1
Elementary Concepts
But what is the nature of a program? First, we need to know that computers are built to execute
instructions written in what is called machine language. In machine language, everything is
expressed in terms of the binary number system—1s and 0s. Each computer has its own machine
language and the computer can execute instructions written in that language only.
The instructions themselves are very simple, for example, add or subtract two numbers, compare
one number with another or copy a number from one place to another. How, then, can the
computer perform such a wide variety of tasks, solving such a wide variety of problems, with
such simple instructions?
The answer is that no matter how complex an activity may seem, it can usually be broken down
into a series of simple steps. It is the ability to analyze a complex problem and express its
solution in terms of simple computer instructions that is one of the hallmarks of a good
programmer.
Machine language is considered a low-level programming language. In the early days of
computing (1940s and 50s) programmers had to write programs in machine language, that is,
express all their instructions using 1s and 0s.
To make life a little easier for them, assembly language was developed. This was closely related
to machine language but it allowed the programmer to use mnemonic instruction codes (such as
ADD and names for storage locations (such as sum) rather than strings of binary digits (bits). For
instance, a programmer could refer to a number by sum rather than have to remember that the
number was stored in memory location 1000011101101011.
A program called an assembler is used to convert an assembly language program into machine
language. Still, programming this way had several drawbacks:
It was very tedious and error prone.
It forced the programmer to think in terms of the machine rather than in terms of his
problem.
A program written in the machine language of one computer could not be run on a
computer with a different machine language. Changing your computer could mean
having to rewrite all your programs.
To overcome these problems, high-level or problem-oriented languages were developed in the
late 1950s and 60s. The most popular of these were FORTRAN (FORmula TRANslation) and
COBOL (COmmon Business-Oriented Language). FORTRAN was designed for solving
scientific and engineering problems which involved a great deal of numerical computation.
COBOL was designed to solve the data-processing problems of the business community.
The idea was to allow the programmer to think about a problem in terms familiar to him and
relevant to the problem rather than have to worry about the machine. So, for instance, if he
wanted to know the larger of two quantities, A and B, he could write
IF A IS GREATER THAN B THEN BIGGER = A ELSE BIGGER = B
rather than have to fiddle with several machine or assembly language instructions to get the
same result. Thus high-level languages enabled the programmer to concentrate on solving the
problem at hand, without the added burden of worrying about the idiosyncrasies of a particular
machine.
However, the computer still could execute instructions written in machine language only . A
program called a compiler is used to translate a program written in a high-level language to
machine language. (And, just so you know, there are different kinds of compilers.)
We speak of a FORTRAN compiler or a C compiler for translating FORTRAN and C programs,
respectively. But that’s not the whole story. Since each computer has its own machine language,
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Mastro da
Ballo
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: Italian
Alzata de piedi. 23
Balzetti inanzi. 52
Balzetti indietro. 53
Balzetti à Piedi pari [per] fi[an]co. 47
Balzetti à Piedi pari inanzi. 49
Balzetti à Piedi pari indietro. 50
Balzetti in Volta. 51
Battuta de Piedi. 24
Cadenza Battuta. 76
Cadenza finta. 76
Cadenza ordinaria. 70
Cadenza à Piedi pari in Prospettiua. 77
Cadenza Ritornata. 74
Cadenza ritornata Strisciata. 75
Cad[en]za Spaccata. 72
Cadenza Strisciata. 73
Cadenza di Zoppetto. 71
Calcagnio di Piede ordinario. 83
Calcagnio di Piede Strisciato Caminato. 83
Cambiata de Piedi. 26
Cambiata de Piedi Strisciata. 27
Caminare, e Portar la Vita. 144
Caminata Strisciata in dietro. 65
Caminata Strisciata [per] fianco. 60
Caminata Strisciata inanzi. 64
Campanella ordinaria. 120
Campanella in Volta. 120
Campanella Strisciata in Volta. 120
Capriola Terza. 90
Capriola Quarta. 91
Capriola Quinta. 92
Capriola Sesta. 92
Capriola Terza c[on] un Piede in Aria. 92
Capriola Quarta c[on] un Piede in Aria. 93
Capriola Quinta c[on] un Piede in Aria. 94
Capriola Quarta sul Collo del Piede. 95
Capriola sul Collo del Piede, et Intrecciata. 96
Capriola Intrecciata, ò uero Incrociata. 97
Capriola Intrecciata in Volta. 98
Capriola Intrecciata Doppia. 98
Capriola Intrecciata di Cadenza. 98
Cauar del Cappello. 148
Continenza Graue. 142
Continenza Semigraue. 143
Continenza Breue. 143
Continenza Semibreue. 143
Corintho. 125
Dama, modo che deue tenere à Inuitare il Cau.ro
à Ballare;
Come deuono far la Reuer[en]za, e come si
deuono lic[en]ziare doppo il Ballo. 155
Dattilo. 123
Destice. 126
Doppio Breue. 138
Doppio Graue. 138
Doppio Semigraue. 139
Doppio Pontato. 139
Doppio Fr[an]zese. 139
Finta Inanzi. 63
Finta Strisciata Inanzi. 63
Finta Indietro. 63
Finta Strisciata Indietro. 64
Fioretto Ordinario. 126
Fioretto di Cadenza Ritornata. 126
Fioretto Battuto. 129
Fioretto Battuto Doppio. 130
Fioretto Fianchegiato. 128
Fioretto [per] Fianco. 128
Fioretto Graue. 127
Fioretto Strisciato. 130
Fioretto Tagliato. 129
Fioretto in Volta. 129
Ganzo in Prospettiua. 66
Ganzo Rouerso. 67
Ganzo in Volta. 66
Girata Battuta. 145
Girata de Ginocchio. 114
Girata Incrociata. 115
Groppo. 123
Incrociata di Gamba inanzi. 67
Incrociata di Punta Strisciata. 79
Incrociata di Gamba indietro. 57
Inuito della Dama. 153
Meza Capriola di Cadenza Ordinaria. 99
Meza Capriola di Cadenza Ritornata. 100
Meza Capriola sul Collo del Piede. 102
Meza Capriola [per] fianco. 100
Meza Capriola di fioretto. 100
Meza Capriola in dietro. 101
Meza Capriola di Passo in Aria. 99
Meza Capriola Recacciata in Prospettiua & in
Volta. 102
Meze Capriole Tagliate in Quinto. 103
Meza Reuerenza. 151
Passi in Aere. 41
Passo in Aere Cromatico. 42
Passi in Aere Strisciati. 43
Passo Costatetto. 40
Passi Cromatici. 31
Passi [per] fianco. 34
Passi finti Indietro. 35
Passi Finti Strisciati Indietro. 36
Passo Finto in[an]zi e dello Strisciato. 40
Passi Incrociati. 37
Passi Incrociati Strisciati. 38
Passi Indietro. 31
Passi in Volta. 32
Passi Longhi. 30
Passi Minimi. 30
Passi Naturali. 28
Passi à Piedi Pari. 60
Passo Puntato Breue. 140
Passo Puntato Graue. 140
Passo Puntato Minimo. 141
Passo Puntato Semibreue. 141
Passo Puntato Semigraue. 140
Passi Semigraui. 29
Passi Semiminimi. 30
Passi Strisciati Indietro. 33
Passi Strisciati Inuolta. 34
Passi Strisciati Inanzi. 38
Passo Trango. 39
Portar Cappa, e Spada in Balletti Graui. 145
Portar Cappa, e Spada, nella Gagliarda, et altri
Balletti Alterati. 146
Punta e Calcagnio Ordinario. 121
Punta, e Calcagnio di Zoppetto. 122
Punta, e Calcagnio Strisciata, e Battuta. 122
Punta, e Calcagnio Strisciata Caminata. 122
Punta dè Piedi Ordinaria in[an]zi, et indietro. 82
Punta dè Piedi Strisciata Caminata. 82
Recacciata [per] fianco. 117
Recacciata in Prospettiua. 116
Recacciata in Volta. 117
Represa [per] fianco. 118
Represa Inanzi. 117
Represa Indietro. 119
Represa Strisciata Inanzi [per] fi[an]co, e
Indietro. 119
Reuer[en]za Breue. 150
Reuerenza Caminata. 151
Reuerenza Graue alla Spagniuola. 149
Reuerenza Semibreue. 151
Reuerenza Semigraue. 150
Reuerenza Spezzata. 152
Salto tondo ordinario in Aria. 104
Salto Tondo due ò trè uolte in Aria. 105
Salto Tondo Incrociato. 105
Salto Tondo Rouerso. 107
Salto Tondo Spacchato. 106
Salto Tondo Spacchato Incrociato Recacciato. 107
Salto del fiocco. 108
Salto del fiocco Incrociato Scorso. 111
Salto del fiocco Tondo Incrociato. 110
Salto del fiocco Mezo Rouerso. 111
Salto del fiocco Rouerso. 112
Salto del fiocco Scorso. 109
Scrociata di Calcagnio Strisciata Ordinaria. 81
Scrociata di Punta Strisciata. 80
Schicciata di Calcagnio. 62
Schicciata di Punta. 60
Seguito Battuto. 133
Seguito Battuto Doppio. 133
Seguito Battuto Spezzato Strisciato. 137
Seguito Doppio. 132
Seguito finto. 131
Seguito franzese Alterato. 135
Seguito franzese Ordinario. 135
Seguito Ordinario. 131
Seguito Scorso. 134
Seguito Semidoppio. 131
Seguito Soffice. 138
Seguito Spezzato finto. 136
Seguito Spezzato Indietro. 137
Seguito Spezzato Ordinario. 136
Seguito Spezzato Puntato. 136
Seguito Spezzato Strisciato. 137
Seguito Trangato. 134
Seguito Trangato Doppio. 134
Sincopa. 124
Soprapiede Ordinario. 77
Soprapiede Strisciato. 78
Sottopiede. 43
Sottopiede [per] fianco. 44
Sottopiede à Piedi Pari [per] le Dame. 45
Sottopiede Strisciato. 44
Spacchata Doppia. 85
Spaccata [per] fianco. 85
Spaccata Inanzi. 83
Spaccata Incrociata Inanzi. 85
Spaccata Incrociata [per] fianco. 86
Spaccata Indietro. 84
Spaccata Indietro in Volta. 87
Spaccata Incrociata in Volta. 88
Spaccata in Prospettiua. 87
Spaccata in Prospettiua indietro. 90
Spaccata Ricacciata. 89
Spondeo. 124
Strisci [per] fianco. 53
Strisci in Volta. 54
Trabocchetto Breue. 45
Trabocchetto Minimo anco [per] le Dame. 46
Trabocchetto Semibreue. 46
Trabocchetto Strisciato. 47
Trillo Doppio. 70
Trillo Inanzi et Indietro. 69
Trillo de Piedi [per] fianco. 68
Trito Minuto. 124
Zoppetto di Calcagnio. 59
Zoppetto [per] fianco. 54
Zoppetto finto inanzi. 55
Zoppetto finto indietro, Tornato inanzi. 56
Zoppetto indietro. 56
Zoppetto Incrociato indietro. 57
Zoppetto Ordinario. 54
Zoppetto di Punta de Piedi. 58
Zoppetto Strisciato. 55
Zurlo Pirlato, ò Girata. 113
Per far il Passo Minimo farà quanto s'è detto nella prossima Regola
sud.a partendolo [per] metà, cioè nel tempo d'una battuta binaria, ò
ternaria perfetta, e spartirla in due meze battute, e si chiama cosi,
perche si fà nell tempo d'una Minima e lo potrà anco fare [per]
contrario.