Skip to content

Instantly share code, notes, and snippets.

instance Ord StackTraceElement where
compare (StackTraceElement x1 y1 z1) (StackTraceElement x2 y2 z2) =
compare x1 x2 `mappend` compare y1 y2 `mappend` compare z1 z2
ste11 :: StackTraceElement
ste11 = StackTraceElement
{ className = "Main"
, method = "main"
, lineNumber = 12 }
ste12 :: StackTraceElement
ste12 = StackTraceElement
{ className = "Mapper"
rotateAroundX :: (Storable a, Floating a) => a -> Tensor a
rotateAroundX a = Tensor 4 4 $ V.fromList m
where m = concat $ Data.List.transpose [
[1, 0, 0, 0],
[0, cos a, -sin a, 0],
[0, sin a, cos a, 0],
[0, 0, 0, 1] ]
class AList a
instance AList Nil
instance (A x, AList xs) => AList (Cons x xs)
class Equal x y b | x y -> b
instance Equal x x True
instance Not True b => Equal x y b
class Equal x y b | x y -> b
instance x ~ y => Equal x y True
instance Equal x y False
nubRuns :: Eq a => [a] -> [a]
nubRuns [] = []
nubRuns (x : xs) = foldr (\x list -> if x == head list then list else x : list) [x] xs
{-
(x - xs)^2 + (y - ys)^2 + (z - zs)^2 = r^2
x(t) = xr + t * xv
y(t) = yr + t * yv
z(t) = zr + t * zv
(xr - xs + t * xv)^2 + (yr - ys + t * yv)^2 + (zr - zs + t * zv)^2 = r^2
t^2(xv^2 + yv^2 + zv^2) + 2t(xv(xr - xs) + yv(yr - ys) + zv(zr - zs)) +
(xr - xs)^2 + (yr - ys)^2 + (zr - zs)^2 - r^2 = 0
{-# LANGUAGE ViewPatterns #-}
module Memo where
import Data.Bits (testBit, setBit, finiteBitSize)
data Memo a b = Fork (Memo a b) b (Memo a b)
deriving Show
type Bit = Bool
newtype Bits = Bits [Bit]
{-# LANGUAGE ViewPatterns #-}
module Memo where
import Data.Bits (testBit, setBit, finiteBitSize)
data Memo a b = Fork (Memo a b) b (Memo a b)
deriving Show
type Bit = Bool
newtype Bits = Bits [Bit]