Skip to content

Instantly share code, notes, and snippets.

@ericshortcut
Last active September 12, 2020 02:06
Show Gist options
  • Select an option

  • Save ericshortcut/6124d67231a7c73905726c45cde63080 to your computer and use it in GitHub Desktop.

Select an option

Save ericshortcut/6124d67231a7c73905726c45cde63080 to your computer and use it in GitHub Desktop.

Revisions

  1. ericshortcut revised this gist Sep 12, 2020. No changes.
  2. ericshortcut created this gist Aug 5, 2020.
    49 changes: 49 additions & 0 deletions functions.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@

    texto = "String"
    texto2 = ['S','t','r','i','n','g']
    texto3 = ['a'..'z']

    lista = []
    lista2 = [1..10]
    lista3 = [1,4..]


    _map :: (a -> b) -> [a] -> [b]
    _map f [] = []
    _map f (x:xs) = [f x] ++ (_map f xs)


    _filter :: (a -> Bool) -> [a] -> [a]
    _filter f [] = []
    _filter f (x:xs)
    | f x = [x] ++ (_filter f xs)
    | otherwise = _filter f xs

    _filter2 f [] = []
    _filter2 f (x:xs)
    | f x = [x] ++ (_filter f xs)
    | otherwise = _filter f xs

    fun3 acc item = acc ++ "," ++ (show item)


    data Company = Enterprise { key::Int, name::String } deriving Show

    data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show, Read, Eq)

    arvoreToList :: Show a => Tree a -> IO ()
    arvoreToList EmptyTree = return ()
    arvoreToList (Node a l r) = do
    arvoreToList l
    putStrLn $ show a
    arvoreToList r

    companies = [ (Enterprise k ("Company" ++ show k)) | k <-[1..] ]


    filtroMenor x (Enterprise k _ ) = k > x

    extractName (Enterprise _ nome) = nome