Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

And how does it (or does not) correspond to "polymorphic"? Occasionally I see this notion like in: Implement and represent polyadic operations. I checked Wiktionary but it only gives a general meaning, not specific to functional programming.

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

It's really simple to understand.

  • A function that takes zero arguments is called niladic function.
  • A function that takes one argument only is called monadic function.
  • A function that takes two arguments is called dyadic function.
  • A function that takes three arguments it called triadic function.
  • A function that takes multiple arguments is called polyadic function.
  • A function that takes a variable number of arguments is called variadic function.

How does this relate to polymorphy? Imho it does not relate to polymorphy at all. I think often times polyadic and variadic are substitutable. See wikipedia for further information.

How does this relate to functional programming?

I think the following wikipedia quote sais it all:

There are many mathematical and logical operations that come across naturally as variadic functions. For instance, the summing of numbers or the concatenation of strings or other sequences are operations that can logically apply to any number of operands.

share|improve this answer
1  
How is that different from unary, binary, ternary etc.function? Just a note, in the context of functional programming, a monadic function could also mean something very different (a function that works with a monad). –  Petr Pudlák Dec 9 '12 at 15:05
3  
It is not different from unary, binary, ternary. It's very much the same. There can be differences depending on the language used. An unary operator can also be called monadic operator. –  Falcon Dec 9 '12 at 15:08
    
What it the difference between a variadic function and a function that takes one argument of type list? –  Giorgio Dec 9 '12 at 16:01
    
@Giorgio: The signature and the type of the function. func(List) != func(arg1, arg2... arg_n); This is merely in the typesystem. As an anlogy, think about recursive functions that can always be implemented as stack-based iterative functions. –  Falcon Dec 9 '12 at 16:04
1  
@Falcon Look at Haskell's Text.Printf for a curried variadic function. –  Ptharien's Flame Dec 9 '12 at 19:06
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.