some small improvements in English

This commit is contained in:
2026-02-22 19:18:21 +01:00
parent 3b9c141c44
commit 552438aebe
8 changed files with 83 additions and 99 deletions

View File

@@ -11,7 +11,7 @@ using InteractiveUtils
# First Contact
This chapter helps you get started. It omits many details and the code examples are often rather suboptimal.
This chapter helps you get started. It omits many details, and the code examples are often rather suboptimal.
## Julia as a Calculator
@@ -41,7 +41,7 @@ end
# IJulia.set_verbose(true)
```
Compute $\qquad 12^{1/3} + \frac{3\sqrt{2}}{\sin(0.5)-\cos(\frac{\pi}{4})\log(3)}+ e^5$
Compute: $\qquad 12^{1/3} + \frac{3\sqrt{2}}{\sin(0.5)-\cos(\frac{\pi}{4})\log(3)}+ e^5$
```{julia}
12^(1/3) + 3sqrt(2) / (sin(.5) - cos(pi/4)*log(3)) + exp(5)
@@ -50,14 +50,14 @@ Compute $\qquad 12^{1/3} + \frac{3\sqrt{2}}{\sin(0.5)-\cos(\frac{\pi}{4})\log(3)
Note that:
- Powers are written as `a^b`.
- The constant `pi` is predefined.
- The constant `π` is predefined.
- `log()` is the natural logarithm.
- The multiplication sign `a*b` can be omitted after a number if followed by a variable, function, or parenthesis.
- The multiplication sign `a*b` can be omitted after a number if it is followed by a variable, function, or parenthesis.
## The most important keys: `Tab` and `?` {#sec-tab}
When programming, repeatedly press the Tab key as soon as 2...3 letters of a word have been typed. Potential completions are then displayed or completed if the completion is unique. This saves time and is extremely helpful:
When programming, repeatedly press the Tab key as soon as 23 letters of a word have been typed. Potential completions are then displayed or completed if the completion is unique. This saves time and is extremely helpful.
```{julia}
lo = "lo" #| hide_line
@@ -69,7 +69,7 @@ pri = "pri" #| hide_line
pri ▷ Tab
```
The built-in Julia help `?name` for all functions and constructs is very comprehensive. Here is a rather short example:
The built-in Julia help `?name` for all functions and constructs is very comprehensive. Here is a rather brief example:
```{julia}
?for
@@ -105,17 +105,17 @@ julia> for i in [1, 4, 0]
## Variables and Assignments
Variables are created through assignment with the assignment operator `=` . Afterward, they can be used in further statements.
Variables are created through assignment with the assignment operator `=`. Afterwards, they can be used in further statements.
```{julia}
x = 1 + sqrt(5)
y = x / 2
```
In interactive mode, Julia displays the result of the last operation.
In interactive mode, Julia displays the result of the last statement.
:::{.callout-note .titlenormal}
Assignments are not mathematical equations. The semantics of the assignment operator (equals sign) is:
Assignments are not mathematical equations. The semantics of the assignment operator (the equals sign) is:
- Compute the right side and
- Assign the result to the left side.
@@ -142,11 +142,11 @@ for x ∈ (42, 12.0, 3.3e4, "Hello!", true)
println("x = ", x, " ..... Type: ", typeof(x))
end
```
The standard floating-point number has a length of 64 bits, which corresponds to a `double` in C/C++/Java.
The standard floating-point number has a size of 64 bits, which corresponds to a `double` in C/C++/Java.
Julia is a [dynamically typed](https://en.wikipedia.org/wiki/Dynamic_typing) language.
Variables have no type. They are typeless references (pointers) to objects.
When one speaks of the "type of a variable", one means the type of the object currently assigned to the variable.
Variables have no type; they are typeless references (pointers) to objects.
When people speak of the "type of a variable", they mean the type of the object currently assigned to the variable.
```{julia}
x = sqrt(2)
@@ -189,7 +189,7 @@ println("One dollar: 1\$ and three backslashes: \\\\\\ ")
:::
## Functions
Function definitions begin with the keyword `function` and end with the keyword `end`. Typically, they have one or more arguments and return a computed object with the `return` statement on calling.
Function definitions begin with the keyword `function` and end with the keyword `end`. Typically, they have one or more arguments and return a computed result via the `return` statement.
```{julia}
function hypotenuse(a, b) # particularly cumbersome today
c2 = a^2 + b^2
@@ -252,7 +252,7 @@ else
end
```
Indentation improves readability but is optional. Line breaks separate statements. This can also be done with semicolons. The above code block is identical to the following line for Julia:
Indentation improves readability but is optional. Line breaks separate statements, and this can also be done with semicolons. The above code block is identical to the following line in Julia:
```{julia}
# Please don't program like this! You will regret it!
x=sqrt(100); if x > 20 println("Strange!") else println("OK"); y = x + 3 end
@@ -263,7 +263,7 @@ It is strongly recommended to format your own code from the beginning with clear
## Simple `for` loops
for repeated execution of statements have the form
`for` loops for repeated execution of statements have the form
```default
for <counter> = start:end
<statement1>
@@ -299,7 +299,7 @@ v[1] = v[4] + 10
v
```
Empty vectors can be created and extended.
Empty vectors can be created and extended with `push!()`.
```{julia}
v = [] # empty vector
push!(v, 42)
@@ -310,7 +310,7 @@ v
:::{.callout-note icon="false" .titlenormal collapse="true" font-variant-ligatures="no-contextual" }
## Postscript: how the effect of the Tab key was simulated on this page...
## Postscript: how the effect of the Tab key was simulated on this page
```{julia}
using REPL