Skip to content

Commit 77332d4

Browse files
committed
Use consistent spacing in examples
1 parent 0d7f029 commit 77332d4

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,59 +184,59 @@ see the implementation of set `intersection` in this library.
184184
`head` returns the first element of the array:
185185

186186
```fortran
187-
print *, head([1,2,3])
187+
print *, head([1, 2, 3])
188188
1
189189
```
190190

191191
`tail` returns everything but the first element of the array:
192192

193193
```fortran
194-
print *, tail([1,2,3])
194+
print *, tail([1, 2, 3])
195195
2 3
196196
```
197197

198198
Similarly, `last` returns the last element of the array:
199199

200200
```fortran
201-
print *, last([1,2,3])
201+
print *, last([1, 2, 3])
202202
3
203203
```
204204

205205
`init` returns everything but the last element of the array:
206206

207207
```fortran
208-
print *, init([1,2,3])
208+
print *, init([1, 2, 3])
209209
1 2
210210
```
211211

212212
Subscript an array at specific indices:
213213

214214
```fortran
215-
print *, subscript([1,2,3,4,5], [3,4])
215+
print *, subscript([1, 2, 3, 4, 5], [3, 4])
216216
3 4
217217
```
218218

219219
Unlike the Fortran 2008 vector subscript, the `subscript` function is out-of-bounds safe,
220220
i.e. subscripting out of bounds returns an empty array:
221221

222222
```fortran
223-
print *, subscript([1,2,3], [10])
223+
print *, subscript([1, 2, 3], [10])
224224
225225
```
226226

227227
We can prepend, append, or insert an element into an array using `insert`:
228228

229229
```fortran
230230
! insert a 5 at position 0 to prepend:
231-
print *, insert(5, 0, [1,2,3])
231+
print *, insert(5, 0, [1, 2, 3])
232232
5 1 2 3
233233
234234
! insert a 5 at position 4 to append:
235-
print *, insert(5, 4, [1,2,3])
235+
print *, insert(5, 4, [1, 2, 3])
236236
1 2 3 5
237237
238238
! insert a 2 at position 2:
239-
print *, insert(2, 2, [1,3,4])
239+
print *, insert(2, 2, [1, 3, 4])
240240
1 2 3 4
241241
```
242242

@@ -307,7 +307,7 @@ pure recursive integer function fibonacci(n) result(fib)
307307
end if
308308
end function fibonacci
309309
310-
print *, map(fibonacci, [17,5,13,22])
310+
print *, map(fibonacci, [17, 5, 13, 22])
311311
1597 5 233 17711
312312
```
313313

@@ -321,13 +321,13 @@ pure logical function even(x)
321321
even = mod(x, 2) == 0
322322
endfunction even
323323
324-
print *, filter(even,[1,2,3,4,5])
324+
print *, filter(even, [1, 2, 3, 4, 5])
325325
2 4
326326
```
327327
Functions can be chained together into pretty one-liners:
328328

329329
```fortran
330-
print *, filter(even,map(fibonacci,arange(1,10)))
330+
print *, filter(even, map(fibonacci, arange(1, 10)))
331331
2 8 34
332332
```
333333

@@ -354,11 +354,11 @@ input using the above-defined functions and a start value
354354

355355
```fortran
356356
! left-fold an array using add to compute array sum
357-
print *, foldl(add,0.,arange(1.,5.))
357+
print *, foldl(add, 0., arange(1., 5.))
358358
15.0000000
359359
360360
! left-fold an array using mult to compute array product
361-
print *, foldl(mult,1.,arange(1.,5.))
361+
print *, foldl(mult, 1., arange(1., 5.))
362362
120.000000
363363
```
364364
The above is a trivial example that re-invents Fortran intrinsics
@@ -381,7 +381,7 @@ pure real function multpt1(x)
381381
multpt1 = 1.1 * x
382382
endfunction multpt1
383383
384-
write(*,*) unfold(multpt1,[1.],5)
384+
write(*,*) unfold(multpt1, [1.], 5)
385385
1.00000000 1.10000002 1.21000004 1.33100009 1.46410012
386386
```
387387

@@ -390,23 +390,23 @@ write(*,*) unfold(multpt1,[1.],5)
390390
Function `set` returns all unique elements of an input array:
391391

392392
```fortran
393-
print *, set([1,1,2,2,3])
393+
print *, set([1, 1, 2, 2, 3])
394394
1 2 3
395395
```
396396
Common functions that operate on sets, `union`,
397397
`intersection`, and `complement`, are also available:
398398

399399
```fortran
400400
! unique elements that are found in either array
401-
print *, union([1,2,2],[2,3,3,4])
401+
print *, union([1, 2, 2], [2, 3, 3, 4])
402402
1 2 3 4
403403
404404
! unique elements that are found in both arrays
405-
print *, intersection([1,2,2],[2,3,3,4])
405+
print *, intersection([1, 2, 2], [2, 3, 3, 4])
406406
2
407407
408408
! unique elements that are found first but not in second array
409-
print *, complement([1,2,2],[2,3,3,4])
409+
print *, complement([1, 2, 2], [2, 3, 3, 4])
410410
1
411411
```
412412

0 commit comments

Comments
 (0)