This file contains hidden or 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
// | |
// hash_table.hpp | |
// The Shift-C compiler | |
// | |
// Created by Arpad Goretity (H2CO3) | |
// on 02/06/2015 | |
// | |
// Licensed under the 2-clause BSD License | |
// |
This file contains hidden or 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 { | |
int x; | |
} Foo; | |
int main() | |
{ | |
int n = 1; | |
int VLA_is_not_in_cplusplus[n]; | |
Foo f = { .x = 42 }; | |
f = (Foo){ 42 }; |
This file contains hidden or 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
// takes no arguments, and returns a StringLiteral AST node containing the current date formatted as a string | |
macro CompilationDateAsString() -> std::ASTNode * { | |
// imagine that we already have date/time support in our standard library | |
let cur_date = new std::Date(); | |
return std::StringLiteralAST(cur_date.to_string()); | |
} | |
// So, the following main() function: | |
fn main() { | |
print(@CompilationDateAsString()); |
This file contains hidden or 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
def read_FASTA_file(fname): | |
with open(fname, "r") as f: | |
sequs = filter(len, f.read().split(">")) | |
return ["".join(seq.split("\n")[1:]) for seq in sequs] |
This file contains hidden or 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 <sys/mman.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
void try_mprotect(void *p, size_t len, int prot) | |
{ | |
if (mprotect(p, len, prot) != 0) { |
This file contains hidden or 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
$ swift tree.swift | |
tree.swift:1:8: error: recursive value type 'Node' is not allowed | |
struct Node { | |
^ | |
0 swift 0x000000010248933b llvm::sys::PrintStackTrace(__sFILE*) + 43 | |
1 swift 0x0000000102489a7b SignalHandler(int) + 379 | |
2 libsystem_platform.dylib 0x00007fff95d1bf1a _sigtramp + 26 | |
3 libsystem_platform.dylib 0x00007fff5f689e20 _sigtramp + 3382107936 | |
4 swift 0x000000010067889b swift::irgen::TypeConverter::convertAnyNominalType(swift::CanType, swift::NominalTypeDecl*) + 379 | |
5 swift 0x0000000100678295 swift::irgen::TypeConverter::convertType(swift::CanType) + 181 |
This file contains hidden or 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
override func llvmType() -> LLVMTypeRef { | |
// a function with a 'Void' argument is a | |
// special case: it means '0 arguments'. | |
var args: [LLVMTypeRef] = [] | |
if self.argType != VoidType() { | |
args.append(self.argType.llvmType()) | |
} | |
return LLVMFunctionType( | |
self.retType.llvmType(), |
This file contains hidden or 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
// cloud must be sorted beforehand | |
size_t num_rows = 10; | |
size_t num_cols = 10; | |
size_t min_x = … // find from cloud | |
size_t max_x = … // find from cloud | |
size_t dx = (max_x - min_x) / num_rows; | |
size_t min_y = … // find from cloud |
This file contains hidden or 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 <vector> | |
#include <array> | |
#include <cstdio> | |
#include <iostream> | |
#include <random> | |
enum State: unsigned char { | |
Empty, | |
X, |
This file contains hidden or 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 <stdio.h> | |
#include <spn/ctx.h> | |
typedef struct { | |
SpnContext *ctx; | |
SpnFunction *fn; | |
SpnValue arg; | |
} CallbackData; |