Sep 16, 2010

More about list

Dot Dot notation
You can get a sequence of integer numbers like;
[1..10] it will give the result as [1,2,3,4,5,6,7,8,9,10]
And also if you type it as
[1,3..10] it will be like
[1,3,5,7,9]
And also on the other way around too.
[5..0]
[5,4,3,2,1,0]

Never ending list
This is like a never ending loop;

loop n=n: loop(n+1)
runLoop = loop 1

If the user type;
runLoop
The haskell will give a never ending loop.

Head and tali
If you type;
let list = [1,2,3,4,5,6]
head list
it will give the output as
1
tail list
it will give the output as
[2,3,4,5,6]

This will devide a list to two parts like (x:sx)

No comments:

Post a Comment

Your comments are always welcome ...