Filtering arrays with other value types| Matthias Noback
Introducing functional programming in Fortran with filtering integers| Matthias Noback
Higher-order functions and closures| Matthias Noback
We’ve implemented filter and map operations. The results of both these operations are new arrays. Yet another common operation on arrays is the so-called reduction operation; we “reduce” multiple values to a single value. The most obvious example is calculating the sum of an array of integers: the input is an array (or list) and the output is a single integer: purefunction sum_all(numbers) result(res) integer, dimension(:), intent(in) :: numbers integer:: res integer:: i res =0do i =1, ...| Software Development & Design on Matthias Noback
In the previous post we looked at this dream scenario: list([1, 3, 5, 7]) % filter(divisible_by(3)) % map(square) As mentioned, we can’t chain function calls like this. But we can put intermediate results in local variables and achieve something similar: integers = list([1, 3, 5, 7]) divisible_by_3 = integers%filter(divisible_by(3)) squared = divisible_by_3%map(square) If the intermediate values are all the same type, we can reuse the variable: integers = list([1, 3, 5, 7]) integers = integ...| Software Development & Design on Matthias Noback
Transforming arrays| Matthias Noback