Last active
December 18, 2015 10:38
-
-
Save actsasgeek/5769490 to your computer and use it in GitHub Desktop.
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
| (def sales-data [ | |
| {:person_id 1 | |
| :deal_id 2 | |
| :date "2013-01-04"} | |
| {:person_id 1 | |
| :deal_id 3 | |
| :date "2013-01-05"} | |
| {:person_id 1 | |
| :deal_id 4 | |
| :date "2013-01-05"} | |
| {:person_id 2 | |
| :deal_id 2 | |
| :date "2013-01-04"} | |
| {:person_id 2 | |
| :deal_id 3 | |
| :date "2013-01-04"} | |
| {:person_id 2 | |
| :deal_id 4 | |
| :date "2013-01-05"} | |
| {:person_id 3 | |
| :deal_id 1 | |
| :date "2013-01-06"} | |
| {:person_id 4 | |
| :deal_id 2 | |
| :date "2013-01-06"} | |
| {:person_id 5 | |
| :deal_id 2 | |
| :date "2013-01-05"} | |
| {:person_id 5 | |
| :deal_id 3 | |
| :date "2013-01-04"} | |
| {:person_id 6 | |
| :deal_id 4 | |
| :date "2013-01-05"} | |
| ]) | |
| (defn sales-per-person [data]) ;; {1 3, 2 3, 3 1, 4 1, 5 2, 6 1} | |
| (defn sales-per-deal [data]) ;; {2 4, 3 3, 4 3, 1 1} | |
| (defn sales-per-day [data]) ;; {"2013-01-04" 4, "2013-01-05" 5, "2013-01-06" 2} | |
| (def intervals1 [[1.3 4.5] [2.1 7.8] [0.8 2.3]]) ;; [2.1 2.3] | |
| (def intervals2 [[1.3 3.4] [2.0 4.9] [0.8 1.9]]) ;; [] | |
| (defn interval-intersection [intervals] | |
| "Takes a list of ordered pairs [double, double] representing intervals and returns | |
| either the intersection of all the intervals or the empty list." | |
| ) | |
| (permute "fred") ;; ("fred" "frde" "ferd" "fedr" "fdre" ...) | |
| (defn permute [string] | |
| "Takes a string and returns all distinct permutations of it." | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment