This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Runtime.InteropServices | |
type AddFunction = delegate of int * int -> int | |
[<DllImport("libc.so.6", SetLastError = true)>] | |
extern nativeint mmap(nativeint addr, uint32 length, int prot, int flags, int fd, int offset) | |
[<DllImport("libc.so.6", SetLastError = true)>] | |
extern int munmap(nativeint addr, uint32 length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// This module implements a generic [union-find](https://en.wikipedia.org/wiki/Disjoint-set_data_structure) data structure. | |
/// This structure is used to manage disjoint sets, often used in partitioning or clustering problems. | |
/// | |
/// Here is a summary of the features and members of this data structure: | |
/// | |
/// 1. **Constructor**: The `UnionFind` constructor initializes a new instance of the Union-Find data structure with | |
/// default elements of the original set specified as a sequence. This set can be extended. | |
/// | |
/// 2. **Public Members** : | |
/// - `UnionFind.AddElement` Adds a new element to the set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: FParsec, 1.1.1" | |
open FParsec | |
let ws = skipMany (pchar ' ' <|> pchar '\t') | |
let ws1 = skipMany1 (pchar ' ' <|> pchar '\t') | |
let parseComment = | |
pstring "#" >>. skipRestOfLine true >>% [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct stack_s | |
{ | |
long sz; | |
long sp; | |
void **s; | |
} *stack_t; | |
#define stack_pop(__t,__s) ((__t)_stack_pop(__s)) | |
#define stack_peek(__t,__s) ((__t)_stack_peek(__s)) | |
#define stack_is_empty(_s) (_s->sp == -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct pool_s | |
{ | |
char *next; | |
char *end; | |
} pool_t; | |
pool_t *pool_create(const size_t sz) | |
{ | |
pool_t *p = malloc(sz + sizeof *p); | |
assert(p != NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defines which shell command to use to clean the terminal, depending on the platform. | |
ifeq ($(OS), Windows_NT) | |
# Clean on Windows | |
clean_cmd = @del /s /q *.o > null | |
else | |
# Clean on UNIX systems | |
clean_cmd = @rm -f *.o | |
endif | |
# A recursive function that allows to list all files with a given extension, in folders and sub-folders, from a given source. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#ifdef _WIN32 | |
#include "mman.h" | |
#else | |
#include <sys\mman> | |
#endif | |
// This simple JIT program just returns the user input number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# riddle-of-100-prisoners | |
import numpy as np | |
import random | |
def algo(number): | |
midl = int((number / 2) - 1) | |
boxes = np.arange(number) | |
random.shuffle(boxes) |