I will call the C code with function names f1, f2, and f3, in the same order that your three Clojure functions were given in your question. I have not attempted to compile and run these, but they should be pretty close, since I have used C quite a bit.
char *f1 (long x)
{
if (x >= 0) {
return "X é positivo";
} else if (x < 0) {
return "X é negativo";
}
}
One possible difference in behavior is that the returned string is ASCII encoding with default C compiler options at least, rather than Clojure's UTF-16 for Unicode. Also I am not sure whether the strings returned by f1 are mutable or not.
bool f2(long x)
{
if (x == 0) {
printf("Zero\n");
return TRUE;
} else {
printf("Outro valor\n");
return FALSE;
}
}
For f3, I know that in C with a library called varargs one can write C functions that take a variable number of arguments, but it is a bit tedious to use, and I don't have it memorized precisely how. I will write a C function that always takes two arguments, and thus implements the 2-argument version of the Clojure function, but not the 1-arg version.
There are also many many slight variations on how one can represent lists of things in C, and the C code for traversing a list depends upon exactly how one represents those. I will pick one way to do it, where each element is an instance of a C struct that contains one number, and a next pointer to the next struct in the list.
typedef struct list_elem {
long number;
list_elem_t *next;
} list_elem_t;
long f3(long total, list_elem_t *lst)
{
if (lst == NULL) {
return total;
} else {
return f3(lst->number + total, lst->next);
}
}