Skip to content

Instantly share code, notes, and snippets.

@chase-lambert
Last active May 17, 2023 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chase-lambert/71cb1dad861b7593ed2e3f2b64ee3705 to your computer and use it in GitHub Desktop.
Save chase-lambert/71cb1dad861b7593ed2e3f2b64ee3705 to your computer and use it in GitHub Desktop.
rendezvous with cassidoo challenge: 22.09.04
(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