(ns distractionless.arithmetic-tasks) (def ^:private task-types [:addition :subtraction :multiplication]) (defn gen-task [] {:type (rand-nth task-types) :numbers [(inc (rand-int 20)) (inc (rand-int 20))]}) (defn- type->function [type] (condp = type :addition + :subtraction - :multiplication *)) (defn type->str [type] (condp = type :addition "+" :subtraction "-" :multiplication "*")) (defn test-result? [task input] (= input ((type->function (:type task)) (first (:numbers task)) (second (:numbers task)))))