Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare
- fun{AppendList X Y}
- case X of nil then Y
- [] H|T then H|{AppendList T Y}
- end
- end
- declare
- fun{FlattenList X}
- fun{IsList L}
- case L of nil then true
- [] H|T then true
- else false
- end
- end
- in
- case X of nil then nil
- [] H|T then
- if {IsList H} then {AppendList {FlattenList H}{FlattenList T}}
- else H|{FlattenList T}
- end
- end
- end
- declare
- fun{Primitive K}
- case K of road then
- realitem(kind: road p1: pt(x: 0.0 y: 0.0) p2: pt(x: 1.0 y: 0.0))
- [] building then
- 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))
- [] water then
- 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))
- [] pokemon then
- pokeitem(kind: pokemon position: pt(x: 0.0 y: 0.0))
- [] pokestop then
- pokeitem(kind: pokestop position: pt(x: 0.0 y: 0.0))
- [] arena then
- pokeitem(kind: arena position: pt(x: 0.0 y: 0.0))
- end
- end
- declare
- fun{PokeTranslate Dx Dy L1}
- L = {FlattenList L1}
- in
- case L of nil then nil
- [] H|T then
- case H of primitive(kind: K) then
- {PokeTranslate Dx Dy [{Primitive K}]}|{PokeTranslate Dx Dy T}
- [] pokeitem(kind: K position: pt(x: X y: Y)) then
- pokeitem(kind: K position: pt(x: plus(X Dx) y: plus(Y Dy)))|{PokeTranslate Dx Dy T}
- [] translate(dx: D1 dy: D2 1:Ru) then
- {PokeTranslate Dx Dy {PokeTranslate D1 D2 Ru}}|{PokeTranslate Dx Dy T}
- end
- end
- end
- declare
- fun{PokeSearch Pu}
- case Pu of nil then nil
- [] H|T then
- case H of primitive(kind: K) then {Primitive K}|{PokeSearch T}
- [] translate(dx: Dx dy: Dy 1: Pu2) then
- {FlattenList {PokeTranslate Dx Dy Pu2}}|{PokeSearch T}
- end
- end
- end
- declare
- fun{Formula F Time}
- % donne les 'formules' du monde pokemon
- if {Float.is F} then F
- else
- case F
- of time then Time
- [] plus(1:A 2:B) then {Formula A Time} + {Formula B Time}
- [] minus(1:A 2:B) then {Formula A Time} - {Formula B Time}
- [] mult(1:A 2:B) then {Formula A Time} * {Formula B Time}
- [] 'div'(1:A 2:B) then {Formula A Time} / {Formula B Time}
- [] cos(1:A) then {Float.cos {Formula A Time}}
- [] sin(1:A) then {Float.sin {Formula A Time}}
- [] tan(1:A) then {Float.tan {Formula A Time}}
- [] exp(1:A) then {Float.exp {Formula A Time}}
- [] log(1:A) then {Float.log {Formula A Time}}
- [] neg(1:A) then ~{Formula A Time}
- [] ite(1:A 2:B 3:C) then if {Formula A Time} == 0.0 then {Formula C Time} else {Formula B Time} end
- [] eq(1:A 2:B) then if {Formula A Time} == {Formula B Time} then 1.0 else 0.0 end
- [] ne(1:A 2:B) then if {Formula A Time} \= {Formula B Time} then 1.0 else 0.0 end
- [] lt(1:A 2:B) then if {Formula A Time} < {Formula B Time} then 1.0 else 0.0 end
- [] le(1:A 2:B) then if {Formula A Time} =< {Formula B Time} then 1.0 else 0.0 end
- [] gt(1:A 2:B) then if {Formula A Time} > {Formula B Time} then 1.0 else 0.0 end
- [] ge(1:A 2:B) then if {Formula A Time} >= {Formula B Time} then 1.0 else 0.0 end
- end
- end
- end
- declare
- fun{PokeBuild Pu1}
- Pu = {FlattenList Pu1}
- in
- case Pu of nil then nil
- [] H|T then
- case H of pokeitem(kind: K position: pt(x:X y:Y)) then
- fun{$ Time}pokeitem(kind: K position: pt(x:{Formula X Time} y:{Formula Y Time}))end|{PokeBuild T}
- else nil
- end
- end
- end
- declare
- Pu = [translate(dx:time dy:time [translate(dx:time dy:time [primitive(kind:pokemon)])])]
- {Browse {PokeBuild {PokeSearch Pu}}}
- declare
- Pb = {PokeBuild {PokeSearch Pu}}
- {Browse {Pb.1 2.0}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement