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 characters
module Prova2 where | |
--Questao 1 | |
data ListaAninhada a = Elem a | Lista [ListaAninhada a] | |
planificar :: ListaAninhada a -> [a] | |
planificar (Elem a) = [a] | |
planificar (Lista l) = concat $ map planificar l |
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 characters
{-# LANGUAGE NegativeLiterals #-} | |
module Tipos where | |
{- | |
Questao 1 | |
Semelhante à função somar, defina uma função de multiplicação recursiva para números | |
naturais mult :: Nat -> Nat -> Nat. Dica: use a função somar definida no material de aula para os números naturais. | |
-} |
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 characters
module Lib | |
( someFunc, getLine', putStr', putStrLn', putStr'', acumular, somador, somador2, obterLinha | |
) where | |
import Text.Printf | |
import System.IO | |
someFunc :: IO () | |
someFunc = putStrLn "someFunc" |
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 characters
module Lib | |
( reverso, converter, rotateLeft, removeMin, menor2, menor, escolheFuncoes, mapF | |
) where | |
{- | |
Questao 1 | |
Implemente a função reverso :: [a] -> [a], que inverte a ordem dos elementos de uma lista. OBS: Não é permitido usar a função reverse da biblioteca padrão. | |
Ex: reverso "abc" | |
Main> "cba" |
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 characters
import java.util.Arrays; | |
public class Quicksort { | |
public static void ordenar(int[] vetor, int inicio, int fim) { | |
if (inicio < fim) { | |
int particao = particionar(vetor, inicio, fim); | |
ordenar(vetor, inicio, particao - 1); | |
ordenar(vetor, particao + 1, fim); | |
} |
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 characters
foldr :: (a -> b -> b) -> b -> [a] -> b | |
foldr f v [] = v | |
foldr f v (x:xs) = f x (foldr f v xs) |
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 characters
#exercicio 1 | |
#Escreva um programa que desenha um quadrado onde quer que o mouse esteja na tela, | |
#centralizado na posição do mouse. O quadrado deve deixar um rastro na tela | |
#quando você mover o mouse. | |
def setup(): | |
size(300,300) | |
def draw(): | |
tamanhoLado = 30 | |
rect(mouseX-tamanhoLado/2, mouseY - tamanhoLado/2, tamanhoLado, tamanhoLado) |
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 characters
# Copyright (c) 2013 Georgios Gousios | |
# MIT-licensed | |
# Edited to handle two new tables: postLinks and tags that are present in the 2014 dataset | |
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; | |
use stackoverflow; | |
create table badges ( | |
Id INT NOT NULL PRIMARY KEY, |