Permalink
Browse files

Adding string reverse

Ignore-this: e540c08076a085f909c8c8b6add2e349

darcs-hash:20100422132310-6ac22-9329f45ab1d093b2e96563f7d8d4400bd49c0811.gz
  • Loading branch information...
1 parent 5bb7fa8 commit 92e77629daedf18b0516dc368653b1390efc7adb eb committed Apr 22, 2010
Showing with 13 additions and 0 deletions.
  1. +11 −0 evm/stdfuns.c
  2. +2 −0 evm/stdfuns.h
View
@@ -112,6 +112,17 @@ char* strCons(int h, char* str) {
return buf;
}
+char* strrev(char* str) {
+ char* buf = EMALLOC((1+strlen(str))*sizeof(char));
+ int x = strlen(str);
+ buf[x+1]='\0';
+ int y = 0;
+ while(x>0) {
+ buf[y++] = str[--x];
+ }
+ return buf;
+}
+
char* append(char* x, char* y) {
char* buf = EMALLOC((strlen(x)+strlen(y))*sizeof(char));
strcpy(buf,x);
View
@@ -65,6 +65,8 @@ int strIndex(char* str, int i);
int strHead(char* str);
char* strTail(char* str);
char* strCons(int h, char* str);
+char* strrev(char* str);
+
char* append(char* x, char* y);
// Big integer arithmetic

0 comments on commit 92e7762

Please sign in to comment.