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
| {- | |
| Minimum distance for ray intersection to be considered important. | |
| This is due to limited numerical precision with floating point numbers. A ray could be reflected and then be immediately registered as intersecting with the object it just bounced off. | |
| -} | |
| epsilon :: Scalar | |
| epsilon = 0.1 | |
| {-| | |
| Defines a mathematical sphere. | |
| -} |
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
| #include <iostream> | |
| #include <functional> | |
| // Polymorphic Maybe type. | |
| template <typename T> | |
| class Maybe | |
| { | |
| public: | |
| // Returns True if Maybe contains a value. | |
| virtual bool isJust() = 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
| module Main where | |
| import Control.Monad (replicateM) | |
| import Control.Monad.Trans (lift) | |
| import Control.Monad.Reader (ReaderT, ask, runReaderT) | |
| import Control.Monad.Random (Rand, getRandomR, evalRand) | |
| import System.Random (getStdGen, StdGen) | |
| import Text.Printf | |
| op :: ReaderT Int (Rand StdGen) String |
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
| test :: Int -> [Int] | |
| test f | |
| | f <= 0 = [] | |
| | otherwise = f : test (f-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
| Build LeapC of project LeapC with configuration Debug | |
| CompileC build/LeapC.build/Debug/LeapC.build/Objects-normal/x86_64/leap_controller.o ../src/leap_controller.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2 | |
| cd /Users/tom/Documents/LeapC/xcode | |
| setenv LANG en_US.US-ASCII | |
| /Developer/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -Wuninitialized -Wshorten-64-to-32 -DDEBUG=1 -isysroot /Developer/SDKs/MacOSX10.6.sdk -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 -iquote /Users/tom/Documents/LeapC/xcode/build/LeapC.build/Debug/LeapC.build/LeapC-generated-files.hmap -I/Users/tom/Documents/LeapC/xcode/build/LeapC.build/Debug/LeapC.build/LeapC-own-target-headers.hmap -I/Users/tom/Documents/LeapC/xcode/build/LeapC.build/Debug/LeapC.build/LeapC-all-target-headers.hmap -iquote /Users/tom/Documents/LeapC/xcode/build/LeapC.build/Debug/LeapC.build/LeapC-project-headers.hmap -F/Users/tom/Documents/LeapC/xcode |
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
| module Main where | |
| import Criterion.Main | |
| -- We're going to use this constant as a known prime to test our functions with. | |
| testPrime :: Int | |
| testPrime = 16127 | |
| -- And a known non-prime as well. | |
| testNonPrime :: Int |
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
| trait Monoid { | |
| static fn mempty() -> self; | |
| fn mappend(other: self) -> self; | |
| } | |
| impl int: Monoid { | |
| static fn mempty() -> int { 0 } | |
| fn mappend(other: int) -> int { self + other} | |
| } |
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
| \begin{landscape} | |
| \begin{longtable}{|l|p{120pt}|p{120pt}|p{120pt}|p{120pt}|} | |
| \caption{Functional Requirements} \\ | |
| \hline | |
| \textbf{ID} & \textbf{What} & \textbf{How} & \textbf{Test} & \textbf{Expected Result} \\ \hline | |
| \endfirsthead | |
| \multicolumn{4}{c}% | |
| {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\ | |
| \hline | |
| \textbf{ID} & \textbf{What} & \textbf{How} & \textbf{Test} & \textbf{Expected Result} \\ \hline |
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
| diffuseM :: Colour -> Material () (BSDF Colour) | |
| diffuseM col = proc () -> do | |
| out <- diffuse -< col -- Get diffuse shading | |
| shad <- traceM <<< getInidentRay -< () -- Test path to light | |
| returnA -< maybe holdout (\(_,_,_,e) -> if e then out else holdout) shad -- Set BSDF to black if in shadow |
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
| #include <iostream> | |
| #include <functional> | |
| #include <memory> | |
| #include <assert.h> | |
| // Based on Bartosz Milewski's immutable list class. | |
| // http://bartoszmilewski.com/2013/11/13/functional-data-structures-in-c-lists/ | |
| // Defined externally to List because it needs to be independent from the size parameter. | |
| template <typename T> |