lisp

continuation in common lisp by macros — regarding an implemetation in OnLisp

穿精又带淫゛_ 提交于 2019-11-30 05:28:52
In On Lisp , p. 267, Paul Graham provides an implementation of continuation passing macros: (setq *cont* #'identity) (defmacro =lambda (parms &body body) `#'(lambda (*cont* ,@parms) ,@body)) (defmacro =defun (name parms &body body) (let ((f (intern (concatenate 'string "=" (symbol-name name))))) `(progn (defmacro ,name ,parms `(,',f *cont* ,,@parms)) (defun ,f (*cont* ,@parms) ,@body)))) (defmacro =bind (parms expr &body body) `(let ((*cont* #'(lambda ,parms ,@body))) ,expr)) (defmacro =values (&rest retvals) `(funcall *cont* ,@retvals)) The following code to traverse a tree t2 for each leaf

Running SICP Pattern Matching Rule Based Substitution Code

烂漫一生 提交于 2019-11-30 05:16:34
I have found the code from this lesson online (http://groups.csail.mit.edu/mac/ftpdir/6.001-fall91/ps4/matcher-from-lecture.scm), and I am having a heck of a time trying to debug it. The code looks pretty comparable to what Sussman has written: ;;; Scheme code from the Pattern Matcher lecture ;; Pattern Matching and Simplification (define (match pattern expression dictionary) (cond ((eq? dictionary 'failed) 'failed) ((atom? pattern) (if (atom? expression) (if (eq? pattern expression) dictionary 'failed) 'failed)) ((arbitrary-constant? pattern) (if (constant? expression) (extend-dictionary

在Ubuntu12.04上的Common Lisp开发环境配置

南楼画角 提交于 2019-11-30 05:15:19
一,安装最新的Emacs 1,清理旧的emacs sudo apt-get update sudo apt-get install sudo apt-get purge emacs emacs-snapshot-common emacs-snapshot-bin-common emacs-snapshot emacs-snapshot-el emacs-snapshot-gtk emacs23 emacs23-bin-common emacs23-common emacs23-el emacs23-nox emacs23-lucid auctex apel emacs24 emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacs-el 2,添加PPA: sudo add-apt-repository ppa:cassou/emacs sudo apt-get update 3,安装emacs-snapshot sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot 或者安装emacs24 sudo apt-get install emacs24 emacs24-el emacs24-common-non-dfsg 二,安装

Using Let in Scheme

我怕爱的太早我们不能终老 提交于 2019-11-30 05:11:14
I want to write a program to find the roots of the quadratic equation in Scheme. I used LET for certain bindings. (define roots-with-let (λ (a b c) (let ((4ac (* 4 a c)) (2a (* 2 a)) (discriminant (sqrt ( - (* b b) (4ac))))) (cons ( / ( + (- b) discriminant) 2a) ( / ( - (- b) discriminant) 2a))))) I defined the discriminant with 4ac since I did not want (* 4 a c) . Even though I have defined (4ac (* 4 a c)) , it is giving me this error: expand: unbound identifier in module in: 4ac . My question is how is let evaluated (what order)? And if i want 4ac in my let should i write another inner let ?

Help writing emacs lisp for emacs etags search

浪子不回头ぞ 提交于 2019-11-30 05:09:53
问题 I'm looking for some help developing what I think should be an easy program. I want something similar to Emacs tags-search command, but I want to collect all search results into a buffer. (I want to see all results of M-,) I'm thinking this python style pseudo code should work, but I have no idea how to do this in emacs lisp? Any help would be greatly appreciated. def myTagsGrep(searchValue): for aFile in the tag list: result = grep aFile seachValue if len(result) > 0: print aFile # to the

want to learn common lisp [closed]

倾然丶 夕夏残阳落幕 提交于 2019-11-30 05:02:27
I have some basic python experience so I know the basics of programming such as variables, data types, functions and basic OO. What is a good source to learn common lisp? Try Practical Common Lisp by Peter Seibel, it's available online. In my opinion, Common Lisp: A Gentle Introduction to Symbolic Computation is the best introductory Lisp book available. It has a good pace for (even absolute) beginners, and there are nice little exercises with solutions. If I interpret your self-description correctly, this would be a good read for you. When I recommended it to some of my fellow students, all

Reload .emacs for all active buffers

故事扮演 提交于 2019-11-30 05:02:09
A question already has been asked how to reload a .emacs file after changing it . The proposed solutions were to use M-x load-file or M-x eval-region RET on the changed region. Neither of these solutions affect other open buffers for me. Is there a way to reload the .emacs file for all open buffers? I should also note that the M-x load-file does not have the desired effect for reasons outlined in the comments to that answer . Your .emacs file is a global configuration that gets evaluated once only. It does not get applied to each buffer individually. How you actually achieve what you want is

Using a lambda value from function as first element of list

旧时模样 提交于 2019-11-30 04:41:22
问题 I'm reading over Peter Norvig's Paradigms of Artificial Intelligence Programming, and I've come across an issue I cannot resolve on my own (this is my introduction to Lisp). The issue is quite a small one, really, but obviously not one my little brain can solve. Why is it that when a function's value is a lambda, it is an error to use that function as the first element to a list. For example: Lisp: (defun some-func () #'(lambda (x) x)) ;; At REPL ;; Does not work > ((some-func) 1) ;; Does

How is the `*var-name*` naming-convention used in clojure?

核能气质少年 提交于 2019-11-30 04:17:36
As a non-lisper coming to clojure how should I best understand the naming convention where vars get a name like *var-name* ? This appears to be a lisp convention indicating a global variable. But in clojure such vars appear in namespaces as far as I can tell. I would really appreciate a brief explanation of what I should expect when an author has used such vars in their code, ideally with a example of how and why such a var would be used and changed in a clojure library. It's a convention used in other Lisps, such as Common Lisp, to distinguish between special variables , as distinct from

How to process input and output streams in Steel Bank Common Lisp?

青春壹個敷衍的年華 提交于 2019-11-30 04:11:55
I'm trying to figure out how to use the output stream of one program I start with RUN-PROGRAM so it can be used as the input of another program started with RUN-PROGRAM (i.e., the moral and perhaps literal equivalent of piping). I've tried using a number of combinations of the :INPUT , :OUTPUT and :WAIT keyword arguments, but nothing I've hit upon has been productive so far. Any tips would be helpful; for example, how would I go about doing something like ls | grep lisp from the shell? One of my attempts is (defun piping-test () (let ((grep-process (run-program "/usr/bin/grep" '("lisp") :input