This file contains 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
private void btnCalcular_Click(object sender, EventArgs e) | |
{ | |
decimal[] notas = {txtNota0.Value, txtNota1.Value, txtNota2.Value, txtNota3.Value}; | |
lblMenor.Text = notas.Min().ToString(); | |
lblMaior.Text = notas.Max().ToString(); | |
lblMedia.Text = notas.Average().ToString(); | |
} |
This file contains 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
private void btnCalcular_Click(object sender, EventArgs e) | |
{ | |
decimal[] notas = new decimal[4]; | |
notas[0] = txtNota0.Value; | |
notas[1] = txtNota1.Value; | |
notas[2] = txtNota2.Value; | |
notas[3] = txtNota3.Value; | |
Array.Sort(notas); |
This file contains 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
(loop [fs [] | |
nums (range 2 23)] | |
(let [f (first nums)] | |
(if (empty? nums) | |
fs | |
(recur (conj fs f) | |
(filter #(not= 0 (mod % f)) nums))))) |
This file contains 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
(defn better-count [lista] ; 1 | |
(loop [lista lista ; 2 | |
items 0] ; 3 | |
(if (empty? lista) ; 4 | |
items ; 5 | |
(recur (rest lista) ; 6 | |
(inc items))))) ; 7 | |
;; ---------------------------- | |
;; o jeito errado: |
This file contains 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
;annotation syntax | |
(import [java.lang.annotation Retention RetentionPolicy Target ElementType] | |
[javax.xml.ws WebServiceRef WebServiceRefs]) | |
(definterface Foo (foo [])) | |
;annotation on type | |
(deftype ^{Deprecated true | |
Retention RetentionPolicy/RUNTIME | |
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"] |
This file contains 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
[09:50] == pbalduino [b3a45769@gateway/web/freenode/ip.179.164.87.105] has joined #clj-br | |
[09:50] <pbalduino> mario-goulart: bom dia | |
[09:51] <mario-goulart> Alô pbalduino. Bom dia. | |
[09:56] == andrewhr [~andrewhr@179.159.190.106] has joined #clj-br | |
[09:56] == andreanastacio [~andreanas@179.159.190.106] has joined #clj-br | |
[10:01] <mario-goulart> andreanastacio e andrewhr: vocês são a mesma pessoa? :-) | |
[10:02] <andreanastacio> hehe nao | |
[10:02] <andreanastacio> trabalhamos juntos | |
[10:02] <mario-goulart> ! | |
[10:02] <mario-goulart> Bacana. :-) |
This file contains 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
(def matches [[:bra 3 :cro 1] | |
[:mex 1 :cam 0] | |
[:esp 1 :hol 5] | |
[:chi 3 :aus 1] | |
[:col 3 :gre 0] | |
[:cdm 2 :jap 1] | |
[:uru 1 :cos 3] | |
[:ing 1 :ita 2] | |
[:sui 2 :equ 1] | |
[:fra 3 :hon 0] |
This file contains 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
(def trans (transient [])) | |
(conj! trans "Main thread") | |
(defn outra-thread [] | |
(conj! trans "New thread")) | |
(. (Thread. outra-thread) start) | |
; Exception in thread "Thread-21" java.lang.IllegalAccessError: Transient used by non-owner thread | |
; at clojure.lang.PersistentVector$TransientVector.ensureEditable(PersistentVector.java:464) |
This file contains 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
;; Por que existe um tipo para números racionais em Clojure? | |
(/ 1 3) ; Clojure retorna o tipo Ratio por padrão numa divisão | |
; 1/3 | |
(double (/ 1 3)) ; agora temos um tipo Double do Java | |
; 0.3333333333333333 | |
(->> 1/3 ; o valor de 1 / 3 | |
double ; é convertido para Double |
This file contains 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
Para a resposta, basta apresentar a expressão regular utilizada e o parâmetro, caso seja utilizado, | |
1. Dada uma lista de CEPs válidos, escreva uma expressão regular que funcione com todos os itens: | |
04567003 | |
04567-003 | |
04.567-003 | |
04.567.003 | |
04 567 003 | |
04567 003 | |
04567.003 |