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

allow pattern matching parameters on function like elixir #72

Open
decioferreira opened this issue Feb 6, 2025 · 0 comments
Open

allow pattern matching parameters on function like elixir #72

decioferreira opened this issue Feb 6, 2025 · 0 comments
Milestone

Comments

@decioferreira
Copy link

allow for multiple entries of the same function with pattern matching the parameters, like a case statement.

The following implementation of Fibonacci Sequence:

fib : Int -> Int
fib x =
    case x of
        0 ->
            1

        1 ->
            1

        _ ->
            fib (x - 1) + fib (x - 2)

Could be converted into:

fib : Int -> Int
fib 0 = 1
fib 1 = 1
fib x = fib (x - 1) + fib (x - 2)

The second example should probably be converted back to the original version with the use of the case statement, by using a tuple for the arguments (this might need #70).

@decioferreira decioferreira added this to the v1.x milestone Feb 6, 2025
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