Friday 29 April 2016

Haskell: Comments

Comments are used to document your code neatly. Haskell provides two types of comments.

Single line comments
Single line comments starts with -- and continues till the end of line.

Multi line comments
You can write multi line comments in between {- … -}.


interest.hs
p = 100000 -- Principal 
t = 1.10   -- Time in years
r = 5      -- Rate of interest per annum (p.a.) 

{- Let Principal = P, Rate = R% per annum (p.a.) and Time = T years. Then, 
Simple Interest =	 (P x R x T)/100
 -}
interest = p * t * r *0.01

*Main> :load interest.hs
[1 of 1] Compiling Main             ( interest.hs, interpreted )
Ok, modules loaded: Main.
*Main> 
*Main> interest
5500.000000000001



Previous                                                 Next                                                 Home

No comments:

Post a Comment