History variables: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 568:
2013-Jan-19 23:04:55.1662596; goodby
</pre>
=={{header|EchoLisp}}==
No native support. We implement an anonymous stack associated with the variable, and a few syntax rules to define the needed operations.
Line 594 ⟶ 595:
(h-undo x) → ❌ error: no more values x
</lang>
=={{header|Elena}}==
ELENA 5.0 :
Line 1,147 ⟶ 1,149:
</pre>
=={{header|Julia}}==
Julia currently does not support overloading the assignment "=" operator.
Line 1,811 ⟶ 1,814:
undo 3, current value: a
$x is: a</lang>
=={{header|Perl 6}}==▼
{{works with|Rakudo|2018.03}}▼
<lang perl6>class HistoryVar {▼
has @.history;▼
has $!var handles <Str gist FETCH Numeric>;▼
method STORE($val) is rw {▼
push @.history, [now, $!var];▼
$!var = $val;▼
}▼
}▼
my \foo = HistoryVar.new;▼
foo = 1;▼
foo = 2;▼
foo += 3;▼
foo = 42;▼
.say for foo.history;▼
say "Current value: {foo}";</lang>▼
{{out}}▼
<pre>[Instant:1523396079.685629 (Any)]▼
[Instant:1523396079.686844 1]▼
[Instant:1523396079.687130 2]▼
[Instant:1523396079.687302 5]▼
Current value: 42▼
</pre>▼
=={{header|Phix}}==
Line 2,081 ⟶ 2,057:
(check-equal? (hvar-current hv) 0)
</lang>
(formerly Perl 6)
▲{{works with|Rakudo|2018.03}}
▲<lang perl6>class HistoryVar {
▲ has @.history;
▲ has $!var handles <Str gist FETCH Numeric>;
▲ method STORE($val) is rw {
▲ push @.history, [now, $!var];
▲ $!var = $val;
▲ }
▲}
▲my \foo = HistoryVar.new;
▲foo = 1;
▲foo = 2;
▲foo += 3;
▲foo = 42;
▲.say for foo.history;
▲say "Current value: {foo}";</lang>
▲{{out}}
▲<pre>[Instant:1523396079.685629 (Any)]
▲[Instant:1523396079.686844 1]
▲[Instant:1523396079.687130 2]
▲[Instant:1523396079.687302 5]
▲Current value: 42
▲</pre>
=={{header|REXX}}==
Line 2,348 ⟶ 2,353:
x history.
</lang>
=={{header|Swift}}==
Swift does not support history variables. However, you can add a watcher that can track when the variable will change.
|