Models | Examples |
---|---|
Display ads | Yahoo! |
Search ads |
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.
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
(ns codelesson.week1 | |
(:require [clojure.math.combinatorics :as mc])) | |
(defn add-up [coeffs terms] | |
"ax + by + cz + ... | |
this adds up a Specific set of coefficients for terms(coins)" | |
(reduce + (map #(* %1 %2) coeffs terms))) | |
(defn coeffs [dollar coin] | |
"return a sequence of coeffs from 0 to the divisor of the dollar amt by the coin |
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
(ns codelesson.week1-3) | |
(defn debugme [cp cd rp rd] | |
(prn cp cd ) | |
(prn rp) | |
(prn rd) | |
(println "-------------")) | |
(defn nomore [a b] | |
(and (empty? a) (empty? b))) |
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
(ns codelesson.week3-1 | |
(:require [clojure.string]) | |
(:gen-class)) | |
(defn merge-with-padding [x y] | |
" merge arrays x & y and padding the shorter of the two with nils " | |
(let [cx (count x) cy (count y)] | |
(if (not= cx cy) | |
(if (< cx cy) | |
(map #(vector %1 %2) (concat x (take (- cy cx) (repeat nil) )) y) |
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
(ns codelesson.week3-2) | |
(def fees { :checking {:interest 0.02 :overdraft 0.10} | |
:savings {:interest 0.04 :overdraft 0.075} | |
:money-market {:interest 0.06 :overdraft 0.05}}) | |
(def overall-overdraft (atom 100000)) | |
(def accounts (atom [])) | |
(defn random-account-type [] | |
(rand-nth [:checking :savings :money-market])) |
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
(ns codelesson.week4-1 | |
(:require clojure.string) | |
(:import (org.slf4j.impl.StaticLoggerBinder)) | |
(:import (javax.swing JFrame JPanel JButton JLabel JTextField JTextArea JScrollPane)) | |
(:import java.awt.event.ActionListener) | |
(:import (javax.swing.event DocumentListener)) | |
(:import (java.awt GridBagLayout GridBagConstraints Dimension)) | |
(:import (java.util.concurrent TimeUnit))) | |
(def fees { :checking {:interest 0.02 :overdraft 0.10} |
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
λ lein deps ✭ | |
Retrieving codox/codox/0.6.4/codox-0.6.4.pom from clojars | |
Retrieving codox/codox.leiningen/0.6.4/codox.leiningen-0.6.4.pom from clojars | |
Retrieving codox/codox/0.6.4/codox-0.6.4.jar from clojars | |
Retrieving codox/codox.leiningen/0.6.4/codox.leiningen-0.6.4.jar from clojars | |
[:~/clojure/git/lib-noir on master] | |
λ lein doc ✭ | |
Exception in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project [])) | |
at leinjacker.deps$add_if_missing.invoke(deps.clj:43) | |
at leiningen.d |
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
[:~/clojure/git/lib-noir on master] | |
λ lein clean 1 ↵ ✭ | |
[:~/clojure/git/lib-noir on master] | |
λ lein deps ✭ | |
[:~/clojure/git/lib-noir on master] | |
λ lein doc ✭ | |
Exception in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project [])) | |
OlderNewer