小编Pau*_*han的帖子

如何对列表中的汽车和干部?

假设我有一些代码:

let listB = [ 1; 2; 3 ]  
Run Code Online (Sandbox Code Playgroud)

使用Lisp表示法,我该如何处理carcadr反对此列表?我知道缺点是::.

或者在Scheme中,firstrest

f# functional-programming list

4
推荐指数
2
解决办法
459
查看次数

Elisp函数返回标记而不是正确的值

我正在编写一个例程来测试点是否在实际的最后一行.

(defun end-of-line-p ()
  "T if there is only \w* between point and end of line" 
  (interactive)
  (save-excursion
    (set-mark-command nil)      ;mark where we are
    (move-end-of-line nil)      ;move to the end of the line
    (let ((str (buffer-substring (mark) (point))))    ;; does any non-ws text exist in the region? return false
      (if (string-match-p "\W*" str)
      t
    nil))))
Run Code Online (Sandbox Code Playgroud)

问题是,在运行它时,我在迷你缓冲窗口中看到"标记集",而不是T或nil.

lisp emacs elisp

4
推荐指数
1
解决办法
257
查看次数

Common Lisp Loop工具中的语法错误

这拒绝编译.注释掉该(setf roll行可以编译.但是,(setf roll...它本身在REPL中正确评估.

程序:

;; loop n times
; sum up number of hits over value v
(defun num-hits (n v)
  (let 
     ((roll)
       (table))
    (setq table (make-hash-table))
    ;;until i == n
    (loop for i from 1 to n
      (setf roll (rolld6))
;     (if (nilp (view_hash table))
;         (oxuassign_hash table roll 1)
;       (assign_hash table (+ 1 (view_hash table roll))))
      )
    (+ (view_hash table 5) (view_hash table 6))))
Run Code Online (Sandbox Code Playgroud)

信息:

*** - LOOP: illegal syntax near (SETF ROLL …
Run Code Online (Sandbox Code Playgroud)

common-lisp

4
推荐指数
1
解决办法
912
查看次数

使用gnu clisp运行shell命令

我正在尝试为clisp创建一个像这样工作的"系统"命令

(setq result (system "pwd"))

;;now result is equal to /my/path/here
Run Code Online (Sandbox Code Playgroud)

我有这样的事情:

(defun system (cmd)
 (ext:run-program :output :stream))
Run Code Online (Sandbox Code Playgroud)

但是,我不确定如何将流转换为字符串.我已经多次回顾了hyperspec和google.

编辑:使用Ranier的命令并使用with-output-to-stream,

(defun system (cmd)
  (with-output-to-string (stream)
    (ext:run-program cmd :output stream)))
Run Code Online (Sandbox Code Playgroud)

然后试着跑grep,这是我的道路......

[11]> (system "grep")

*** - STRING: argument #<OUTPUT STRING-OUTPUT-STREAM> should be a string, a
      symbol or a character
The following restarts are available:
USE-VALUE      :R1      Input a value to be used instead.
ABORT          :R2      Abort main loop
Break 1 [12]> :r2
Run Code Online (Sandbox Code Playgroud)

lisp clisp stream

4
推荐指数
1
解决办法
2513
查看次数

常见的lisp中的串口通信

Windows上的Common Lisp中是否有用于串口通信的库?

common-lisp serial-communication

4
推荐指数
1
解决办法
2602
查看次数

如何在Mongo中指定插入字段的类型

检查Mongo文档,我找不到如何在插入上指定类型.

我确信这是我想念的简单事.

mongodb

4
推荐指数
1
解决办法
3458
查看次数

单元测试MVC4中的路由/控制器

目标:测试给定的url返回给定的控制器函数.

在这个过程中,我已经闯入了路由系统,我无法弄清楚如何测试路由(或者,就此而言,找到与路由相对应的控制器: - /).

示例代码,不起作用:

[Test]       
public void kick_the_tires()
{
   var rc = new RouteCollection();

   Infrastructure.RouteRegistry.RegisterRoutes(rc);

   // get the route corresponding to name.
   var got = rc["name"];

   var expected = //What? foo is an internal type that can't be instantiated.

   Assert.AreEqual(foo, frob);
}
Run Code Online (Sandbox Code Playgroud)

编辑:使用Simon的链接博客文章作为存根类.

[TestCase("/", "~/", "Home", "Index")]
[TestCase("/", "api/command", "Other", "command")]
internal void stub_mocker(string apppath, string route, string expected_controller,\
  string expected_action)
{
  var rc = new RouteCollection();
  Infrastructure.RouteRegistry.RegisterRoutes(rc);

  var httpmock = new StubHttpContextForRouting(
      appPath: apppath,
      requestUrl: route);

  // this …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc-4

4
推荐指数
1
解决办法
2450
查看次数

什么是矩阵的能带存储?

有人问我矩阵的各种存储方式。特别是关于频段存储和其他变化。我知道这与有效存储稀疏矩阵有关。但是,我不清楚细节。

algorithm computer-science data-structures

4
推荐指数
1
解决办法
259
查看次数

如何测试Perl程序是否从我的测试套件编译?

我正在为一些Perl脚本构建回归系统(而不是单元测试).

该系统的核心组成部分是

  `perl script.pl @params 1>stdoutfile 2>stderrfile`;
Run Code Online (Sandbox Code Playgroud)

但是,在实际处理脚本的过程中,它们有时不会编译(Shock!).但是perl本身会正确执行.但是,我不知道如何在stderr上检测Perl是否无法编译(因此写入stderr),或者我的脚本在输入上被禁止(因此写入stderr).

如何检测程序是否执行,没有详尽地查找Perl错误消息并轻击stderr文件?

testing perl

3
推荐指数
1
解决办法
1005
查看次数

使用SQLite从SQL插入中获取主键

我有一个SQL表集,看起来像这样

create table foo ( 
    id int primary key asc, 
    data datatype );

create table bar ( 
    id int primary key asc, 
    fk_foo int,
    foreign key(foo_int) references foo(id));
Run Code Online (Sandbox Code Playgroud)

现在,我想插入一个记录集.

insert into table foo (data) values (stuff);
Run Code Online (Sandbox Code Playgroud)

但是等一下 - 要让Bar全部修补好,我需要来自Foo的PK.我知道这是一个已解决的问题.

解决方案是什么?

sql sqlite

3
推荐指数
1
解决办法
438
查看次数