Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behaviour of two semantically identical functions. #770

Closed
ashwanidausodia opened this issue Jun 28, 2020 · 2 comments
Closed

Comments

@ashwanidausodia
Copy link

I was trying out some examples on https://wren.io/try/ and I came across a weird behaviour. I am not at all familiar with wren, I was just checking it out after seeing a Hacker News post. Below two functions look semantically identical to me and should give same output but they don't. But if I swap the last two print statements, I get the same output (i.e 144). I was just wondering if it is the expected behaviour or is it a bug.

var Fib1 = Fn.new {|n|
  if (n <= 2) {
    return 1
  } else {
    return Fib1.call(n-1) + Fib1.call(n-2)
  }
}

var Fib2 = Fn.new {|n|
  if (n <= 2) {
    return 1
  } else {
    var left = Fib2.call(n-1)
    var right = Fib2.call(n-2)
    return left + right
  }
}
System.print(Fib2.call(12))
System.print(Fib1.call(12))
@mhermier
Copy link
Contributor

mhermier commented Jun 28, 2020 via email

@ruby0x1
Copy link
Member

ruby0x1 commented Sep 18, 2020

With #807 merged both functions return the same result. Let me know if you see otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants