I'm trying to write my own multiple LCM function in Haskell, one that computes the LCM of all the elements in a given list. I'm trying to use the property lcm(a,b,c) = lcm(a,lcm(b,c)) to make it recursive. Here is what I could come up with so far, but it is giving me errors which I'm not able to understand.
multLCM xs
| length(xs) == 2 = lcm head(xs) last(xs)
| length(xs) > 2 = lcm head(xs) multLCM(drop 1 xs)
Can someone help me improve this function so that it works?
Thanks a lot!