gpt4 book ai didi

emacs - 如何以交互方式读取两个输入并在函数调用中使用它们

转载 作者:行者123 更新时间:2023-12-02 03:33:16 25 4
gpt4 key购买 nike

我目前正在学习 elisp 类(class),所以我没有这门语言的经验。我试图以交互方式读取两个输入(矩形的宽度和长度),然后使用它们调用函数来计算矩形的面积。我的代码如下:

(defun rectangle_Area(w l)
"Compute the area of a rectangle, given its width and length interactively."
(interactive "nWidth: ")
(interactive "nLength: ")
(setq area (rectangleArea w l))
(message "The rectangle's area is %f." area))

目前我收到参数数量错误错误。就像我说的,我以前没有经验......我真正需要知道的是如何使用交互式存储/读取两个单独的值。

感谢您的帮助

最佳答案

C-hf 交互式 RET:

To get several arguments, concatenate the individual strings, separating them by newline characters.

所以我们有:

(defun rectangle_Area(w l)
"Compute the area of a rectangle, given its width and length interactively."
(interactive "nWidth: \nnLength: ")
(setq area (rectangleArea w l))
(message "The rectangle's area is %f." area))

关于emacs - 如何以交互方式读取两个输入并在函数调用中使用它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14449048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com