Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Haskell: Partial applications

By using partial application, we can pass less number of arguments to a function, that expecting more arguments.

Example
additon x y = (x+y)
add10ToMe = additon 10

add10ToMe is result of partially applying function addition. add10ToMe is completely a new function, that takes a number n as input and add 10 to it.

add10ToMe 123 returns 133

add10ToMe 25 returns 35.
*Main> let addition x y = (x+y)
*Main> let add50ToMe = addition 50
*Main> let add10ToMe = addition 10
*Main>
*Main> add10ToMe 123
133
*Main> add10ToMe 25
35
*Main>
*Main> add50ToMe 23
73
*Main> add50ToMe 345
395


Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Haskell: Partial applications

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×