Installing Jess 71p2 in Eclipse 4.2

  1. Downloaded “Eclipse IDE for Java Developers”.
  2. The file name is “eclipse-java-juno-SR1-win32.zip”.
  3. This is release number 4.2 (Juno).
  4. Extracted the archive. Started Eclipse and stopped it.
  5. Extracted Jess plugins to the desired dir.
  6. Started Jess. Verified it’s presence.
  7. Installed GEF by using the built in “Juno” repository and searching for “GEF”. It showed up under “Modeling”. The installation took 10 minutes.
  8. Restarted Eclipse.

When you run this sample program:

(reset)
; define the counter
(deftemplate counter
  (slot count (type integer) (default 0)))
; define the rule
(defrule switchme
  ?p <- (counter {count < 10})
  =>
  (printout t ?p.count crlf)
  (bind ?p.count (+ ?p.count 1)))
; initialise counter
(deffunction init ()
  (assert (counter (count 1))))
;initialise program
(init)
;run program
(run)

Then you get a nice structure breakdown and syntax-highlighting:

You can set breakpoints and get debug information:

Here is the Rete network:

Good to know it is available, not that I know the value of it yet! I’m just investigating the plugins.
Next step is to do the studying!

Which power function is right for Clojure?

(ns power.examples)
(defn non-acc-pow [base exp]
  (if (zero? exp)
    1
    (* base (non-acc-pow base (dec exp)))))
(defn acc-pow [base exp]
  (letfn [(loop [base exp acc]
            (if (zero? exp)
              acc
              (recur base (dec exp) (* base acc))))]
    (loop base exp 1)))
(defn lazy-pow [base exp]
  (letfn [(loop [cur]
            (cons cur (lazy-seq (loop (* cur base)))))]
    (nth (take exp (loop base)) (dec exp))))
(defn iter-pow [base exp]
  (nth (take exp (iterate (partial * base) base)) (dec exp)))
(defn apply-pow [base exp]
  (apply * (repeat exp base)))
(= 16
   (non-acc-pow 2 4)
   (acc-pow 2 4)
   (lazy-pow 2 4)
   (iter-pow 2 4)
   (apply-pow 2 4))

Geiser 0.2.1 ELPA Package

Here is an ELPA package for the Geiser library.
The code is original from the author, I just packaged it up!
Here is one way to install it:

(require 'package)
(when (not (package-installed-p 'geiser))
  (url-copy-file
 "https://www.wisdomandwonder.com/wp-content/uploads/2012/09/geiser-0.2.1.tar"
 "/tmp/geiser-0.2.1.tar"
 t)
  (package-install-file "/tmp/geiser-0.2.1.tar"))

Emacs Pretty Mode Plus ELPA Package

Here is an ELPA package for the pretty-mode.el library.
The code functionality is original from the author, I just tweaked the pretty symbols and packaged it up!
Here is one way to install it:

(url-copy-file
 "https://www.wisdomandwonder.com/wp-content/uploads/2012/09/pretty-mode-plus-1.0.tar"
 "/tmp/pretty-mode-plus-1.0.tar"
 t)
(require 'package)
(package-install-file "/tmp/pretty-mode-plus-1.0.tar")

Addendum: 09/29/12
Fixed the package definition and now it is on Marmalade here.
Addendum: 11/29/12
Added Jess mode support.

Debugging an ELPA Package Install on Marmalade

To get started with ELPA packages I started small by trying to package up hide-comnt.el. Marmalade wouldn’t let me upload it though giving me a “520 Bad Gateway error”. Here is the package that I’m testing with.
Here are the steps I have since followed to try to address it:

  1. Guys in #emacs said it might be Internet access. I think it could be Internet access, package format might be wrong, OS issues, or tar might be bad.
  2. Tried first with Chrome on Windows, and then Firefox on Windows. No change.
  3. Tried first with GNU Tar on Windows, and then 7zip on Windows. No change.
  4. Installed Lubuntu 12.04 then tried GNU Tar and Chrome. No change.
  5. On Windows, blew away my manually installed copy of hide-comnt and installed the package (from above) from inside Emacs using ‘package-install-file’. This worked fine; the package installed and worked as expected. The package seems ok since Emacs installed it.
  6. Tried using a web proxy from home and did not get the 502 error, but the file was not uploaded.
  7. Noticed that there is a sample multi-file TAR package here. Think mine is OK but this is a useful reference.
  8. Found this package and tried doing a programmatic upload. It didn’t work, the result was “502 Bad Gateway”.
  9. Tried uploading using 4G on my Android and got the same result, “502 Bad Gateway”.
  10. #2, #5, and #9 make it seem like the package I made is OK and it is not my Internet connection. Only Nic can check, so I’m passing it to him now.

Tweaking the modeline characters for a minor mode

The modeline characters (call the lighter in Emacs terms) weren’t displaying correctly on my system for this excellent plugin. A cent sign should have been displayed but instead ” \242″ was displayed. ‘forcer’ in #emacs explained that those display settings are stored in ‘minor-mode-alist’ so we can modify them. I added this code at the end of my config:

(let ((ccm-cons (assoc 'centered-cursor-mode minor-mode-alist)))
  (when ccm-cons
    (setcdr ccm-cons '(" ccm"))))

Understanding the Y-Combinator with Racket

Understanding the Y-Combinator seems to be one of the functional programming right-of-passage things, and for good reason, it is fun. Not all of the articles out there spoke to me, so I took notes while coding it up in a way that I understood it.
My notes are attached in the form of a Scribble here How the Y Works, viewable here, and the source code version here y.
It is Racket, but it is really close to Scheme and if you wrote a couple of macros it would probably run on Clojure pretty easily.
The goal is for there to be no gaps in the code, it should be pretty obvious how each step was taken. Hand-coding it made it clear what was happening. This is what worked for me :).

Bless You Emacs

Trying to set up a dev mode in Emacs on Windows today, the code complained that $SHELL was not defined. Not sure what to use I guessed and used ‘cmd’.
At startup, that is startup, not runtime, Emacs gave me this warning:

Warning! The $SHELL environment variable uses cmd.
You probably want to change it so that it uses cmdproxy.exe instead.
Warning! shell-file-name uses cmd.
You probably want to change it so that it uses cmdproxy.exe instead.
Warning! shell-command-switch is "-c".
You should set this to "/c" when using a system shell.
Warning! w32-quote-process-args is t.
You should set this to nil when using a system shell.

Bless you Emacs! ‘cmdproxy’ worked perfectly.