Hot answers tagged

6

You are almost there. There are only two little details you need to take care of: Remove the quoting #' in (funcall #'(average-damp 'square) 10). You do want to eval average-damp and give you the actual function for the funcall. That is what Aquaactress correctly statet as problem 1. For the form (defun average-damp (f) (lambda (x) (average x (...


5

At a guess, your path to the Scheme implementation may be incorrect. Why do you think you need a backslash there? What do you want to quote/escape with it? Now, go to *scratch* buffer and evaluate your path. You will see that it may be a bit surprising: "C:/Program Files\ (x86)/Chicken Scheme/bin/csi.exe" ⇒ "C:/Program Files(x86)/Chicken Scheme/bin/csi....


5

I think geiser-mode may provide what you are looking for at least for guile and racket, but apparently not MIT Scheme. I know that provides M-. to jump to symbol definition in environment, completion, and inline documentation help. Take a look at the introduction, and cheat sheet for a quick overveiw of features. Alternative, it does appear mit-scheme has ...


4

There are two problems I found with the code you wrote. problem 1 (funcall #'(average-damp 'square) 10) funcall requires a function as it's first argument. However, here you're trying to pass in the unevaluated list (average-damp 'square) as if it were a function. But it's not, it's data. Remember that #' is a shorthand for function and function does not ...


4

Use cl-labels to define local functions (cl-flet works, but recursive function reports error), and in the beginning of the .el file enable the lexical scoping: ;; -*- lexical-binding: t -*- (defun make-account () (cl-labels ((withdraw (amount) (print "in withdraw"))) (lambda () #'withdraw))) Remember the # before the quoting ...


2

I think the issue is that RET is probably mapped to comint-send-input, which doesn't do any indentation. What I do is map C-j to newline-and-indent and leave RET mapped to comint-send-input. So I press C-j to enter a newline, and indent the new line, or RET to actually send the form for evaluation. (Actually I map C-j to paredit-newline, but newline-and-...


2

You leave these two lines in you .emacs file (add-hook 'scheme-mode-hook 'geiser-mode) (setq geiser-default-implementation 'racket)


1

Yes, there is. There are a few customization suggestions for common-lisp-indent-function inside cl-indent.el. The same mechanism is used for scheme-indent-function. Place the following in your init file: (put 'if 'scheme-indent-function 1) To achieve the following indentation in a Scheme buffer: (if foo bar baz)


1

You can not enter x value to (average-damp ) in your code. You should declare x as a function argument or define (average-damp ) as a macro. (defun average-damp (f x) (average x (funcall f x))) (defmacro average-damp2 (f) `(lambda (x) (average x (funcall ,f x)))) (defun average (x y) ;; Keep the float (/ (+ x y) 2.0)) (defun square (x) (* x x))...


1

Select the whole code (e.g. by pressing C-Space at the start and using cursor keys to get to the end) and run indent-region (bound to C-M-\ in my Emacs).


1

Don't have enough reputation to upvote this, but this stymied me for too long. Same config, Emacs 26, geiser from MELPA stable. The bug is always some version of apply: Invalid function: (lambda (&rest) ...) Simply upgrade to the latest version on MELPA, thanks for figuring this out.


1

I've got an workaround: open an terminal in Emacs with the Shell layer. After installing the Shell layer, you can toggle a shell window using SPC '​. You can execute mit-scheme < xxx.scm in that terminal, which seems more convenient to me than using the Scheme layer


1

The face in question is font-lock-comment-face, just change the color to something more to your liking. In general, when one wants to figure out what properties are being applied to a string, one can go to the character in question and M-x describe-char.


1

But what I really want, is org-mode to tangle it behind the scenes a print the result of the execution into this file. For that you need the :results directive as shown below. BEGIN_SRC scheme :tangle yes :noweb yes :results output See babel documentation for details of whether to use value instead of output in the :results directive. Value is good if ...


1

I can't reproduce this in emacs -Q, the prompts can be deleted for both Scheme and Python buffers. Customizing comint-prompt-read-only gives me a read-only prompt for both again. ansi-term is much slower as it emulates a full terminal, should behave correctly and is less Emacs-like (captures more keys, harder to customize). comint-derived modes on the ...


Only top voted, non community-wiki answers of a minimum length are eligible