Skip to content

Instantly share code, notes, and snippets.

View tibbe's full-sized avatar

Johan Tibell tibbe

View GitHub Profile
test :: [Int] -> [Int]
test [] = []
test (x:xs)
| even x = x : test xs
| otherwise = test xs
even :: Int -> Bool
even x = x `mod` 2 == 0
test :: [Int] -> [Int]
test xs = filter even xs
{-# INLINE filter #-}
test :: [Int] -> [Int]
test [] = []
test (x:xs)
| x `mod` 2 == 0 = x : test xs
| otherwise = test xs
test :: [Int] -> [Int]
test xs = filter (\x -> x `mod` 2 == 0) xs
filter :: (a -> Bool) -> [a] -> [a]
filter p = go
where
go [] = []
go (x:xs)
| p x = x : go xs
| otherwise = go xs
filter :: (a -> Bool) -> [a] -> [a]
filter _ [] = []
filter p (x:xs)
| p x = x : filter p xs
| otherwise = filter p xs
member :: Int -> [Int] -> Bool
member n = go
where
go [] = False
go (x:xs)
| x == n = True
| otherwise = go xs
member :: Int -> [Int] -> Bool
member _ [] = False
member n (x:xs)
| x == n = True
| otherwise = member n xs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy as S
import qualified Data.Text as T
import qualified Data.Text.Lazy.Encoding as E
import Data.Text.Template