This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-03
Channels
- # aleph (1)
- # announcements (9)
- # babashka (3)
- # beginners (200)
- # calva (22)
- # cider (74)
- # clojure (97)
- # clojure-dev (43)
- # clojure-europe (15)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-sanfrancisco (2)
- # clojure-uk (103)
- # clojuredesign-podcast (2)
- # clojurescript (45)
- # core-async (5)
- # cursive (13)
- # datomic (42)
- # emacs (20)
- # fulcro (6)
- # graalvm (37)
- # jackdaw (10)
- # leiningen (7)
- # mid-cities-meetup (3)
- # off-topic (2)
- # pathom (1)
- # pedestal (3)
- # re-frame (6)
- # reagent (38)
- # reitit (5)
- # shadow-cljs (117)
- # spacemacs (1)
- # sql (1)
- # tools-deps (17)
- # vim (14)
- # xtdb (18)
idea: 4clojure as a babashka script, it stores the scores in a local sqlite3 database
Naive first version:
(ns babashka.4clojure
(:require [clojure.walk :refer [postwalk]]
[clojure.edn :as edn]))
(def problems
{"Intro to Strings"
{:description "Clojure strings are Java strings. This means that you can use any of the Java string methods on Clojure strings."
:puzzle '(= __ (.toUpperCase "hello world"))}})
(defn -main []
(loop [[title puzzle] (rand-nth (seq problems))]
(loop []
(println title)
(println (:description puzzle))
(prn (:puzzle puzzle))
(let [answer (edn/read-string (read-line))
substituted (postwalk #(if (= '__ %) answer %) (:puzzle puzzle))]
(prn substituted)
(if (eval substituted)
(println "Correct!\n")
(do (println "Incorrect. Try again.")
(recur)))))
(recur (rand-nth (seq problems)))))
(-main)
😎 20