Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 3.66 KB | None | 0 0
  1. declare
  2. fun{AppendList X Y}
  3.    case X of nil then Y
  4.    [] H|T then H|{AppendList T Y}
  5.    end
  6. end
  7.  
  8. declare
  9. fun{FlattenList X}
  10.    fun{IsList L}
  11.       case L of nil then true
  12.       [] H|T then true
  13.       else false
  14.       end
  15.    end
  16. in
  17.    case X of nil then nil
  18.    [] H|T then
  19.       if {IsList H} then {AppendList {FlattenList H}{FlattenList T}}
  20.       else H|{FlattenList T}
  21.       end
  22.    end
  23. end
  24.  
  25. declare
  26. fun{Primitive K}
  27.    case K of road then
  28.       realitem(kind: road p1: pt(x: 0.0 y: 0.0) p2: pt(x: 1.0 y: 0.0))
  29.    [] building then
  30.       realitem(kind: building p1: pt(x: 0.0 y: 0.0) p2: pt(x: 1.0 y: 0.0) p3: pt(x: 1.0 y: 1.0) p4: pt(x: 0.0 y: 1.0))
  31.    [] water then
  32.       realitem(kind: water p1: pt(x: 0.0 y: 0.0) p2: pt(x: 1.0 y: 0.0) p3: pt(x: 1.0 y: 1.0) p4: pt(x: 0.0 y: 1.0))
  33.    [] pokemon then
  34.       pokeitem(kind: pokemon position: pt(x: 0.0 y: 0.0))
  35.    [] pokestop then
  36.       pokeitem(kind: pokestop position: pt(x: 0.0 y: 0.0))
  37.    [] arena then
  38.       pokeitem(kind: arena position: pt(x: 0.0 y: 0.0))
  39.    end
  40. end
  41.  
  42. declare
  43. fun{PokeTranslate Dx Dy L1}
  44.    L = {FlattenList L1}
  45. in
  46.    case L of nil then nil
  47.    [] H|T then
  48.       case H of primitive(kind: K) then
  49.      {PokeTranslate Dx Dy [{Primitive K}]}|{PokeTranslate Dx Dy T}
  50.       [] pokeitem(kind: K position: pt(x: X y: Y)) then
  51.      pokeitem(kind: K position: pt(x: plus(X Dx) y: plus(Y Dy)))|{PokeTranslate Dx Dy T}
  52.       [] translate(dx: D1 dy: D2 1:Ru) then
  53.      {PokeTranslate Dx Dy {PokeTranslate D1 D2 Ru}}|{PokeTranslate Dx Dy T}
  54.       end
  55.    end
  56. end
  57.  
  58. declare
  59. fun{PokeSearch Pu}
  60.    case Pu of nil then nil
  61.    [] H|T then
  62.       case H of primitive(kind: K) then {Primitive K}|{PokeSearch T}
  63.       [] translate(dx: Dx dy: Dy 1: Pu2) then
  64.      {FlattenList {PokeTranslate Dx Dy Pu2}}|{PokeSearch T}
  65.       end
  66.    end
  67. end
  68.  
  69. declare
  70. fun{Formula F Time}
  71.       % donne les 'formules' du monde pokemon
  72.    if {Float.is F} then F
  73.    else
  74.       case F
  75.       of time then Time
  76.       [] plus(1:A 2:B) then {Formula A Time} + {Formula B Time}
  77.       [] minus(1:A 2:B) then {Formula A Time} - {Formula B Time}
  78.       [] mult(1:A 2:B) then {Formula A Time} * {Formula B Time}
  79.       [] 'div'(1:A 2:B) then {Formula A Time} / {Formula B Time}
  80.       [] cos(1:A) then {Float.cos {Formula A Time}}
  81.       [] sin(1:A) then {Float.sin {Formula A Time}}
  82.       [] tan(1:A) then {Float.tan {Formula A Time}}
  83.       [] exp(1:A) then {Float.exp {Formula A Time}}
  84.       [] log(1:A) then {Float.log {Formula A Time}}
  85.       [] neg(1:A) then ~{Formula A Time}
  86.       [] ite(1:A 2:B 3:C) then if {Formula A Time} == 0.0 then {Formula C Time} else {Formula B Time} end
  87.       [] eq(1:A 2:B) then if {Formula A Time} == {Formula B Time} then 1.0 else 0.0 end
  88.       [] ne(1:A 2:B) then if {Formula A Time} \= {Formula B Time} then 1.0 else 0.0 end
  89.       [] lt(1:A 2:B) then if {Formula A Time} < {Formula B Time} then 1.0 else 0.0 end
  90.       [] le(1:A 2:B) then if {Formula A Time} =< {Formula B Time} then 1.0 else 0.0 end
  91.       [] gt(1:A 2:B) then if {Formula A Time} > {Formula B Time} then 1.0 else 0.0 end
  92.       [] ge(1:A 2:B) then if {Formula A Time} >= {Formula B Time} then 1.0 else 0.0 end
  93.       end
  94.    end
  95. end
  96.  
  97. declare
  98. fun{PokeBuild Pu1}
  99.    Pu = {FlattenList Pu1}
  100. in
  101.    case Pu of nil then nil
  102.    [] H|T then
  103.       case H of pokeitem(kind: K position: pt(x:X y:Y)) then
  104.      fun{$ Time}pokeitem(kind: K position: pt(x:{Formula X Time} y:{Formula Y Time}))end|{PokeBuild T}
  105.       else nil
  106.       end
  107.    end
  108. end
  109.  
  110. declare
  111. Pu = [translate(dx:time dy:time [translate(dx:time dy:time [primitive(kind:pokemon)])])]
  112.  
  113. {Browse {PokeBuild {PokeSearch Pu}}}
  114.  
  115. declare
  116. Pb = {PokeBuild {PokeSearch Pu}}
  117. {Browse {Pb.1 2.0}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement