The output directory is now cleared when the program is ran.
This commit is contained in:
parent
a36de2bde1
commit
cd0f9dd456
2 changed files with 29 additions and 11 deletions
|
|
@ -19,16 +19,32 @@
|
|||
-- main = apply (krimp) 2 3;
|
||||
-- answer: 5
|
||||
|
||||
fibbonaci : Int -> Int;
|
||||
fibbonaci x = case x of {
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
-- abusing overflows to represent negatives like a boss
|
||||
_ => (fibbonaci (x - 2))
|
||||
+ (fibbonaci (x - 1))
|
||||
-- fibbonaci : Int -> Int;
|
||||
-- fibbonaci x = case x of {
|
||||
-- 0 => 0,
|
||||
-- 1 => 1,
|
||||
-- -- abusing overflows to represent negatives like a boss
|
||||
-- _ => (fibbonaci (x - 2))
|
||||
-- + (fibbonaci (x - 1))
|
||||
-- } : Int;
|
||||
-- main : Int;
|
||||
-- main = fibbonaci 10;
|
||||
-- answer: 55
|
||||
|
||||
succ : Int -> Int;
|
||||
succ x = x - 1;
|
||||
|
||||
isZero : Int -> Int;
|
||||
isZero x = case x of {
|
||||
0 => 1,
|
||||
_ => 0
|
||||
} : Int;
|
||||
|
||||
minimization : (Int -> Int) -> Int -> Int;
|
||||
minimization p x = case p x of {
|
||||
1 => 0,
|
||||
_ => minimization p (succ x)
|
||||
} : Int;
|
||||
|
||||
main : Int;
|
||||
main = fibbonaci 10;
|
||||
-- answer: 55
|
||||
main = minimization isZero 10;
|
||||
|
|
@ -14,7 +14,8 @@ import Data.List.Extra (isSuffixOf)
|
|||
import LambdaLifter (lambdaLift)
|
||||
import Renamer (rename)
|
||||
import System.Directory (createDirectory, doesPathExist,
|
||||
getDirectoryContents,
|
||||
getDirectoryContents, removeDirectory,
|
||||
removeDirectoryRecursive,
|
||||
setCurrentDirectory)
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
|
|
@ -54,7 +55,8 @@ main' debug s = do
|
|||
--putStrLn compiled
|
||||
|
||||
check <- doesPathExist "output"
|
||||
unless check (createDirectory "output")
|
||||
when check (removeDirectoryRecursive "output")
|
||||
createDirectory "output"
|
||||
writeFile "output/llvm.ll" compiled
|
||||
if debug then debugDotViz else putStrLn compiled
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue