[clean-list] Can anyone improve this program?

Jigang Sun js035288 at student.paisley.ac.uk
Sun Jul 10 00:20:32 MEST 2005


In order to print [(5,0), (6,0), (7,0)], I use a temporary variable (as if) n  (Int type). Can anyone  improve it without using the temporary variable? 
i.e. the function will be defined as count::[a]->[(a,Int)]

Many thanks.



count::Int [a]->[(a,Int)]
count n []=[] 
count n [x:xs]=[(x, n ): count (n+1) xs]

Start=count 0 [5,6,7]





More information about the clean-list mailing list