Last active
June 27, 2019 22:41
-
-
Save pietroluongo/885a6c3885ca8a49b6770704e54d2ca5 to your computer and use it in GitHub Desktop.
Revisions
-
pietroluongo revised this gist
Jun 27, 2019 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -25,8 +25,15 @@ buscar x (Node a l r) | x < a = buscar x l | x > a = buscar x r data Fila a = Empty | Fila a (Fila a) deriving (Show) vazia :: Fila a vazia = Empty -- inserir :: (Maybe a) => a -> Fila a -> Fila a insereInicio a Empty = Fila (a) (Empty) insereInicio a (Fila x y) = Fila (a) (Fila x y) insereFinal a Empty = Fila (Empty) (a) insereFinal a (Fila x y) = Fila (Fila x y) a -
pietroluongo revised this gist
Jun 27, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ -- Monads https://medium.com/@julianoalves/functors-applicatives-e-monads-explicados-com-desenhos-2c45d5db7d25 data Arv a = Vazia | Node a (Arv a) (Arv a) deriving (Eq, Show, Read) instance Functor Arv where -
pietroluongo revised this gist
Jun 27, 2019 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ data Arv a = Vazia | Node a (Arv a) (Arv a) deriving (Eq, Show, Read) instance Functor Arv where fmap f Vazia = Vazia fmap f (Node a l r) = Node (f a) (fmap f l) (fmap f r) singleton :: a -> Arv a singleton a = Node a Vazia Vazia @@ -18,4 +22,10 @@ buscar _ Vazia = False buscar x (Node a l r) | x == a = True | x < a = buscar x l | x > a = buscar x r type No = Int type Adj b = [(b, No)] type Contexto a b = (Adj b, No, a, Adj b) data Grafo a b = Vazio | Conectado (Contexto a b) (Grafo a b) deriving(Show) -
pietroluongo revised this gist
Jun 27, 2019 . 1 changed file with 19 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,21 @@ data Arv a = Vazia | Node a (Arv a) (Arv a) deriving (Eq, Show, Read) singleton :: a -> Arv a singleton a = Node a Vazia Vazia insere :: (Ord a) => a -> Arv a -> Arv a insere x Vazia = singleton x insere x (Node a l r) | x == a = Node x l r | x < a = Node a (insere x l) r | x > a = Node a l (insere x r) criar :: (Ord a) => [a] -> Arv a criar xs = foldr insere Vazia xs buscar :: (Ord a) => a -> Arv a -> Bool buscar _ Vazia = False buscar x (Node a l r) | x == a = True | x < a = buscar x l | x > a = buscar x r -
pietroluongo created this gist
Jun 27, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ data Arv a = Vazia | Node a (Arv a) (Arv a) deriving (Eq, Show)