DzLox

:)
git clone https://git.sr.ht/~ashymad/DzLox
Log | Files | Refs | Submodules | LICENSE

closure.lox (184B)


      1 fun mk() {
      2     var i = 0;
      3     var l = [];
      4     return fun() {
      5         l[len(l)] = i = i + 1;
      6         print l;
      7     };
      8 }
      9 
     10 con f = mk();
     11 
     12 f();
     13 f();
     14 f();
     15 
     16 con f2 = mk();
     17 
     18 f2();
     19 f2();
     20 f2();