Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programmer's Music Mix for Dark Minds

Name: Anonymous 2016-12-30 0:47

Get to work
Enterprise IntelliJ Java Beans and Node.js ES6 Enterprise frameworks
Pajeet just won't stop talking about his shitting street
Need something to cut out the noise
Can count on Programmer's Music Mix for Dark Minds every time

https://www.youtube.com/watch?v=6dkqVj7heiA

Name: Anonymous 2017-01-05 3:26

>>7
It supports functional programming a lot better than C. JS makes partial application trivial:

function add(a, b) {
return a + b;
}

function multiply(a, b) {
return a * b;

function partialApplication(func, arg) {
return function(n) {
return func(arg, n);
}
}

var addToFive = partialApplication(add, 5);
var multiplyBySeven = partialApplication(multiply, 7);

addToFive(3); //8
multiplyBySeven(9); //63


The equivalent code in C is quite clumsy, and the resulting partially-applied functions will always stand out from "real" functions:

#include <stdio.h>

int add(int a, int b) {
return a + b;
}

int multiply(int a, int b) {
return a * b;
}

typedef struct {
int (*func)(int, int);
int arg;
} closure;

closure partialApplication(int (*f)(int, int), int n) {
closure c;
c.func = f;
c.arg = n;
return c;
}

int call(closure c, int x) {
return c.func(x, c.arg);
}

int main(void) {
closure addToFive = partialApplication(add, 5);
closure multiplyBySeven = partialApplication(multiply, 7);
call(addToFive, 3);
printf("%d\n", call(addToFive, 3)); //8
printf("%d\n", call(multiplyBySeven, 9)); //63
return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List