{"id":4233,"date":"2013-01-11T09:00:28","date_gmt":"2013-01-11T14:00:28","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=4233"},"modified":"2013-01-11T16:57:02","modified_gmt":"2013-01-11T21:57:02","slug":"functional-programming-constructs","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2013\/01\/11\/functional-programming-constructs\/","title":{"rendered":"Functional Programming Constructs"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39735-functional-programming-constructs\">Functional Programming Constructs<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/225094\">Tucker McClure<\/a>.\r\n   <\/p>\r\n   <p><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/matlab_prog\/anonymous-functions.html\">Anonymous functions<\/a> are extremely powerful and useful, and I use them all the time whenever I want to create a quick function without writing\r\n      a MATLAB file. For me, it's one of those features which the more I use, the more I appreciate. Loren has written <a href=\"https:\/\/blogs.mathworks.com\/loren\/2012\/08\/29\/thoughts-about-anonymous-functions\/\">this post<\/a> on anonymous functions, and she has discussed the topic in other posts as well.\r\n   <\/p>\r\n   <p>For those of you who are not familiar with anonymous functions, let me give you a simple example. Tapping into my mechanical\r\n      engineering background, let's simulate a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Harmonic_oscillator#Damped_harmonic_oscillator\">damped harmonic oscillator<\/a> by solving the second-order differential equation numerically with <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/ode45.html\"><tt>ode45<\/tt><\/a>.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_eq81241.png\"> <\/p>\r\n   <p>We solve the ODE by passing in the system of first order differential equations in the form of<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_eq60148.png\"> <\/p>\r\n   <p>A second order differential equation becomes a system of two first order differential equations.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #0000FF\">function<\/span> dY = odeFcn(t, y, m, k, b)\r\n  dY = [y(2); -1\/m * (k * y(1) + b * y(2))];\r\n<span style=\"color: #0000FF\">end<\/span><\/pre><p>Then you can solve the system like this (after defining <tt>m<\/tt>, <tt>k<\/tt>, <tt>b<\/tt>, and <tt>T<\/tt>):\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">[~, Y] = ode45(@(t, y) odeFcn(t, y, m, k, b), T, [0, 1]);<\/pre><p>Simple enough. However, instead of creating a separate function file for <tt>odeFcn<\/tt>, I can just create an anonymous function. I can do this because this is a simple, one-statement function.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Define mass, spring stiffness, and damping<\/span>\r\nm = 5; k = 5; b = 1;\r\n\r\n<span style=\"color: #228B22\">% Create anonymous function for the damped harmonic oscillator<\/span>\r\nodeFcnAnon = @(t, y) [y(2); -1\/m * (k * y(1) + b * y(2))];<\/pre><p>Now, we can just pass the function handle (to the anonymous function) <tt>odeFcnAnon<\/tt> to <tt>ode45<\/tt>:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Define time vector<\/span>\r\nT = 0:0.1:25;\r\n\r\n<span style=\"color: #228B22\">% Solve<\/span>\r\n[~, Y] = ode45(odeFcnAnon, T, [0, 1]);\r\nplot(T, Y);\r\nlegend(<span style=\"color: #A020F0\">'Position'<\/span>, <span style=\"color: #A020F0\">'Velocity'<\/span>);<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_01.png\"> <p>Wasn't that great? I didn't have to write a separate file or a function. I just created the ODE function \"on the fly\". However,\r\n      I can't create <i>any<\/i> function on the fly. An anonymous function can only contain one executable statement, i.e. I cannot have multiple statements\r\n      or flow control commands like <tt>if<\/tt> and <tt>for<\/tt>.\r\n   <\/p>\r\n   <p>Well, that's a bummer! I wanted to make my dampled oscillator behave a little differently by adding an external force at a\r\n      certain time. To do that, my ODE function would look something like this:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #0000FF\">function<\/span> dY = odeFcn(t, y, m, k, b, t0, F)\r\n  <span style=\"color: #0000FF\">if<\/span> t &gt; t0  <span style=\"color: #228B22\">% after time t0, apply force F<\/span>\r\n    dY = [y(2); -1\/m * (k * y(1) + b * y(2) - F)];\r\n  <span style=\"color: #0000FF\">else<\/span>\r\n    dY = [y(2); -1\/m * (k * y(1) + b * y(2))];\r\n  <span style=\"color: #0000FF\">end<\/span>\r\n<span style=\"color: #0000FF\">end<\/span><\/pre><p>This certainly has more than one statement. How can I possibly do this with an anonymous function? Is my only choice to write\r\n      a separate function?? ...\r\n   <\/p>\r\n   <p>Not anymore! My colleague, Tucker, comes to the rescue! He has created a number of functions for flow control commands, as\r\n      well as other functions that aide in use inside anonymous functions. For example, he has a function <tt>iif<\/tt>, which is the functional form of <tt>if<\/tt>.\r\n   <\/p><pre>iif(&lt;if this&gt;,      &lt;then that&gt;, ...\r\n    &lt;else if this&gt;, &lt;then that&gt;, ...\r\n    &lt;else&gt;,         &lt;then that&gt;);<\/pre><p>Let's see what our ODE anonymous function would look like with this.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">odeFcnAnon = @(t, y, t0, F) iif( <span style=\"color: #0000FF\">...<\/span>\r\n   t &gt; t0, @() [y(2); -1\/m*(k*y(1)+b*y(2)-F)], <span style=\"color: #0000FF\">...<\/span><span style=\"color: #228B22\"> % if t &gt; t0<\/span>\r\n   true  , @() [y(2); -1\/m*(k*y(1)+b*y(2)  )]);    <span style=\"color: #228B22\">% else<\/span><\/pre><p>And, let's solve. Notice that I'm passing in two extra arguments, <tt>t0<\/tt> and <tt>F<\/tt>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">t0 = 15;   <span style=\"color: #228B22\">% Force applied at 15 seconds<\/span>\r\nF = 5;     <span style=\"color: #228B22\">% External force<\/span>\r\n[~, Y] = ode45(@(t, y) odeFcnAnon(t, y, t0, F), T, [0, 1]);\r\nplot(T, Y);\r\nlegend(<span style=\"color: #A020F0\">'Position'<\/span>, <span style=\"color: #A020F0\">'Velocity'<\/span>);<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_02.png\"> <p>That was cool. I was able to create an anonymous function for my function that contained conditional statements.<\/p>\r\n   <p>There are lots more to Tucker's functions, and he has written a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39735-functional-programming-constructs\/content\/html\/functional_programming_examples.html\">detailed document<\/a> deriving some of those functions step by step. It's well-written for such a complex topic. I highly recommend reading through\r\n      it.\r\n   <\/p>\r\n   <p>Let me show a couple of more functions, and I'll leave the rest for you to explore. One of the things that are not possible\r\n      with anonymous functions is the ability to deal with outputs of functions. For example, inside an anonymous function, I am\r\n      not able to access the second output of a function, or index into the first column of the output. This is because I can't\r\n      have multiple statements inside an anonymous function, like this:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">@() [var1, var2] = myFunction;var2(:, 1)<\/pre><p>For this, Tucker has created <tt>output<\/tt> and <tt>paren<\/tt>. Let's create an anonymous function that would solve the ODE, extract the position vector, and plot it.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">plotODEFcn = @(t0, F) plot(T, <span style=\"color: #0000FF\">...<\/span>\r\n   paren(<span style=\"color: #0000FF\">...<\/span>\r\n         output(<span style=\"color: #0000FF\">...<\/span>\r\n                @() ode45(@(t,y) odeFcnAnon(t,y,t0,F), T, [0, 1]), <span style=\"color: #0000FF\">...<\/span>\r\n                2), <span style=\"color: #0000FF\">...<\/span><span style=\"color: #228B22\">   % Get the 2nd output from ODE45  -  Y<\/span>\r\n         <span style=\"color: #A020F0\">':'<\/span>, 1));        <span style=\"color: #228B22\">% Get the 1st column of Y        -  Y(:, 1)<\/span><\/pre><p>A little confusing? Don't worry. I was confused as well at first. If you read Tucker's documentation, you'll get a better\r\n      understanding.\r\n   <\/p>\r\n   <p>Now, we can easily create multiple plots with different forcing conditions.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">figure; hold <span style=\"color: #A020F0\">all<\/span>;\r\nplotODEFcn(15, 5);   <span style=\"color: #228B22\">% Force of 5 at 15 seconds<\/span>\r\nplotODEFcn(10, 5);   <span style=\"color: #228B22\">% Force of 5 at 10 seconds<\/span>\r\nplotODEFcn(20, 10);  <span style=\"color: #228B22\">% Force of 10 at 20 seconds<\/span>\r\nplotODEFcn(5, 2);    <span style=\"color: #228B22\">% Force of 2 at 5 seconds<\/span>\r\nplotODEFcn(0, 0);    <span style=\"color: #228B22\">% No external force<\/span>\r\n\r\nxlabel(<span style=\"color: #A020F0\">'Time'<\/span>); ylabel(<span style=\"color: #A020F0\">'Position'<\/span>);\r\nlegend(<span style=\"color: #A020F0\">'t0=15, F=5'<\/span>, <span style=\"color: #A020F0\">'t0=10, F=5'<\/span>, <span style=\"color: #A020F0\">'t0=20, F=10'<\/span>, <span style=\"color: #A020F0\">'t0=5, F=2'<\/span>, <span style=\"color: #A020F0\">'No force'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n   <span style=\"color: #A020F0\">'Location'<\/span>, <span style=\"color: #A020F0\">'NorthWest'<\/span>)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_03.png\"> <p><b>Comments<\/b><\/p>\r\n   <p>I found Tucker's entry very educational. I learned quite a few techniques I wasn't aware of. If you would like to have some\r\n      discussion on this topic, feel free to leave comments <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=4233#respond\">here<\/a> or you can visit <a href=\"https:\/\/blogs.mathworks.com\/loren\/2013\/01\/10\/introduction-to-functional-programming-with-anonymous-functions-part-1\/\">this post<\/a> in Loren's blog where Tucker's functions are also highlighted.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_8e7ffcb3c96048799127bb267649aa80() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='8e7ffcb3c96048799127bb267649aa80 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 8e7ffcb3c96048799127bb267649aa80';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Jiro Doke';\r\n        copyright = 'Copyright 2013 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_8e7ffcb3c96048799127bb267649aa80()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2012b<br><\/p>\r\n<\/div>\r\n<!--\r\n8e7ffcb3c96048799127bb267649aa80 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39735-functional-programming-constructs Functional\r\n% Programming Constructs> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/225094\r\n% Tucker McClure>.\r\n%\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/matlab_prog\/anonymous-functions.html\r\n% Anonymous functions> are extremely powerful and useful, and I use them\r\n% all the time whenever I want to create a quick function without writing a\r\n% MATLAB file. For me, it's one of those features which the more I use, the\r\n% more I appreciate. Loren has written\r\n% <https:\/\/blogs.mathworks.com\/loren\/2012\/08\/29\/thoughts-about-anonymous-functions\/\r\n% this post> on anonymous functions, and she has discussed the topic in\r\n% other posts as well.\r\n%\r\n% For those of you who are not familiar with anonymous functions, let me\r\n% give you a simple example. Tapping into my mechanical engineering\r\n% background, let's simulate a\r\n% <http:\/\/en.wikipedia.org\/wiki\/Harmonic_oscillator#Damped_harmonic_oscillator\r\n% damped harmonic oscillator> by solving the second-order differential\r\n% equation numerically with\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/ode45.html |ode45|>.\r\n%\r\n% $m\\ddot{y} + b\\dot{y} + ky = 0$\r\n%\r\n% We solve the ODE by passing in the system of first order differential\r\n% equations in the form of\r\n%\r\n% $y' = f(t,y)$\r\n%\r\n% A second order differential equation becomes a system of two first order\r\n% differential equations.\r\n% \r\n%   function dY = odeFcn(t, y, m, k, b)\r\n%     dY = [y(2); -1\/m * (k * y(1) + b * y(2))];\r\n%   end\r\n%\r\n% Then you can solve the system like this (after defining |m|, |k|, |b|,\r\n% and |T|):\r\n%\r\n%   [~, Y] = ode45(@(t, y) odeFcn(t, y, m, k, b), T, [0, 1]);\r\n%\r\n% Simple enough. However, instead of creating a separate function file for\r\n% |odeFcn|, I can just create an anonymous function. I can do this because\r\n% this is a simple, one-statement function.\r\n\r\n% Define mass, spring stiffness, and damping\r\nm = 5; k = 5; b = 1;\r\n\r\n% Create anonymous function for the damped harmonic oscillator\r\nodeFcnAnon = @(t, y) [y(2); -1\/m * (k * y(1) + b * y(2))]; \r\n\r\n%%\r\n% Now, we can just pass the function handle (to the anonymous function)\r\n% |odeFcnAnon| to |ode45|:\r\n\r\n% Define time vector\r\nT = 0:0.1:25;\r\n\r\n% Solve\r\n[~, Y] = ode45(odeFcnAnon, T, [0, 1]);\r\nplot(T, Y);\r\nlegend('Position', 'Velocity');\r\n\r\n%%\r\n% Wasn't that great? I didn't have to write a separate file or a function.\r\n% I just created the ODE function \"on the fly\". However, I can't create\r\n% _any_ function on the fly. An anonymous function can only contain one\r\n% executable statement, i.e. I cannot have multiple statements or flow\r\n% control commands like |if| and |for|.\r\n%\r\n% Well, that's a bummer! I wanted to make my dampled oscillator behave a\r\n% little differently by adding an external force at a certain time. To do\r\n% that, my ODE function would look something like this:\r\n%\r\n%   function dY = odeFcn(t, y, m, k, b, t0, F)\r\n%     if t > t0  % after time t0, apply force F\r\n%       dY = [y(2); -1\/m * (k * y(1) + b * y(2) - F)];\r\n%     else\r\n%       dY = [y(2); -1\/m * (k * y(1) + b * y(2))];\r\n%     end\r\n%   end\r\n%\r\n% This certainly has more than one statement. How can I possibly do this\r\n% with an anonymous function? Is my only choice to write a separate\r\n% function?? ...\r\n%\r\n% Not anymore! My colleague, Tucker, comes to the rescue! He has created a\r\n% number of functions for flow control commands, as well as other functions\r\n% that aide in use inside anonymous functions. For example, he has a\r\n% function |iif|, which is the functional form of |if|.\r\n%\r\n%  iif(<if this>,      <then that>, ...\r\n%      <else if this>, <then that>, ...\r\n%      <else>,         <then that>);\r\n%\r\n% Let's see what our ODE anonymous function would look like with this.\r\n\r\nodeFcnAnon = @(t, y, t0, F) iif( ...\r\n   t > t0, @() [y(2); -1\/m*(k*y(1)+b*y(2)-F)], ... % if t > t0\r\n   true  , @() [y(2); -1\/m*(k*y(1)+b*y(2)  )]);    % else\r\n\r\n%%\r\n% And, let's solve. Notice that I'm passing in two extra arguments, |t0|\r\n% and |F|.\r\n\r\nt0 = 15;   % Force applied at 15 seconds\r\nF = 5;     % External force\r\n[~, Y] = ode45(@(t, y) odeFcnAnon(t, y, t0, F), T, [0, 1]);\r\nplot(T, Y);\r\nlegend('Position', 'Velocity');\r\n\r\n%%\r\n% That was cool. I was able to create an anonymous function for my function\r\n% that contained conditional statements.\r\n%\r\n% There are lots more to Tucker's functions, and he has written a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/39735-functional-programming-constructs\/content\/html\/functional_programming_examples.html\r\n% detailed document> deriving some of those functions step by step. It's\r\n% well-written for such a complex topic. I highly recommend reading through\r\n% it.\r\n%\r\n% Let me show a couple of more functions, and I'll leave the rest for you\r\n% to explore. One of the things that are not possible with anonymous\r\n% functions is the ability to deal with outputs of functions. For example,\r\n% inside an anonymous function, I am not able to access the second output\r\n% of a function, or index into the first column of the output. This is\r\n% because I can't have multiple statements inside an anonymous function,\r\n% like this:\r\n%\r\n%   @() [var1, var2] = myFunction;var2(:, 1)\r\n%\r\n% For this, Tucker has created |output| and |paren|. Let's create an\r\n% anonymous function that would solve the ODE, extract the position vector,\r\n% and plot it. \r\n\r\nplotODEFcn = @(t0, F) plot(T, ...\r\n   paren(...\r\n         output(...\r\n                @() ode45(@(t,y) odeFcnAnon(t,y,t0,F), T, [0, 1]), ...\r\n                2), ...   % Get the 2nd output from ODE45  -  Y\r\n         ':', 1));        % Get the 1st column of Y        -  Y(:, 1)\r\n\r\n%%\r\n% A little confusing? Don't worry. I was confused as well at first. If you\r\n% read Tucker's documentation, you'll get a better understanding.\r\n%\r\n% Now, we can easily create multiple plots with different forcing\r\n% conditions.\r\n\r\nfigure; hold all;\r\nplotODEFcn(15, 5);   % Force of 5 at 15 seconds\r\nplotODEFcn(10, 5);   % Force of 5 at 10 seconds\r\nplotODEFcn(20, 10);  % Force of 10 at 20 seconds\r\nplotODEFcn(5, 2);    % Force of 2 at 5 seconds\r\nplotODEFcn(0, 0);    % No external force\r\n\r\nxlabel('Time'); ylabel('Position');\r\nlegend('t0=15, F=5', 't0=10, F=5', 't0=20, F=10', 't0=5, F=2', 'No force', ...\r\n   'Location', 'NorthWest')\r\n\r\n%%\r\n% *Comments*\r\n%\r\n% I found Tucker's entry very educational. I learned quite a few techniques\r\n% I wasn't aware of. If you would like to have some discussion on this\r\n% topic, feel free to leave comments\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=4233#respond here> or you can visit\r\n% <https:\/\/blogs.mathworks.com\/loren\/2013\/01\/10\/introduction-to-functional-programming-with-anonymous-functions-part-1\/\r\n% this post> in Loren's blog where Tucker's functions are also highlighted.\r\n\r\n##### SOURCE END ##### 8e7ffcb3c96048799127bb267649aa80\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_functionalprogramming\/potw_functionalprogramming_eq81241.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   Jiro's pick this week is Functional Programming Constructs by Tucker McClure.\r\n   \r\n   Anonymous functions are extremely powerful and useful, and I use them all the time whenever I want to... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2013\/01\/11\/functional-programming-constructs\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4233"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=4233"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4233\/revisions"}],"predecessor-version":[{"id":4242,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4233\/revisions\/4242"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=4233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=4233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=4233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}