lisp

LISP - Program to search a specific function through its parameters

﹥>﹥吖頭↗ 提交于 2019-12-06 07:21:25
For a course project I got to write a program in lisp. The program should contain the most important lisp functions, their input and output parameters and maybe optional parameters. For example: function - first, input - list, output - object (first member of list). The program should work in 2 different ways: You give the program the name of a function and it should return the function parameters. You enter function parameters and if a function with these parameters exists, it should return the name of the function. My questions: What would be the right way to approach a task like this in

How do I get a terminal program to honour cursor keys?

眉间皱痕 提交于 2019-12-06 07:19:05
I'm using ccl/openmcl on Mac OS X. (latest versions of both). When the lisp prompt is displayed, using the cursor keys to navigate the current line results in escape codes, rather than movement, eg: Welcome to Clozure Common Lisp Version 1.2-r9226-RC1 (DarwinX8664)! ? (^[[D Here I've pressed the ( key, and then the left cursor key. When I run ccl/openmcl on a Debian Etch box, the cursor behaves as expected, and moves the insert point one position left. I guess this is some sort of terminal configuration option? If Clozure CL doesn't provide native readline/editline/whatever support or is

Common Lisp对象系统(CLOS)的一个小小的实例

血红的双手。 提交于 2019-12-06 06:29:27
本文是对《Practical Common Lisp》第16章的简单代码注解。CLOS为Common Lisp Object System的缩写,与所有面向对象语言相同,CLOS是基于类组织起来的,所不同的是广义函数而非消息传递是对象与方法通信的桥梁。 以下是实现的几个简单功能,模拟电梯升降的逻辑可能有不妥之处,但不影响对简单CLOS的表述。 ;;;;;; 电梯模拟程序 ;;;;; (defclass lift () ((lift-length :initarg :lift-length :initform 3) (lift-wide :initarg :lift-wide :initform 2) (lift-height :initarg :lift-height :initform 3) (lift-status :initarg :lift-status :initform 1) (floor-count :initform 8 :reader floor-count :writer (setf floor-count)) (floor-number-now :initform 1 :reader floor-number-now :writer (setf floor-number-now)))) #| @brief 电梯运行延时 @param seconds --

Lisp-Stat 翻译 —— 第一章 简介

自闭症网瘾萝莉.ら 提交于 2019-12-06 06:29:17
第一章 简介 1.1 统计计算环境 以前,统计计算主要集中于数值 计算 。那时的计算机运行速度慢,为了获得合理的性能,人们不得不在一个相对较低水平上细心地编写程序。结果,为了效率,大多数早期的统计系统都是简单的终端机而不是严格的数值算法。使用这些系统的人们需要提交他们的统计需求,然后在当天的晚些时候或者第二天才能拿到结果。 随着计算机变得越来越快,越来越廉价,将以前花费几小时或者几天才能完成的计算工作在几分钟或几秒钟内完成已经成为可能。这种发展对统计软件提出了新的挑战。由于现在的计算机硬件能够在短期内完成不同的计算与分析任务,一个支持性的统计软件环境要使以下步骤变得简单易行——将不同的计算结果展示到计算机上,将一台计算机的计算结果传递到另一台计算机上,检测计算结果,跟踪计算过程。进一步说,随着一些计算流程的重复使用(有可能有细微的变化),将此计算流程作为一个单元来描述和请求调用,建立一个简单的抽象已经成为可能。简而言之,为了补充现代计算机硬件的能力,统计环境必须是一个带有交互能力的统计语言。 另一个重要的发展发生在对计算速度的并行性上。越来越多的统计计算是在配置了高分辨率的个人电脑和工作站上完成的。这类高分辨率显示硬件开拓了很多新的机遇。统计研究的一个最令人激动的领域就是动态计算机绘图领域和它在统计学上的应用。多年以来,绘图方法已经成为统计学上的一个重要工具。但是

Lisp Reverse “all” Function

折月煮酒 提交于 2019-12-06 05:46:19
I want to write a function in lisp that reverses all elements from the list using map functions but I don't have any idea how to start this.. I think I have to use the built in reverse function somehow.. For example if I have the list (1 2 3 (4 5 6 (7 8 9))) I would get (((9 8 7) 6 5 4) 3 2 1) or if I had the list(1 2 3 (4 5) (6 7)) I would get ((7 6) (5 4) 3 2 1) .. Any help is appreciated! Just a quick answer, not sure about efficiency/elegancy: (defun reverse-deeply (list) (mapcar #'(lambda (li) (cond ((consp li) (reverse-deeply li)) (t li))) (reverse list))) (defun reverse-list (list) (let

Multiple lines comments in Scheme (RnRS)

独自空忆成欢 提交于 2019-12-06 05:31:45
问题 I created this solution: ; use like this: ; (/* content ... */ <default-return>) ; or ; (/* content ... */) => #f (define-syntax /* (syntax-rules (*/) ((/* body ... */) #f) ((/* body ... */ r) r))) But is it really the best or easiest way? 回答1: You can't do it this way -- it won't work for a number of contexts. Here are some examples that won't work: (+ (/* foo */) 1 2) (define (foo a (/* b */) c) ...) (/* foo; bar */) (/*x*/) (let ((x (/* 1 */) 2)) ...) (let ((/* (x 1) */) (x 2)) ...) (car '

no mouse-wheel event when shift key is down (shift+mouse-wheel events?)

守給你的承諾、 提交于 2019-12-06 04:37:14
问题 I'm trying to manage some events in lisp with lispbuilder-sdl . Thus far I got this. ;; Load package : (ql:quickload "lispbuilder-sdl") ;; main definition: (defun main (argv) (defparameter *ticks* 0) (sdl:with-init () (sdl:window 100 100 :title-caption "test") (sdl:with-events () (setf (sdl:frame-rate) 60) (:quit-event () (progn (sdl:quit-image) (exit) t)) (:mouse-button-down-event (:button button :x x :y y) (format t "~&LSHIFT: ~a RSHIFT: ~a BUTTON: ~a X: ~d Y: ~d" (sdl:get-key-state :sdl

How do I install LFE on Ubuntu Karmic?

隐身守侯 提交于 2019-12-06 04:28:08
问题 Erlang was already installed: $dpkg -l|grep erlang ii erlang 1:13.b.3-dfsg-2ubuntu2 Concurrent, real-time, distributed function ii erlang-appmon 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP application monitor ii erlang-asn1 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP modules for ASN.1 support ii erlang-base 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP virtual machine and base applica ii erlang-common-test 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP application for automated testin ii erlang-debugger 1:13.b.3-dfsg-2ubuntu2 Erlang/OTP

comma-comma-at in Common Lisp

折月煮酒 提交于 2019-12-06 04:16:01
问题 I am confused about how comma-comma-at does what it does. An example of use of comma-comma-at is in Is there a use for double unquote (double comma) when defining a Lisp macro? It seems to me that (let ((parms '(x y))) ``(beg ,,@parms end)) expands to or something equivalent to `(beg ,x ,y end) How does it expands to that? I was thinking, if I evaluate the double backquote form, it causes the second comma to do its work, and the result is: `(beg ,<splice stuff here> end) and it looks like

With case, which is the best of these methods for expressing the cases?

こ雲淡風輕ζ 提交于 2019-12-06 03:49:45
问题 These all work: (defun testcaseexpr (thecase) (case thecase ('foo (format t "matched foo")) (bar (format t "matched bar")) ((funk) (format t "matched funky")))) Which of these three expressions is considered the idiomatic way? And perhaps as a side point, why are they all working, when clearly they are not the same syntax. In fact in other contexts they have different semantics completely. A list (funk) is certainly not the same as a quoted atom, 'foo . Yet just passing in the words foo bar