
The 2009/10 Konditori van Gogh award for excellence in Impressionist Scripting
This Sunday morning, O.X. Dive dusts our inboxes with powdered gold:
s{1}=char(39); % Quote mark s{2}=char(10); % Newline s{3}='s{1}=char(39); % Quote mark'; s{4}='s{2}=char(10); % Newline'; s{5}=' '; s{6}=' ...'; s{7}='='; s{8}=','; s{9}='}'; s{10}='('; s{11}=')'; s{12}=';'; s{13}='['; s{14}=']'; s{15}=':'; s{16}='+'; s{17}='-'; s{18}='*'; s{19}='/'; s{20}='s{'; s{21}='i'; s{22}='a'; s{23}='s'; s{24}='int2str('; s{25}='for i='; s{26}='end'; s{27}='disp('; s{28}='length('; s{29}='clear'; s{30}='0'; s{31}='1'; s{32}='2'; s{33}='3'; s{34}='4'; s{35}='7'; s{36}='9'; a=[ ... 2 27 20 33 9 11 12 2 27 20 ... 34 9 11 12 2 2 25 33 15 28 ... 23 11 2 5 27 13 20 32 30 9 ... 8 24 21 11 8 20 36 9 8 20 ... 35 9 8 20 31 9 8 20 21 9 ... 8 20 31 9 8 20 31 32 9 14 ... 11 12 2 26 2 2 27 20 32 9 ... 11 12 2 27 1 22 7 13 6 1 ... 11 12 2 25 31 15 28 22 11 19 ... 31 30 2 5 27 13 1 5 1 8 ... 24 22 10 31 30 18 10 21 17 31 ... 11 16 31 15 31 30 18 21 11 11 ... 8 1 6 1 14 11 12 2 26 2 ... 27 13 1 5 1 8 24 22 10 31 ... 30 18 16 31 15 26 11 11 8 1 ... 14 12 1 14 11 12 2 2 27 13 ... 20 22 9 14 11 12 2 2 29]; disp(s{3}); disp(s{4}); for i=3:length(s) disp([s{20},int2str(i),s{9},s{7},s{1},s{i},s{1},s{12}]); end disp(s{2}); disp('a=[ ...'); for i=1:length(a)/10 disp([' ',int2str(a(10*(i-1)+1:10*i)),' ...']); end disp([' ',int2str(a(10*i+1:end)),'];']); disp([s{a}]); clear
Save it (quine.m would be a sensible name), find a copy of Matlab and run it. Good times follow. Bonus Van Gogh cake for extending the script to match the default keyword colouring of the in-built Matlab editor.
Clever stuff. I can confirm that it also works in the current version of GNU Octave.
So after some searching, I haven’t been able to find a way to render coloured text in the Command Window.
I also thought it would be cute to have the script open itself in the m-file editor, using some command-line options to ensure that all the text displays in black, but I couldn’t find a way to do that either.
If anyone can show me how to do either of these, then the extension to the script should be fairly straightforward.
I am well aware that this is not the most elegant way to do this, but I’m quite pleased with the reception it has recieved. Thanks guys!
Malkovich!
[…] I extolled at length my concerns about non-Gaussianity. Reams of Matlab script, rather different to Owen’s, appeared on my Macbook. Chunks of the Universe were loaded, manipulated, cleared. And this is the […]