lisp

Editing programs “while they are running”? How?

冷暖自知 提交于 2019-12-14 00:17:24
问题 This question is a corollary to: Editing programs “while they are running”? Why? I'm only recently being exposed to the world of Clojure and am fascinated by a few examples I've seen of "live coding". The question linked above discusses the "why." My question is: How is this live coding technique possible? Is it a characteristic of the clojure language which makes it possible? Or is it just a pattern that they applied which could be applied to any language? I've got a background in python and

How to order a list in sublists in Lisp?

谁说胖子不能爱 提交于 2019-12-13 22:24:31
问题 I have a list like this: (4 5 6 3 12 22 4 4 55 43 1 4 0) and want an output like this: ((4 5 6) (3) (12 22) (4) (4 55) (43) (1 4) (0)) I think you can guess the order, it has an ascending order, I'm totally new with Lisp and need some help 回答1: Here is one possible solution in TXR Lisp: (defun ascending-partitions (list) (let ((indices (mappend (do if (>= @1 @2) (list @3)) list (cdr list) (range 1)))) (split list indices))) We obtain the numeric index positions of the elements in the list

lisp error: should be lambda expression

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 22:09:07
问题 I'm learning lisp by myself and I can´t figure out why am I getting this error. If somebody could help me that would be great :) This is the condition where I'm getting the error: (cond ((equal c1 caracter) (push caracter pilatemp)) ((or (equal c2 caracter) (equal c3 caracter) (equal c4 caracter) (equal c5 caracter) (equal c6 caracter)) ((loop (setf t1 (jerarquia(caracter))) (setf t2 (jerarquia(first pilatemp))) if((or (= t1 t2) (> t1 t2)) (return)) (push (pop pilatemp) piladef)) (push

Eval not working on unexpanded macro quote

跟風遠走 提交于 2019-12-13 17:03:51
问题 In common lisp I can do this: src-> (defmacro macro-hello () `"hello") (eval '(macro-hello)) no problem. In clojure: (defmacro macro-hello [] `"hello") (eval '(macro-hello)) gives me an error. Have I done something wrong? Clojure Error: Exception in thread "main" java.lang.Exception: Unable to resolve symbol: macro-hello in this context (NO_SOURCE_FILE:12) at clojure.lang.Compiler.analyze(Compiler.java:4340) at clojure.lang.Compiler.analyze(Compiler.java:4286) at clojure.lang.Compiler

Lisp - replace all the appereances of an element in a list [duplicate]

孤人 提交于 2019-12-13 15:21:54
问题 This question already has answers here : Common lisp error: “should be lambda expression” (4 answers) Closed 2 years ago . I try to replace a certain element E in a list with another list K at all the main list levels. (defun replaceList(l e k) (cond ((null l) nil) ((equal e (car l)) (cons k (replaceList (cdr l) e k))) ((listp (car l)) ((equal e (car (car l))) (cons k (replaceList (cdr (car l)) e k)))) (t (cons (car l) (replaceList (cdr l) e k))))) Example: (replaceList '(3 1 2 (6 1) 7 (5 (5

Printing contents of array LISP

好久不见. 提交于 2019-12-13 14:22:53
问题 Why does this code not print out the content of the array - (defun loopfn (state) (loop for x from 0 to 2 do (loop for y from 0 to 2 do (aref state x y)))) Here I am passing a 3x3 matrix which is built like this - `(setq i (make-array '(3,3) :initial-contents '((0 1 3) (4 2 5) (7 8 6))))` I am calling - (loopfn i) Edit-------- @Greg Thanks for pointing that out... I had the following question.. Why does this print the output ... (defun loopfn () (loop for x from 0 to 3 do (if (eq x 2)(return

Error when I try to make clone of HN in Windows 7: 'rm' is not recognized

走远了吗. 提交于 2019-12-13 14:17:21
问题 I have downloaded Arc 3.1 and Racket to my Windows 7 machine. I have solved many errors as instructed in http://www.arclanguage.org/item?id=12397 Now when I enter (nsv) the following error occurs and localhost:8080 comes out blank: arc> (nsv) 'rm' is not recognized as an internal or external command, operable program or batch file. load items: ranking stories. user break === context === C:\arc3.1\ac.scm:1031:20 gs1259 ready to serve port 8080 user break === context === C:\arc3.1\ac.scm:1031

Macro for more than 1 line of code

这一生的挚爱 提交于 2019-12-13 13:32:01
问题 I'm learning the macro system of Common Lisp and suddenly found a problem (defun hello () (format t "hello ~%")) (defun world () (format t "world ~%")) (defmacro call-2-func (func1 func2) `(,func1) `(,func2)) (macroexpand-1 '(call-2-func hello world)) (WORLD) T Well. Why can't I generate 2 LoC from only one macro? How can I work around? ( progn will not work in a more complicated situation... ) 回答1: Your macro needs to return just one form that will call both functions. Instead you are

Lisp soap client

為{幸葍}努か 提交于 2019-12-13 13:23:59
问题 It was very easy to use Apache CXF to develop a client for a SOAP web service. All I had to do was call wsdl2java and all the required classes were present. Is there such a client for lisp? If not, what can I do to write a soap client for lisp? The only restriction is that I don't have access to commercial implementations such as franz/lispworks or macs. 回答1: There's CL-SOAP which I tried earlier this year. The nice thing about it is that it can read a WSDL file and use that to generate the

repeating elements in common lisp [closed]

北城以北 提交于 2019-12-13 13:17:41
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am try to create a function with two arguments x and y which creates a list of y times repeated elements X but im getting confused on how to do it which or which method to use i think list compression can do