Created
December 19, 2025 12:52
-
-
Save andradefil/c25338c7e3d39fb6c331ea5333dffb94 to your computer and use it in GitHub Desktop.
gen and select
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
| (require '[clojure.test.check.generators :as tgen]) | |
| (def gen-vals-and-select | |
| (tgen/bind | |
| gen-db-vals | |
| (fn [db-vals] | |
| (def db-vals db-vals) | |
| (if (seq db-vals) | |
| (tgen/let [nth1 (tgen/choose 1 3) | |
| nth2 (tgen/choose 1 3) | |
| sz1 (tgen/choose 1 (count db-vals)) | |
| sz2 (tgen/choose 1 (count db-vals))] | |
| [(into {} (take sz1 (take-nth nth1 db-vals))) | |
| (into {} (take sz2 (take-nth nth2 db-vals)))]) | |
| (tgen/return [{} {}]))))) | |
| (def gen-vals-and-select2 | |
| (tgen/bind | |
| gen-db-vals | |
| (fn [vs] | |
| (if (seq vs) | |
| (tgen/return | |
| [(into {} (tgen/vector-distinct | |
| (tgen/elements vs))) | |
| (into {} (tgen/vector (tgen/elements vs)))]) | |
| (tgen/return [{} {}]))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment