include "doc.cd";; (*********function *********) let fun count_bad([Any*]->Int) [] -> 0 | [_;t] -> 1+count(t);; (* tail recursive definition *) let fun count(x : [Any*]) : Int = let tr_count((Int,[Any*]) -> Int) | (n,[]) -> n | (n,[_;t]) -> tr_count(n+1,t) in tr_count(0,x) (***************************) (***************************************************************** For each book that has at least one author, list the title and first two authors, and an empty "et-al" element if the book has additional authors. ******************************************************************) let q6x= select ([b]/_ @ (match ([b]/<author>_) with | [a b _+ ] ->[a b] @ [<et-al>[]] | a ->a ) ) from b in [doc]/<book>[_* Author _*];; let q6p= <bib> select <book>[t !a !(if etal=[] then [] else [<et-al>[]])] from <bib>[b::Book*] in [doc], <book>[t&Title a::(Author Author) etal::Author* ;_] in b;; (* le typage est differents entre q6x et q6p: on a pour q6x: <bib {| |}>[ <book {| |}>[ X1 X2 | X1 X2 X2 | X1 X2 X2 <et-al {| |}>[ ] | X1 ]* ] where X1 = <title>[ Char* ] and X2 = <author>[ Last First ] et pour q6p: <bib {| |}>[ <book {| |}>[ Title Author | Title Author Author | Title Author Author X1 | Title Author X1 ]* ] where X1 = <et-al {| |}>[ ] Dans le premier cas on a soit + Title Author = Ok + Title Author Author = Ok + Title Author Author Et-aL = Ok + Title = pas possible d etre dans ce cas avec la condition, mais le typage ne peut le detecter Dans le deuxieme cas on a soit: + Title Author =ok + Title Author Author =ok + Title Author Author Et-aL =ok + Title Author Et-al =ok pas possible aussi mais vient du if il est rigolo de remarquer que pour cqlx on sait qu on aura pas de Title Author Et-al et qu en cqlp on sait qu on aura pas de Title tout court q6x n est pas entierement ecrit en cqlx puisqu on se sert de patterns patterns qu on pourrait utilise en cqlp et on aurait un type plus fin, mais une expression plus longue. *)