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
(defn gen-doors [] | |
(update (vec (repeat 3 0)) (rand-int 3) inc)) | |
(defn stay [doors chosen] | |
(doors chosen)) | |
(defn switch [doors chosen] | |
(let [reveal (rand-nth | |
(keep | |
(fn [[idx v]] |
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 right | |
{:N :E | |
:E :S | |
:S :W | |
:W :N}) | |
(def left | |
(clojure.set/map-invert right)) | |
(defn bound [bottom top n] |
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
(defn frame-size [[a :as rolls]] | |
(if (= 10 a) | |
1 | |
2)) | |
(defn frame-score [[a b c :as rolls]] | |
(if (>= 10 (+ a b)) | |
(+ a b c) | |
(+ a b))) |
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
class Post < ActiveRecord::Base | |
scope :task -> { joins(:ideas)} | |
scope :crowdfunding -> { joins(:crowdfunding)} | |
scope :tailored_for_user -> { order("created_at DESC").tagged_with.current_user.tag_list } | |
scope :popular -> { order("cached_votes_score DESC") } | |
... | |
end | |
class PostsController < ApplicationController | |
... |
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
(defn cartesianProduct [a b] | |
(clojure.set/union | |
(map | |
#(into [] | |
(list* | |
(first b) | |
(if (coll? %) | |
% | |
(list %) | |
) |