Guest User

Untitled

a guest
Jan 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. Inductive bin : Type :=
  2. | Z
  3. | A (n : bin)
  4. | B (n : bin).
  5.  
  6. Fixpoint bin_to_nat (m:bin) : nat :=
  7. (* What to do here? *)
  8.  
  9. #include <stdio.h>
  10.  
  11. unsigned int pow2(unsigned int power)
  12. {
  13. if(power != 0)
  14. return 2 << (power - 1);
  15. else
  16. return 1;
  17. }
  18.  
  19. void rec_converter(char str[], size_t i)
  20. {
  21. if(str[i] == 'Z')
  22. printf("%c", 'Z');
  23. else if(str[i] == '0')
  24. rec_converter(str, ++i);
  25. else if(str[i] == '1')
  26. {
  27. unsigned int n = pow2(i);
  28.  
  29. for (size_t j = 0; j < n; j++)
  30. {
  31. printf("%c", 'S');
  32. }
  33. rec_converter(str, ++i);
  34. }
  35. }
  36.  
  37. int main(void)
  38. {
  39. char str[] = "11Z";
  40.  
  41. rec_converter(str, 0);
  42. printf("n");
  43.  
  44. return 0;
  45. }
  46.  
  47. unsigned int n = pow2(i);
  48.  
  49. for (size_t j = 0; j < n; j++)
  50. {
  51. printf("%c", 'S');
  52. }
  53. rec_converter(str, ++i);
  54.  
  55. Fixpoint bin_to_nat (m: bin): nat :=
  56. match m with
  57. | Z => 0
  58. | A n => 2 * (bin_to_nat n)
  59. | B n => 2 * (bin_to_nat n) + 1
  60. end.
  61.  
  62. Inductive Positive :=
  63. | one
  64. | times_two (x: Positive): Positive
  65. | times_two_plus_one (x: Positive): Positive.
  66.  
  67. Inductive BinNat :=
  68. | zero
  69. | pos (x: Positive).
Add Comment
Please, Sign In to add comment