News for hackers. Stuff that matters.
Re:The Earl Grey programming language by istvan__ on Thursday May 07, 2015 @10:30PM (#9509689)
I think the first one is a single function that has pattern matching for the parameter while the second one is defining the function twice and relying on the language to call the right one based on the parameter.

I think in Erlang the function identification is the name and the arity and this is as close I know of what you would like to have.

Re:The Earl Grey programming language by mikkom on Friday May 08, 2015 @04:37AM (#9510562)
Erlang has both methods, pattern matching in function definition and case-clause pattern matching.

(some random link http://stackoverflow.com/questions/1050913/erlang-style-case...)

Re:The Earl Grey programming language by TheDong on Thursday May 07, 2015 @11:27PM (#9509821)
In haskell you can write exactly the following:

    fact 0 = 0
    fact 1 = 1
    fact n = n * fact (n-1)
It works as you would expect and really they aren't that dissimilar.
Re:The Earl Grey programming language by FreeFull on Friday May 08, 2015 @09:19AM (#9511495)
Small correction, fact 0 = 1
Re:The Earl Grey programming language by arh68 on Thursday May 07, 2015 @11:32PM (#9509832)
Erlang does it very much like GP's suggestion with the one downside of being 'noisy' with its punctuation (some might say 'clearer'):

  factorial(0) -> 1;
  factorial(N) -> N * factorial(N-1).

  factorial(Foo, 0) -> .. ;
  factorial(Foo, Bar) -> .. .
Semicolons separate partial definitions for a single function of a single arity, and periods end those definitions. Removing the punctuation might make parsing a bit more difficult (will there be more partial definitions?), so it's understandable to not offer it.
Re:The Earl Grey programming language by Vignitus on Friday May 08, 2015 @02:54AM (#9510335)
Off-topic: I'm kinda new here, what does GP stand for ?
Re:The Earl Grey programming language by jfarmer on Friday May 08, 2015 @03:39AM (#9510425)
The grandparent comment, as opposed to the parent comment or the original post.
Re:The Earl Grey programming language by akst on Friday May 08, 2015 @07:38AM (#9510986)
I'd imagine you could compile them both down to the same thing, as there has to be a conditional at some point to determine what code to run (unless there was some kind of dynamic dispatch), I think it's just a matter of preference