Skip to content

Instantly share code, notes, and snippets.

View Mr-Andersen's full-sized avatar

Andrey Vlasov Mr-Andersen

View GitHub Profile
{-# OPTIONS --overlapping-instances #-}
module Pointer where
open import Prelude
-- Allowes retrieving data by valid pointer
data Heap : Set
private variable h : Heap
-- Works (no `List` at all) ------------------------------------------------------
data Layers2 : Nat -> Type -> Type where
Leaf2 : t -> Layers2 lvl t
Node2 : Layers2 (S lvl) t -> Layers2 (S lvl) t -> Layers2 lvl t
total
mapLayers2 : (a -> b) -> Layers2 lvl a -> Layers2 lvl b
mapLayers2 f (Leaf2 x) = Leaf2 (f x)
mapLayers2 f (Node2 left right) = Node2 (mapLayers2 f left) (mapLayers2 f right)
@Mr-Andersen
Mr-Andersen / kernel.cl
Created April 2, 2020 19:57
ocl bug report
typedef struct {
float mass;
float rx;
float ry;
float vx;
float vy;
} Particle_t;
__kernel void time_to_collision(
__global Particle_t parts[PART_NUM],
@Mr-Andersen
Mr-Andersen / Variant.cpp
Last active August 1, 2024 08:18
Implementation of tagged union without typeinfo library. Beware: this code contains a dozen undefined behaviours and a dozen more. Use only as inspiration.
#include <iostream>
// get_type<i, Ts...>::type -> Ts[i] (Compile error of i >= length(Ts))
template<size_t i, typename T, typename... Ts>
struct get_type {
typedef typename get_type<i - 1, Ts...>::type type;
};
template<typename T, typename... Ts>