Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
@Heimdell
Heimdell / Makefile
Last active December 21, 2015 01:48
N-body gravity simulator. There are two identical stars, rotating around the center-of-mass, and the light probe. Requires g++ >=4.6. Run "make".
SHELL = /bin/bash
all: test-c test-cc test-cpp
clean:
-rm c cpp cc
test-c: c
@echo "running c version..."
@time ./c
@Heimdell
Heimdell / Cell.hs
Last active December 25, 2015 16:09
module Cell where
data Cell item topology
= Cell
{ get :: IO item
, set :: item -> IO ()
, move :: topology -> Cell item topology
, location :: topology
}
@Heimdell
Heimdell / run.sh
Last active December 26, 2015 07:09
Sinus-generator
ghc -O3 sin-gen && ./sin-gen && aplay -f S16_LE -r 8000 test.wav
@Heimdell
Heimdell / AST.hs
Last active December 26, 2015 07:29
Lambda calculus interpreter, written with variable storage. No GC at now, so, don't use many vars. Infinite structures are impossible by construct, although some constructible finite ones can outfill the memory. Run `main` in ghci.
module AST where
import qualified Data.Map as Map
import Data.Map (Map)
import Control.Monad.State as State
import Data.List
data Ast
= App [Ast] -- stack of actions
#include <math.h>
#include <memory.h>
#include <iostream>
#include <vector>
using namespace std;
template <int WIDTH, int HEIGHT, class Cell = char, Cell empty = '?'>
struct Image
@Heimdell
Heimdell / gist:7244162
Created October 31, 2013 03:54
Radial projection test
import Control.Monad
import qualified Control.Monad.State as State
import Control.Monad.State (State)
import qualified Data.Map as Map
import Data.Map (Map)
import Data.Maybe
type Image = Map (Int, Int)
@Heimdell
Heimdell / Levelgen.hs
Last active December 28, 2015 10:08
Rogue-like game level generator
import qualified Data.Set as Set
import Data.Set (Set)
import qualified Data.Map as Map
import Data.Map (Map)
import Data.List
import System.IO
@Heimdell
Heimdell / map_can_fuse.v
Last active December 29, 2015 12:39
Definitely.
Require Import List.
Definition compose (A B C : Set) (f : B -> C) (g : A -> B) : (A -> C) :=
fun x => f (g x).
Notation "f @ g" := (compose _ _ _ f g) (at level 50).
Fixpoint map (A B : Set) (f : A -> B) (az : list A) : list B :=
match az with
Require Import List.
Fixpoint fold_left_raw
(A B : Set)
(step : A -> B -> B)
(accum : B)
(src : list A)
: B
:=
@Heimdell
Heimdell / eat-spaces.hs
Last active December 31, 2015 03:28
Utility to remove spaces from haskell sources. Recursive.
import Control.Monad
import Control.Arrow
import System.Directory (getDirectoryContents, doesDirectoryExist)
import System.Environment (getArgs)
import System.FilePath.Posix ((</>))
import Data.String.Utils (startswith, endswith, rstrip)
main :: IO ()