Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 1.96 KB | None | 0 0
  1. EXAMEN 2015
  2. declare
  3. local Modes ModesFixe in
  4. fun{Modes L}
  5.    local Modesbis in
  6.       fun{Modesbis L Prev}
  7.      case L
  8.      of H1|H2|T then
  9.         if {And H1>Prev H1>H2} then H1|{Modesbis H2|T H1}
  10.         else {Modesbis H2|T H1} end
  11.      [] H|nil then
  12.         if H>Prev then H|{Modesbis nil H}
  13.         else {Modesbis nil H} end
  14.      else nil
  15.      end
  16.       end
  17.       {Modesbis L L.2.1}
  18.    end
  19. end
  20. fun{ModesFixe L}
  21.    if {Length L}==1 then L
  22.    else {ModesFixe {Modes L}}
  23.    end
  24. end
  25. {Browse {ModesFixe [4 1 2 4 0 5 4]}}
  26. end
  27.  
  28. EXAMEN 2016
  29. declare
  30. local Yo Match Find Lp Hp Lq Hq Line Matrix Run P Q in
  31.    P=[[1 0 0][1 1 1]]
  32.    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]]
  33.    Lp={Length P.1}
  34.    Hp={Length P}
  35.    Lq={Length Q.1}
  36.    Hq={Length Q}
  37.  
  38.    fun{Yo A B} %check une ligne de P avec une ligne de Q
  39.       case A of H|T then
  40.      if H==1 then
  41.         if B.1==0 then {Yo T B.2}
  42.         else no end
  43.      else yes end
  44.       else yes
  45.       end
  46.    end
  47.    
  48.    fun{Match P Q}
  49.       case P of H|T then
  50.      if {Yo H Q.1}==yes then {Match T Q.2}
  51.      else no end
  52.       else yes
  53.       end
  54.    end
  55. %................................................
  56.    fun{Line L A B}
  57.       local C in
  58.      C={NewCell nil}
  59.      for I in B..A;~1 do
  60.         C:={Nth L I}|@C
  61.      end
  62.      @C
  63.       end
  64.    end
  65.    
  66.    %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)
  67.    fun{Matrix Q I J}
  68.       local C in
  69.      C={NewCell nil}
  70.      for K in I+Hp-1..I;~1 do
  71.         C:={Line {Nth Q K} J J+Lp-1}|@C
  72.      end
  73.      @C
  74.       end
  75.    end
  76.    %fonction parcourt l'entierete de Q pour trouver un bon endroit ou placer la matrice P
  77.    fun{Run P Q I J}
  78.       if I > Hq-Hp+1 then notfound
  79.       else
  80.      if J > Lq-Lp+1 then {Run P Q I+1 1}
  81.      else
  82.         if {Match P {Matrix Q I J}}==yes then found(I J)
  83.         else {Run P Q I J+1} end
  84.      end
  85.       end
  86.    end
  87.    fun{Find P Q}
  88.       {Run P Q 1 1}
  89.    end
  90.    {Browse {Find P Q}}
  91. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement