Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EXAMEN 2015
- declare
- local Modes ModesFixe in
- fun{Modes L}
- local Modesbis in
- fun{Modesbis L Prev}
- case L
- of H1|H2|T then
- if {And H1>Prev H1>H2} then H1|{Modesbis H2|T H1}
- else {Modesbis H2|T H1} end
- [] H|nil then
- if H>Prev then H|{Modesbis nil H}
- else {Modesbis nil H} end
- else nil
- end
- end
- {Modesbis L L.2.1}
- end
- end
- fun{ModesFixe L}
- if {Length L}==1 then L
- else {ModesFixe {Modes L}}
- end
- end
- {Browse {ModesFixe [4 1 2 4 0 5 4]}}
- end
- EXAMEN 2016
- declare
- local Yo Match Find Lp Hp Lq Hq Line Matrix Run P Q in
- P=[[1 0 0][1 1 1]]
- Q=[[1 0 0 1 1][0 1 1 0 1][0 0 0 1 1][0 0 0 1 1][1 0 0 0 1]]
- Lp={Length P.1}
- Hp={Length P}
- Lq={Length Q.1}
- Hq={Length Q}
- fun{Yo A B} %check une ligne de P avec une ligne de Q
- case A of H|T then
- if H==1 then
- if B.1==0 then {Yo T B.2}
- else no end
- else yes end
- else yes
- end
- end
- fun{Match P Q}
- case P of H|T then
- if {Yo H Q.1}==yes then {Match T Q.2}
- else no end
- else yes
- end
- end
- %................................................
- fun{Line L A B}
- local C in
- C={NewCell nil}
- for I in B..A;~1 do
- C:={Nth L I}|@C
- end
- @C
- end
- end
- %creation d'une sous matrice Q' dont les dimensions correspondent a celles de la matrice P, la premiere entree de Q' est situee aux positions (I,J)
- fun{Matrix Q I J}
- local C in
- C={NewCell nil}
- for K in I+Hp-1..I;~1 do
- C:={Line {Nth Q K} J J+Lp-1}|@C
- end
- @C
- end
- end
- %fonction parcourt l'entierete de Q pour trouver un bon endroit ou placer la matrice P
- fun{Run P Q I J}
- if I > Hq-Hp+1 then notfound
- else
- if J > Lq-Lp+1 then {Run P Q I+1 1}
- else
- if {Match P {Matrix Q I J}}==yes then found(I J)
- else {Run P Q I J+1} end
- end
- end
- end
- fun{Find P Q}
- {Run P Q 1 1}
- end
- {Browse {Find P Q}}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement