Advertisement
Sawy3R11

LiTM_LAB__cw_4

May 12th, 2016
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.00 KB | None | 0 0
  1. 4.2.2 a)
  2. 2 ?- A = [2,3,1,7,8], findall(X, (member(X,A), X>2), L).
  3.  
  4. A = [2, 3, 1, 7, 8]
  5. X = _G506
  6. L = [3, 7, 8]
  7.  
  8. Yes
  9. 4.2.2 b)
  10. 3 ?- A = [2,3,1,7,8], findall(X, (member(X,A), X), L).
  11. ERROR: Type error: `callable' expected, found `2'
  12. 4 ?- A = [2,3,1,7,8], findall(X, (member(X,A), member(X,A)), L).
  13.  
  14. A = [2, 3, 1, 7, 8]
  15. X = _G554
  16. L = [2, 3, 1, 7, 8]  
  17.  
  18. 4.2.2 d)
  19.  
  20. 3 ?- A=[2,3,1,7,8], findall( X, (member(X,A), X>2, X=<7), L).
  21.  
  22. 4.2.2 e)
  23. [1] 8 ?- A=[a, b], B=[[], 1], findall((X,Y), (member(X,A), member(Y,B)), L).
  24.  
  25. 4.2.2 4 a)
  26. [2] 10 ?- A=[a], findall((X,Y), (member(X,A), member(Y,A)), L).
  27.  
  28. 4.2.2 5
  29. A)
  30. [3] 12 ?- A=[x,y,z], B=[1,2], C=[u],   findall((X,Y, Z), (member(X,A), member(Y,B), member(Z, C)), L).
  31.  
  32. 6
  33. a) A=[1,2], B=[1,2,4],    findall((X,Y), (member(X,B),  member(Y,B), X<Y), L).
  34.  
  35. f) [8] 21 ?- A=[1,2], B=[1,2,4],    findall((X,Y), (member(X,A),  member(Y,B), Y is X*X ), L).
  36.  
  37. = porównanie wyglądu
  38. is przypiasnaie/ porównaie wartości / obliczanie a póżniej podstawianie
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement