lisp

Lisp Web Frameworks? [closed]

旧街凉风 提交于 2019-11-28 15:16:12
What are the popular (ok, popular is relative) web frameworks for the various flavours of LISP? Matthias Benkard PLT Scheme features a built-in, continuation-based web server . Update: PLT Scheme is now called Racket. Hunchentoot is also quite widespread What is Weblocks? Weblocks is a continuations-based web framework written in Common Lisp. http://common-lisp.net/project/cl-weblocks/ Most (perhaps all) of the well-known Common Lisp web frameworks have already been mentioned, so I'll just add some comments. Hunchentoot is not a "web framework" in the sense that most people mean. It's an HTTP

Why does Clojure have “keywords” in addition to “symbols”?

只愿长相守 提交于 2019-11-28 15:13:03
I have a passing knowledge of other Lisps (particularly Scheme) from way back. Recently I've been reading about Clojure . I see that it has both "symbols" and "keywords". Symbols I'm familiar with, but not with keywords. Do other Lisps have keywords? How are keywords different from symbols other than having different notation (ie: colons)? Brian Carper Here's the Clojure documentation for Keywords and Symbols. Keywords are symbolic identifiers that evaluate to themselves. They provide very fast equality tests... Symbols are identifiers that are normally used to refer to something else. They

Are Databases and Functional Programming at odds?

一世执手 提交于 2019-11-28 15:07:31
I've been a web developer for some time now, and have recently started learning some functional programming. Like others, I've had some significant trouble apply many of these concepts to my professional work. For me, the primary reason for this is I see a conflict between between FP's goal of remaining stateless seems quite at odds with that fact that most web development work I've done has been heavily tied to databases, which are very data-centric. One thing that made me a much more productive developer on the OOP side of things was the discovery of object-relational mappers like

Where to learn how to practically use Common Lisp [closed]

假如想象 提交于 2019-11-28 15:02:21
I am a C++ programmer trying to learn Common Lisp. I have looked at some books like Land of Lisp and read numerous online articles about the various virtues of Lisp. However, I need some advice. Almost everything I have read about Common Lisp has to do with how amazing it is and how amazingly fast you can get stuff done with it and how it amazingly solved many problems with modern programming languages 30 years ago. Also how amazing macros are, and how every every programming paradigm (OO, functional, actor based or whatever, etc) can be used in Lisp, and how lists are the ultimate data

Why does my lisp code give me …should be a lambda expression?

随声附和 提交于 2019-11-28 14:33:16
(defun helper-2 (list) (if (null (first (rest list))) 0) (+ (distance ((car list) (first (rest list)))) (helper-2 (rest list)))) I'm new to lisp and I'm writing a program to compute the perimeter of any polygon with input following clockwise order. My logic is that I use a helper method to compute the length of two points next to each other and do the sum. After recursion is done, I will do a separate call to calculate the length from the beginning point to its end and sum everything up. I've finished the distance method which takes 2 points and return the length. (distance '(2 0) '(4 0))

How to modify this “make-matrix” function?

帅比萌擦擦* 提交于 2019-11-28 14:13:44
Well, the flawed function is as follows: (defun make-matrix (n) (make-array (n n) :initial-element 0)) I want to use functions like (make-matrix 8) to replace the longer (make-array '(8 8) :initial-element 0) , but CLISP says there is a fault in (n n) , because n is not a defined function. How do I write this make-matrix function? You try to use (n n) , but that is Lisp syntax for calling a function named n with an argument n . You should invoke make-array like this: (make-array (list n n) :initial-element 0) 来源: https://stackoverflow.com/questions/19678906/how-to-modify-this-make-matrix

How can I modify function bindings in Common Lisp?

随声附和 提交于 2019-11-28 14:11:31
Here is something you can do in Scheme: > (define (sum lst acc) (if (null? lst) acc (sum (cdr lst) (+ acc (car lst))))) > (define sum-original sum) > (define (sum-debug lst acc) (print lst) (print acc) (sum-original lst acc)) > (sum '(1 2 3) 0) 6 > (set! sum sum-debug) > (sum '(1 2 3) 0) (1 2 3) 0 (2 3) 1 (3) 3 () 6 6 > (set! sum sum-original) > (sum '(1 2 3) 0) 6 If I were to do the following in Common Lisp: > (defun sum (lst acc) (if lst (sum (cdr lst) (+ acc (car lst))) acc)) SUM > (defvar sum-original #'sum) SUM-ORIGINAL > (defun sum-debug (lst acc) (print lst) (print acc) (funcall sum

Writing a destructive macro or function like incf?

戏子无情 提交于 2019-11-28 14:03:51
I need an incf function which does some bounds checking during the increment: val := val + delta if val >= 1.0 then return 1.0 else return val I can write this using incf : (defun incf-bounded(val delta) (incf val delta) (if (>= val 1.0) 1.0 val)) In such case I need to use this like (setf x (incf-bounded x delta)) . But how do I write one which I can use like (incf-bounded x delta) , i.e., where x will be modified? Joshua Taylor This is a good use case for define-modify-macro (which has also been described in what is to append as push is to cons, in Lisp? , but the present case is simpler).

Nicer pythonic `join` in common-lisp

ⅰ亾dé卋堺 提交于 2019-11-28 13:53:56
In Edi Weitz's cl cookbook, for the pythonic join , this function is suggested: (defun join (separator list) (with-output-to-string (out) (loop for (element . more) on list do (princ element out) when more do (princ separator out)))) However, somehow I was thinking, there must be a way to express join in another way, maybe using format 's capabilities ... In Seibel's book, (in the chapter about format ) we find joining of strings in a list to a single string with the separator ", " by: (defvar l '("a" "b" "c")) (format nil "~{~A~^, ~}" l) ;; "a, b, c" Which is a pythonic join and which is very

How to implement continuations?

人盡茶涼 提交于 2019-11-28 13:36:57
问题 I'm working on a Scheme interpreter written in C. Currently it uses the C runtime stack as its own stack, which is presenting a minor problem with implementing continuations. My current solution is manual copying of the C stack to the heap then copying it back when needed. Aside from not being standard C, this solution is hardly ideal. What is the simplest way to implement continuations for Scheme in C? 回答1: I remember reading an article that may be of help to you: Cheney on the M.T.A. :-)