Skip to content

Instantly share code, notes, and snippets.

@Bromind
Bromind / philosophers.c
Created April 25, 2019 09:12
Dining philosophers problem
#include<stdlib.h>
#include<stdio.h>
#include<pthread.h>
pthread_mutex_t *forks;
pthread_t * philosophers;
pthread_mutex_t output_lock;
int nb_philosopher = 5;
int take(int philosopher, int fork) {
@Bromind
Bromind / morgensen.ml
Last active January 3, 2018 10:38
Quick and dirty implementation of Morgensen-Scott numerals for https://stackoverflow.com/questions/47999267
let identity = fun x -> x
let tuple = fun t1 -> fun t2 -> fun x -> x t1 t2
let proj12 = fun t -> t (fun x1 -> fun x2 -> x1)
let proj22 = fun t -> t (fun x1 -> fun x2 -> x2)
let shift0 = fun n -> fun z -> fun x0 -> fun x1 -> x0 (n z x0 x1)
let shift1 = fun n -> fun z -> fun x0 -> fun x1 -> x1 (n z x0 x1)