« first day (70 days earlier)      last day (3003 days later) » 

8:19 AM
There's a MATL answer to this challenge that would beat all current answers. Does anyone wan to try?
I don't want to post it myself because it's me who wrote the challenge
 
2 hours later…
10:05 AM
... That was before the Osabie answer :-)
 
5 hours later…
3:28 PM
I wrote fibonnacci in MATL. Does anyone have tips on how to shorten it?
 
6 hours later…
9:23 PM
So why couldn't you do 8W:'\w'XX! which I tried but doesn't work — Dr Green Eggs and Iron Man 2 hours ago
@DrGreenEggsandIronMan There are two types of arrays in MATL: normal arrays and cell arrays. Normal arrays can contain numbers, chars, or Booleans. They are always rectangular (or parallelepipedic) in shape, i.e. they cannot be "jagged". Example: [1 2 3; 4 5 6] defines a 2x2 matrix. [1 2; 4 5 6] is not possible.
Cell arrays, on the other hand, can contain arbitrary arrays, possibly with different sizes or types. Example: {'a', 'abc', [1 2; 3 4]}. They are like lists in Python, I think (but used less often). Cell arrays in MATL are displays with each cell's contents on a newline. Try for example {'a', 'abc', [1 2; 3 4]}‌​. This happens regardless of the shape of the cell array. So adding a ! doesn't affect.
XX outputs all matches collected in a cell array. A normal array (char matrix) can't be used because each string might have a different length.
9:34 PM
@DrGreenEggsandIronMan A few tips for your Fibonacci code:
0:1 can be shortened to FT. F is false (which will be cast to 0 when needed), T is true (1), and they "stick to each other", so FT is [false true].
You can replace -1:0) by P2:). P is "flip" (reverse)
Anyway, in this case I think it's better to use separate numbers instead of an array: O1i:"yy+
O      % Push a 0. I use letter "O" so that it doesn't stick to the next 1
1      % Push a 1
i:     % Take input n. Generate arary [1 2 ... n]
"      % For each (i.e. loop that many times)
  y    %   Duplicate the second-top element
  y    %   Do the same
  +    %   Add them
9:47 PM
@Suever More fun with Octave (in this case it doesn't seem harmful, though):
>> str2num('e')
ans =  2.71828182845905
10:02 PM
@LuisMendo cool, thanks for the tips!
@LuisMendo Whaaaaatttttttt???
I guess it's smart enough to differentiate 'e' from '2e10'
How did you find that one?
@Suever I was using str2num in some code golf answer, hoping non-numbers would give []. That didn't work, because i or j do produce numbers. But the funny thing is, I tried e and got the familiar 2.71... :-)
@Suever Yes. But e can be used as an operand
>> str2num('2*e*10')
ans =  54.3656365691809
>> str2num('e^pi')
ans =  23.1406926327793
So basically str2num is just eval in octave
Actually Matlab's str2num calls eval under the hood. But it has some kind or protection
I get it now. The protection is simply that the call to eval is in a subfunction, so as to "block" all variables. Clever
Oh interesting
10:17 PM
Other than that, it's essentially eval
so what about global x; x = 2; str2num('global x; x')
(I think that's how you do global vars in MATLAB)
But x would have to be declared global within the protecting subfunction
Oh, I see your point
Perhaps global doesn't work within eval
eval is not that evil? :-)
Yea that's one of the few ways to get into that subfunction
that or messing with groot
Oh. Part of the protection is that enclosing brackets are added. So the string that gets evaluated is [global x; x]. Again, clever!
Hmmmmm. Now I'm going to have to try that out
10:21 PM
I guess the brackets deactivate global
that may still work because I think global x just returns []
Hacking MATLAB 101
>> [global x; x]
 [global x; x]
  ↑
Error: Illegal use of reserved keyword "global".
oh interesting
>> eval('[global x, x]')
Error: Illegal use of reserved keyword "global".
So it's similar to function or any keyword like that
10:23 PM
Yes, that seems to be the case
str2num doesn't show the error in that case because it's within a try...catch
(last few lines of str2num code)

« first day (70 days earlier)      last day (3003 days later) »