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
connectStatement :: String -> State -> Statement -> State | |
connectStatement name state stmt = case stmt of | |
AST.Line expr -> connectExpression name expr state | |
AST.If cond th el -> let s = connectStatement name (connectExpression name state cond) th in case el of | |
Just ex -> connectExpression name s ex | |
Nothing -> s | |
AST.While cond s -> connectStatement name (connectEpxression name state cond) s | |
AST.Routine ss -> foldl (connectStatement name) state ss | |
_ -> | |
let (this, expr) = case stmt of |
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
instance Ord StackTraceElement where | |
compare (StackTraceElement x1 y1 z1) (StackTraceElement x2 y2 z2) = | |
compare x1 x2 `mappend` compare y1 y2 `mappend` compare z1 z2 |
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
ste11 :: StackTraceElement | |
ste11 = StackTraceElement | |
{ className = "Main" | |
, method = "main" | |
, lineNumber = 12 } | |
ste12 :: StackTraceElement | |
ste12 = StackTraceElement | |
{ className = "Mapper" |
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
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] ] |
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 AList a | |
instance AList Nil | |
instance (A x, AList xs) => AList (Cons x xs) |
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 Equal x y b | x y -> b | |
instance Equal x x True | |
instance Not True b => Equal x y b |
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 Equal x y b | x y -> b | |
instance x ~ y => Equal x y True | |
instance Equal x y False |
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
nubRuns :: Eq a => [a] -> [a] | |
nubRuns [] = [] | |
nubRuns (x : xs) = foldr (\x list -> if x == head list then list else x : list) [x] xs |
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
{- | |
(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 |
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 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] |