mit-scheme

Use mit-scheme with REPL and editor together

拈花ヽ惹草 提交于 2021-02-10 20:12:10
问题 I'm going through SICP course and as recommended installed mit-scheme. I want to use the REPL together with a scheme file. The reason is because I can add scheme code in the file and then run the commands in REPL. What I have works, but the problem is every time I edit the file, I have to quit terminal and reload the file for REPL to see changes. Is there a way to reload the file easily or some other way for REPL to see changes from the file? This my setup: I installed mit-scheme with brew

Why does this return a list '(5) rather than the number 5?

放肆的年华 提交于 2021-01-28 12:01:02
问题 I am working through SICP, and the exercise I am working on asks for a procedure that returns the last element in a list. I implemented the procedure last-pair to do this, but I'm confused why it's returning a list rather than a number: (define (last-pair alist) (cond ((null? (cdr alist)) (car alist)) ; still happens if this is just "car alist)" (else (last-pair (cdr alist))))) When I invoke it on a list of the integers from 1 to 5, I get the output '(5): > (last-pair (list 1 2 3 4 5)) '(5) I

how to programmatically call M-x functions in Edwin for MIT-Scheme?

喜你入骨 提交于 2020-02-25 13:17:32
问题 I'm using the Edwin editor with MIT-scheme, and because the default font size is so small, I do M-x set-font and then choose -adobe-courier-bold-r-normal--24-240-75-75-m-150-iso8859-1 to make the font bigger. This works fine, but when I try to put (set-font "-adobe-courier-bold-r-normal--24-240-75-75-m-150-iso8859-1") in my ~/.edwin , it complains about Unbound variable: set-font . In emacs, interactive functions from M-x can usually be straightforwardly called programmatically in Elisp, but

Taking the 'and' of a list by folding in Scheme

独自空忆成欢 提交于 2020-02-25 04:02:19
问题 In the book Structure and Interpretation of Computer Programs by H. Abelson and G. J. Sussman with J. Sussman, the accumulation or fold-right is introduced in Section 2.2.3 as follows: (define (accumulate op initial sequence) (if (null? sequence) initial (op (car sequence) (accumulate op initial (cdr sequence))))) I tried to use this to take the and of a list of Boolean variables, by writing: (accumulate and true (list true true false)) However, this gave me the error and: bad syntax in

Returning variable from a different environment

 ̄綄美尐妖づ 提交于 2020-01-05 21:25:16
问题 I'm attempting to return a variable in the scope of a different environment. What I have currently is (define make-empty-env (lambda() (make-top-level-environment) ) ) which creates a new environment when you call it from the interpreter i.e. (define env (make-empty-env)) If I define the variable "a" as 15 in "env", my goal is to return this value through a function called from the user-initial-environment. Something along the lines of (apply-env env 'v) outputs -> value of variable v in

(load “file.scm”) in a New Environment in Scheme

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 13:07:42
问题 MIT Scheme's (load ...) procedure apparently takes in an environment as a parameter. Is there any way I could "clone" the current environment and pass it there, so that I can isolate the file's environment from my own? (I've looked here but I haven't found anything...) 回答1: How about something like this ? (define (clone-env env) (let ((bindings (environment-bindings env))) (make-top-level-environment (map car bindings) (map cadr bindings)))) 1 ]=> (define foo 1) ;Value: foo 1 ]=> (eq? (the

mit-scheme — run a script and exit

喜你入骨 提交于 2019-12-21 12:51:32
问题 I want to evaluate a script from makefile and exit, like this mit-scheme --load "fact.scm" However, after it evaluates the file, it does not exit, and the repl appears; if I try the (exit) primitive, it asks for confirmation y/n. Is it possible to solve this ? 回答1: For Unix mit-scheme reads the input files via redirection: mit-scheme < /usr/cph/foo.in > /usr/cph/foo.out 2>&1 & This is taken from the documentation http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/Command

mit-scheme — run a script and exit

本小妞迷上赌 提交于 2019-12-21 12:51:06
问题 I want to evaluate a script from makefile and exit, like this mit-scheme --load "fact.scm" However, after it evaluates the file, it does not exit, and the repl appears; if I try the (exit) primitive, it asks for confirmation y/n. Is it possible to solve this ? 回答1: For Unix mit-scheme reads the input files via redirection: mit-scheme < /usr/cph/foo.in > /usr/cph/foo.out 2>&1 & This is taken from the documentation http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/Command

How to configure SublimeREPL for mit-scheme?

為{幸葍}努か 提交于 2019-12-18 05:21:56
问题 I have installed SublimeREPL, and now I am trying to customize the interpreters a bit. How can I add MIT Scheme to the Tools->SublimeREPL menu? I am new to Sublime Text 2. 回答1: You can read documentation about configuring additional REPLs here:http://sublimerepl.readthedocs.org/en/latest/#basics-of-language-integration-configuration-and-launch-commands And take a look at existing Scheme configuration here: https://github.com/wuub/SublimeREPL/tree/master/config/Scheme Most Scheme/Lisp dialects

How do I execute a .scm script (outside of the REPL) with MIT-Scheme?

ⅰ亾dé卋堺 提交于 2019-12-17 17:47:16
问题 I want to type something like 'scheme file.scm' and have it interpret the file, and then take me back to my shell, rather than loading it in the REPL. edit: I tried scheme < test.scm and it still uses the REPL, the only difference is that scheme exits when the stream ends. 回答1: scheme < file.scm should work (as long as you don't specify --interactive and stdin is not a terminal, scheme works non-interactively). 回答2: To run a scheme program using MIT Scheme: scheme --quiet < program.scm The -