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 three(a, b, c) | |
puts "a: #{a}, b: #{b}, c: #{c}" | |
end | |
def four(a, b, c, d) | |
puts "a: #{a}, b: #{b}, c: #{c}, d: #{d}" | |
end | |
three(:x, :y, :z) | |
# a: x, b: y, c: z |
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
application_type = 'application/json; charset-utf-8' | |
request = AJAX.method(:get).to_proc.curry.(conn).(address).(application_type) | |
# … GET request to … failed. | |
# from …/ajax.rb:154:in `_request’ | |
# from …/ajax.rb:31:in `get’ |
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
parameters = { … } | |
response = request.(parameters) |
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
if post | |
request = lambda { |p| AJAX.form_post(conn, address, p) } | |
else | |
request = lambda { |p| AJAX.get(conn, address, AJAX::CONTENT_TYPE::JSON, p) } | |
end | |
response = request.(parameters) | |
# ... | |
while # ... | |
# Change parameters |
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
; Inspired by https://twitter.com/gigasquid/status/530699466891067392 ... | |
; An implementation of the Fizz Buzz Kata with no conditionals. | |
(defn fb-gen | |
[step value] | |
(into (sorted-map) (zipmap (range step 101 step) (repeat value)))) | |
(def nums (into (sorted-map) (zipmap (range 1 101) (range 1 101)))) | |
(def threes (fb-gen 3 "fizz")) | |
(def fives (fb-gen 5 "buzz")) | |
(def fifteens (fb-gen 15 "fizzbuzz")) |
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- next-link [dom] | |
; Written this way to avoid Util.java:221 RuntimeException for Unmatched delimiter: ) | |
; Will throw NPE for single-page wish lists. | |
; Will throw CCE for last page of multi-page lists. | |
(az-link (((first ((first (html/select dom [:#wishlistPagination :li.a-last])) :content)) :attrs) :href))) |
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- next-link [dom] | |
; Single page wishlists will not have the element at all. | |
(if-let [a-last (first (html/select dom [:#wishlistPagination :li.a-last]))] | |
; The last page will not have a link, just text. | |
(if-let [nxt (-> a-last :content first :attrs)] | |
(az-link (:href nxt))))) |
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
resolve(Str) -> | |
lists:foldl(fun combine/2, [""], Str). | |
combine($?, Acc) -> | |
[E ++ [N] || E <- Acc, N <- "01"]; | |
combine(C, Acc) -> | |
[E ++ [C] || E <- Acc]. |
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 combine [acc e] | |
(if (= e \?) | |
(for [l acc n "01"] (conj l n)) | |
(for [l acc] (conj l e)))) | |
(defn translate [phrase] | |
(map #(apply str %) | |
(reduce combine [[]] phrase))) |
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
package rtb.onezero; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.function.BiFunction; | |
import java.util.stream.Collectors; | |
public final class Parser { | |
private static BiFunction<List<String>, Character, List<String>> appender |
OlderNewer