我正在打印一个我认为是列表的值,但我得到的输出是:
[...]
Run Code Online (Sandbox Code Playgroud)
这代表什么?我该如何测试呢?我试过了:
myVar.__repr__() != '[...]'
Run Code Online (Sandbox Code Playgroud)
和
myVar.__repr_() != Ellipsis
Run Code Online (Sandbox Code Playgroud)
但没有骰子......
这是给出问题的代码的缩减:
def buildPaths(graph, start, end, path=[], totalPaths=[]):
"""
returns list of all possible paths from start node to the end node
"""
path = path + [start]
if start == end:
return path
for nextNode in graph.childrenOf(start):
if nextNode not in path:
newPath = buildPaths(graph, nextNode, end, path, totalPaths)
if newPath != []: # test
totalPaths.append(newPath)
return totalPaths
Run Code Online (Sandbox Code Playgroud)
totalPaths包含很多所谓的递归列表,但我不明白为什么.我在#test修改了测试以防止这种情况发生.
我也尝试过:
def buildPaths(graph, thisNode, end, path=[], totalPaths=None):
"""
returns list …Run Code Online (Sandbox Code Playgroud) 我曾经看过这个用过一次,但无法理解它做了什么.参考文献说它是
#n=object读取为任何对象具有对象作为其打印表示.但是,该对象标记为n,即必需的无符号十进制整数,可通过语法#n#进行引用.标签的范围是最外面的read调用读取的表达式; 在此表达式中,相同的标签可能不会出现两次.
对我来说,只读了56个随机选择的英语单词...请问您能举例说明何时可以使用这个单词?
在Linux中运行sbcl 1.3.7,我有一个对象有一个有意为循环列表的插槽,遵循Rainer Joswig 在Common Lisp中的循环列表中的建议和一个旨在成为正确列表的全局变量(不打算是圆).
(setf *print-circle* t)
(defun circular (items)
(setf (cdr (last items)) items)
items)
(defclass circular ()
((items :accessor items :initarg :items)))
(defmethod initialize-instance :after ((c circular) &rest initargs)
(setf (slot-value c 'items)
(circular (slot-value c 'items))))
(defmethod next-item ((c circular))
(prog1 (first (slot-value c 'items))
(setf (slot-value c 'items)
(rest (slot-value c 'items)))))
(defparameter *notes* (make-instance 'circular :items '(A A# B C C# D D# E F F# G G#)))
(defparameter *stuff1* '(A …Run Code Online (Sandbox Code Playgroud) 我们已经从lisp获得了作业,我需要使用"循环"列表(我不知道这是什么命名).通过"循环"列表,我的意思是列表,cdr最后一个cons的哪一个指向同一列表中的第一个.
(Value1 . PointerValue2) (Value2 . PointerValue3) (Value3 . PointerValue1)
Run Code Online (Sandbox Code Playgroud)
我们被教导要创建这样的列表:
(defun cykl (l)
(setf (cdr (last l)) l)
)
Run Code Online (Sandbox Code Playgroud)
我使用的Lisp软件(Lispbox)不支持这种列表.我也在Debian上尝试了clisp,但是在创建了这样的列表后它已经崩溃了.
你知道哪些lisp实现支持这个(免费软件,os独立)?