Is C functional or object-oriented?
>>55005199
hardly functional
>>55005199
Neither. It's procedural.
No.
>>55005203
you see that's kind of funny because in french "functional" kind of translates to "does work",
so it's a cool way of saying that C "hardly works" but using a programming paradigm way
high functioning autistic
>>55005199
Both.
>functional
https://lucabolognese.wordpress.com/2013/01/04/functional-programming-in-c/
>OO C
https://www.cs.rit.edu/~ats/books/ooc.pdf
>>55007376
Same as in any language. FP fags simply hijacked the word.
>>55005199
It's traditionally viewed as within the imperative camp
>>55007376
In French oop is poo
>>55005199
can it do thislet (^) x y = pown y x
let fs = List.map
let f1 = (*) 2
let f2 = (^) 2
let fsf1 = fs f1
let fsf2 = fs f2
printfn "%A" (fsf1 [0; 1; 2; 3])
printfn "%A" (fsf1 [2; 4; 6; 8])
printfn "%A" (fsf2 [0; 1; 2; 3])
printfn "%A" (fsf2 [2; 4; 6; 8])[0; 2; 4; 6]
[4; 8; 12; 16]
[0; 1; 4; 9]
[4; 16; 36; 64]
>>55007904
Of course not nearly as flexible (C++ has far more support with std::bind and with std::function and of course lambdas)#include <stdio.h>
#include <stdlib.h>
typedef int (*func_t)(int, int);
typedef struct {
func_t func;
int arg;
} bound_t;
bound_t* bind(func_t func, int arg)
{
bound_t* bound = malloc(sizeof(bound_t));
bound->func = func;
bound->arg = arg;
return bound;
}
void unbind(bound_t* bound)
{
free(bound);
}
void map(size_t count, int* list, const bound_t* bound)
{
if (bound->func != NULL)
{
for (size_t i = 0; i < count; ++i)
{
list[i] = bound->func(list[i], bound->arg);
}
}
}
void print(size_t count, int* list)
{
for (size_t i = 0; i < count; ++i)
{
printf("%d ", list[i]);
}
printf("\n");
}
int multiply(int a, int b)
{
return a * b;
}
int power(int a, int b)
{
int x = 1;
while (b > 0)
{
x *= a;
--b;
}
return x;
}
int main()
{
int list1[] = { 0, 1, 2, 3 };
int list2[] = { 0, 1, 2, 3 };
bound_t* f1 = bind(multiply, 2);
bound_t* f2 = bind(power, 2);
print(4, list1);
map(4, list1, f1);
print(4, list1);
print(4, list2);
map(4, list2, f2);
print(4, list2);
unbind(f2);
unbind(f1);
return 0;
}
>>55007376
>>55007845
That's all deliberate. The FP shills in the 70s were trying to use "functional" as a marketing tool, but it backfired so badly due to the poor quality, complexity, and uselessness of functional languages that calling your language "not functional" was considered a good thing.
That's not the only word they hijacked either. Another synonym they used was "applicative" which means "Having practical application; applicable." That also backfired so they switched to using "functional."
Some antonyms of "functional" are impractical, useless, worthless, and broken, which happen to describe "functional" languages a lot better than "functional" does.
>>55008869
I'm working on a better version now, stay tuned.
>>55005199
Procedural faggot
>>55009477
Functional fags on suicide watch
>>55005251
This senpai.