History variables: Difference between revisions
→{{header|Kotlin}}
(Add Factor example) |
|||
Line 1,098:
</pre>
=={{header|Julia}}==
<lang Julia>mutable struct Historied
num::Number
history::Vector{Number}
Historied(n) = new(n, Vector{Number}())
end
assign(y::Historied, z) = (push!(y.history, y.num); y.num = z; y)
x = Historied(1)
assign(x, 3)
assign(x, 5)
assign(x, 4)
println("Past history of variable x: $(x.history). Current value is $(x.num)")
</lang>{{output}}<pre>Past history of variable x: Number[1, 3, 5]. Current value is 4</pre>
=={{header|Kotlin}}==
<lang scala>// version 1.1.4
Line 1,137 ⟶ 1,156:
Currentvalue is 3
</pre>
=={{header|M2000 Interpreter}}==
We can make objects type of Group to act as History Variables. Each group has a pointer to a stack object (a linked list).
|