Olympic puzzle number one

11 ビュー (過去 30 日間)
Jan
Jan 2012 年 7 月 31 日
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 件のコメント
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 日
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 日
  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 日
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 日
Missing from the obvious solutions are:
clear = str2func('clear'); clear();
and
feval('clear');
  3 件のコメント
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 日
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 件のコメント
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBoard games についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by