blob: e7357d9c32c8f67c08a30c37090425a577e48f29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(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)))))
|