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

Haskell: Functions take priority over anything else

Tags: square

In Haskell functions take more priority than anything else. For example 'square x = x*x' return the Square of x. What will be the value of square 5*2, well you may tell square 5*2 = square 10 =  10 * 10 = 100. But once you evaluate square 5*2, you will get 50.
Prelude> let square x = x*x
Prelude>
Prelude> square 5*2
50

Why square 5*2 returns 50?
It is because, functions take more pririty. So the expression 'square 5*2' evaluated like below.

square 5*2 = (5 * 5) * 2 = 25 * 2 = 50




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: Functions take priority over anything else

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×