Olympic puzzle number one
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clear = @()disp('Have fun undoing this (:');
Let's solve this challenge and restore the original clear command in as many ways as you find.
3 Kommentare
Akzeptierte Antwort
Weitere Antworten (4)
Mike Hosea
am 31 Jul. 2012
Bearbeitet: Mike Hosea
am 31 Jul. 2012
- builtin('clear','clear')
- You can delete the variable from the workspace window (highlight and press delete or right click and delete).
I look forward to reading some more creative ways.
2 Kommentare
Daniel Shub
am 1 Aug. 2012
I wonder if the workspace window method method can be accessed by a java method from the commandline.
Daniel Shub
am 31 Jul. 2012
Missing from the obvious solutions are:
clear = str2func('clear'); clear();
and
feval('clear');
3 Kommentare
Mike Hosea
am 1 Aug. 2012
If you wanted to leave the rest of the workspace undisturbed it would have been four mentions of "clear":
clear = str2func('clear'); clear('clear');
Daniel Shub
am 31 Jul. 2012
Somewhat surprisingly the CLEARVARS function is not a solution and gives an unhelpful error message. I think the failure probably qualifies as a bug.
3 Kommentare
Daniel Shub
am 1 Aug. 2012
@Sean, my point was that it could be a slightly fancy wrapper that could catch this error
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!