1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Bài tập prolog da tap hop docx

18 1,6K 52

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 103,5 KB

Nội dung

               !"#$!%&'#(%")%*+,-.)#/+,#%0+%1% +( +(+(  +(  +(  +12 3#!!+(2 41""+56)66+6)    2   )1+,!%- !0+%-'7#8"'!7"+%9#% 3%:;<+#8"'!%=%>?!-@&A+,#%B#9!%CD+, )1+,!%E )1+,!%)1+,!%FFG  )1+,!% E  )1+,!%   )1+,!% E  )1+,!%   )"==+7,H+,%#+#"!7I+,- ,%J=%"7"+%9#%!%+%'!7"+%9#% )"==+7(( )"==+7(()"==+7((  )"==+7  )"==+7(2K (2K  )"==+7    2L%J=MMN!0-@&!<+#8"7"+%9#%( ,%=+O( ,%=+O((( ,%=+O(2K  ,%=+O((P  (P  ,%=+O(K( QLR (QLRK  ,%=+O(( QLP ( QLP QLP (QLK QLPQLK  ,%=+O(PKRPK R  ,%=+O(   P9=%@+!S%T7"+%9#%( )M(( )M()M(  )M  )M   )M   )M   )M2P( (2P (2P (2P  K3%U+MMN!0V!W!+,7"+%9#%( )M(( )M()M( +!+(()M(  +!+(2( (2 (2 (2 (2  +!+(2K2 K  +!+((2X  (2X 2 (X  (2X X (2  +!+(PX( QLEE (QLEEPX QLEE (PQLEEX QLEE (PQLEEX QLEE (PXQLEE QLEE (PXQLEE  XM->+,CY#7"+%9#%(#9#=%@+!S!%MN!0!Z"&-[+!C\# M M(M(#+#"!((  M( (  M( (  R="1+7+ !"]7"+%9#%#$-*]^+,%*+, M M(M(#+#"!(( ="1+7+(M((  ="1+7+  ="1+7+  E=1"#!%")!%[+%B+,=%@+!S#$,9!N1]!%+%,9!N1!+,7"+%9#%( =1"#_ =1"#_(_(=1"#_(( =1"#_((=1"#_(( =1"#( (  =1"#2( (2  =1"#( (  71!"11]9!V!#>#9#=%@+!S#$,9!NA+,]!+,7"+%9#%( 71!"11 71!"11((71!"11(( 71!"11((71!"11(( 71!"112PK( (2PK  71!"11(  (  71!(  71!"11( (  71!"112P( (2P  71!"112P2P  #&+!7M-[#9#=%@+!S!+,7"+%9#%#%"%[!#% #&+!7M_E #&+!7M_(7_E #&+!7M_(F FG #&+!7M_(7_`E #&+!7M_( #&+!7M E  #&+!7M   #&+!7M2K E  #&+!7M2P   77&!0+%!a+,#9#H1b!+,7"+%9#%( 77&E 77&(7 77&(F FG 77&(7E 77&( 77& E  77&P E  77&2 R  77&2PKX 2  77&2R  M+#&+!-[!V!#>#9#H#%c+#$!+,7"+%9#%( M+#&+!E M+#&+!(7E M+#&+!(F FG M+#&+!(7`E M+#&+!( M+#&+! E  M+#&+!2K E  M+#&+!2  M+#&+!PX 2  M+#&+!2P  M+#&+!P   2d+"## OE O Ode   Od Od ddGd Od d  OEd d  O   O2f fX  O2X  O2K  PO"#!0+%+g O"#E O"#deE F O"#Fd dhd O"#E   O"#   O"#   O"# P  O"#2 E  O"#K 2EE  O"#2E   O"#2E   K=5!0+%" +  =5iE =5i4eE F =5iF4 44hi =5E   =5   =5 X  =5P P  =5P jkklki,&+!"+!&OO#+!1)+!"+!"!7 j]#=!+KQLKeE#= =5iX jkklki,&+!"+!&OO#+!1)+!"+!"!7 mj]#=!+RQLXhQLE#= =5X  =5 X#!0+%-N+%!%^#3+ #_dn_ 5!616 #E # #_d __ #_d #_d ddGd #d 1 dQLXX  #Ed d  #d d  #d d  #2d dE +[&E%o#+ 3+G3+M\%9# [...]... 2) ? creep 21.Hàm sumlist tính tổng các phần tử của một danh sách sumlist([],0) sumlist([X|L],N):-sumlist(L,M), N is M+X ?- sumlist([],N) N=0 Yes ?- sumlist([],0) Yes ?- sumlist([2],N) N=2 Yes ?- sumlist([2,3,4,5],N) N = 14 Yes ?- sumlist([1,2,3,4,5],15) Yes ?- sumlist([2,5,3],2) No 22.Hàm subset là hàm kiểm tra tập hợp này có phải là tập con của tập kia subset([],L) subset([X|T],L):-member(X,L), subset(T,L)... subset([1,2,3],[]) No ?- subset([1,2],[4,2,5,6,1]) Yes ?- subset([1,2],[3,4,5,6,1]) No ?- subset(L,[1,2,3,4,5,6]) L = [] Yes ?- subset(L,[1,2,3,4,5,6]) L = [] ; No 23.Hàm sumlist kiểm tra danh sách này có phải là danh sách con của danh sách kia không concat([],L,L) concat([H|T],L,[H|L1]):-concat(T,L,L1) sublist(T,L):-concat(L1,L2,L),concat(T,L3,L2) ?- sublist([],[]) Yes ?- sublist([],[1,2,3]) Yes ?- sublist([1,2,3],[])... sequence([1,2],[2,3,1]) No ?- sequence([1,2],[3,4,1,2]) No ?- sequence([1,2],[1,2,3,4]) Yes ?- sequence([1,2],[1,2]) Yes ?- sequence([1,2],[1,2,3]) Yes ?- sequence([1,2],[1,1,2]) No 25.Hàm countk đếm số phần tử k trong danh sách L(k là ký tự hoặc chữ số) countk(K,[],0) countk(K,[K|L],N):-countk(K,L,M), N is M+1 countk(K,[X|L],N):-countk(K,L,N) ?- countk(a,[a,b,c,d],N) N=1 Yes ?- countk(a,[a,b,c,d,a,b,c,d],N) N=2 Yes

Ngày đăng: 12/12/2013, 14:15

TỪ KHÓA LIÊN QUAN

w