Olympic puzzle number one

Daniel has provided this nice puzzler:
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
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
Daniel Shub 2012년 7월 31일
Credit should really be given to Loren.
Jan
Jan 2012년 7월 31일
Yes, extra credits for Loren. Extra point for Daniel for the link to Loren's blog!

댓글을 달려면 로그인하십시오.

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 7월 31일

2 개 추천

system('matlab &');quit

댓글 수: 1

Jan
Jan 2012년 7월 31일
편집: Jan 2012년 7월 31일
The rebirth method! +1 from Heidelberg!
On stage deeper: WinPower('rebootmatlab', 'which clear -all') I've always known that this tool will be useful for anything sometimes.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Mike Hosea
Mike Hosea 2012년 7월 31일
편집: Mike Hosea 2012년 7월 31일

3 개 추천

  1. builtin('clear','clear')
  2. 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

Jan
Jan 2012년 7월 31일
편집: Jan 2012년 7월 31일
First! Thanks for taking the builtin out of the race. The workspace browser is an almost external tool to operate in the workspace. +1
Daniel Shub
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
Sean de Wolski 2012년 7월 31일

3 개 추천

clear = rand(1000,500,700);
pack

댓글 수: 2

Daniel Shub
Daniel Shub 2012년 7월 31일
I like this solution.
Jan
Jan 2012년 7월 31일
Relief by much beef. The weight-lifting method.

댓글을 달려면 로그인하십시오.

Daniel Shub
Daniel Shub 2012년 7월 31일

3 개 추천

Missing from the obvious solutions are:
clear = str2func('clear'); clear();
and
feval('clear');

댓글 수: 3

Sean de Wolski
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.
Jan
Jan 2012년 7월 31일
편집: Jan 2012년 7월 31일
Re-identification using str2func is fine. I'm surprised that feval does not fail. Most of all: The first approach contains "clear" three times. This is the winner in synchronized swimming.
Mike Hosea
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
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

clearvars is just a fancy wrapper for evalin with clear.
edit clearvars
Jan
Jan 2012년 7월 31일
Disqualified. Who cares, the most important thing is not to win but to take part!
Daniel Shub
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에 대해 자세히 알아보기

질문:

Jan
2012년 7월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by