scmutils, 3

Structure and Interpretation of Classical Mechanics

Scheme Mechanics Installation for GNU/Linux

.

This post assumes that you have already installed the scmutils library and been able to open it using the standard editor Emacs.

If not, go to the bottom of this post to click the category scmutils, so that you can see all the posts in this scmutils series.

d_2020_02_22__16_02_00_PM_

Then go to the post “scmutils, 2.3.2” to follow the installation and setup instructions.

.

After installing and setting up the scmutils library, you can start to use it.

d_2020_02_22__18_12_54_PM_

However, what if you want to close the Emacs editor? How to save your scheme program before closing Emacs?

By default, you cannot. So I have written a small program to help. Here is the installation instruction:

1. Go to the end of the .emacs file. Add the following code, if it does not already exist:


(defun mechanics()
  (interactive)
  (run-scheme
   "/usr/local/scmutils/mit-scheme/bin/scheme --library
/usr/local/scmutils/mit-scheme/lib"
  ))

2. Add the following code:


(fset 'set-working-dir
      (lambda (&optional arg) "Keyboard macro."
	(interactive "p")
	(kmacro-exec-ring-item
	 (quote ("(set-working-directory-pathname! 
                  \"~/Documents/\")\n" 0 "%d")) arg)))
 
(fset 'load-scm
      (lambda (&optional arg) "Keyboard macro."
	(interactive "p")
	(kmacro-exec-ring-item
	 (quote ("(load \"tt.scm\")" 0 "%d")) arg)))
 
(defun mechan ()
  (interactive)
  (split-window-below)
  (windmove-down)
  (mechanics)
  (set-working-dir)
  (comint-send-input)
  (windmove-up)			
  (find-file "~/Documents/tt.scm")
  (end-of-buffer)
  (windmove-down)
  (cond ((file-exists-p "~/Documents/tt.scm")
	 (interactive)
	 (load-scm)
	 (comint-send-input)))
  (windmove-up)
)
 
(defun cxce ()
  (interactive)
  (save-buffer)
  (windmove-down)
  (load-scm)
  (comint-send-input)
  (windmove-up)
)
 
(global-set-key (kbd "C-x C-e") 'cxce)

3. Close Emacs. Re-open it.

4. Type the command

M-x mechan

The command M-x means pressing the Alt key and x together. Then type the word mechan.

5. You will see the Emacs editor is split into two windows, one up and one down.

The lower window is the scheme environment. You can type a line of code and the press Enter to execute it.

The upper window is the editor. You can type multiple lines of code and the type

C-x C-e

to execute it. The command C-x C-e means pressing Ctrl and x together and then Ctrl and e.

d_2020_03_11__20_28_27_PM_

6. Your scheme code is saved to the following file

"~/Documents/tt.scm"

In case you need to backup your code, backup this file.

— Me@2020-03-10 10:59:45 PM

.

.

2020.03.10 Tuesday (c) All rights reserved by ACHK

scmutils, 2.3.2

Scheme Mechanics Installation for GNU/Linux

.

Steps:

1. The following steps are tested in Ubuntu 18.04. Prepare Ubuntu 18.04 if you can.

Note: Since the installation of the library scmutils requires the root access of your Linux system, please do NOT use it on your working computer. Instead, create an isolated virtual machine to use it.

.

2. Go to the bottom of this post to click the category scmutils, so that you can see all the posts in this scmutils series.

d_2020_02_22__16_02_00_PM_

3. Go to the post titled “scmutils, 2.3” to download

scmutils-20160827-x86-64-gnu-linux

4. Although the official installation guide advises you to install “MIT/GNU Scheme system” before installing scmutils, you do NOT need to install “MIT/GNU Scheme system” at all.

5. Unzip the file scmutils-20160827-x86-64-gnu-linux.

In the following, if you need to copy any commands or programming codes, remember that any number on the left of the vertical green line is NOT part of the code.

6. Run the command

tar xzf scmutils-20160827-x86-64-gnu-linux.tar.gz

to further extract the file.

-x — extract files from an archive;
-f — specify the archive’s name;
-v — show a list of processed files.

— Wikipedia on tar (computing)

Then two folders will be created: bin and scmutils.

7. Run the command

cd bin

to go into the folder.

You will see a file called mechanics.

.

8.1 Run the command

mechanics

You will get the error

mechanics: command not found

8.2 Instead, you should run the command

./mechanics

to specify that the file mechanics is actually in the current folder.

You will get the error

./mechanics: line 16: exec: xterm: not found

It is because your Linux system has not the program xterm yet.

8.3 Run the following command to install it.

sudo apt-get install xterm

8.4 Run the command again:

./mechanics

There will be an xterm window popup, but with an error message inside:

d_2020_02_22__17_08_35_PM_

That means you should move the two folders, bin and scmutils, to the pre-defined locations.

.

9.1 Run the command to move the folder scmutils to its pre-defined location:

mv scmutils /usr/local/

You will get the error

mv: cannot move 'scmutils' to '/usr/local/scmutils': 
Permission denied

9.2 Try again by

sudo mv scmutils /usr/local/

.

10.1 Go inside the folder bin.

10.2 Move its content to the pre-defined location by this command:

sudo mv mechanics /usr/local/bin/

.

11. Run the command

mechanics

Then you will see the Edwin window is opened. That means, in theory, you system has successfully installed the scmutils library. You can use it within the Edwin window if you like.

However, in practice, it is difficult, because it provides no syntax-highlighting. Also, you cannot use mouse in the Edwin window, so if you want to copy and paste a command or a series of commands, there will be no obvious way to achieve that.

So I suggest you to use the standard Emacs as the editor instead.

.

12.1 If you do not know Emacs, learn its basics.

12.2 Also, learn how to open Emacs’ initialization file, which has the filename

.emacs

After opening the file, you will see that it is just a text file.

12.3 Go to the end of the .emacs file. Add the following code:

(defun mechanics()
  (interactive)
  (run-scheme
     "/usr/local/scmutils/mit-scheme/bin/scheme --library
     /usr/local/scmutils/mit-scheme/lib"))

12.4 Save the file. Close Emacs. Then re-open Emacs.

12.5 Within Emacs, type the command

M-x mechanics

M-x means that while the Alt key is pressed down, press also x. Then type the word mechanics.

d_2020_02_22__18_12_12_PM_

12.6 Type the command

(+ 1 1)

to test the system.

d_2020_02_22__18_12_54_PM_

13. If you want to access your last command without re-typing it, type the command

M-p

d_2020_02_22__18_19_31_PM_

— Me@2020-02-22 06:25:47 PM

.

.

2020.02.22 Saturday (c) All rights reserved by ACHK

scmutils, 2.3

Within the MIT Scheme environment, it is not the original command line (bash) anymore. I can neither repeat the last command by just pressing the up key once, nor select the last command by mouse in order to copy it.

So I think I have to use an older version of scmutils.

However, this method is not easy to implement, because the author’s website does not provide an older version. Luckily, I have found an old version in my computer. You can download it here:

scmutils-20160827-x86-64-gnu-linux

Note: Since the installation of the library scmutils requires the root access of your Linux system, please do NOT use it on your working computer. Instead, create an isolated virtual machine to use it.

— Me@2020-02-09 10:27:32 PM

.

.

2020.02.09 Sunday (c) All rights reserved by ACHK

scmutils, 2.2

Either use an older version of scmutils in order to follow the previous instructions for setting up Emacs for scmutils, or give up using Emacs for scmutils for the time being.

Using command line is the best way to go, so far.

The “using command line” method does not really work.

d_2020_01_27__16_12_48_PM_

Within the MIT Scheme environment, it is not the original command line (bash) anymore. I can neither repeat the last command by just pressing the up key once, nor select the last command by mouse in order to copy it.

So I think I have to use an older version of scmutils.

— Me@2020-01-26 07:38:31 PM

.

.

2020.01.26 Sunday (c) All rights reserved by ACHK

scmutils, 2

The original method of setting up Emacs for scmutils does not work anymore if you uses the newest (August 2019) version of scmutils, because its installation directories are not the same as those in the previous version.

Either use an older version of scmutils in order to follow the previous instructions for setting up Emacs for scmutils, or give up using Emacs for scmutils for the time being.

Using command line is the best way to go, so far.

Do not use the Edwin editor, since you cannot easily run, edit, or copy existing lines of code, unless you are familiar with it. I do not like it anyway, because after all, it does not provide syntax highlighting.

— Me@2019-12-28 07:50:32 PM

.

.

2019.12.28 Saturday (c) All rights reserved by ACHK

Literal numbers

All primitive mathematical procedures are extended to be generic over
symbolic arguments. When given symbolic arguments, these procedures
construct a symbolic representation of the required answer. There are
primitive literal numbers. We can make a literal number that is
represented as an expression by the symbol “a” as follows:

(literal-number 'a)        ==>  (*number* (expression a))

The literal number is an object that has the type of a number, but its
representation as an expression is the symbol “a”.

(type (literal-number 'a))          ==>  *number*

(expression (literal-number 'a))    ==>  a

— SCMUTILS Reference Manual

.

.

2019.08.17 Saturday ACHK

scmutils

In order to run the SICM code, you need to install the scmutils library. Just go to the official page to download the library and follow the official instructions to install it in a Linux operating system.

When you try to run it, your system may give the following error message:

/usr/local/bin/mechanics: line 16: exec: xterm: not found

If so, you should install the program xterm first.

.

Also, in case you like to use Emacs as editor, you can:

Just include the following in your .emacs file:

(defun mechanics ()
  (interactive)
  (run-scheme
    "ROOT/mit-scheme/bin/scheme --library ROOT/mit-scheme/lib"
  ))

Replace ROOT with the directory in which you installed the scmutils software. (Remember to replace it in both places. If it is installed differently on your system, just make sure the string has the form “/path/to/mit-scheme --library /path/to/scmutils-library“.) Restart emacs (or use C-x C-e to evaluate the mechanics defun), and launch the environment with the command M-x mechanics.

— Using GNU Emacs With SCMUtils

— Aaron Maxwell

.

In my Ubuntu 18.04, the paths are:

(defun mechanics()
  (interactive)
  (run-scheme
   "/usr/local/scmutils/mit-scheme/bin/scheme --library 
/usr/local/scmutils/mit-scheme/lib"
  ))

— Me@2019-04-07 02:52:50 PM

.

.

2019.04.07 Sunday (c) All rights reserved by ACHK