Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
I hereby claim:
- I am vladymir on github.
- I am vladymirlb (https://keybase.io/vladymirlb) on keybase.
- I have a public key ASBmzIREtN1_TU0C_rGd_G3QjyqMFvXHX3WDU-QjPKLTRAo
To claim this, I am signing this object:
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
drop database mercadinho; | |
create database mercadinho; | |
use mercadinho; | |
create table produto ( | |
id int auto_increment primary key, | |
nome varchar(255) not null, | |
valor decimal(10,2) not null | |
); |
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
CREATE TABLE Pessoa ( | |
id_pessoa int NOT NULL AUTO_INCREMENT, | |
nome VARCHAR(255) NOT NULL, | |
PRIMARY KEY(id_pessoa)); | |
CREATE TABLE Gato ( | |
id_gato int NOT NULL AUTO_INCREMENT, | |
nome VARCHAR(255) NOT NULL, | |
id_pessoa int, | |
PRIMARY KEY(id_gato), |
Seja um conjunto A = {a,b,c} e R uma relação em A onde R = {(a,b), (b,c)}, o fecho transitivo deve conter a tupla (a,c), uma vez que (a,b) e (b,c) pertencem à R, então, por transitividade, (a,c) deve estar na nova relação: R+ = {(a,b),(b,c),(a,c)} Já o fecho reflexivo de R resulta em {(a,b),(b,c),(a,a),(b,b),(c,c)} O fecho transitivo-reflexivo será {(a,b),(b,c),(a,c),(a,a),(b,b),(c,c)}
Já a função flatten, o exemplo é o seguinte: seja A uma lista A=[1,[2,[3,[4]]]], flatten(A) = [1,2,3,4] (obs. não importando a profundidade do aninhamento das listas, a função deve sempre retornar uma lista plana)
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
from collections import deque | |
from math import inf | |
# BFS (Breadth-First Search) implementado em Python3 | |
# Prof. Vladymir Bezerra | |
#chamar BFS(grafo1, 2) | |
grafo1 = [[1], [0,2], [1,3], [2,4,5], [3,5,6,7], [3,4,6], [4,5,7], [4,6]] |
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
########################### | |
## JOGO DA VELHA ## | |
## IFCE - Boa Viagem ## | |
########################### | |
# Copyright: Vladymir Bezerra | |
# O Jogo todo é representado apenas por funcoes. Cada funcao tem uma funcionalidade | |
# bastante específicas. As funcoes devem ser pequenas e devem fazer apenas UMA coisa. |
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
package monoids; | |
public abstract class Monoid<T> { | |
public abstract T combine(T one, T other); | |
public abstract T identity(); | |
public T fold(Iterable<T> elements) { | |
T result = identity(); | |
for (T i : elements) { |
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 datetime | |
dias = ['segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado', 'domingo'] | |
meses = ['', 'janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'] | |
startdate = datetime.date(2012,1,1) | |
while(startdate.year == 2012): | |
if startdate.weekday() in [5,6]: | |
print "%s %d %s" % (meses[startdate.month],startdate.day,dias[startdate.weekday()]) | |
startdate += datetime.timedelta(1) |
NewerOlder