Hello!
Thanks for your help with the program I was producing a while ago. I
finished it and it works fine. I now have another query. I am trying to
make a function that performs an insertion sort on a list of numbers.
My code is as follows
foldll f u nil=u
foldll f u (x:xs) =foldll f (f u x) xs
reduce f id []=id
reduce f id (x:xs) = f x (reduce f id xs)
cons x xs=x:xs
append xs ys = reduce cons ys xs
insert x [] = x:[]
insert x (y:ys)=if x<=y then x:(y:ys)
else y:(insert x ys)
sort=reduce insert nil
for some reason, HUGS is objecting to the final nil. Even though it has no
objections to the occurrence of nil in the foldl function. Have you any
idea what I am doing wrong? If possible, please could you reply before
Monday.
Thanks
Paul Saxton