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

HE vs ML discrepancy: ML factorial function hangs (doesn't terminate) on non-numeric input #244

Open
zariuq opened this issue Feb 5, 2025 · 0 comments

Comments

@zariuq
Copy link

zariuq commented Feb 5, 2025

  • I modified the tutorial factorial example to not infinitely recurse on negative input.
  • This works for numbers, but ML freezes when given "monkey".
(= (factorial $x)
   (case $x
     ((0 1)
      ($_ 
        (if (> $x 0)
            (* $x (factorial (- $x 1)))
            (Undefined)
        )))
   )
)
  • With the following calls:
! (factorial 5)
! (factorial -1)
! (factorial monkey)

HE:

[120]
[(Undefined)]
[(if (> monkey 0) (* monkey (factorial (- monkey 1))) (Undefined))]

ML:

[120]
[(Undefined)]
...
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

1 participant