Решенеия на задачите от упражненията

Седмица 6:Решения на някои задачи

Седмица 6:Решения на някои задачи

от Антон Илиев -
Number of replies: 0

whiteSpaces = [' ','\n','.','!',','];
getWord s
 |null s =[]
 |elem (head s) whiteSpaces =[]
 |otherwise =(head s):(getWord (tail s))

dropWord s
 |null s=[]
 |(s==whiteSpaces)||(elem (head s) whiteSpaces) =s
 |otherwise =dropWord (tail s)
 
dropSpaces s
 |null s =[]
 |elem (head s) whiteSpaces = dropSpaces (tail s)
 |otherwise = s

splitWords s
 |null s =[]
 |otherwise = (dropSpaces (getWord s)):(splitWords (dropSpaces (dropWord s)))

clearWord s
 |null s =[]
 |elem (head s) whiteSpaces = clearWord (dropSpaces (tail s))
 |otherwise = (head s):(clearWord (tail s))