LISP中未定义的函数错误

编程入门 行业动态 更新时间:2024-10-04 19:27:21
本文介绍了LISP中未定义的函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在研究一个Lisp程序,该程序包含的代码可以读取框的维数,然后将它们从最短到最长的长度进行排序(并将每个新长度设置为新变量)。

当我尝试将我的文件加载到解释器中时,出现以下错误:

** * - EVAL:未定义函数NEW-D1

我很困惑,为什么我会得到这个错误,因为 new-d1 不是函数,它是给定框的最短边的长度的变量。

以下代码首先对 new-d1 进行初始化和设置:

defun get-box()(let(d1 0)(d2 0)(d3 0)(new-d1 0)(new-d2 0)(new-d3 0))(setf d1(read))(setf d2(read))(setf d3(read))(if(= d1 -1) )(setq new-d1(first(sort(list d1 d2 d3)#'<)))(setq new- (第二(sort(list d1 d2 d3)#'<)))(next(sort(list d1 d2 d3)#'<)))(setq new-d3 - 程序的一部分(新-d1新-d2新-d3))))))

如何更改我的代码,以便解释器知道new-d1不是一个函数,并且不会将其视为这样?感谢您的帮助!

编辑添加:程序代码的下一部分:

d2 b)(put-on-c-list(d1 c-list))code>(defun next-part-of-program (b1)(b1))(如果(> d2a)和(注意:我已经初始化了a-列表和c列表早些时候作为全局变量/列表添加到后面。

再次感谢!

解决方案

最后一行 get-box 应该是:

<$ p $ (程序的下一部分新的d1新的d2新的d3)))))

你不应该在下一部分程序

的参数

I am working on a Lisp program that contains code to read in the dimensions of boxes and then sort them from shortest to longest lengths (and set each of these new lengths as new variables).

When I attempt to load my file into the interpreter, I get the following error:

*** - EVAL: undefined function NEW-D1

I am confused as to why I'd be getting this error because new-d1 isn't a function, it's a variable for the length of the shortest edge of a given box.

Here's the code where new-d1 is first initialized and set:

(defun get-box () (let ((d1 0) (d2 0) (d3 0) (new-d1 0) (new-d2 0) (new-d3 0)) (setf d1 (read)) (setf d2 (read)) (setf d3 (read)) (if (= d1 -1) (exit) (progn (setq new-d1 (first (sort (list d1 d2 d3) #'<))) (setq new-d2 (second (sort (list d1 d2 d3) #'<))) (setq new-d3 (third (sort (list d1 d2 d3) #'<))) (next-part-of-program (new-d1 new-d2 new-d3))))))

How can I change my code so the interpreter knows new-d1 isn't a function and doesn't treat it as such? Thanks for any help!

Edited to add: Next part of program code:

(defun next-part-of-program(d1 d2 d3) (if (> d2 b) (put-on-c-list(d1 c-list)) (if (> d2 a) and (< d2 c) (put-on-b-list (d1 b-list)) (put-on-a-list (d1 a-list)))))

Note: I've initialized a-list, b-list, and c-list earlier as global variables/lists to be added to later.

Thanks again!

解决方案

The last line of get-box should be:

(next-part-of-program new-d1 new-d2 new-d3)))))

You should not have parens around the arguments to next-part-of-program

更多推荐

LISP中未定义的函数错误

本文发布于:2023-11-26 23:23:05,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   中未   定义   错误   LISP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!