lisp

Recursive euclidean distance

纵然是瞬间 提交于 2019-11-30 10:01:41
问题 I was tasked to write a recursive euclidean distance. I have been googling around but could not find any sample. I understand the function of euclidean distance and has no problem writing it in an iterative manner as shown below. Is there anyone who could advise me on how I should start for the recursive function? The requirement is the same as the iterative version. Thanks. (defun euclidean-distance-it (p q) (cond ((or (null p) (null q)) nil) ;return nil if either list is null ((or (atom p)

Running Clojure and other Lisp at the same time on Emacs

◇◆丶佛笑我妖孽 提交于 2019-11-30 09:48:41
I use Aquamacs , and Aquamacs is pre-equipped with SLIME . (setq inferior-lisp-program "/usr/local/bin/sbcl") #####!!! (add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME/contrib") (add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME") (require 'slime) (slime-setup) As is asked in somewhere, I try to use Clojure by adding this code. (add-to-list 'load-path "~/clojure/clojure-mode") (setq inferior-lisp-program "/Users/smcho/bin/clj") ################ (require 'clojure-mode) (setq auto-mode-alist (cons '("\\.clj$ . clojure-mode") auto-mode-alist))

In Lisp, how many inputs can the + function actually have?

筅森魡賤 提交于 2019-11-30 08:33:48
问题 I'm relatively new to Lisp, and I was wondering if there really is an upper limit to the "+" function. (I guess this applies to all the other arithmetic functions "-", "/" etc.) 回答1: Yes, there is an upper limit, but the exact upper limit is implementation-dependent. You're guaranteed to be able to pass at least 50, but it all depends. If you need to sum a list, you're probably better off with (reduce #'+ list) , that should give you a much better scalability than any other method. Common

Using string object as a hash key in Common Lisp

霸气de小男生 提交于 2019-11-30 08:00:45
问题 I'm trying to create a "dictionary" type - ie hash table with a string as a key. Is this possible or wise in Lisp? I noticed that this works as expected: > (setq table (make-hash-table)) #<HASH-TABLE :TEST EQL size 0/60 #x91AFA46> > (setf (gethash 1 table) "one") "one" > (gethash 1 table) "one" However, the following does not: > (setq table (make-hash-table)) #<HASH-TABLE :TEST EQL size 0/60 #x91AFA0E> > table #<HASH-TABLE :TEST EQL size 0/60 #x91AFA0E> > (setf (gethash "one" table) 1) 1 >

If you already know LISP, why would you also want to learn F#?

浪子不回头ぞ 提交于 2019-11-30 07:22:39
What is the added value for learning F# when you are already familiar with LISP? Static typing (with type inference) Algebraic data types Pattern matching Extensible pattern matching with active patterns. Currying (with a nice syntax) Monadic programming , called 'workflows', provides a nice way to do asynchronous programming. A lot of these are relatively recent developments in the programming language world. This is something you'll see in F# that you won't in Lisp, especially Common Lisp, because the F# standard is still under development. As a result, you'll find there is a quite a bit to

Writing a formal language parser with Lisp

£可爱£侵袭症+ 提交于 2019-11-30 07:10:37
My company is designing a new domain specific scripting language; I have to implement a parser that translates our brand new programming language into a common scripting language so as to be able to enact it. The usual way I do this is by means of Bison and Flex tools that generate the C/C++ code of the translator. I found other tools, for most of the mainstream programming languages, but none for Lisp . Hasn't Lisp ever been used for that? What is the usual way to write a parser with Lisp ? Note: to me, any Lisp implementation / dialect that could help is ok, I do not have any preference. To

How to see docstrings and other symbol information in Common Lisp REPL?

て烟熏妆下的殇ゞ 提交于 2019-11-30 06:31:17
I'm completely new to CL, and I'd like to learn how to read documentation strings and get other help information from the REPL. Something like help(symbol) in Python, or symbol? in iPython, or :t and :i in Haskell's GHCi. So, given a symbol name, I'd like to be able to know: what kind of value it is bound to, if any (a function, a variable, none at all) if it is a function or a macro, then what are its positional arguments if it has a docstring, show it what package or file it is coming from or when it was defined I found there is (documentation '_symbol_ '_type_) , but it is not exactly what

Read macros: what do you use them for? [closed]

隐身守侯 提交于 2019-11-30 06:28:11
I'm trying to get a feel for the parts of Lisp that I haven't used very much up to now. Read macros have caught my attention at the moment. There isn't a huge amount of info about their use and it would help to see what people have done with them, both to get examples of how they work and also to see what sorts of problems can be approached with them. Following on that, are there any guidelines for knowing what constitutes good and bad use of read macros? S-expressions are Lisp's syntax for Lisp data. S-expressions are read with the function READ and read macros are Lisp's built-in way to

In Lisp (Clojure, Emacs Lisp), what is the difference between list and quote?

喜夏-厌秋 提交于 2019-11-30 06:14:38
From reading introductory material on Lisp, I now consider the following to be identical: (list 1 2 3) '(1 2 3) However, judging from problems I face when using the quoted form in both Clojure and Emacs Lisp, they are not the same. Can you tell me what the difference is? The primary difference is that quote prevents evaluation of the elements, whereas list does not: user=> '(1 2 (+ 1 2)) (1 2 (+ 1 2)) user=> (list 1 2 (+ 1 2)) (1 2 3) For this reason (among others), it is idiomatic clojure to use a vector when describing a literal collection: user=> [1 2 (+ 1 2)] [1 2 3] Trey Jackson Quoted

The tool for visual programming

回眸只為那壹抹淺笑 提交于 2019-11-30 05:51:08
I need the tool for graphical representing of work flow in a program (like electronic circuits are described with graphical representation). The representation has to be like the following: functions are boxes and arrows between boxes are "messages". Like this: alt text http://img372.imageshack.us/img372/8471/functionsqv0.png This picture shows the following: (c (a) (b)) Where parameters of c() are named as d and e. On C it would be void c( someType1 d, someType2 e ); someType1 a( void ); someType2 b( void ); .... c( a(), b() ); So I think that I need the tool for manipulation and visual