Advertisement
zxhouse

Untitled

Jan 6th, 2019
1,399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.58 KB | None | 0 0
  1. let rec odejmijWielomianyPom w1 w2 =
  2.    match w1, w2 with
  3.    | [], n2::tail2 -> [n2]@(odejmijWielomianyPom [] tail2)
  4.    | n1::tail1, [] -> [n1]@(odejmijWielomianyPom tail1 [])
  5.    | [], [] -> []
  6.    | n1::tail1, n2::tail2 -> [n1+n2]@(odejmijWielomianyPom tail1 tail2)
  7.    
  8. let odejmijWielomiany w1 w2 =
  9.    let w1n = List.rev w1
  10.    let w2n = List.rev w2
  11.    let result = odejmijWielomianyPom w1n w2n
  12.    List.rev result
  13.  
  14. let rec wielomian1 = [2; 3; 0; 0; -1] //2x^4+3x^3-1
  15. let rec wielomian2 = [1; -1] //0x^4+0x^3+0x^2+x-1    
  16. printfn "%A" (odejmijWielomiany wielomian1 wielomian2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement