Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Paradygmaty
  2. Lab 4
  3. zadanie 2.6
  4. module ListaLiczb where
  5. funkcja [] x = 0
  6. funkcja lista x = length (filter (>x) lista)
  7. // w konsoli funkja [2,4,5,6] 3
  8. zadanie2.7
  9. module ListaLiczb where
  10. funkcja [] = (0,0)
  11. funkcja lista = (length (filter (>0) lista), length (filter (<0) lista))
  12. //w konsoli funkcja [2,7]
  13. // w domu 2.8
  14.  
  15. Lab 5
  16. zadanie 2.1
  17. module ListaLiczb where
  18. pierwiastek x = until f1 f2 1.0
  19. where
  20. y=1
  21. f1 y = abs(y*y-x) < 0.001
  22. f2 y = 0.5*(y + (x/y))
  23.  
  24. zadanie 2.2
  25. //pierwszy punkt
  26. module ListaLiczb where
  27. calkowanie f a b n = h * sum (map f punkty)
  28. where
  29. h = (b-a)/n
  30. punkty = [a+i*h | i <-[1..n]]
  31.  
  32. module ListaLiczb where
  33. calkowanie f a b n = h * sum (map f punkty)
  34. where
  35. h = (b-a)/n
  36. punkty = [a+i*h | i <-[0..n-1]]
  37.  
  38.  
  39. // DRZEWA
  40.  
  41. module Drzewa where
  42. data DrzewoBinarne a = Lisc a
  43. | Wezel a (DrzewoBinarne a) (DrzewoBinarne a)
  44. | Null
  45. deriving(Show)
  46.  
  47. rozmiar Null = 0
  48. rozmiar (Lisc _) = 1
  49. rozmiar (Wezel _ leweDrzewo praweDrzewo) = 1 + rozmiar leweDrzewo + rozmiar praweDrzewo
  50.  
  51. d = Wezel 1 (Lisc 2) (Lisc 5)
  52. //rozmiar d
  53.  
  54. //let d1 = Wezel 1 (Lisc 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement