view test/bug-52851/script1.m @ 31214:19bd1953fc1d stable

GitHub-CI: Remove ubuntu-18.04 runners from build matrix. * .github/workflow/make.yaml (ubuntu): GitHub-hosted runners for ubuntu-18.04 are being deprecated. Remove them from build matrix. See also: https://github.com/actions/runner-images/issues/6002
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 30 Aug 2022 11:16:27 +0200
parents d45d1b4bb919
children
line wrap: on
line source

1; %script identifier

function r = caller (fun, num)
  persistent funarray
  if (isempty (fun))
    r = funarray(num).fun ();
  else
    if (isempty (funarray))
      funarray(1).fun = fun;
    else
      funarray(num).fun = fun;
    endif
  endif
endfunction

function r = computation ()
  r = 1;
endfunction

caller (@computation, 1);

r11 = caller ([], 1);

function r = computation ()
  r = 2;
endfunction

caller (@computation, 2);

r21 = caller ([], 1);
r22 = caller ([], 2);