Last active
May 17, 2023 00:43
-
-
Save chase-lambert/71cb1dad861b7593ed2e3f2b64ee3705 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 22.09.04
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
(ns from-to | |
(:require [clojure.test :refer [deftest is]])) | |
(defn from-to [lower upper] | |
(let [gen (atom (dec lower))] | |
(fn [] | |
(when (< @gen upper) | |
(swap! gen inc) | |
(deref gen))))) | |
(deftest from-to-test | |
(let [gen (from-to 5 7)] | |
(is (= 5 (gen))) | |
(is (= 6 (gen))) | |
(is (= 7 (gen))) | |
(is (= nil (gen))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment