Gregb12

Untitled

Apr 11th, 2017
590
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. %1
  3. <01> ::= <|<=|=|<>|>=|>|in
  4. <02> ::= +|-|or
  5. <03> ::= /|div|mod|and
  6. <04> ::= not
  7.  
  8. <w1> ::= <w2>|<w1><01><w2>
  9. <w2> ::= <w3>|-<w3>|<w2><02><w3>
  10. <w3> ::= <w4>|<w3>|<03><w4>
  11. <w4> ::= <w>|<04><w>
  12. <w> ::= <atom>|(<w1>)
  13.  
  14. %2
  15. <wyr bool> ::= <wyr><op_bool><wyr>
  16. <wyr> ::= <skladnik>|<wyr><op_add><skladnik>
  17. <skladnik> ::=<czynnik>|<skladnik><op_mul><czynnik>
  18. <czynnik> ::= <wyr at>|<wyr at><op_pot><czynnik>
  19. <wyr at> ::= <liczba>|(<wyr>)
  20. <liczba> ::= <cyfra>|<cyfra><liczba>
  21. <cyfra> ::= 0|1|...|9
  22. <op_bool> ::= <|=
  23. <op_add> ::= +
  24. <op_mul> ::= *
  25. <op_pot> ::= ^
  26.  
  27. %3
  28. <cyfra> ::= 0|1|...|9
  29. <ciag cyfr> ::= <cyfra>|<ciag cyfr><cyfra.
  30. <znak> ::= +|-|<puste>
  31. <puste> ::=
  32. <wyk> ::= e
  33. <liczba> ::= <znak><ciag cyfr><wyk>|<znak><ciag cyfr>.<ciag cyfr>|<znak><ciag cyfr>.<ciag cyfr><wyk>
  34.  
  35. %7
  36. /*
  37. :- op(200, xf, !).
  38. :- arithmetic_function(!/1).
  39. */
  40. :- op(200, xf, !!).
  41. :- arithmetic_function(!!/1).
  42. /*
  43. !(N, M):-
  44.   !(1, N, 1, M).
  45.  */
  46.  
  47.  
  48. !(N, N, Acc, Acc):-!.
  49. !(Num, N, Acc, Wyn):-
  50.   NewNum is Num+1,
  51.   NewAcc is NewNum*Acc,
  52.   !(NewNum, N, NewAcc, Wyn).
  53.  
  54.  
  55.  
  56. '!!'(N, M):-
  57.   '!!'(1, N, 1, M).
  58.  
  59. '!!'(Num, N, Acc, Acc):-
  60.   Num is N-1, !.
  61. '!!'(N, N, Acc, Acc):-!.
  62. '!!'(Num, N, Acc, Wyn):-
  63.   NewNum is Num+2,
  64.   NewAcc is NewNum*Acc,
  65.   '!!'(NewNum, N, NewAcc, Wyn).
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×