Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login
I am unreasonably proud of this recursive anonymous quicksort done in Matlab (gist.github.com) similar stories update story
8.0 points by adambard | karma 1299 | avg karma 3.39 2012-05-03 23:55:15+00:00 | hide | past | favorite | 3 comments



view as:

Good stuff. I sometimes have to help my girlfriend who's a cognitive psychologist set up her experiences on MATLAB and coming from the Ruby world, it's always quite brutal.

Nice.

I find it annoying to have to EITHER -write one file per function and completely crap up a directory OR -write multiple functions in one file that can only be called by code in that file (nested functions / subfunctions)

The clear solution is to write utility functions as anonymous functions. The major limitation of anonymous functions is that they evaluate an expression and cannot contain statements... unless you use eval()!

    %come to the dark side

    if_ = @(cond, then_fn, else_fn) ...
            eval('if(cond) then_fn(); else else_fn(); end');
    %this can make code better and it can make code terrible;
    %whether it is a better terrible than the MATLAB you have
    %to deal with on a regular basis is unclear.

Legal | privacy