This file contains 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
{ | |
"name": "tstuts", | |
"version": "1.0.0", | |
"description": "TypeScript environment to follow tutorials", | |
"main": "dist/app.js", | |
"scripts": { | |
"start": "tsc && node dist/app.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", |
This file contains 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 (main) where | |
import RecursiveContents | |
import System.FilePath (takeExtension) | |
import System.IO (hPutStrLn,stderr) | |
import GHC.IO.Encoding (setLocaleEncoding, utf8) | |
import System.Environment (getArgs) | |
hasExtension :: String -> -- extension | |
String -> -- filepath |
This file contains 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 RecursiveContents | |
main :: IO () | |
main = do | |
contents <- getRecursiveContents "." | |
mapM_ putStrLn contents |
This file contains 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 RecursiveContents (getRecursiveContents) | |
where | |
import Control.Monad (forM) | |
import Control.Applicative (liftA2) | |
import System.Directory (doesDirectoryExist, listDirectory) | |
import System.FilePath ((</>)) | |
myFilterM :: (Applicative m) => (a -> m Bool) -> [a] -> m ([a],[a]) |
This file contains 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
cabal: Could not resolve dependencies: | |
[__0] trying: base-4.12.0.0/installed-4.1... (user goal) | |
[__1] trying: bytestring-0.10.10.0 (user goal) | |
[__2] next goal: directory (user goal) | |
[__2] rejecting: directory-1.3.4.0, directory-1.3.3.2, directory-1.3.3.1 | |
(constraint from user target requires ==1.3.3.0) | |
[__2] trying: directory-1.3.3.0/installed-1.3... | |
[__3] next goal: Win32 (dependency of directory) | |
[__3] rejecting: Win32-2.6.1.0/installed-2.6... (conflict: | |
bytestring==0.10.10.0, Win32 => bytestring==0.10.8.2/installed-0.1...) |
This file contains 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 HighestClose where | |
import qualified Data.ByteString.Lazy.Char8 as L | |
closing = readPrice . (!!7) . L.split ';' | |
readPrice :: L.ByteString -> Maybe Int | |
readPrice str = do | |
(tl,rest) <- L.readInt str | |
case rest of | |
L.empty -> Nothing |
This file contains 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 ExeMagic where | |
import qualified Data.ByteString.Lazy as L | |
hasExeMagic :: L.ByteString -> Bool | |
hasExeMagic content = L.take 2 content == exeMagic | |
where exeMagic = L.pack [0x4D, 0x5A] | |
isExeFile :: FilePath -> IO Bool |
This file contains 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
myGroup :: (Eq a) => [a] -> [[a]] | |
myGroup = foldr myMatchMaker [] | |
where myMatchMaker x' ((x:xs):xss) = if x' == x then (x':x:xs):xss else [x']:(x:xs):xss | |
myMatchMaker x' [] = [[x']] |
This file contains 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
import System.Environment (getArgs) | |
import Data.Char (isAsciiLower, isAsciiUpper, isDigit) | |
import Data.List (intercalate) | |
splitWith :: (a -> Bool) -> [a] -> [[a]] | |
splitWith pred = foldr f [[]] | |
where f elem acc@(x:xs) | pred elem = (elem:x):xs | |
| otherwise = []:acc |
This file contains 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 Hull where | |
data Direction = L | R | S | |
instance Show Direction where | |
show L = "Left" | |
show R = "Right" | |
show S = "Straight" |
NewerOlder