I will illustrate Julia:
Suppose I have a function counter (), which is a closure.
function mycl()
state=0
function counter()
state=state+1
end
end
Now suppose I create mycoutner function:
mycounter=mycl()
and now display this function in an array of length 10, with all elements equal to 1.
map(x->x+mycounter(),ones(1:10))
The output is as follows:
julia> map(x->x+mycounter(),ones(1:10))
10-element Array{Int64,1}:
2
3
4
5
6
7
8
9
10
11
It seems that the function is applied sequentially over the displayed array.
In the end, I try to avoid cycles, but with a local state variable of the state of mutation of the circuit, I need it to be applied sequentially. It seems so, is it an accepted standard? (did not test the equivalent version of R using * apply). And is it really “functional” because the local state variable mutates?