Fast IFS using RPN notation
python
c
x86-64
nasm
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

rpn_mutation.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2020 Weber Yann
  3. *
  4. * This file is part of pyrpn.
  5. *
  6. * pyrpn is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * pyrpn is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "rpn_mutation.h"
  20. /**@file rpn_mutation.c
  21. * @todo continue implementation */
  22. const rpn_mutation_profile_t rpn_default_mutprof = {16,
  23. { RPN_del, RPN_del,
  24. RPN_add, RPN_add,
  25. RPN_chg, RPN_chg, RPN_chg, RPN_chg, RPN_chg, RPN_chg,
  26. RPN_upd, RPN_upd, RPN_upd, RPN_upd, RPN_upd, RPN_upd}
  27. };
  28. rpn_expr_t* rpn_expr_mutation(rpn_expr_t *src, size_t mutations)
  29. {
  30. return rpn_expr_mutation_p(src, mutations, &rpn_default_mutprof);
  31. }
  32. rpn_expr_t* rpn_expr_mutation_p(rpn_expr_t *src, size_t mutations,
  33. const rpn_mutation_profile_t *prof)
  34. {
  35. unsigned char op;
  36. prof = prof?prof:&rpn_default_mutprof;
  37. op = prof->mods[(int)(drand48() / (1.0 / prof->mods_sz))];
  38. switch(op)
  39. {
  40. case 0: // add a token
  41. break;
  42. case 1: // delete a token
  43. break;
  44. case 2: // update token type
  45. break;
  46. default: // update token, same type
  47. break;
  48. }
  49. return NULL;
  50. }