Renderer and basis for physics and lighting.
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
{-# language PatternSynonyms #-} | |
import Text.ParserCombinators.Parsec hiding (token) | |
data SExpr info atom | |
= Atom info atom | |
| SExpr info [SExpr info atom] | |
sexpr_elim onAtom onSexpr = recure |
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
find(write, _, [], [], []). | |
find(_, X, [X | After], [], After). | |
find(Mode, X, [Y | Rest], [Y | Before], After) | |
:- find(Mode, X, Rest, Before, After). | |
access(Mode, Label, Pred, I, O) :- | |
find(Mode, Label - X, I, B, A), | |
!, | |
call(Pred, X, Y), |
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
require 'colorize' | |
class String | |
def indent | |
lines.map { |l| ' ' + l }.join('') | |
end | |
def nest | |
if lines.count == 1 then |
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
require 'colorize' | |
class ParseError < Exception | |
end | |
class EOF < ParseError | |
end | |
class Stream < Struct.new :stream, :line, :col, :offset |
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
{-# language GADTs #-} | |
{-# language RankNTypes #-} | |
{-# language NamedFieldPuns #-} | |
{- | |
This is an universal zipper (functional-update iterator) over any recursive | |
data structure. | |
You can enter /any/ data structure 'a' and navigate between recursion points |
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
{-# language NamedFieldPuns #-} | |
{-# language GeneralizedNewtypeDeriving #-} | |
import Control.Monad (when) | |
import Control.Monad.IO.Class (liftIO) | |
import Control.Monad.Reader (ReaderT(..), asks) | |
import Control.Monad.Primitive (PrimMonad, PrimState) | |
import Data.Bits (testBit, (.|.), shiftL) |
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
class Integer | |
def orBit(i, bool) | |
if bool then self | (1 << i) else self end | |
end | |
def bit(i) | |
mask = 1 << i | |
(self & mask) / mask | |
end | |
end |
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
parseOp(Soup, Operator) | |
:- append([Operator], Pattern) | |
, append(Pattern, Soup) | |
. | |
opTable(Table) :- | |
Table = | |
[ [Whole, [<], Index, [>]] -> index(left, Whole, Index) | |
, [[if], Bool, [then], Yes, [else], No] -> if_then_else_(right, Bool, Yes, No) |
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
{-# language TypeFamilies #-} | |
{-# language TypeApplications #-} | |
{-# language ScopedTypeVariables #-} | |
{-# language MultiParamTypeClasses #-} | |
{-# language FlexibleInstances #-} | |
{-# language FlexibleContexts #-} | |
{-# language UndecidableInstances #-} | |
{-# language AllowAmbiguousTypes #-} | |
{-# language GeneralizedNewtypeDeriving #-} |