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

Haskell: Variables

A Variable is a named memory location used to store a value. Variables and function names must always start with lower case letter.


interest.hs
p = 100000
t = 1.10
r = 5

interest = p * t * r *0.01

In above program, I defined four variables p, t, r and interest. All these variables store a number.

Prelude> :load interest.hs
[1 of 1] Compiling Main ( interest.hs, interpreted )
Ok, modules loaded: Main.
*Main>
*Main> p
100000.0
*Main> t
1.1
*Main> r
5.0
*Main> interest
5500.000000000001
*Main> 10*p
1000000.0
*Main> 10-p
-99990.0


Variables in Haskell are immutable, that means you can’t change the value of a variable after its definition.


sample.hs
var1 = 10
var1 = 13.24



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

Share the post

Haskell: Variables

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×