lisp

Circular list in Common Lisp

≡放荡痞女 提交于 2019-12-29 01:33:31
问题 I am working using a visual programming environment for musical composition based on CL . I am trying to create a function that when given say 3 elements (1 2 3) will return 1, 2, 3, 1, 2, 3 etc., one number at the time each time it is evaluated. The book Common Lisp a Gentle Introduction , mentions briefly that it's possible to create circular lists using sharp-equal notation but does not get into details on how to use them. Keep in mind that I can insert actual Lisp code in the program

Why (apply and '(1 2 3)) doesn't work while (and 1 2 3) works in R5RS? [duplicate]

微笑、不失礼 提交于 2019-12-28 07:02:08
问题 This question already has answers here : Using AND with the apply function in Scheme (9 answers) Closed 6 years ago . I tried it in Racket like this > (apply and '(1 2 3)) . and: bad syntax in: and > (and 1 2 3) 3 Does anyone have ideas about this? 回答1: Chris Jester-Young's answer is right, but there's one other point I want to highlight. The standard and operator is a macro which delays the evaluation of its arguments, by (essentially, if not exactly) turning (and a b c) into (if a (if b c

Running a Common Lisp function from a Terminal command prompt

百般思念 提交于 2019-12-28 05:52:12
问题 I'm having some difficulty finding an answer to this, so maybe it isn't possible. I'd like the flexibility of being able to load/compile a lisp file from a command line, i.e. not inside emacs, and then also run one of the lisp functions in that file also from the command line. This is no doubt implementation specific feature, so any pointers on an implementation that offers this (or perhaps it is fairly standard, I don't know). I'm using SBCL and like it, so it would be great if that could do

emacs compile error

烂漫一生 提交于 2019-12-28 03:52:08
I've managed to build and install (using checkinstall) an GNU Emacs 25.1 Debian package on 16.04, but on 16.10 for some unknown reason the compilation fails (at the make stage) giving the truncated output: Loading language/czech... Loading language/slovak... Loading language/romanian... Loading language/greek... Loading language/hebrew... Loading international/cp51932... Loading international/eucjp-ms... Loading language/japanese... Loading language/korean... Loading language/lao... Loading language/tai-viet... Loading language/thai... Loading language/tibetan... Loading language/vietnamese...

SICP 第一章 构造过程抽象 1

本秂侑毒 提交于 2019-12-27 00:03:10
Chapter 1 Building Abstractions with Procedures /*--> */ /*--> */ Chapter 1 Building Abstractions with Procedures Table of Contents 1. 构造过程抽象 1.1. 程序设计的基本元素 1.1.1. 表达式(expressions) 1.1.2. 命名和环境 1.1.3. 组合式的求值 1.1.4. 复合过程(compound procedures) 1.1.5. 过程应用的代换模型 1.1.6. 条件表达式和谓词 1.1.7. 练习 1.1.8. 实例:采用牛顿法求平方根 1.1.9. 过程作为黑箱抽象 1.1.10. 练习 1 构造过程抽象 心智活动就是: 组合. 将 simple ideas 变成 compound ideas 关系. 将idea放在一起, setting them by one another, 同时观察. 抽象. 隔离开实际中的相伴的其他idea, 从而抽取出 general idea. 我们研究 the idea of a computational process. 计算过程(computational process) 计算机中的 抽闲存在, 操作 data. 一套规则即 program

LISP: Find occurrences of each word in a sentence.

╄→гoц情女王★ 提交于 2019-12-26 07:43:53
问题 Can someone please explain to me how I search for the occurrences of each word in a sentence, such as "the cat sat on the mat" in Common lisp ? The user has to have inputted this line of text before hand and then the occurrences must be counted from that. Any help on even where to start would help. 回答1: Have a look at split-by-one-space in The Common Lisp Cookbook (defun split-by-one-space (string) "Returns a list of substrings of string divided by ONE space each. Note: Two consecutive spaces

LISP: Find occurrences of each word in a sentence.

核能气质少年 提交于 2019-12-26 07:43:32
问题 Can someone please explain to me how I search for the occurrences of each word in a sentence, such as "the cat sat on the mat" in Common lisp ? The user has to have inputted this line of text before hand and then the occurrences must be counted from that. Any help on even where to start would help. 回答1: Have a look at split-by-one-space in The Common Lisp Cookbook (defun split-by-one-space (string) "Returns a list of substrings of string divided by ONE space each. Note: Two consecutive spaces

LISP: Find occurrences of each word in a sentence.

我的未来我决定 提交于 2019-12-26 07:43:14
问题 Can someone please explain to me how I search for the occurrences of each word in a sentence, such as "the cat sat on the mat" in Common lisp ? The user has to have inputted this line of text before hand and then the occurrences must be counted from that. Any help on even where to start would help. 回答1: Have a look at split-by-one-space in The Common Lisp Cookbook (defun split-by-one-space (string) "Returns a list of substrings of string divided by ONE space each. Note: Two consecutive spaces

LISP: Find occurrences of each word in a sentence.

前提是你 提交于 2019-12-26 07:42:26
问题 Can someone please explain to me how I search for the occurrences of each word in a sentence, such as "the cat sat on the mat" in Common lisp ? The user has to have inputted this line of text before hand and then the occurrences must be counted from that. Any help on even where to start would help. 回答1: Have a look at split-by-one-space in The Common Lisp Cookbook (defun split-by-one-space (string) "Returns a list of substrings of string divided by ONE space each. Note: Two consecutive spaces

How do I pass in a list of list into a function?

半腔热情 提交于 2019-12-25 18:26:59
问题 (defun square (n) (* n n)) (defun distance (a b) (let ( (h (- (second b) (second a))) (w (- (first b) (first a)))) (sqrt (+ (square h) (square w))) ) ) (defun helper-2 (head) (if (null (first (rest head)))) 0 (+ (distance (car head) (first (rest head))) (helper-2 (rest head)) ) I have this code written. My question is how do I use the helper-2 method? I've tried (helper-2 '((2 0) (4 0))) (helper-2 '(2 0) '(4 0)) neither works. Could anyone help? Thanks. 回答1: Please cut and paste the code in