Olympic puzzle number one
Afficher commentaires plus anciens
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 commentaires
John Petersen
le 31 Juil 2012
Modifié(e) : John Petersen
le 31 Juil 2012
Would somebody please answer this so I can use clear again? aaaah... Thanks Mike!!
Daniel Shub
le 31 Juil 2012
Jan
le 31 Juil 2012
Réponse acceptée
Plus de réponses (4)
Mike Hosea
le 31 Juil 2012
Modifié(e) : Mike Hosea
le 31 Juil 2012
3 votes
- 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 commentaires
Daniel Shub
le 1 Août 2012
I wonder if the workspace window method method can be accessed by a java method from the commandline.
Sean de Wolski
le 31 Juil 2012
clear = rand(1000,500,700);
pack
Daniel Shub
le 31 Juil 2012
Missing from the obvious solutions are:
clear = str2func('clear'); clear();
and
feval('clear');
3 commentaires
Sean de Wolski
le 31 Juil 2012
Modifié(e) : Sean de Wolski
le 31 Juil 2012
Nice! I would've thought the str2func solution would have recursively called itself.
Mike Hosea
le 1 Août 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
le 31 Juil 2012
1 vote
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 commentaires
Sean de Wolski
le 31 Juil 2012
clearvars is just a fancy wrapper for evalin with clear.
edit clearvars
Jan
le 31 Juil 2012
Daniel Shub
le 1 Août 2012
@Sean, my point was that it could be a slightly fancy wrapper that could catch this error
Catégories
En savoir plus sur Board games dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!