问题标签 [cons]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
scala - Scala:同伴中的“应用”方法需要创建案例类实例吗?
下面的代码定义了一个 List 类型和两个案例类的实现,一个代表空列表,一个代表创建实际列表的 Cons
我的假设是正确的,即列表是在val example = ...
执行时由上面的递归应用方法创建的。
如果是这样的话。创建 ConsCons(head, tail)
的签名是由于应用的签名不兼容variad
def apply[A](as: A*): List[A]
,scala 是如何实际推断val example
的List(1, 2, 3, Nil)
lisp - LISP 程序需要不小的调整。
该程序应该在列表中找到某个符号之后的每个符号。该函数获取传入的参数。一个可以包含嵌套列表和符号的列表。该函数必须扫描列表并搜索给定符号并打印给定符号之后的符号。
例子:
到目前为止我的代码:
此代码有效,除非它要查找的符号是列表中的最后一个原子。在这些测试用例中失败:
但在这些情况下工作正常:
问题可能出在我的缺点声明中,我无法解决此问题。
c++ - 无法设置窗口名称
所以我试着把一个窗口放在一起,但是当我需要给窗口命名时,我告诉了我。(错误:“const char*”类型的参数与“LPCWSTR”类型不兼容) CreateWindow 方法的编程在下面。错误应该在第 2 行。
非常欢迎所有帮助!提前致谢。
list - Removing Item from List in Scheme leaves empty null list element
I have the following code:
The goal is to remove a certain character from this list. For instance,
Instead of this I am getting:
I am brand new to scheme. I have tried not returning anything if the value is found, however that just makes it behave like:
Any ideas? Many thanks!
scheme - 方案说明(构造)
有人可以解释一下为什么:
我不认为我明白。谢谢
common-lisp - 使用 Common Lisp 创建一对
我需要使用 Common Lisp 创建一个包含两个对的对。
输出需要是:
((1 . 2) . (3 . 4))
文献状态(cons (cons 1 2) (cons 3 4))
应该输出我需要的东西,但是当我运行时,我得到:
((1 . 2) 3 . 4)
任何帮助表示赞赏。
scheme - `(mcons (mcons '() 25) 16)` 和 `(mcons 25 (mcons 16 `()))` 有什么区别
我正忙于计算机程序的结构和解释练习 2.18。在这里,我们必须定义一个过程 reverse 来反转一个列表。它应该执行以下操作:
我提出了以下定义:
然后在一个解决方案中发现类似如下:
append
和这里有区别cons
,我不能指手画脚。
我的问题:有什么区别,为什么结果不显示为(25 16 9 4 1)
?
scheme - 如何以相反的方式使用 CONS?
通常,我们cons
在 RACKET 中将两个参数传递给 ,
eg:
(cons 23 '(1 2 3))
哪个输出'(23 1 2 3)
是否有任何程序可以执行以下操作
(procedure '(1 2 3) 23)
=>'(1 2 3 23)
ocaml - OCaml 的缺点
我正在阅读 OCaml 的语言手册并遇到了“cons”运算符,表示为
但是,根本没有解释它是什么,以及它通常用于什么。
scheme - 方案解释中的缺点
(cons 1 2)
给我们(1 . 2)
。
(cons 3 4)
给我们(3 . 4)
。
那么为什么(cons (cons 1 2) (cons 3 4))
给我们((1 . 2) 3 . 4)
呢?为什么不是((1 . 2) (3 . 4))
?