Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun poly [] x = 0.0
- | poly (hd::tl) x = hd + x*(poly tl x);
- poly = [1,2,3]
- ##If polynomials exists solely as a list of coefficients,
- ##then to differentiate, we must first drop the first element of the list,
- ##then multiply each element of the list by it's index.
- For example diff [1,2,3] -> [2, 6]
- diff (1 + 2x + 3x^2) -> (2 + 6x)
- fun diff L = let fun mult_elements n [] = []
- | mult_elements n (hd::tl) = (n*hd)::mult_elements (n+1) tl
- in tl (mult_elements 0 L) end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement