Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on Clojure.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/clojure.e>
#           or at <http://angg.twu.net/e/clojure.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.simple-forth»	(to "simple-forth")
# «.simple-graphics»	(to "simple-graphics")
# «.mal»		(to "mal")



# http://clojure.org
# (find-status   "clojure")
# (find-vldifile "clojure.list")
# (find-udfile   "clojure/")
# (find-zsh "installeddebs | sort | grep clojure")
# (find-zsh "availabledebs | sort | grep clojure")
# https://clojure.org/guides/getting_started
# https://clojure.org/guides/editors
# https://clojure.org/guides/structural_editing
# https://clojure.org/guides/repl/introduction
# https://clojure.org/guides/learn/clojure
# https://clojure.org/reference/reader
# https://clojure.org/api/api
# https://clojure.org/guides/weird_characters
# https://clojure.org/guides/destructuring
# https://clojure.org/guides/learn/clojure

https://clojure.org/guides/learn/functions#_multi_arity_functions
https://clojure.org/guides/learn/functions.html#_multi_arity_functions



#####
#
# A simple Forth interpreter
# 2011sep23
#
#####

# «simple-forth»  (to ".simple-forth")
# (find-es "java" "clojure")
# http://nakkaya.com/2010/12/02/a-simple-forth-interpreter-in-clojure/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
clojure -r

(ns forth
  (:refer-clojure :exclude [pop!]))

(declare forth-eval)

(defn pop! [stack]
  (let [first (first @stack)]
    (swap! stack pop)
    first))

(defn push! [stack item]
  (swap! stack conj item))

(defn next-token [stream]
  (if (. stream hasNextBigInteger)
    (. stream nextBigInteger)
    (. stream next)))

(defn init-env []
  (let [stream (java.util.Scanner. System/in)
        stack (atom '())
        dict (atom {})
        prim (fn [id f] (swap! dict assoc id f))]
    (prim ".s" #(do (println "---")
                    (doseq [s @stack] (println s))
                    (println "---")))
    (prim "cr" #(println))
    (prim "+" #(push! stack (+ (pop! stack) (pop! stack))))
    (prim "*" #(push! stack (* (pop! stack) (pop! stack))))
    (prim "/" #(let [a (pop! stack)
                     b (pop! stack)]
                 (push! stack (/ b a))))
    (prim "-" #(let [a (pop! stack)
                     b (pop! stack)]
                 (push! stack (- b a))))
    (prim "dup" #(push! stack (first @stack)))
    (prim "." #(println (pop! stack)))
    (prim ":" #(let [name (next-token stream)
                     block (loop [b [] n (next-token stream)]
                             (if (= n ";")
                               b
                               (recur (conj b n) (next-token stream))))]
                 (prim name (fn [] (doseq [w block]
                                     (forth-eval dict stack w))))))
    [dict stack stream]))

(defn forth-eval [dict stack token]
  (cond (contains? @dict token) ((@dict token))
        (number? token) (push! stack token)
        :default (println token "??")))

(defn repl [env]
  (let [[dict stack stream] env
        token (next-token stream)]
    (when (not= token "bye")
      (forth-eval dict stack token)
      (repl env))))

(repl (init-env))

5 6 + 7 8 + *
.
cr

3 2 1 + *
. cr

: sq dup * ;
2 sq
.

bye




#####
#
# Simple graphics
# 2011sep24
#
#####

# «simple-graphics»  (to ".simple-graphics")
# (find-books "__comp/__comp.el" "clojure")
# (find-joyofclojurepage (+ 33  52) "(def frame (java.awt.Frame.))")
# (find-joyofclojuretext            "(def frame (java.awt.Frame.))")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
clojure -r

(def frame (java.awt.Frame.))
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 200 200))

(defn xors [max-x max-y]
  (for [x (range max-x) y (range max-y)]
    [x y (bit-xor x y)]))
 
(doseq [[x y xor] (xors 200 200)]
  (.setColor gfx (java.awt.Color. xor xor xor))
  (.fillRect gfx x y 1 1))




#####
#
# mal
# 2023mar31
#
#####

# «mal»  (to ".mal")
# https://emacsninja.com/posts/implementing-mal.html
# https://github.com/kanaka/mal
# https://github.com/kanaka/mal/blob/master/process/guide.md
# (find-git-links "https://github.com/kanaka/mal" "mal")
# (find-gitk  "~/usrc/mal/")
# (code-c-d "mal" "~/usrc/mal/")
# (find-malfile "")
# (find-malfile "impls/lua/")
# (find-malfile "impls/tcl/")
# (find-malfile "process/")
# (find-malfile "process/guide.md")






https://github.com/cognitect-labs/transcriptor Convert REPL interactions into example-based tests.
https://news.ycombinator.com/item?id=33909241 Babashka is a fast-starting scripting environment for Clojure (medium.com/graalvm)
https://news.ycombinator.com/item?id=33962090 Clojure is a trinity of language, REPL, and structural editor (jakubholy.net)
https://news.ycombinator.com/item?id=36115321 Joker is a small interpreted dialect of Clojure written in Go (joker-lang.org)

https://news.ycombinator.com/item?id=35507001 REBL (datomic.com)
https://docs.datomic.com/cloud/other-tools/REBL.html

http://www.infoq.com/presentations/Simple-Made-Easy
https://docs.cider.mx/cider/index.html
https://download.clojure.org/papers/clojure-hopl-iv-final.pdf
https://rattlin.blog/bbgum.html

https://www.youtube.com/playlist?list=PLZdCLR02grLpIQQkyGLgIyt0eHE56aJqd Clojure/conj 2023




#  Local Variables:
#  coding:               utf-8-unix
#  End: