Skip to content

Instantly share code, notes, and snippets.

View specdrake's full-sized avatar

Anurag Hooda specdrake

View GitHub Profile
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Exit
import System.IO
import Data.Char
import Database.SQLite.Simple
import Text.RawString.QQ
import Data.Text (Text)
import qualified Data.Text as T
import Database.SQLite.Simple.Types
-- For [p_1,p_2 ... p_n]
-- Find three indices i, j and k such that:
-- 1 ≤ i < j < k ≤ n;
-- p_i < p_j and p_j > p_k.
-- Or say that there are no such indices.
func :: S.Seq Int -> String
func sq = let (a,b,c,suc) = S.foldrWithIndex (\ind a (i, j, k, b) ->
case b of
0 ->
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import System.IO
import System.Random
import Data.Char
import Text.Read
import Control.Monad.IO.Class
import Control.Monad
import Data.Maybe
import Control.Monad.Trans.State as S
@specdrake
specdrake / Main.hs
Last active July 3, 2020 10:31
A simple State example in haskell
module Main where
import Control.Monad.Trans.State
import Data.Functor.Identity
type PScore = Int
type CScore = Int
type GameState = (PScore, CScore)
valFromGameState :: GameState -> (Int, Int)
valFromGameState = id
module Phone where
import Text.Trifecta
import Control.Applicative
import Data.Char
type NumberingPlanArea = Int
type Exchange = Int
type LineNumber = Int
module SemVer3 where
import Control.Applicative
import Control.Monad
import Data.Char
import Text.Trifecta
import Data.List.NonEmpty (NonEmpty(..), fromList)
type Letter = Char
-- parseLetter :: Parser Letter
f1 = (<$> ((:[]) <$>))
f1 :: (Functor f) => (f [a] -> b) -> f a -> b
:: (Functor f) => (f [a] -> b) -> (f a -> b)
(=<<) :: (Monad m) => (a -> m b) -> m a -> m b
:: (Monad m) => (a -> m b) -> (m a -> m b)
-- Applying f1 to (=<<)
f = f1 (=<<)
f :: (a -> b) -> [a] -> [b]
:: (a -> b) -> ([a] -> [b])
module Main where
import Data.Char
main :: IO ()
main = do
lf <- getLine
ls <- getLine
let m = (words lf) !! 0
let n = (words lf) !! 1
let r = (words lf) !! 2
let m1 = (words ls) !! 0
module Main where
main :: IO ()
main = do
guessI <- getLine
if (read guessI /= 0) then
oneGame True (read guessI) (1, 10)
else
return ()
module String where
import Data.List
notThe :: String -> Maybe String
notThe = wrapper . unwords . filter (\x -> x /="the" && x /="The") . words
notThe' :: String -> String
notThe' l@(x0:x1:x2:x3:x4) = case (x0) of
' ' -> case (x4) of
(' ':_) -> case (x1:x2:x3:[]) of