Olympic puzzle number one
이전 댓글 표시
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
John Petersen
2012년 7월 31일
편집: John Petersen
2012년 7월 31일
Would somebody please answer this so I can use clear again? aaaah... Thanks Mike!!
Daniel Shub
2012년 7월 31일
Jan
2012년 7월 31일
채택된 답변
추가 답변 (4개)
Mike Hosea
2012년 7월 31일
편집: Mike Hosea
2012년 7월 31일
3 개 추천
- 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
Daniel Shub
2012년 8월 1일
I wonder if the workspace window method method can be accessed by a java method from the commandline.
Sean de Wolski
2012년 7월 31일
clear = rand(1000,500,700);
pack
Daniel Shub
2012년 7월 31일
Missing from the obvious solutions are:
clear = str2func('clear'); clear();
and
feval('clear');
댓글 수: 3
Sean de Wolski
2012년 7월 31일
편집: Sean de Wolski
2012년 7월 31일
Nice! I would've thought the str2func solution would have recursively called itself.
Mike Hosea
2012년 8월 1일
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
2012년 7월 31일
1 개 추천
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
Sean de Wolski
2012년 7월 31일
clearvars is just a fancy wrapper for evalin with clear.
edit clearvars
Jan
2012년 7월 31일
Daniel Shub
2012년 8월 1일
@Sean, my point was that it could be a slightly fancy wrapper that could catch this error
카테고리
도움말 센터 및 File Exchange에서 Board games에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!