kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

Another recursion problem #549

Closed tavmem closed 4 years ago

tavmem commented 4 years ago
$ rlwrap -n ./k
kona      \ for help. \\ to exit.

   g:{a:x; {:[x=0; a:x; g(0)]}a; a}
  g 2
0

   g:{a:x; {:[x=0; a:x; _f(0)]}a; a}
  g 2
2

This case is discussed in some detail in the comments for closed issue

521: Recursive call overrides earlier data.

I'm setting it up as a separate issue since:

tavmem commented 4 years ago

From another angle:

  g:{a:x; if[x=0; a:x]; if[~x=0; g(0)]; a}
  g 2
2