Skip to content

Instantly share code, notes, and snippets.

(defn come-back? [match-to-fix]
(let [match (fix-match match-to-fix)
first-scored-side (first-scored-side match)
winner-side (winner-side match)]
(and (not (nil? winner-side))
(not= winner-side first-scored-side))))
(defn own-goal? [event]
(= "goal-own" (:type_of_event event)))
(defn own-goals [events]
(->> events (filter own-goal?)))
(defn remove-own-goals [events]
(remove own-goal? events))
(defn fix-match [match-to-fix]
(defn teams [match]
(select-keys match [:home_team_country :away_team_country :winner]))
(defn winner-side [match]
(let [winner (:winner match)]
(cond
(= winner (:home_team_country match)) :home
(= winner (:away_team_country match)) :away)))
(defn come-back? [match]
(let [first-scored-side (first-scored-side match)
winner-side (winner-side match)]
(and (not (nil? winner-side))
(defn team-goal-times [events side]
(->> events
(filter goal?)
(map :time)
(map part-and-time)
(map vector (repeat side))))
(defn first-scored-side [match]
(let [goal-times
(concat
(team-goal-times (:home_team_events match) :home)
(team-goal-times (:away_team_events match) :away))]
(->> goal-times (sort-by second) first first)))
(require '[clojure.string :as string])
(defn goal-time [t]
(->>
(string/split t #"\+")
(map string/trim)
(map #(string/replace % #"'" ""))
(map #(Integer/parseInt %))
(reduce +)))
(defn goal? [e]
(let [type (:type_of_event e)]
(or (= "goal" type)
(= "goal-penalty" type)
(= "goal-own" type))))
(->> lst
(map op1)
(map op2)
(filter p1)
first)
lst.stream()
.map(op1)
.map(op2)
.filter(p1)
(ns worldcup.matches
(:require
[clj-http.client :as http]))
(def api-root "https://worldcup.sfg.io")
(defn get-all-matches []
(->
(http/get (str api-root "/matches") {:as :json})
:body))