Mercurial > hg > Papers > 2012 > aplas
changeset 27:33df9b3612f0
add src
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 15 Jun 2012 20:12:37 +0900 |
parents | 680becde8c9f |
children | c9a55906a64f |
files | paper/rectype.ind paper/src/fibonacci2.cbc paper/src/fibonacci2_norec.cbc paper/src/norectype.cbc |
diffstat | 4 files changed, 125 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/paper/rectype.ind Fri Jun 15 20:07:24 2012 +0900 +++ b/paper/rectype.ind Fri Jun 15 20:12:37 2012 +0900 @@ -392,6 +392,7 @@ There was no difference in the results are as we predicted. + --Conclusion We have designed and implemented Continuation based language for practical use. @@ -403,7 +404,3 @@ - - - -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paper/src/fibonacci2.cbc Fri Jun 15 20:12:37 2012 +0900 @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <stdlib.h> +__code print(__rectype *p, long int num, long int count, long int result, long int prev) { + printf("fibonacci(%d) = %ld\n",num,result); + goto cs_while(print, num, count, result, prev); +// exit(0); +} + +__code fibonacci(__rectype *p, long int num, long int count, long int result, long int prev) { +//__code fibonacci(__code (*p)(__code(*)(__rectype),int), long int num, long int count, long int result, long int prev) { + if (count == 0) { + result += 0; + count++; + } else if (count == 1) { + result += 1; + count++; + } else if (count > 1){ + long int tmp = prev; + prev = result; + result = result + tmp; + count++; + } else { + printf("please enter nutural number\n"); + exit(0); + } + if (num < count) { + goto p(fibonacci, num, count, result, prev); + } + goto fibonacci(p, num, count, result, prev); +} + +__code cs_while(__rectype *p, long int num, long int count, long int result, long int prev) { + if (num > 0) { + num--; + goto fibonacci(print, num, 0, 0, 0); + } + exit(0); +} + + +int main(int argc, char* argv[]) { + if (argc < 2) { + printf("usage: ./fibonacci number \n"); + exit(0); + } + long int num = (long int)atoi(argv[1]); + goto fibonacci(print, num, 0, 0, 0); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paper/src/fibonacci2_norec.cbc Fri Jun 15 20:12:37 2012 +0900 @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +//__code print(__rectype *p, long int num, long int count, long int result, long int prev) { +__code print(__code (*p)(__code(*)(),long int,long int,long int,long int), long int num, long int count, long int result, long int prev) { + printf("fibonacci(%d) = %ld\n",num,result); + goto cs_while(print, num, count, result, prev); +// exit(0); +} + +//__code fibonacci(__rectype *p, long int num, long int count, long int result, long int prev) { +__code fibonacci(__code (*p)(__code(*)(),long int,long int, long int,long int), long int num, long int count, long int result, long int prev) { + if (count == 0) { + result += 0; + count++; + } else if (count == 1) { + result += 1; + count++; + } else if (count > 1){ + long int tmp = prev; + prev = result; + result = result + tmp; + count++; + } else { + printf("please enter nutural number\n"); + exit(0); + } + if (num < count) { + goto p(fibonacci, num, count, result, prev); + } + goto fibonacci(p, num, count, result, prev); +} + +//__code cs_while(__rectype *p, long int num, long int count, long int result, long int prev) { +__code cs_while(__code (*p)(__code(*)(),long int, long int, long int, long int), long int num, long int count, long int result, long int prev) { + if (num > 0) { + num--; + goto fibonacci(print, num, 0, 0, 0); + } + exit(0); +} + + +int main(int argc, char* argv[]) { + if (argc < 2) { + printf("usage: ./fibonacci number \n"); + exit(0); + } + long int num = (long int)atoi(argv[1]); + goto fibonacci(print, num, 0, 0, 0); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paper/src/norectype.cbc Fri Jun 15 20:12:37 2012 +0900 @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +__code print(__code (*p)(__code(*)())) +{ + printf("print\n"); + exit(0); +} +__code csA(__code (*p)(__code(*)())) +{ + goto p(csA); +} + +void main1() +{ + goto csA(print); +} + +int main() +{ + main1(); + return 0; +}